[J3] Are coindexed allocatable scalars allocatable (and/or allocate-objects)?

Tobias Burnus burnus at net-b.de
Mon Sep 6 23:58:58 UTC 2021


Hi all,

my question is whether for
   integer, allocatable :: a[:]
the 'a[2]' is allocatable or not.

Or in other words: whether it can be used as actual argument
to a dummy argument with 'allocatable' (and intent(in)/value)
attribute or be passed to the 'allocatable' intrinsic inquiry
function.


Actually, I already fail to find the wording which
states that for
   integer, allocatable :: b(:)
the 'b(:)' is not an allocatable.

Well, that's not quite true, I do find (F2018, Section 9.5.3):

'NOTE 2
Unless otherwise specified, an array element or array
section does not have an attribute of the whole array.
In particular, an array element or an array section
does not have the POINTER or ALLOCATABLE attribute.'

But notes are per ISO/IEC Directives, Part 2 not normative.


I also find

R932 allocate-object  is  variable-name
                       or  structure-component

in F2018:9.7.1.1 but that's for allocate-object while,
e.g. F2018:19.9.11 requires for ALLOCATED an
"allocatable array" or "allocatable scalar", linking
to 3.2 "allocatable – having the ALLOCATE attribute (8.5.3)",
where allocate-object does not appear.


In any case, I do note that for
   integer, allocatable :: c(:)[:]
I may not use 'c[1]' as C916 mandates a section-subscript-list
and per NOTE 2, 'c(:)[1]' does not have the ALLOCATABLE
attribute as it is an array section.

But even when accepting NOTE 2, it still does not solve the
question whether 'a[1]' does or does not have the ALLOCATABLE
attribute.


Also 'allocate-object' itself seems to have a loophole: While
'variable-name' is clear,
   R913 structure-component is data-ref
   C920 ... the rightmost part-ref shall not have a
        section-subscript-list.
with
   R912 part-ref is part-name [ ( section-subscript-list ) ] [ image-selector ]

Thus, for
   type t
     integer, allocatable :: x[:]
   end type t
   type(t) :: var
the designator 'var%x[4]' seems to be a structure-component.

As
   R931  allocation  is  allocate-object [ ( allocate-shape-spec-list ) ]
                                         [ lbracket allocate-coarray-spec rbracket ]
I wonder whether
   var%x[4][6]
is a valid 'allocation'?


Have I found loopholes? Or just not dug deep enough
into the standard to find the relevant words?

And, in any case: is 'a[4]' allocatable or not?

Tobias

PS: I do note that at least 'allocated(c[1])' is a bit pointless
as 'c' must be allocated collectively in the whole team; thus, the
result of the coindexed inquiry should be equivalent to the uncoindexed
'allocated(c)' on all images of the team.



More information about the J3 mailing list