Re: undefined variable problem



Bart Vandewoestyne wrote:
On 2007-03-30, Bart Vandewoestyne <MyFirstName.MyLastName@xxxxxxxxxx> wrote:
I am a bit confused...

[...]

Reference to undefined variable A
Program terminated by fatal error

Hmmm... seems like I experienced the same problem a little while
ago:

http://groups.google.be/group/comp.lang.fortran/browse_thread/thread/fa7d431fca962807/db8480b5067c6d7c?lnk=st&q=&rnum=1&hl=nl#db8480b5067c6d7c

So probably the problem will not be an undefined variable but
something else...

I'll check my code with different compilers to see if i can find
that nasty bug... and after fixing it i hope I also get rid of
the above error message...

Regards,
Bart


Check out Catherine's reply again. I think you may have misunderstood what the compiler means by "undefined". It doesn't mean "not allocated" or "not declared" or "not associated". It means "used before set" - i.e. no value has been assigned to a since it was created (by allocation or whatever). It is an error to use the value of a variable if it has never been given a value, and that is what the compiler is complaining about.

In this instance, checking the code with different compilers will probably not help. Most compilers do not spot this type of error, but that doesn't mean there is no error - just that you are lucky to have one that does spot it.

--
John Appleyard - (send email to john!news@.. rather than spamtrap@..)
Polyhedron Software
Programs for Programmers - QA, Compilers, Graphics, Consultancy
********* Visit our Web site on http://www.polyhedron.co.uk/ *********
.