allocate() interface (PR30115)
Tobias Burnus
burnus@net-b.de
Fri Dec 8 23:00:00 GMT 2006
Hi,
Thomas Koenig wrote:
> This is legal, and required to work:
>
> real, pointer :: a(:)
> allocate (a(4))
> allocate (a(3))
>
> and this is illegal:
>
> real, allocatable :: a(:)
> allocate (a(4))
> allocate (a(3))
>
Sorry, I fail to find this in the standard.
Fortran 97, "6.3.1.1 Allocation of allocatable arrays":
"Allocating a currently allocated allocatable array causes an error
condition in the ALLOCATE statement."
Fortran 2003, "6.3.1.1 Allocation of allocatable variables":
"An allocatable variable with this status ["allocated" is ment] may be
referenced, defined, or deallocated; allocating it causes an error
condition in the ALLOCATE statement."
Reading this, I would claim both are invalid.
However, if I run your program, gfortran and all my three other
compilers accept happily both versions without raising any error.
Tobias
More information about the Fortran
mailing list