Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

F'2003 allocatable array assignment semantics: do they apply in masked constructs?

72 views
Skip to first unread message

Peter Klausler US

unread,
Mar 6, 2023, 1:50:54 PM3/6/23
to
There's no language in the standards that I can find that states that the (re)allocating semantics of assignments to allocatable arrays applies only to "normal" assignment statements that aren't in a WHERE statement, WHERE construct, or FORALL with a mask-expression in its concurrent-header. But if they do apply in those contexts, what do they mean, especially for left-hand side elements that correspond to .false. values in the mask?

Steven G. Kargl

unread,
Mar 6, 2023, 3:33:12 PM3/6/23
to
By "normal"assignment, I assume you mean intrinsic assignment.

Are you asking if re-allocation on assignment can/should occur
in, for example, a WHERE statement. I believe the answer is
'no'. The language of the Fortran 2003 standard seems clear.

03-007r2.pdf, p. 148:

When a where-assignment-stmt is executed, the values of expr
that correspond to true values of the control mask are assigned
to the corresponding elements of variable.

Note the last 4 words talk about assignments to elements not whole
arrays. If you are doing an intrinsic assignment to an array element
of an allocatable array, no re-allocation occurs.

gah4

unread,
Mar 7, 2023, 2:47:39 AM3/7/23
to
On Monday, March 6, 2023 at 10:50:54 AM UTC-8, Peter Klausler US wrote:
> There's no language in the standards that I can find that states that the
> (re)allocating semantics of assignments to allocatable arrays applies only
> to "normal" assignment statements that aren't in a WHERE statement,
> WHERE construct, or FORALL with a mask-expression in its concurrent-header.

There are some interesting cases of array assignment where the size of
the expression is not so easy to determine.

REAL, ALLOCATABLE :: X(:)
X = PACK(SPREAD(1,1,1000000), COS(COS(COS(REAL([(I,I=1,1000000)])))).GT.0.857553)
PRINT *,SIZE(X)
END
0 new messages