[J3] Are coindexed allocatable scalars allocatable (and/or allocate-objects)?
Malcolm Cohen
malcolm at nag-j.co.jp
Tue Sep 7 01:54:58 UTC 2021
(1)
In principle, an object only has an attribute if the standard says it does. See for example the TARGET attribute, which says that subobjects also have the attribute.
There is no such statement for ALLOCATABLE or POINTER, and thus, subobjects (including array sections) do not have those attributes.
(2)
I have no time to develop an opinion as to whether a[2] might have the ALLOCATABLE attribute. It seems pointless anyway.
(3)
> the designator 'var%x[4]' seems to be a structure-component.
I should certainly hope so, otherwise it would not be a designator.
(4)
> I wonder whether
>var%x[4][6]
>is a valid 'allocation'?
Well, it is a syntax error, as the coarray-spec does not end with a *.
And if the syntax error is fixed, it is still not valid, as it violates
C950 (R932) An allocate-object shall not be a coindexed object.
(5)
> Have I found loopholes?
Not as such.
(6)
> And, in any case: is 'a[4]' allocatable or not?
I agree that question deserves further research. Offhand, *and this is not definitive*, I would be inclined to say that it does. It would perhaps be clearer if 9.6 “Image selectors” said something like “Except for the corank and codimensions, the attributes of a coindexed object are the attributes of the object on the selected image.”
Definitely more research and thought required.
(7)
I wonder what the array bounds and length type parameters of an object on a failed image are. We don’t say, so I’d guess that LEN(var[failed]%string) is not conforming. But that’s a horse of a different colour.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Tobias Burnus via J3
Sent: Tuesday, September 7, 2021 8:59 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Tobias Burnus <burnus at net-b.de>
Subject: [J3] Are coindexed allocatable scalars allocatable (and/or allocate-objects)?
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.
Disclaimer
The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: 30 St. Giles, Oxford, OX1 3LE, United Kingdom. Please see our Privacy Notice <https://www.nag.co.uk/content/privacy-notice> for information on how we process personal data and for details of how to stop or limit communications from us.
This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210907/df786825/attachment.htm>
More information about the J3
mailing list