Re: undefined variable problem
- From: Catherine Rees Lay <catherine.news@xxxxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 12:10:20 +0100
Bart Vandewoestyne wrote:
I am a bit confused... I have a module with the following
variable:
integer(kind=i4b), dimension(:,:,:), allocatable, private :: a
Within that module, I have a subroutine that tries to access this
variable using a simple print statement:
print *, a
I am quite sure the variable a is allocated, because if i check
it right before the print statement with the ALLOCATED intrinsic,
it appears to be allocated.
However, when i compile and run my code with the NAGWare f95
compiler Release 5.1(282) on Linux, i get the following error:
Reference to undefined variable A
Program terminated by fatal error
With gfortran and g95 i don't get this error.
I have no clue what is going wrong here... what
are the things I should look for? I refuse to believe that this
is a compiler bug... i guess it is more likely that the problem
is at my side, but i cannot think of what could be wrong...
Thanks,
Bart
What values have you assigned to A?
It's perfectly possible to have something that's both allocated and undefined. If you want it given a value when it's allocated, you have to do so yourself. Some compilers are much pickier about it that others - but it is always an error. At best you get the message you have seen. Next best, at least in the "are you feeling lucky" sense, is that it gets allocated to zero and that's what you wanted. And then there's the third case, where what's in it is random bits from whatever happened to be in the memory being used beforehand.
Catherine.
--
Catherine Rees Lay
Polyhedron Software Ltd. Registered Office: Linden House,
93 High St, Standlake, Witney, OX29 7RH, United Kingdom.
Registered in England No.2541693. Vat Reg No. GB 537 3214 57
.
- References:
- undefined variable problem
- From: Bart Vandewoestyne
- undefined variable problem
- Prev by Date: Re: undefined variable problem
- Next by Date: Re: Starting to doubt fortran
- Previous by thread: Re: undefined variable problem
- Next by thread: Re: undefined variable problem
- Index(es):
Relevant Pages
|