To: J3 J3/21-175r1 From: John Reid Subject: US 12, arrays of coarrays Date: 2021-October-13 Reference: 21-007r2 Discussion ---------- An ALLOCATE statement for a non-coarray that has a coarray ultimate component is not an image control statement because the coarray ultimate component will be undefined so that its value will not be able to be referenced or defined by any image. However, a DEALLOCATE statement for such an object is an image control statement because it might involve deallocation of the coarray ultimate component on all the images, which would require synchronization. I think it would be better for such a DEALLOCATE statement always to involve synchronization and I include an edit for this. Without this change, using coarray components of allocatable variables would be somewhat error prone, as the user might not know whether there will be a synchronisation without checking the allocation status of every coarray component. If a non-coarray of unlimited-polymorphic type were allowed to be allocated to have a dynamic type with a coarray ultimate component its deallocation would be an image control statement. It was intended to disallow this because it is undesirable to have a data value determine whether a statement is an image control statement. For the ALLOCATE statement, the constraint C953 (R932) The declared type of shall not have a coarray ultimate component. applies both to MOLD= and SOURCE= and ensures that an unlimited- polymorphic is not given a dynamic type with a coarray ultimate component in this way but there is no comparable constraint for . Such a constraint is not needed for a polymorphic with a declared type that has a coarray ultimate component and the constraint on MOLD= is not needed in this case either. I propose moving the SOURCE= part of C953 to C952, deleting the MOLD= part of C953 and adding this restriction: "If an is unlimited polymorphic, the dynamic type of neither nor shall have a coarray ultimate component." It is a runtime restriction so it cannot be a constraint but can be normative. I have found that the subclause on the STAT= specifier for ALLOCATE and DEALLOCATE does not allow for the deallocation of an object with a coarray ultimate component. I propose edits to correct this. While looking at 21-007r2, I noticed an error in a note, and places where the text appears not to cover adequately the case of an object with a coarray subobject and cases where "component" is used when "ultimate component" is needed. Edits are proposed for these. Edits to 21-007r2 ----------------- [74:5-] In 7.5.4.3 Coarray components, NOTE 1, last sentence, change "an array, an allocatable object, a coarray, or a pointer" to "a coarray or a pointer" so that the sentence becomes "An object of type grid_type cannot be a coarray or a pointer." [142:27,30] In 9.7.1.1 Form of the ALLOCATE statement, in C952 after "not" add "have a coarray ultimate component," so that the constraint becomes "C952 (R929) If SOURCE= appears, the declared type of shall not have a coarray ultimate component, be EVENT_TYPE, LOCK_TYPE, or NOTIFY_TYPE from the intrinsic module ISO_FORTRAN_ENV, or have a potential subobject component of type EVENT_TYPE, LOCK_TYPE or NOTIFY_TYPE." Delete "C953 (R932) The declared type of shall not have a coarray ultimate component." [143:12] In 9.7.1.1 Form of the ALLOCATE statement, at the end of para 5 add "If an is unlimited polymorphic, the dynamic type of neither nor shall have a coarray ultimate component." [143:34-35] In 9.7.1.2 Execution of an ALLOCATE statement, para 4, change the third sentence to "If the coarray is a dummy argument or a subobject of a dummy argument, the ultimate argument (15.5.2.4) of the dummy argument shall be the same object on those images." [147:3] In 9.7.3.2 Deallocation of allocatable variables, para 10, first sentence, after "coarray" add "or an object with a coarray subobject" to make the sentence read "When a statement that deallocates a coarray or an object with a coarray subobject is executed, there is an implicit synchronization of all active images in the current team." [147:10-11] In 9.7.3.2 Deallocation of allocatable variables, change para 11 to "If a DEALLOCATE statement that deallocates a coarray has an that is a dummy argument or a subobject of a dummy argument, the ultimate argument (15.5.2.4) of the dummy argument shall be the same object on those images." [148:7&9] In 9.7.4 STAT= specifier, para 5, in sentence 1 change "with a coarray " to "that is an image control statement (11.7.1)" and in sentence 2 change "an is a coarray" to "the statement is an image control statement" so that the two sentences become "If an ALLOCATE or DEALLOCATE statement that is an image control statement (11.7.1) is executed when the current team contains a stopped image, the stat-variable becomes defined with the value STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV (16.10.2). Otherwise, if the statement is an image control statement, the current team contains a failed image, and no other error condition occurs, the stat-variable becomes defined with value STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV." [170:5] In 10.2.1.2 Intrinsic assignment statement, para 1, item (1), add "ultimate" before "component" so that the item becomes "if the variable is polymorphic it shall be allocatable, and not a coarray or a data object with a coarray ultimate component". [170:9] In 10.2.1.2 Intrinsic assignment statement, para 1, item (3), add "ultimate" before "component" so that the item becomes "the variable and expr shall be conformable unless the variable is an allocatable array that has the same rank as expr and is not a coarray or of a type that has a coarray ultimate component".