To: J3 J3/19-252r1 From: Srinath Vadlamani & Dan Nagle Subject: Specification for auto-allocating processor messages Date: 2019-October-17 Reference: 18-007r1, 18-279r1 1. Introduction --------------- At the Tokyo meeting, WG5 approved this work item for further work. These specifications are based on the discussion in 18-279r1. There are three cases to cover; firstly, the case of strings returned from statements; secondly, the case of strings returned from intrinsic procedures; and thirdly, the case of an internal write to a scalar character variable. These cases currently require the applications programmer to provide sufficient storage, but the standard provides no mechanism to determine the sufficient length. Note that, for this to make sense, the character variable must be scalar and not an array element. The elements of an array all have the same length; adjusting the length of elements not appearing is unexpected. Example edits are supplied solely to show the magnitude of the changes to the standard implied by this work item. 2. Requirements --------------- In the three cases identified above, the need to pre-allocate an allocatable scalar character with deferred length is removed. This shifts from applications programmer to the processor the need to know an appropriate length of the receiving character variable. The processor allocates as needed. If no data would be assigned, the allocation status remains unchanged. 3. Specifications ----------------- 1. When a character variable is to receive character data from IOMSG or ERRMSG, it is as if by intrinsic assignment. 2. When a character variable is to receive character data from an argument of an intrinsic procedure, it is as if by intrinsic assignment. 3. When the character variable to receive character data as the file variable of an internal file is an allocatable character scalar declared with deferred length, the processor shall allocate the variable to the length needed to contain the data, if needed. 4. Example edits to 18-007r1 ---------------------------- { edits in page order } { put remarks briefly describing the new features in Introduction } [xiii] { in the bullet item Data usage and computation: } add "an allocatable character variable appearing as an ERRMSG variable is allocated by the processor to the correct length" { in the bullet item Input/output: } add "an allocatable character variable appearing as an IOMSG variable is allocated by the processor to the correct length" { in the bullet item Intrinsic procedures and modules: } add "when an allocatable character variable appearing in the argument list is to receive character data, it is allocated by the processor to the correct length" { the Introduction has remarks about each new feature } { update the description of ERRMSG } { 9.7.5 ERRMSG= specifier } [139:10-12p2] now reads: "If an error condition occurs during execution of an ALLOCATE or DEALLOCATE statement with an ERRMSG= specifier, the <> is assigned an explanatory message, truncated or padded according to the rules of intrinsic assignment." change "truncated or padded according to the rules of" to "as if by" so the resulting sentence reads: "If an error condition occurs during execution of an ALLOCATE or DEALLOCATE statement with an ERRMSG=specifier, the <> is assigned an explanatory message as if by intrinsic assignment." { ERRMSG now allocates as needed } { update the description file variable } { in 12.4 Internal files } [216:12-14]p2 The fourth bullet item now reads: "A record of the internal file becomes defined by writing the record. If the number of characters written in a record is less than the length of the record, the remaining portion of the record is filled with blanks. The number of characters to be written shall not exceed the length of the record." in the second sentence, change the initial "If" to "When the record is an allocatable character scalar declared with deferred length and is allocated with sufficient length, or is not an allocatable character, if" and at the end of the paragraph, add a sentence "Otherwise, when the record is an allocatable character scalar declared with deferred length, the character variable is allocated with the length needed to contain the record." so the resulting paragraph reads: "A record of the internal file becomes defined by writing the record. When the record is an allocatable character scalar declared with deferred length and is allocated sufficiently long, or is not an allocatable character scalar declared with deferred length, if the number of characters written in a record is less than the length of the record, the remaining portion of the record is filled with blanks. The number of characters to be written shall not exceed the length of the record. Otherwise, when the record is an allocatable character scalar declared with deferred length, the character variable is allocated with the length needed to contain the record." { writing an internal file to a scalar allocates as needed } { update the description of IOMSG } { 12.11.6 IOMSG= specifier } [255:2-3p1] now reads: "If an error, end-of-file, or end-of-record condition occurs during execution of an input/output statement, <> is assigned an explanatory message, truncated or padded according to the rules of intrinsic assignment." change "truncated or padded according to the rules of" to "as if by" so the resulting sentence reads: "If an error, end-of-file, or end-of-record condition occurs during execution of an input/output statement, <> is assigned an explanatory message as if by intrinsic assignment." { IOMSG now allocates as needed } { treat all intrinsics by adding a general rule } [339:8+] add a new paragraph "When the actual argument corresponding to an INTENT(INOUT) or INTENT(OUT) argument is an allocatable character scalar declared with deferred length is assigned a value, the value is assigned as if by intrinsic assignment." { intrinsic procedures now allocate as needed } /eof