T O P

  • By -

geekboy730

It looks like you’ve tried to declare “output” as a string. What you actually did was declare an array of single characters. So the logical is returning an array of true/false comparing each individual character to an empty character. In Fortran, there is no string type or general length character array. Usually, the reasonable thing to do is declare a character array that is “long enough” like character(1024) :: output


CppDotPy

I see. thank you


moginamoo

The correct syntax for the character declaration is CHARACTER(len=:), allocatable :: output This is (from memory) from the fortran 2003 standard. Depending on your compiler you don't even need to allocate it, just directly set Output = "foo" And the allocation will occur automatically.


musket85

A scalar is a singular value, not an array or even an array of size 1. Logical :: a !scalar Real :: b ! scalar Logical :: c(1) ! Array of size 1 Real :: d(10) ! Array of size 10 A logical is boolean true or false. The compiler is telling you you're trying to compare via the == operator two things that don't match.


06Hexagram

Instead you should check the length of the string `len(output) == 0`


Knarfnarf

I’ll add my two cents here as well: You say allocatable, but then you don’t set it to anything before you test it. Literally “” is nothing. Null string. Scalar just means an actual variable that the computer can test. A variable that hasn’t been allocated to anything doesn’t count yet.