GFortran Bug Report: Size of pointer variables
Tobias Burnus
burnus@net-b.de
Tue Dec 15 21:05:00 GMT 2009
Am 15.12.2009 21:52, schrieb Tink,James [NCR]:
> I tried to compile the following source (in test.f90):
>
> PROGRAM TEST
> INTEGER, POINTER :: I(:)
> I=>NULL()
> PRINT *, SIZE(I)
> END PROGRAM TEST
>
> Using: gfortran [...] I get the following output:
> 1
> [...] using the Portland [...]
> 0
> Which compiler is producing the correct output and why?
>
Both compiler give the correct output. Looking at the current Fortran
standard (Fortran 2003) one finds in "13.7.112 SIZE (ARRAY [, DIM, KIND])":
"Arguments.
"ARRAY may be of any type. It shall not be scalar. It shall not be an
unallocated
allocatable or a pointer that is not associated. [...]"
And your pointer is not associated. As your program is not conforming to
the standard, anything is possible. Solution: Use the ASSOCIATE statement.
(For the Fortran standards, see http://gcc.gnu.org/wiki/GFortranStandards )
Tobias
More information about the Fortran
mailing list