[J3] Co-array question
Malcolm Cohen
malcolm at nag-j.co.jp
Fri Aug 20 00:23:01 UTC 2021
Hi John,
There is nothing out of the ordinary in the ALLOCATE statement in itself. It is perfectly ordinary Fortran 2003.
> In the context of F2018, it does not seem right that an allocation be
allowed by referring to an object through a pointer but not by referring
to the object directly.
There’s nothing at all strange about this *not being a constraint*. It’s a runtime thing. I already expressed my opinion that it’s not standard-conforming at runtime anyway (no interpretation being established), and my support for making the requirement explicit.
We have tons of runtime requirements that cannot be constraints, all over the standard. Even ones to do with type.
Once again, the ALLOCATE on its own is perfectly ordinary, a CLASS(*) allocatable being given the value from another CLASS(*) entity. This is a common thing to do (usually with both being pointers though) with heterogenous structures that use CLASS(*).
And it’s not like it would be difficult in principle to detect violation of the “no coarray components” rule at runtime in SOURCE=. Just have a bit in the type header to indicate it.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of John Reid via J3
Sent: Friday, August 20, 2021 7:19 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: John Reid <John.Reid at stfc.ac.uk>; Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: Re: [J3] Co-array question
Malcolm Cohen via J3 wrote:
>
> Mark LeAir writes:
>
> And is the following in violation of any constraint, or is it now a
> conforming program?
>
> program main
>
> type :: type
>
> integer, allocatable :: coarray[:]
>
> end type
>
> type(type), save, target :: object
>
> class(*), pointer :: pointer
>
> class(*), allocatable :: allocatable
>
> allocate(object%coarray[*]);
>
> pointer => object
>
> allocate(allocatable, source = pointer)
>
> end
>
> John Reid opines:
>
> I think we have an omission here. I see no constraint that disallows it
> but it should not be allowed.
>
> My response:
>
> There is nothing here that warrants a constraint – the only
> possibility would be to prohibit the pointer assignment: goodbye
> bathwater, goodbye baby.
>
It is the allocate statement that is a problem, not the pointer assignment.
>
> The pointer can of course be used safely, viz contexts other than as
> input to SOURCE=.
>
Agreed.
>
> The program is, I think, non-conforming because the standard does not
> say what happens. For normal allocatable components there would be a
> copy made, but that doesn’t apply to coarray components so “no
> interpretation is established”.
>
> I agree that a requirement on the dynamic type of source-expr (in
> F2018) that it not have a coarray ultimate component would appear to
> be desirable. (In F202x, that probably should only apply to SOURCE=.)
>
In the context of F2018, it does not seem right that an allocation be
allowed by referring to an object through a pointer but not by referring
to the object directly.
John.
>
> Cheers,
>
> --
>
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
>
> *From:* J3 <j3-bounces at mailman.j3-fortran.org <mailto:j3-bounces at mailman.j3-fortran.org> > *On Behalf Of *Mark
> LeAir via J3
> *Sent:* Thursday, August 19, 2021 2:01 AM
> *To:* fortran standards email list for J3 (j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> )
> <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
> *Cc:* Mark LeAir <mleair at nvidia.com <mailto:mleair at nvidia.com> >
> *Subject:* [J3] Co-array question
>
> Hi,
>
> One of our engineers had the following questions about the co-arrays.
> Can someone from the list answer them?
>
> Does the following program constitute a violation of F’2018 C949 (“The
> declared type of /source-expr /shall not have a coarray ultimate
> component.”)?
>
> program main
>
> type :: type
>
> integer, allocatable :: coarray[:]
>
> end type
>
> type(type), save, target :: object
>
> class(*), allocatable :: allocatable
>
> allocate(object%coarray[*]);
>
> allocate(allocatable, source = object)
>
> end
>
> And is the following in violation of any constraint, or is it now a
> conforming program?
>
> program main
>
> type :: type
>
> integer, allocatable :: coarray[:]
>
> end type
>
> type(type), save, target :: object
>
> class(*), pointer :: pointer
>
> class(*), allocatable :: allocatable
>
> allocate(object%coarray[*]);
>
> pointer => object
>
> allocate(allocatable, source = pointer)
>
> end
>
> *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/20210820/0b1a14b6/attachment.htm>
More information about the J3
mailing list