On Mar 4, 2005, at 5:14 AM, Keith Refson wrote:
> Does anyone know under which level of the standard a declaration such
> as
>
> logical, dimension(size(kpoint_weights_on_node)) :: weight_gt_0
>
> is valid within a module subroutine, where
>
> real(kind=dp), dimension(:), allocatable, public,
> save::kpoint_weights_on_node
>
> is USE associated from another module?...
...
> : An allocatable array is not allowed in this context.
This is insufficient context to tell for sure. In particular, there is
not enough context to tell whether weight_gt_0 is allowed to be an
automatic variable or not.
On the face of it, the declaration looks ok (under f90 and anything
later). If weight_gt_0 could be automatic, the relevant requirements
are those on specification expressions. Specification expressions may
not refer to the size of a *LOCAL* allocatable variable. In f95 (I'm
not going to track down the exact citations for all versions of the
standard, but the essence of this hasn't changed), that is prohibited
in section 7.1.6.2 (Specification expression) by item (7)(2nd b)(iii).
The compiler might possibly be incorrectly applying that restriction.
However, that restriction doesn't apply to variables accessed via USE
association; in that case, you go down the branch (7)(2nd b)(a) because
a use-associated variable is a restricted expression by (7)(4).
Sorry for the somewhat legalese citations. That's what it takes to
track this stuff down in detail. I could elaborate on the above to
explain it, but that would get a bit long (as if this isn't already
:-)).
However, if weight_gt_0 can't be automatic, then we would need to be
looking at initialization expressions instead of restricted
expressions. In that case, the above would not be allowed. Without
bothering to trace the citations for that case, I'll just give the
hand-waving version, which is that initialization expressions are
evaluated at compile time, at which time sizes of allocatable arrays
aren't yet known.
What could keep weight_gt_0 from being automatic? Well, a SAVE
attribute, either explicit or implicit, would be the first way that
comes to mind. For example, a DATA statement could implicitly give the
SAVE attribute. (Being a dummy argument would be another, but dummy
arguments are different and even though they aren't called automatic,
they are ok with specification expressions also).
All in all, particularly considering that you say it worked with other
compilers, I'd guess that this is probably a compiler bug, but the data
presented isn't sufficient for proof of that.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|