To: J3 13-261 From: R. Bader Subject: Amendments to TS 29113 Date: 2013 June 2 References: N1830, 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. 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 Presently it is permitted to have a /result/ parameter with the attribute CFI_attribute_pointer if the /source/ parameter describes an assumed-size object. This must be prohibited. EDIT: At the end of the "source" description of TS/8.3.5.8, add the sentence "If /result/ has the attribute CFI_attribute_pointer, /source/ shall not describe an assumed-size array." (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(*) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EDITS: In section 6.3, after para 1, insert new para 2 "An assumed-type assumed-size rank 1 dummy argument may correspond to a scalar actual argument. NOTE 6.1+ Such a scalar actual argument is considered to be equivalent to a rank 1 array of size one." The edits to the standard also include a correction of para 13 of 12.5.2.4 that presently prohibits associating assumed-rank entities with scalar actual arguments. Replace the first two sentences of 12.5.2.4 para 13 by "If the actual argument is a coindexed scalar, the corresponding dummy argument shall be scalar ~[, an assumed-rank entity, or an assumed-size rank 1 array of assumed type]. If the actual argument is a noncoindexed scalar, the corresponding dummy argument shall be scalar unless ~[* the dummy argument is declared with assumed rank (5.3.8.7), or * the dummy argument is an assumed-size rank 1 array of assumed type, or *] the actual argument is default character, of type character with the C character kind (15.2.2), or is an element or substring of an element of an array that is not an assumed-shape, pointer, or polymorphic array. ~[NOTE 12.22+ A scalar actual argument associated with an assumed-size assumed-type array dummy argument is considered to be equivalent to a rank 1 array of size one.]" ~[...] indicates the additions to the existing text. (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.