To: J3 J3/14-149 From: R. Bader Subject: Amendments to TS 29113 Date: 2014 May 16 References: N1942 Based on implementation experience by Tobias Burnus and further comments by Daniel Chen, Bill Long and others, this paper makes suggestions on amendments to TS 29113 that should be considered for integration of the TS contents into the next edition of the standard. This paper is an updated version of 13-261. The suggested edits are provided against N1942. (A) Assumed rank entities. The Fortran lower bounds of an assumed-rank dummy argument that does not have the POINTER or ALLOCATABLE attribute should be one. Furthermore, C532 must be loosened in order to allow assumed-rank entities to have the POINTER or ALLOCATABLE attribute. EDITS: In section TS/5.2, after C535c, insert "The lower bounds of an assumed-rank entity that does not have the POINTER or ALLOCATABLE attribute and is argument associated with an array are 1." Add the same text at the end of section TS/9.5, after C535c. Before the edits for 5.3.8.7 in section TS/9.5, add "{In 5.3.8.4, change C532 as follows} C532 An array with the POINTER or ALLOCATABLE attribute ~[that is not an assumed-rank entity (5.3.8.7)] shall have an array-spec that is a deferred-shape-spec-list." (the ~[...] text is added and hence gets underwaves). Further comment: For the C descriptor, section TS/8.3.3 already specifies the lower bounds for a non-allocatable non-pointer array as zero. (B) Descriptors for assumed size objects. Such descriptors according to section TS/8.3.2 have a dim[].extent value of -1. For some of the functions from section TS/8.3.5, it is unclear to which extent such descriptors can appear as parameters. In detail: (B.1) CFI_address From the present definition, no valid subscripts[] argument can be specified for an assumed-size object. This is too draconian. EDIT: In the "subscripts" description of TS/8.3.5.2, last sentence, replace "The subscript values" by "The first /r/ - 1 subscript values" and at the end of that sentence, add "; the /r/-th subscript value shall be greater than or equal to the corresponding lower bound of the /dim/ member of the C descriptor." Comment: The last paragraph of TS/8.5 provides the additional necessary restriction that renders any kind of overindexing that may otherwise happen non-conforming. (B.2) CFI_select_part The /source/ parameter is presently permitted to be an assumed-size object, resulting in assumed-size subobjects that are in general non-contiguous. This must be prohibited. EDIT: In the "source" description of TS/8.3.5.8, after "nonallocatable nonpointer array", add " that is not assumed-size". (B.3) CFI_setpointer The /source/ parameter is presently permitted to be an assumed-size object. This must be prohibited. EDIT: In the "source" description of TS/8.3.5.9, after "nonallocatable nonpointer data object", add " that is not an assumed-size array". (B.4) Assumed shape dummy matching An assumed-size object must not appear as an actual argument associated with an assumed-shape dummy. 12.5.2.3 para 13 of the standard specifies this for Fortran, but it may be useful to add a NOTE that confirms this for the interoperation case. EDIT: At the end of TS/8.4, add the following text "NOTE 8.11+ Because an assumed-size object is prohibited from appearing as an actual argument associated with an assumed-shape dummy (12.5.2.3 of ISO/IEC 1539-1:2010), it is not permitted to use a descriptor for an assumed-size object to appear as an actual parameter corresponding to an assumed shape dummy argument." (C) Descriptor updates not uniquely defined ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For the functions CFI_section and CFI_select_part, the update procedure for the descriptor is not uniquely fixed, inasmuch as it is not clear how the /lower_bound/ values are set. The following edits attempt to repair this by specifying that the pre-existing lower bounds are retained. EDITS: (C.1) CFI_section [p27, para 1]: Replace the sentence "Successful execution ... address /source/." by "Successful execution of CFI_section updates the /base_addr/ member and the /extent/ and /sm/ members for each array dimension of the C descriptor with the address /result/ to describe a section of the array described by the C descriptor with the address /source/." (C.2) CFI_select_part [p 28, para 4]: Replace the sentence "Successful execution ... address /source/." by "Successful execution of CFI_select_part updates the /base_addr/ member, the /extent/ and /sm/ members for each array dimension, and possibly the /elem_len/ member of the C descriptor with the address /result/ for an array each element of which is a part of the corresponding element of the array described by the C descriptor with the address /source/." (The term "array section" is not used any more since this is not on-topic; this term should also be replaced a number of times by "array" in the Description and Formal Parameters subsections of TS/8.3.5.8). (D) Allow scalars to be argument associated with assumed-size TYPE(*) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This has been dealt with via 13-283. There is only one fall-out on the Annex A of the TS that is covered by the following. EDIT: In example A.1.2 of Annex A of the TS, replace the line "status = EXAMPLE_send((/ z /), c_sizeof(z), handle)" by "status = EXAMPLE_send(z, c_sizeof(z), handle)" and two lines later, the sentence "For z, it is necessary to explicitly create an array expression." by "The scalar z is treated as if it were an array of size one." (E) Token for assumed-rank entities. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sequence of two dots should be listed as a token in section 3.2.1 of the Fortran standard, to prevent a declaration of the form real, dimension(. .) :: a EDIT: after TS/9.3, add a new section 9.3+ "9.3+ Edits to clause 3 { In 3.2.1, edit paragraph 1 as follows } A lexical token is a keyword, name, literal constant other than a complex literal constant, operator, statement label, delimiter, comma, =, =>, :, ::, ;~[, ..] or %." ~[...] indicates the additions to the existing text.