Re: Allocattable and namelist object
- From: steve <kargls@xxxxxxxxxxx>
- Date: Sun, 14 Feb 2010 14:55:05 -0800 (PST)
On Feb 14, 1:34 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
steve <kar...@xxxxxxxxxxx> wrote:
Someone has reported a bug against gfortran that suggests that
following code is legal Fortran 2003.
REAL, DIMENSION(:), ALLOCATABLE :: TAB
END PROGRAM MAIN
Gfortran currently issues an error in accordance with a
constraint in Fortran 95:
F95, Sec 5.4, p. 66
A namelist-group-object shall not be an array dummy
argument with a nonconstant bound, a variable with
nonconstant character length, an automatic object,
a pointer, a variable of a type that has an ultimate
component that is a pointer, or an allocatable array.
That seems pretty explicit, but I think we all agree on that.
In checking the Fortran 2003 standard, the above constraint
has been removed. Further searching leads to two passages
that appear to be in conflict.
F2003, Sec. 5.4, p. 95
A namelist group object shall either be accessed by use
or host association or shall have its type, type parameters,
and shape specified by previous specification statements or
the procedure heading in the same scoping unit or by the
implicit typing rules in effect for the scoping unit.
F2003, Sec. 220.127.116.11,
Every allocatable namelist-group-object in the namelist group
shall be allocated and every namelist-group-object that is a
pointer shall be associated with a target.
The statement from Sec. 5.4 states that a "namelist group object
... shall have its type, type parameters, and shape specified
by previous specification statements". In the above code, the
shape has not been specified prior to the namelist statement.
However, the statement from Sec. 18.104.22.168 suggests that an allocatable
array can be in a namelist object.
Are these statements in conflict or am I missing some other
part of the Fortran 2003 standard?
I'd probably interpret it as that the shape was specified prior to the
namelist statement. It was specified to be deferred shape. I'm not sure
that the wording is great; it strikes me as wording from the prior
standard that perhaps didn't get changed to reflect other changes. But I
can at least twist my mind to read it that way. No other reading makes
any sense to me at all, as it is just nonsense to say that any
allocatable arrays have to be allocated, but then also say that you
can't have allocatable arrays. The shape of an allocatable array can
never be specified in a specification statement to be anything other
Which is to say that I'd consider the code to be legal f2003, although
illegal f95, based on th eabove citations. (I was to lazy to actually
check your citations, but they seem plausible.)
Thanks for the comment. I had not thought about such an
In the definition of a deferred-shaped array one finds:
22.214.171.124.3 Deferred-shape array
A deferred-shape array is an allocatable array or an
An allocatable array is an array that has the ALLOCATABLE
attribute and a specified rank, but its bounds, and hence
shape, are determined by allocation or argument association.
I would interpret this to mean that the deferred-shape array
does not have a specified shape in the code I posted. Hence,
the two statements in F2003 are contradictory.
The current draft of F2008 is even more convincing that there
is a problem. The language from Sec. 5.4 in the F95 and F2003
standards is idenitical to the language in F2008. F2003 however
has revised the definition of deferred-shape array to include
126.96.36.199 Deferred-shape array
3 The size, bounds, and shape of an unallocated allocatable
array or a disassociated array pointer are undefined.
No part of such an array shall be referenced or defined;
however, the array may appear as an argument to an
intrinsic inquiry function as specified in 13.1.
I guess I need to look into getting an official interpretation.
- Re: Allocattable and namelist object
- From: Richard Maine
- Re: Allocattable and namelist object
- Prev by Date: Re: Allocattable and namelist object
- Next by Date: Re: Allocattable and namelist object
- Previous by thread: Re: Allocattable and namelist object
- Next by thread: Re: Allocattable and namelist object