[J3] Co-array question
Malcolm Cohen
malcolm at nag-j.co.jp
Thu Aug 19 01:13:34 UTC 2021
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.
The pointer can of course be used safely, viz contexts other than as input to SOURCE=.
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=.)
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <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) <j3 at mailman.j3-fortran.org>
Cc: Mark LeAir <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/20210819/8a3607e7/attachment-0001.htm>
More information about the J3
mailing list