To: J3 J3/25-103 From: John Reid Subject: Coarray dummy arguments in auto-generic subprograms Date: 2024-December-29 References: N2217, 23-233r2, 24-147r1, 23-148r1, 24-139r2, 24-188r1, 25-102 1. Introduction =============== At its meeting Jun 12-16, 2023, WG5 decided to approve generic subprograms as described in N2217 for Fortran 202Y. Formal requirements were approved by J3 in 23-233r2 (revised in 24-147r1). No reference is made in these to coarrays. Formal specifications were approved by J3 in 23-148r1, again with no reference to coarrays, but this addition was approved in 24-139r2: sNN A generic dummy argument cannot be a coarray. Reason: This is just a simplification. At a future time we could allow this, and we could also allow generic-corank dummy arguments. Syntax was approved by J3 in 24-139r2. Part x03 has the following constraint and comment C8nn A generic dummy argument shall not be a coarray. Comment Codimension is not mentioned in the requirements, use cases, or specifications, but seems like it would add complication. So we should prohibit it for now. This restriction seems to us to be unreasonably cautious. Coranks play no part in generic resolution because the coranks of an actual argument and the corresponding dummy argument are not required to agree. There is therefore no need to disalow them. For example, GENERIC SUBROUTINE mine(a) TYPE(INTEGER(*)) :: a[*] : END SUBROUTINE mine would define a generic subroutine with versions for all integers supported by the processor. This generic subroutine can be constructed in Fortran 2023 by writing a specific version for each required kind, along with a generic interface that references them all. Note that a dummmy argument will need to be a coarray if the code in the subroutine accesses its data on one image directly from another. The programmer can get round the restriction by adding a non-coarray argument and declaring the coarray to have its type, kind, and rank, for example GENERIC SUBROUTINE mine2(b, a) TYPE(INTEGER(*)) :: b TYPEOF(b) :: a[*] : END SUBROUTINE mine2 Given that this is the case, removing the restriction cannot cause any implementtion difficulty. Use cases are presented by Hidetoshi Iwashita in J3/25-102. 2. Proposal =========== From part x03 of the syntex in 24-139r2, delete the constraint and associated comment: C8nn A generic dummy argument shall not be a coarray. Comment Codimension is not mentioned in the requirements, use cases, or specifications, but seems like it would add complication. So we should prohibit it for now. From the formal specifications delete the constraint and associated comment that were added by 24-139r2: sNN A generic dummy argument cannot be a coarray. Reason: This is just a simplification. At a future time we could allow this, and we could also allow generic-corank dummy arguments. 3. Comment =========== This issue was discussed very late in the October meeting, see 24-188r1. A straw vote was taken which was undecided.