Both synchronous and asynchronous input/output are allowed for files opened with an ASYNCHRONOUS=
specifier of YES. For other files, only synchronous input/output is allowed; this includes files opened with an
ASYNCHRONOUS= specifier of NO, files opened without an ASYNCHRONOUS= specifier, preconnected
files accessed without an OPEN statement, and internal files.
The ASYNCHRONOUS= specifier value in a data transfer statement is a constant expression because it
effects compiler optimizations and, therefore, needs to be known at compile time.
so. For each external file, records and file storage units read or written by asynchronous data transfer statements4 If a variable is used in an asynchronous data transfer statement as234 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
are read, written, and processed in the same order as they would have been if the data transfer statements were
synchronous. The documentation of the Fortran processor should describe when input/output will be performed
asynchronously.
• an item in an input/output list,the base object of the data-ref is implicitly given the ASYNCHRONOUS attribute in the scoping unit of the data• a group object in a namelist, or
• a SIZE= specifier,
transfer statement. This attribute may be confirmed by explicit declaration.
5 When an asynchronous input/output statement is executed, the set of storage units specified by the item list or NML= specifier, plus the storage units specified by the SIZE= specifier, is defined to be the pending input/output6 A pending input/output storage sequence affector is a variable of which any part is associated with a storage unitstorage sequence for the data transfer operation.
NOTE 12.28
A pending input/output storage sequence is not necessarily a contiguous set of storage units.
in a pending input/output storage sequence.1 The scalar-default-char-expr shall evaluate to NULL or ZERO. The BLANK= specifier temporarily changes<IP_ADDRESS> BLANK= specifier in a data transfer statement
(12.5.2) the blank interpretation mode (13.8.6, <IP_ADDRESS>) for the connection. If the specifier is omitted, the mode1 The scalar-default-char-expr shall evaluate to COMMA or POINT. The DECIMAL= specifier temporarily changesis not changed.
<IP_ADDRESS> DECIMAL= specifier in a data transfer statement
(12.5.2) the decimal edit mode (13.6, 13.8.8, <IP_ADDRESS>) for the connection. If the specifier is omitted, the mode is1 The scalar-default-char-expr shall evaluate to APOSTROPHE, QUOTE, or NONE. The DELIM= specifier tem-not changed.
<IP_ADDRESS> DELIM= specifier in a data transfer statement
porarily changes (12.5.2) the delimiter mode (13.10.4, <IP_ADDRESS>, <IP_ADDRESS>) for the connection. If the specifier is1 Successful execution of an asynchronous data transfer statement containing an ID= specifier causes the variableomitted, the mode is not changed.
<IP_ADDRESS> ID= specifier in a data transfer statement
specified in the ID= specifier to become defined with a processor determined value. If this value is zero, the2 If an error condition occurs during the execution of a data transfer statement containing an ID= specifier, thedata transfer operation has been completed. A nonzero value is referred to as the identifier of the data transfer
operation. This identifier is different from the identifier of any other pending data transfer operation for this unit.
It can be used in a subsequent WAIT or INQUIRE statement to identify the particular data transfer operation.
variable specified in the ID= specifier becomes undefined.3 A child data transfer statement shall not specify the ID= specifier.
⃝c ISO/IEC 2017 – All rights reserved 2351 The scalar-default-char-expr shall evaluate to YES or NO. The PAD= specifier temporarily changes (12.5.2) the
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> PAD= specifier in a data transfer statement
pad mode (<IP_ADDRESS>.3, <IP_ADDRESS>) for the connection. If the specifier is omitted, the mode is not changed.1 The POS= specifier specifies the file position in file storage units. This specifier may appear in a data transfer<IP_ADDRESS> POS= specifier in a data transfer statement
statement only if the statement specifies a unit connected for stream access. A child data transfer statement shall2 A processor may prohibit the use of POS= with particular files that do not have the properties necessary tonot specify this specifier.
support random positioning. A processor may also prohibit positioning a particular file to any position prior to3 If the file is connected for formatted stream access, the file position specified by POS= shall be equal to either 1its current file position if the file does not have the properties necessary to support such positioning.
NOTE 12.29
A unit that is connected to a device or data stream might not be positionable.
(the beginning of the file) or a value previously returned by a POS= specifier in an INQUIRE statement for the1 The REC= specifier specifies the number of the record that is to be read or written. This specifier may appearfile.
<IP_ADDRESS> REC= specifier in a data transfer statement
only in a data transfer statement that specifies a unit connected for direct access; it shall not appear in a child1 The scalar-default-char-expr shall evaluate to one of UP, DOWN, ZERO, NEAREST, COMPATIBLE or PRO-data transfer statement. If the io-control-spec-list contains a REC= specifier, the statement is a direct access
data transfer statement. A child data transfer statement is a direct access data transfer statement if the parent
is a direct access data transfer statement. Any other data transfer statement is a sequential access data transfer
statement or a stream access data transfer statement, depending on whether the file connection is for sequential
access or stream access.
<IP_ADDRESS> ROUND= specifier in a data transfer statement
CESSOR_DEFINED. The ROUND= specifier temporarily changes (12.5.2) the input/output rounding mode1 The scalar-default-char-expr shall evaluate to PLUS, SUPPRESS, or PROCESSOR_DEFINED. The SIGN=(<IP_ADDRESS>.8, <IP_ADDRESS>) for the connection. If the specifier is omitted, the mode is not changed.
<IP_ADDRESS> SIGN= specifier in a data transfer statement
specifier temporarily changes (12.5.2) the sign mode (13.8.4, <IP_ADDRESS>) for the connection. If the specifier is1 The SIZE= specifier in an input statement causes the variable specified to become defined with the count ofomitted, the mode is not changed.
<IP_ADDRESS> SIZE= specifier in a data transfer statement
the characters transferred from the file by data edit descriptors during the input operation. Blanks inserted as2 For a synchronous input statement, this definition occurs when execution of the statement completes. For anpadding are not counted.
asynchronous input statement, this definition occurs when the corresponding wait operation is performed.1 An input/output list specifies the entities whose values are transferred by a data transfer statement.12.6.3 Data transfer input/output list
236 ⃝2 An input-item shall not appear as, nor be associated with, the do-variable of any io-implied-do that contains thec ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
R1216 input-item is variable
or io-implied-do
R1217 output-item is expr
or io-implied-do
R1218 io-implied-do is ( io-implied-do-object-list , io-implied-do-control )
R1219 io-implied-do-object is input-item
or output-item
R1220 io-implied-do-control is do-variable = scalar-int-expr ,
scalar-int-expr [ , scalar-int-expr ]
C1231 (R1216) A variable that is an input-item shall not be a whole assumed-size array.
C1232 (R1219) In an input-item-list, an io-implied-do-object shall be an input-item. In an output-item-list, an
io-implied-do-object shall be an output-item.
C1233 (R1217) An expression that is an output-item shall not have a value that is a procedure pointer.
input-item.3 If an input item is a pointer, it shall be associated with a definable target and data are transferred from the file toNOTE 12.30
A constant, an expression involving operators or function references that does not have a pointer result, or
an expression enclosed in parentheses shall not appear as an input list item.
the associated target. If an output item is a pointer, it shall be associated with a target and data are transferred4 If an input item or an output item is allocatable, it shall be allocated.from the target to the file.
NOTE 12.31
Data transfers always involve the movement of values between a file and internal storage. A pointer as such
cannot be read or written. Therefore, a pointer shall not appear as an item in an input/output list unless
it is associated with a target that can receive a value (input) or can deliver a value (output).
5 A list item shall not be polymorphic unless it is processed by a defined input/output procedure (<IP_ADDRESS>). 6 The do-variable of an io-implied-do that is in another io-implied-do shall not appear as, nor be associated with, the do-variable of the containing io-implied-do.7 The following rules describing whether to expand an input/output list item are re-applied to each expanded list
item until none of the rules apply.8 The scalar objects resulting when a data transfer statement’s list items are expanded according to the rules in• If an array appears as an input/output list item, it is treated as if the elements, if any, were specified in
array element order (<IP_ADDRESS>). However, no element of that array may affect the value of any expression in
the input-item, nor may any element appear more than once in a given input-item.
NOTE 12.32
For example:
INTEGER A (100), J (100)
...
READ *, A (A) ! Not allowed
READ *, A (LBOUND (A, 1) : UBOUND (A, 1)) ! Allowed
⃝c ISO/IEC 2017 – All rights reserved 237
ISO/IEC DIS 1539-1:2017 (E)
NOTE 12.32 (cont.)
READ *, A (J) ! Allowed if no two elements
! of J have the same value
A(1) = 1; A(10) = 10
READ *, A (A (1) : A (10)) ! Not allowed
• If a list item of derived type in an unformatted input/output statement is not processed by a defined
input/output procedure (<IP_ADDRESS>), and if any subobject of that list item would be processed by a defined
input/output procedure, the list item is treated as if all of the components of the object were specified in
the list in component order (<IP_ADDRESS>); those components shall be accessible in the scoping unit containing
the data transfer statement and shall not be pointers or allocatable.
• An effective item of derived type in an unformatted input/output statement is treated as a single value in a
processor-dependent form unless the list item or a subobject thereof is processed by a defined input/output
procedure (<IP_ADDRESS>).
NOTE 12.33
The appearance of a derived-type object as an input/output list item in an unformatted input/output
statement is not equivalent to the list of its components.
Unformatted input/output involving derived-type list items forms the single exception to the rule that the
appearance of an aggregate list item (such as an array) is equivalent to the appearance of its expanded
list of component parts. This exception permits the processor greater latitude in improving efficiency or
in matching the processor-dependent sequence of values for a derived-type object to similar sequences for
aggregate objects used by means other than Fortran. However, formatted input/output of all list items and
unformatted input/output of list items other than those of derived types adhere to the above rule.
• If a list item of derived type in a formatted input/output statement is not processed by a defined in-
put/output procedure, that list item is treated as if all of the components of the list item were specified
in the list in component order; those components shall be accessible in the scoping unit containing the
input/output statement and shall not be pointers or allocatable.
• If a derived-type list item is not processed by a defined input/output procedure and is not treated as a list
of its individual components, all the subcomponents of that list item shall be accessible in the scoping unit
containing the data transfer statement and shall not be pointers or allocatable.
• For an io-implied-do, the loop initialization and execution are the same as for a DO construct (<IP_ADDRESS>).
NOTE 12.34
An example of an output list with an implied DO is:
WRITE (LP, FMT = ’(10F8.2)’) (LOG (A (I)), I = 1, N + 9, K), G
this subclause for handling array and derived-type list items are called effective items. Zero-sized arrays and9 An input/output list shall not contain an effective item of nondefault character kind if the data transfer statementio-implied-dos with an iteration count of zero do not contribute to the list of effective items. A scalar character
item of zero length is an effective item.
NOTE 12.35
In a formatted input/output statement, edit descriptors are associated with effective items, which are always
scalar. The rules in 12.6.3 determine the set of effective items corresponding to each actual list item in the
statement. These rules might have to be applied repetitively until all of the effective items are scalar items.
specifies an internal file of default character kind. An input/output list shall not contain an effective item that is1 Execution of a WRITE or PRINT statement for a unit connected to a file that does not exist creates the filenondefault character except for ISO 10646 or ASCII character if the data transfer statement specifies an internal
file of ISO 10646 character kind. An input/output list shall not contain an effective item of type character of any
kind other than ASCII if the data transfer statement specifies an ASCII character internal file.
238 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
12.6.4 Execution of a data transfer input/output statement
<IP_ADDRESS> Data transfer sequence of operations
unless an error condition occurs.2 The effect of executing a synchronous data transfer statement shall be as if the following operations were performed
in the order specified.3 The effect of executing an asynchronous data transfer statement shall be as if the following operations were(1) Determine the direction of data transfer (<IP_ADDRESS>).
(2) Identify the unit (<IP_ADDRESS>).
(3) Perform a wait operation for all pending input/output operations for the unit. If an error, end-of-file,
or end-of-record condition occurs during any of the wait operations, steps 4 through 8 are skipped.
(4) Establish the format if one is specified.
(5) If the statement is not a child data transfer statement (<IP_ADDRESS>),
(a) position the file prior to data transfer (<IP_ADDRESS>), and
(b) for formatted data transfer, set the left tab limit (<IP_ADDRESS>).
(6) Transfer data between the file and the entities specified by the input/output list (if any) or namelist,
possibly mediated by defined input/output procedures (<IP_ADDRESS>).
(7) Determine whether an error, end-of-file, or end-of-record condition has occurred.
(8) Position the file after data transfer (<IP_ADDRESS>) unless the statement is a child data transfer statement
(<IP_ADDRESS>).
(9) Cause any variable specified in a SIZE= specifier to become defined.
(10) If an error, end-of-file, or end-of-record condition occurred, processing continues as specified in 12.11;
otherwise, any variable specified in an IOSTAT= specifier is assigned the value zero.
performed in the order specified.4 For an asynchronous data transfer statement, the data transfers may occur during execution of the statement,(1) Determine the direction of data transfer (<IP_ADDRESS>).
(2) Identify the unit (<IP_ADDRESS>).
(3) Optionally, perform wait operations for one or more pending input/output operations for the unit.
If an error, end-of-file, or end-of-record condition occurs during any of the wait operations, steps 4
through 9 are skipped.
(4) Establish the format if one is specified.
(5) Position the file prior to data transfer (<IP_ADDRESS>) and, for formatted data transfer, set the left tab
limit (<IP_ADDRESS>).
(6) Establish the set of storage units identified by the input/output list. For an input statement, this
might require some or all of the data in the file to be read if an input variable is used as a scalar-
int-expr in an io-implied-do-control in the input/output list, as a subscript, substring-range, stride,
or is otherwise referenced.
(7) Initiate an asynchronous data transfer between the file and the entities specified by the input/output
list (if any) or namelist. The asynchronous data transfer may complete (and an error, end-of-file, or
end-of-record condition may occur) during the execution of this data transfer statement or during a
later wait operation.
(8) Determine whether an error, end-of-file, or end-of-record condition has occurred. The conditions
may occur during the execution of this data transfer statement or during the corresponding wait
operation, but not both.
(9) Position the file as if the data transfer had finished (<IP_ADDRESS>).
(10) Cause any variable specified in a SIZE= specifier to become undefined.
(11) If an error, end-of-file, or end-of-record condition occurred, processing continues as specified in 12.11;
otherwise, any variable specified in an IOSTAT= specifier is assigned the value zero.
⃝c ISO/IEC 2017 – All rights reserved 239
ISO/IEC DIS 1539-1:2017 (E)
during execution of the corresponding wait operation, or anywhere between. The data transfer operation is5 For asynchronous output, a pending input/output storage sequence affector (<IP_ADDRESS>) shall not be redefined,considered to be pending until a corresponding wait operation is performed.
become undefined, or have its pointer association status changed.6 For asynchronous input, a pending input/output storage sequence affector shall not be referenced, become defined,
become undefined, become associated with a dummy argument that has the VALUE attribute, or have its pointer7 Error, end-of-file, and end-of-record conditions in an asynchronous data transfer operation may occur duringassociation status changed.
execution of either the data transfer statement or the corresponding wait operation. If an ID= specifier does not8 If execution of the program is terminated during execution of an output statement, the contents of the file becomeappear in the initiating data transfer statement, the conditions may occur during the execution of any subsequent
data transfer or wait operation for the same unit. When a condition occurs for a previously executed asynchronous
data transfer statement, a wait operation is performed for all pending data transfer operations on that unit. When
a condition occurs during a subsequent statement, any actions specified by IOSTAT=, IOMSG=, ERR=, END=,
and EOR= specifiers for that statement are taken.
undefined.1 Execution of a READ statement causes values to be transferred from a file to the entities specified by the inputNOTE 12.36
Because end-of-file and error conditions for asynchronous data transfer statements without an ID= specifier
can be reported by the processor during the execution of a subsequent data transfer statement, it might be
impossible for the user to determine which data transfer statement caused the condition. Reliably detecting
which input statement caused an end-of-file condition requires that all asynchronous input statements for
the unit include an ID= specifier.
<IP_ADDRESS> Direction of data transfer
list, if any, or specified within the file itself for namelist input. Execution of a WRITE or PRINT statement1 A data transfer statement that contains an input/output control list includes a UNIT= specifier that identifiescauses values to be transferred to a file from the entities specified by the output list and format specification, if
any, or by the namelist-group-name for namelist output.
<IP_ADDRESS> Identifying a unit
an external or internal unit. A READ statement that does not contain an input/output control list specifies a2 The unit identified by an unformatted data transfer statement shall be an external unit.particular processor-dependent unit, which is the same as the unit identified by * in a READ statement that
contains an input/output control list (12.5.1) and is the same as the unit identified by the value of the named
constant INPUT_UNIT of the intrinsic module ISO_FORTRAN_ENV (<IP_ADDRESS>). The PRINT statement
specifies some other processor-dependent unit, which is the same as the unit identified by * in a WRITE statement
and is the same as the unit identified by the value of the named constant OUTPUT_UNIT of the intrinsic module
ISO_FORTRAN_ENV (<IP_ADDRESS>). Thus, each data transfer statement identifies an external or internal unit.
3 The unit identified by a data transfer statement shall be connected to a file when execution of the statement begins.1 If the input/output control list contains * as a format, list-directed formatting is established. If namelist-group-NOTE 12.37
The unit could be preconnected.
240 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> Establishing a format
name appears, namelist formatting is established. If no format or namelist-group-name is specified, unformatted2 For output to an internal file, a format specification that is in the file or is associated with the file shall not bedata transfer is established. Otherwise, the format specified by format is established.
specified.3 An input list item, or an entity associated with it, shall not contain any portion of an established format spe-
cification.1 Data are transferred between the file and the entities specified by the input/output list or namelist. The list items<IP_ADDRESS> Data transfer
<IP_ADDRESS>.1 General
are processed in the order of the input/output list for all data transfer statements except namelist data transfer2 All values needed to determine which entities are specified by an input/output list item are determined at thestatements. The list items for a namelist input statement are processed in the order of the entities specified
within the input records. The list items for a namelist output statement are processed in the order in which the
variables are specified in the namelist-group-object-list. Effective items are derived from the input/output list
items as described in 12.6.3.
beginning of the processing of that item.3 All values are transmitted to or from the entities specified by a list item prior to the processing of any succeeding
list item for all data transfer statements.4 All values following the name= part of the namelist entity (13.11) within the input records are transmitted toNOTE 12.38
In the example
READ (N) N, X (N)
the old value of N identifies the unit, but the new value of N is the subscript of X.
the matching entity specified in the namelist-group-object-list prior to processing any succeeding entity within5 If the input/output item is a pointer, data are transferred between the file and the associated target.the input record for namelist input statements. If an entity is specified more than once within the input record
during a namelist input statement, the last occurrence of the entity specifies the value or values to be used for
that entity.
6 If an internal file has been specified, an input/output list item shall not be in the file or associated with the file.
7 During the execution of an output statement that specifies an internal file, no part of that internal file shall be
referenced, defined, or become undefined as the result of evaluating any output list item.8 During the execution of an input statement that specifies an internal file, no part of that internal file shall be
defined or become undefined as the result of transferring a value to any input list item.9 A DO variable becomes defined and its iteration count established at the beginning of processing of the io-implied-
do-object-list an io-implied-do.10 On output, every entity whose value is to be transferred shall be defined.
⃝c ISO/IEC 2017 – All rights reserved 241ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS>.2 Unformatted data transfer 1 If the file is not connected for unformatted input/output, unformatted data transfer is prohibited. 2 During unformatted data transfer, data are transferred without editing between the file and the entities specified by the input/output list. If the file is connected for sequential or direct access, exactly one record is read or3 A value in the file is stored in a contiguous sequence of file storage units, beginning with the file storage unitwritten.
immediately following the current file position.4 After each value is transferred, the current file position is moved to a point immediately after the last file storage
unit of the value.5 On input from a file connected for sequential or direct access, the number of file storage units required by the
input list shall be less than or equal to the number of file storage units in the record.6 On input, if the file storage units transferred do not contain a value with the same type and type parameters as
the input list entity, then the resulting value of the entity is processor dependent except in the following cases.7 On output to a file connected for unformatted direct access, the output list shall not specify more values than• A complex entity may correspond to two real values with the same kind type parameter as the complex
entity.
• A default character list entity of length n may correspond to n default characters stored in the file, regardless
of the length parameters of the entities that were written to these storage units of the file. If the file is
connected for stream input, the characters may have been written by formatted stream output.
can fit into the record. If the file is connected for direct access and the values specified by the output list do not8 If the file is connected for unformatted sequential access, the record is created with a length sufficient to holdfill the record, the remainder of the record is undefined.
the values from the output list. This length shall be one of the set of allowed record lengths for the file and1 If the file is not connected for formatted input/output, formatted data transfer is prohibited.shall not exceed the value specified in the RECL= specifier, if any, of the OPEN statement that established the
connection.
<IP_ADDRESS>.3 Formatted data transfer
2 During formatted data transfer, data are transferred with editing between the file and the entities specified by the input/output list or by the namelist-group-name. Format control is initiated and editing is performed as3 The current record and possibly additional records are read or written.described in Clause 13.
4 During advancing input when the pad mode has the value NO, the input list and format specification shall not require more characters from the record than the record contains.5 During advancing input when the pad mode has the value YES, blank characters are supplied by the processor
if the input list and format specification require more characters from the record than the record contains.6 During nonadvancing input when the pad mode has the value NO, an end-of-record condition (12.11) occurs if
the input list and format specification require more characters from the record than the record contains, and the7 During nonadvancing input when the pad mode has the value YES, blank characters are supplied by the processorrecord is complete (<IP_ADDRESS>). If the record is incomplete, an end-of-file condition occurs instead of an end-of-record
condition.
if an effective item and its corresponding data edit descriptors require more characters from the record than the8 If the file is connected for direct access, the record number is increased by one as each succeeding record is readrecord contains. If the record is incomplete, an end-of-file condition occurs; otherwise, an end-of-record condition
occurs.
242 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
or written.9 On output, if the file is connected for direct access or is an internal file and the characters specified by the output
list and format do not fill a record, blank characters are added to fill the record.10 On output, the output list and format specification shall not specify more characters for a record than have been
specified by a RECL= specifier in the OPEN statement or the record length of an internal file.1 If list-directed formatting has been established, editing is performed as described in <IP_ADDRESS>.4.6 List-directed formatting
<IP_ADDRESS> Namelist formatting1 If namelist formatting has been established, editing is performed as described in 13.11.
2 Every allocatable namelist-group-object in the namelist group shall be allocated and every namelist-group-object
that is a pointer shall be associated with a target. If a namelist-group-object is polymorphic or has an ultimate1 Defined input/output allows a program to override the default handling of derived-type objects and values incomponent that is allocatable or a pointer, that object shall be processed by a defined input/output procedure
(<IP_ADDRESS>).
<IP_ADDRESS> Defined input/output
<IP_ADDRESS>.1 General
data transfer statements described in <IP_ADDRESS> A defined input/output procedure is a procedure accessible by a defined-io-generic-spec (<IP_ADDRESS>). A particular
defined input/output procedure is selected as described in <IP_ADDRESS>.4.1 For a particular derived type and a particular set of kind type parameter values, there are four possible sets of<IP_ADDRESS>.2 Defined input/output procedures
characteristics for defined input/output procedures; one each for formatted input, formatted output, unformatted2 In the four interfaces, which specify the characteristics of defined input/output procedures, the following syntaxinput, and unformatted output. The program need not supply all four procedures. The procedures are specified
to be used for derived-type input/output by interface blocks (<IP_ADDRESS>) or by generic bindings (7.5.5), with a
defined-io-generic-spec (R1509). The defined-io-generic-specs for these procedures are READ (FORMATTED),
READ (UNFORMATTED), WRITE (FORMATTED), and WRITE (UNFORMATTED), for formatted input,
unformatted input, formatted output, and unformatted output respectively.
term is used:3 If the defined-io-generic-spec is READ (FORMATTED), the characteristics shall be the same as those specifiedR1221 dtv-type-spec is TYPE( derived-type-spec )
or CLASS( derived-type-spec )
C1234 (R1221) If derived-type-spec specifies an extensible type, the CLASS keyword shall be used; otherwise,
the TYPE keyword shall be used.
C1235 (R1221) All length type parameters of derived-type-spec shall be assumed.
by the following interface:ISO/IEC DIS 1539-1:2017 (E)SUBROUTINE my_read_routine_formatted (dtv, &
unit, &
iotype, v_list, &
⃝c ISO/IEC 2017 – All rights reserved 243
iostat, iomsg)! the derived-type variable
dtv-type-spec , INTENT(INOUT) :: dtv
INTEGER, INTENT(IN) :: unit ! unit number
! the edit descriptor string
CHARACTER (LEN=*), INTENT(IN) :: iotype
INTEGER, INTENT(IN) :: v_list(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
4 If the defined-io-generic-spec is READ (UNFORMATTED), the characteristics shall be the same as those specified
by the following interface:SUBROUTINE my_read_routine_unformatted (dtv, &
unit, &
iostat, iomsg)
! the derived-type variable
dtv-type-spec , INTENT(INOUT) :: dtv
INTEGER, INTENT(IN) :: unit
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
5 If the defined-io-generic-spec is WRITE (FORMATTED), the characteristics shall be the same as those specified
by the following interface:SUBROUTINE my_write_routine_formatted (dtv, &
unit, &
iotype, v_list, &
iostat, iomsg)
! the derived-type value/variable
dtv-type-spec , INTENT(IN) :: dtv
INTEGER, INTENT(IN) :: unit
! the edit descriptor string
CHARACTER (LEN=*), INTENT(IN) :: iotype
INTEGER, INTENT(IN) :: v_list(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
6 If the defined-io-generic-spec is WRITE (UNFORMATTED), the characteristics shall be the same as those
specified by the following interface:SUBROUTINE my_write_routine_unformatted (dtv, &
unit, &
iostat, iomsg)
! the derived-type value/variable
dtv-type-spec , INTENT(IN) :: dtv
INTEGER, INTENT(IN) :: unit
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
244 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)7 The actual specific procedure names (the my_..._routine_... procedure names above) are not significant. In
the discussion here and elsewhere, the dummy arguments in these interfaces are referred to by the names given1 If a defined input/output procedure is selected for an effective item as specified in <IP_ADDRESS>.4, the processor shallabove; the names are, however, arbitrary.
<IP_ADDRESS>.3 Executing defined input/output data transfers
call the selected defined input/output procedure for that item. The defined input/output procedure controls the2 A data transfer statement that includes a derived-type list item and that causes a defined input/output procedureactual data transfer operations for the derived-type list item.
to be invoked is called a parent data transfer statement. A data transfer statement that is executed while a parent3 A child data transfer statement is processed differently from a nonchild data transfer statement in the followingdata transfer statement is being processed and that specifies the unit passed into a defined input/output procedure
is called a child data transfer statement.
NOTE 12.39
A defined input/output procedure will usually contain child data transfer statements that read values
from or write values to the current record or at the current file position. The effect of executing the
defined input/output procedure is similar to that of substituting the list items from any child data transfer
statements into the parent data transfer statement’s list items, along with similar substitutions in the format
specification.
NOTE 12.40
A particular execution of a READ, WRITE or PRINT statement can be both a parent and a child data
transfer statement. A defined input/output procedure can indirectly call itself or another defined in-
put/output procedure by executing a child data transfer statement containing a list item of derived type,
where a matching interface is accessible for that derived type. If a defined input/output procedure calls
itself indirectly in this manner, it cannot be declared NON_RECURSIVE.
ways.4 When a defined input/output procedure is invoked, the processor shall pass a unit argument that has a value as• Executing a child data transfer statement does not position the file prior to data transfer.
• An unformatted child data transfer statement does not position the file after data transfer is complete.
• Any ADVANCE= specifier in a child input/output statement is ignored.
follows.5 For formatted data transfer, the processor shall pass an iotype argument that has the value• If the parent data transfer statement uses a file-unit-number, the value of the unit argument shall be that
of the file-unit-number.
• If the parent data transfer statement is a WRITE statement with an asterisk unit or a PRINT statement,
the unit argument shall have the same value as the named constant OUTPUT_UNIT of the intrinsic
module ISO_FORTRAN_ENV (16.10.2).
• If the parent data transfer statement is a READ statement with an asterisk unit or a READ statement
without an io-control-spec-list, the unit argument shall have the same value as the INPUT_UNIT named
constant of the intrinsic module ISO_FORTRAN_ENV (16.10.2).
• Otherwise the parent data transfer statement accesses an internal file, in which case the unit argument
shall have a processor-dependent negative value.
NOTE 12.41
The unit argument passed to a defined input/output procedure will be negative when the parent data
transfer statement specified an internal unit, or specified an external unit that is a NEWUNIT value.
⃝c ISO/IEC 2017 – All rights reserved 245
ISO/IEC DIS 1539-1:2017 (E)
NOTE 12.41 (cont.)
When an internal unit is used with the INQUIRE statement, an error condition will occur, and any variable
specified in an IOSTAT= specifier will be assigned the value IOSTAT_INQUIRE_INTERNAL_UNIT from
the intrinsic module ISO_FORTRAN_ENV (16.10.2).
• “LISTDIRECTED” if the parent data transfer statement specified list directed formatting,6 If the parent data transfer statement is an input statement, the dtv dummy argument is argument associated• “NAMELIST” if the parent data transfer statement specified namelist formatting, or
• “DT” concatenated with the char-literal-constant, if any, of the DT edit descriptor in the format specification
of the parent data transfer statement.
with the effective item that caused the defined input procedure to be invoked, as if the effective item were an7 If the parent data transfer statement is an output statement, the processor shall provide the value of the effectiveactual argument in this procedure reference (5.4.5).
item in the dtv dummy argument.8 If the v-list of the edit descriptor appears in the parent data transfer statement, the processor shall provide the
values from it in the v_list dummy argument, with the same number of elements in the same order as v-list.9 The iostat argument is used to report whether an error, end-of-record, or end-of-file condition (12.11) occurs.If there is no v-list in the edit descriptor or if the data transfer statement specifies list-directed or namelist
formatting, the processor shall provide v_list as a zero-sized array.
NOTE 12.42
The user’s procedure might choose to interpret an element of the v_list argument as a field width, but
this is not required. If it does, it would be appropriate to fill an output field with “*”s if the width is too
small.
If an error condition occurs, the defined input/output procedure shall assign a positive value to the iostat10 If the defined input/output procedure returns a nonzero value for the iostat argument, the procedure shall alsoargument. Otherwise, if an end-of-file condition occurs, the defined input procedure shall assign the value of the
named constant IOSTAT_END (<IP_ADDRESS>) to the iostat argument. Otherwise, if an end-of-record condition
occurs, the defined input procedure shall assign the value of the named constant IOSTAT_EOR (<IP_ADDRESS>) to
iostat. Otherwise, the defined input/output procedure shall assign the value zero to the iostat argument.
return an explanatory message in the iomsg argument. Otherwise, the procedure shall not change the value of11 If the iostat argument of the defined input/output procedure has a nonzero value when that procedure returns,the iomsg argument.
NOTE 12.43
The values of the iostat and iomsg arguments set in a defined input/output procedure need not be passed
to all of the parent data transfer statements.
and the processor therefore terminates execution of the program as described in 12.11, the processor shall make12 While a parent READ statement is active, an input/output statement shall not read from any external unit otherthe value of the iomsg argument available in a processor-dependent manner.
than the one specified by the unit dummy argument and shall not perform output to any external unit.13 While a parent WRITE or PRINT statement is active, an input/output statement shall not perform output to
any external unit other than the one specified by the unit dummy argument and shall not read from any external14 While a parent data transfer statement is active, a data transfer statement that specifies an internal file isunit.
246 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
permitted.15 OPEN, CLOSE, BACKSPACE, ENDFILE, and REWIND statements shall not be executed while a parent data
transfer statement is active.16 A defined input/output procedure may use a format specification with a DT edit descriptor for handling a
component of the derived type that is itself of a derived type. A child data transfer statement that is a list17 Because a child data transfer statement does not position the file prior to data transfer, the child data transferdirected or namelist input/output statement may contain a list item of derived type.
statement starts transferring data from where the file was positioned by the parent data transfer statement’s18 The edit descriptors T and TL used on unit by a child data transfer statement shall not cause the file to bemost recently processed effective item or edit descriptor. This is not necessarily at the beginning of a record.
positioned before the file position at the time the defined input/output procedure was invoked.19 Neither a parent nor child data transfer statement shall be asynchronous.NOTE 12.44
A defined input/output procedure could use INQUIRE to determine the settings of BLANK=, PAD=,
ROUND=, DECIMAL=, and DELIM= for an external unit. The INQUIRE statement provides values as
specified in 12.10.
20 A defined input/output procedure, and any procedures invoked therefrom, shall not define, nor cause to become
undefined, any storage unit referenced by any input/output list item, the corresponding format, or any specifierin any active parent data transfer statement, except through the dtv argument.
NOTE 12.45
A data transfer statement with an ID=, POS=, or REC= specifier cannot be a child data transfer statement
in a standard-conforming program.
NOTE 12.46
A simple example of derived type formatted output follows. The derived type variable chairman has two
components. The type and an associated write formatted procedure are defined in a module so as to be
accessible from wherever they might be needed. It would also be possible to check that iotype indeed has
the value ’DT’ and to set iostat and iomsg accordingly.
MODULE p
TYPE :: person
CHARACTER (LEN=20) :: name
INTEGER :: age
CONTAINS
PROCEDURE,PRIVATE :: pwf
GENERIC :: WRITE(FORMATTED) => pwf END TYPE person
SUBROUTINE pwf (dtv,unit,iotype,vlist,iostat,iomsg)
! argument definitions
CLASS(person), INTENT(IN) :: dtvINTEGER, INTENT(IN) :: unit
CHARACTER (LEN=*), INTENT(IN) :: iotype
⃝c ISO/IEC 2017 – All rights reserved 247
ISO/IEC DIS 1539-1:2017 (E)
NOTE 12.46 (cont.)INTEGER, INTENT(IN) :: vlist(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
! local variable
CHARACTER (LEN=9) :: pfmt
! vlist(1) and (2) are to be used as the field widths of the two
! components of the derived type variable. First set up the format to
! be used for output.
WRITE(pfmt,’(A,I2,A,I2,A)’ ) ’(A’, vlist(1), ’,I’, vlist(2), ’)’
! now the basic output statement
WRITE(unit, FMT=pfmt, IOSTAT=iostat) dtv%name, dtv%age
END SUBROUTINE pwf
END MODULE p
PROGRAM committee
USE p
INTEGER id, members
TYPE (person) :: chairman
...
WRITE(6, FMT="(I2, DT (15,6), I5)" ) id, chairman, members
! this writes a record with four fields, with lengths 2, 15, 6, 5
! respectively
END PROGRAM
NOTE 12.47
In the following example, the variables of the derived type node form a linked list, with a single value at
each node. The subroutine pwf is used to write the values in the list, one per line.
MODULE p
TYPE nodeINTEGER :: value = 0
TYPE (NODE), POINTER :: next_node => NULL ( )
CONTAINS
PROCEDURE,PRIVATE :: pwf
GENERIC :: WRITE(FORMATTED) => pwf END TYPE node
SUBROUTINE pwf (dtv,unit,iotype,vlist,iostat,iomsg)
! Write the chain of values, each on a separate line in I9 format.
CLASS(node), INTENT(IN) :: dtvINTEGER, INTENT(IN) :: unit
CHARACTER (LEN=*), INTENT(IN) :: iotype
INTEGER, INTENT(IN) :: vlist(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
248 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)NOTE 12.47 (cont.)
WRITE(unit,’(i9 /)’, IOSTAT = iostat) dtv%valueEND SUBROUTINE pwfIF(iostat/=0) RETURN
IF(ASSOCIATED(dtv%next_node)) WRITE(unit,’(dt)’, IOSTAT=iostat) dtv%next_node
END MODULE p
<IP_ADDRESS>.4 Resolving defined input/output procedure references 1 A suitable generic interface for defined input/output of an effective item is one that has a defined-io-generic-spec
that is appropriate to the direction (read or write) and form (formatted or unformatted) of the data transfer2 When an effective item (12.6.3) that is of derived type is encountered during a data transfer, defined input/outputas specified in <IP_ADDRESS>.2, and has a specific interface whose dtv argument is compatible with the effective item
according to the rules for argument association in <IP_ADDRESS>.
occurs if both of the following conditions are true.3 If (2a) is true, the procedure referenced is determined as for explicit type-bound procedure references (15.5); that(1) The circumstances of the input/output are such that defined input/output is permitted; that is,
either
(a) the transfer was initiated by a list-directed, namelist, or unformatted input/output statement,
or
(b) a format specification is supplied for the data transfer statement, and the edit descriptor
corresponding to the effective item is a DT edit descriptor.
(2) A suitable defined input/output procedure is available; that is, either
(a) the declared type of the effective item has a suitable generic type-bound procedure, or
(b) a suitable generic interface is accessible.
is, the binding with the appropriate specific interface is located in the declared type of the effective item, and the4 If (2a) is false and (2b) is true, the reference is to the procedure identified by the appropriate specific interfacecorresponding binding in the dynamic type of the effective item is selected.
in the interface block.1 Termination of a data transfer statement occurs when12.6.5 Termination of data transfer statements
• format processing encounters a colon or data edit descriptor and there are no remaining elements in theinput-item-list or output-item-list,
• unformatted or list-directed data transfer exhausts the input-item-list or output-item-list,
• namelist output exhausts the namelist-group-object-list,
• an error condition occurs,
• an end-of-file condition occurs,
• a slash (/) is encountered as a value separator (13.10, 13.11) in the record being read during list-directed
or namelist input, or
• an end-of-record condition occurs during execution of a nonadvancing input statement (12.11).
⃝c ISO/IEC 2017 – All rights reserved 249
ISO/IEC DIS 1539-1:2017 (E)
12.7 Waiting on pending data transfer 12.7.1 Wait operation 1 Execution of an asynchronous data transfer statement in which neither an error, end-of-record, nor end-of-file
condition occurs initiates a pending data transfer operation. There may be multiple pending data transfer2 A wait operation completes the processing of a pending data transfer operation. Each wait operation completesoperations for the same or multiple units simultaneously. A pending data transfer operation remains pending
until a corresponding wait operation is performed. A wait operation may be performed by a BACKSPACE,
CLOSE, ENDFILE, FLUSH, INQUIRE, PRINT, READ, REWIND, WAIT, or WRITE statement.
only a single data transfer operation, although a single statement may perform multiple wait operations.3 If the actual data transfer is not yet complete, the wait operation first waits for its completion. If the data
transfer operation is an input operation that completed without error, the storage units of the input/output4 If any error, end-of-file, or end-of-record conditions occur, the applicable actions specified by the IOSTAT=,storage sequence then become defined with the values as described in <IP_ADDRESS> and <IP_ADDRESS>.
IOMSG=, ERR=, END=, and EOR= specifiers of the statement that performs the wait operation are taken.5 If an error or end-of-file condition occurs during a wait operation for a unit, the processor performs a wait
operation for all pending data transfer operations for that unit.6 After completion of the wait operation, the data transfer operation and its input/output storage sequence are noNOTE 12.48
Error, end-of-file, and end-of-record conditions can be raised either during the data transfer statement that
initiates asynchronous input/output, a subsequent asynchronous data transfer statement for the same unit,
or during the wait operation. If such conditions are raised during a data transfer statement, they trigger
actions according to the IOSTAT=, ERR=, END=, and EOR= specifiers of that statement; if they are
raised during the wait operation, the actions are in accordance with the specifiers of the statement that
performs the wait operation.
longer considered to be pending.1 A WAIT statement performs a wait operation for specified pending asynchronous data transfer operations.12.7.2 WAIT statement
R1222 wait-stmt is WAIT (wait-spec-list)2 The IOSTAT=, ERR=, EOR=, END=, and IOMSG= specifiers are described in 12.11.R1223 wait-spec is [ UNIT = ] file-unit-number
or END = label
or EOR = label
or ERR = label
or ID = scalar-int-expr
or IOMSG = iomsg-variable
or IOSTAT = stat-variable
C1236 No specifier shall appear more than once in a given wait-spec-list.
C1237 A file-unit-number shall be specified in a wait-spec-list; if the optional characters UNIT= are omitted,
the file-unit-number shall be the first item in the wait-spec-list.
C1238 (R1223) The label in the ERR=, EOR=, or END= specifier shall be the statement label of a branch
target statement that appears in the same inclusive scope as the WAIT statement.
250 ⃝c ISO/IEC 2017 – All rights reserved3 The value of the expression specified in the ID= specifier shall be zero or the identifier of a pending data transfer
ISO/IEC DIS 1539-1:2017 (E)
operation for the specified unit. If the ID= specifier appears, a wait operation for the specified data transfer4 Execution of a WAIT statement specifying a unit that does not exist, has no file connected to it, or is not openoperation, if any, is performed. If the ID= specifier is omitted, wait operations for all pending data transfers for
the specified unit are performed.
for asynchronous input/output is permitted, provided that the WAIT statement has no ID= specifier; such a1 A unit that is connected for direct access shall not be referred to by a BACKSPACE, ENDFILE, or REWINDWAIT statement does not cause an error or end-of-file condition to occur.
NOTE 12.49
An EOR= specifier has no effect if the pending data transfer operation is not a nonadvancing read. An
END= specifier has no effect if the pending data transfer operation is not a READ.
12.8 File positioning statements
12.8.1 Syntax
R1224 backspace-stmt is BACKSPACE file-unit-number
or BACKSPACE ( position-spec-list )
R1225 endfile-stmt is ENDFILE file-unit-number
or ENDFILE ( position-spec-list )
R1226 rewind-stmt is REWIND file-unit-number
or REWIND ( position-spec-list )
statement. A unit that is connected for unformatted stream access shall not be referred to by a BACKSPACE2 The IOSTAT=, ERR=, and IOMSG= specifiers are described in 12.11.statement. A unit that is connected with an ACTION= specifier having the value READ shall not be referred
to by an ENDFILE statement.
R1227 position-spec is [ UNIT = ] file-unit-number
or IOMSG = iomsg-variable
or IOSTAT = stat-variable
or ERR = label
C1239 No specifier shall appear more than once in a given position-spec-list.
C1240 A file-unit-number shall be specified in a position-spec-list; if the optional characters UNIT= are omitted,
the file-unit-number shall be the first item in the position-spec-list.
C1241 (R1227) The label in the ERR= specifier shall be the statement label of a branch target statement that
appears in the same inclusive scope as the file positioning statement.
3 Execution of a file positioning statement performs a wait operation for all pending asynchronous data transfer
operations for the specified unit.1 Execution of a BACKSPACE statement causes the file connected to the specified unit to be positioned before12.8.2 BACKSPACE statement
the current record if there is a current record, or before the preceding record if there is no current record. If the2 If a BACKSPACE statement causes the implicit writing of an endfile record, the file is positioned before thefile is at its initial point, the position of the file is not changed.
⃝c ISO/IEC 2017 – All rights reserved 251
ISO/IEC DIS 1539-1:2017 (E)
NOTE 12.50
If the preceding record is an endfile record, the file is positioned before the endfile record.
record that precedes the endfile record.3 Backspacing a file that is connected but does not exist is prohibited.
4 Backspacing over records written using list-directed or namelist formatting is prohibited.
NOTE 12.51An example of a BACKSPACE statement is:
BACKSPACE (10, IOSTAT = N)
12.8.3 ENDFILE statement 1 Execution of an ENDFILE statement for a file connected for sequential access writes an endfile record as the next
record of the file. The file is then positioned after the endfile record, which becomes the last record of the file.2 After execution of an ENDFILE statement for a file connected for sequential access, a BACKSPACE or REWINDIf the file also may be connected for direct access, only those records before the endfile record are considered to
have been written. Thus, only those records may be read during subsequent direct access connections to the file.
statement shall be used to reposition the file prior to execution of any data transfer input/output statement or3 Execution of an ENDFILE statement for a file connected for stream access causes the terminal point of the fileENDFILE statement.
to become equal to the current file position. Only file storage units before the current position are considered4 Execution of an ENDFILE statement for a file that is connected but does not exist creates the file; if the file isto have been written; thus only those file storage units may be subsequently read. Subsequent stream output
statements may be used to write further data to the file.
connected for sequential access, it is created prior to writing the endfile record.NOTE 12.52
An example of an ENDFILE statement is:
ENDFILE K
12.8.4 REWIND statement 1 Execution of a REWIND statement causes the specified file to be positioned at its initial point.
NOTE 12.532 Execution of a REWIND statement for a file that is connected but does not exist is permitted and has no effectIf the file is already positioned at its initial point, execution of this statement has no effect on the position
of the file.
on any file.1 The IOSTAT=, IOMSG= and ERR= specifiers are described in 12.11.NOTE 12.54
An example of a REWIND statement is:
REWIND 10
252 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
12.9 FLUSH statement
R1228 flush-stmt is FLUSH file-unit-number
or FLUSH ( flush-spec-list )
R1229 flush-spec is [UNIT =] file-unit-number
or IOSTAT = stat-variable
or IOMSG = iomsg-variable
or ERR = label
C1242 No specifier shall appear more than once in a given flush-spec-list.
C1243 A file-unit-number shall be specified in a flush-spec-list; if the optional characters UNIT= are omitted
from the unit specifier, the file-unit-number shall be the first item in the flush-spec-list.
C1244 (R1229) The label in the ERR= specifier shall be the statement label of a branch target statement that
appears in the same inclusive scope as the FLUSH statement.
2 Execution of a FLUSH statement causes data written to an external file to be available to other processes, or
causes data placed in an external file by means other than Fortran to be available to a READ statement. These3 Execution of a FLUSH statement for a file that is connected but does not exist is permitted and has no effect onactions are processor dependent.
any file. A FLUSH statement has no effect on file position.4 Execution of a FLUSH statement performs a wait operation for all pending asynchronous data transfer operations
for the specified unit.1 The INQUIRE statement can be used to inquire about properties of a particular named file, of the connectionNOTE 12.55
Because this document does not specify the mechanism of file storage, the exact meaning of the flush
operation is not precisely defined. It is expected that the flush operation will make all data written to a file
available to other processes or devices, or make data recently added to a file by other processes or devices
available to the program via a subsequent read operation. This is commonly called “flushing input/output
buffers”.
NOTE 12.56
An example of a FLUSH statement is:
FLUSH (10, IOSTAT = N)
12.10 File inquiry statement
12.10.1 Forms of the INQUIRE statement
to a particular unit, or the number of file storage units required for an output list. There are three forms of the2 For inquiry by unit, the unit specified need not exist or be connected to a file. If it is connected to a file, theINQUIRE statement: inquire by file, which uses the FILE= specifier, inquire by unit, which uses the UNIT=
specifier, and inquire by output list, which uses only the IOLENGTH= specifier. Assignments to specifier variables
are converted, truncated, or padded according to the rules of intrinsic assignment.
inquiry is being made about the connection and about the file connected.3 For inquiry by file, the file specified need not exist or be connected to a unit. If it is connected to a unit, the
inquiry is being made about the connection as well as about the file.4 An INQUIRE statement may be executed before, while, or after a file is connected to a unit. All values assigned⃝c ISO/IEC 2017 – All rights reserved 253
ISO/IEC DIS 1539-1:2017 (E)
by an INQUIRE statement are those that are current at the time the statement is executed.1 Unless constrained, the following inquiry specifiers may be used in either of the inquire by file or inquire by unitR1230 inquire-stmt is INQUIRE ( inquire-spec-list )
or INQUIRE ( IOLENGTH = scalar-int-variable )
output-item-list
NOTE 12.57
Examples of INQUIRE statements are:
INQUIRE (IOLENGTH = IOL) A (1:N)
INQUIRE (UNIT = JOAN, OPENED = LOG_01, NAMED = LOG_02, &
FORM = CHAR_VAR, IOSTAT = IOS)
12.10.2 Inquiry specifiers
<IP_ADDRESS> Syntax
forms of the INQUIRE statement.2 If file-unit-number identifies an internal unit (<IP_ADDRESS>.2), an error condition occurs.R1231 inquire-spec is [ UNIT = ] file-unit-number
or FILE = file-name-expr
or ACCESS = scalar-default-char-variable
or ACTION = scalar-default-char-variable
or ASYNCHRONOUS = scalar-default-char-variable
or BLANK = scalar-default-char-variable
or DECIMAL = scalar-default-char-variable
or DELIM = scalar-default-char-variable
or DIRECT = scalar-default-char-variable
or ENCODING = scalar-default-char-variable
or ERR = label
or EXIST = scalar-logical-variable
or FORM = scalar-default-char-variable
or FORMATTED = scalar-default-char-variable
or ID = scalar-int-expr
or IOMSG = iomsg-variable
or IOSTAT = stat-variable
or NAME = scalar-default-char-variable
or NAMED = scalar-logical-variable
or NEXTREC = scalar-int-variable
or NUMBER = scalar-int-variable
or OPENED = scalar-logical-variable
or PAD = scalar-default-char-variable
or PENDING = scalar-logical-variable
or POS = scalar-int-variable
or POSITION = scalar-default-char-variable
or READ = scalar-default-char-variable
or READWRITE = scalar-default-char-variable
or RECL = scalar-int-variable
or ROUND = scalar-default-char-variable
or SEQUENTIAL = scalar-default-char-variable
or SIGN = scalar-default-char-variable
or SIZE = scalar-int-variable
or STREAM = scalar-default-char-variable
or UNFORMATTED = scalar-default-char-variable
or WRITE = scalar-default-char-variable
254 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
C1245 No specifier shall appear more than once in a given inquire-spec-list.
C1246 An inquire-spec-list shall contain one FILE= specifier or one file-unit-number, but not both.
C1247 In the inquire by unit form of the INQUIRE statement, if the optional characters UNIT= are omitted,
the file-unit-number shall be the first item in the inquire-spec-list.
C1248 If an ID= specifier appears in an inquire-spec-list, a PENDING= specifier shall also appear.
C1249 (R1229) The label in the ERR= specifier shall be the statement label of a branch target statement that
appears in the same inclusive scope as the INQUIRE statement.
3 When a returned value of a specifier other than the NAME= specifier is of type character, the value returned is
in upper case.4 If an error condition occurs during execution of an INQUIRE statement, all of the inquiry specifier variables
become undefined, except for variables in the IOSTAT= and IOMSG= specifiers (if any).5 The IOSTAT=, ERR=, and IOMSG= specifiers are described in 12.11.
<IP_ADDRESS> FILE= specifier in the INQUIRE statement1 The value of the file-name-expr in the FILE= specifier specifies the name of the file being inquired about. The
named file need not exist or be connected to a unit. The value of the file-name-expr shall be of a form acceptable1 The scalar-default-char-variable in the ACCESS= specifier is assigned the value SEQUENTIAL if the connectionto the processor as a file name. Any trailing blanks are ignored. The interpretation of case is processor dependent.
<IP_ADDRESS> ACCESS= specifier in the INQUIRE statement
is for sequential access, DIRECT if the connection is for direct access, or STREAM if the connection is for stream1 The scalar-default-char-variable in the ACTION= specifier is assigned the value READ if the connection is foraccess. If there is no connection, it is assigned the value UNDEFINED.
<IP_ADDRESS> ACTION= specifier in the INQUIRE statement
input only, WRITE if the connection is for output only, and READWRITE if the connection is for both input1 The scalar-default-char-variable in the ASYNCHRONOUS= specifier is assigned the value YES if the connectionand output. If there is no connection, the scalar-default-char-variable is assigned the value UNDEFINED.
<IP_ADDRESS> ASYNCHRONOUS= specifier in the INQUIRE statement
allows asynchronous input/output; it is assigned the value NO if the connection does not allow asynchronous1 The scalar-default-char-variable in the BLANK= specifier is assigned the value ZERO or NULL, correspondinginput/output. If there is no connection, the scalar-default-char-variable is assigned the value UNDEFINED.
<IP_ADDRESS> BLANK= specifier in the INQUIRE statement
to the blank interpretation mode in effect for a connection for formatted input/output. If there is no connection,1 The scalar-default-char-variable in the DECIMAL= specifier is assigned the value COMMA or POINT, corres-or if the connection is not for formatted input/output, the scalar-default-char-variable is assigned the value
UNDEFINED.
<IP_ADDRESS> DECIMAL= specifier in the INQUIRE statement
ponding to the decimal edit mode in effect for a connection for formatted input/output. If there is no connection,1 The scalar-default-char-variable in the DELIM= specifier is assigned the value APOSTROPHE, QUOTE, oror if the connection is not for formatted input/output, the scalar-default-char-variable is assigned the value
UNDEFINED.
⃝c ISO/IEC 2017 – All rights reserved 255
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> DELIM= specifier in the INQUIRE statement
NONE, corresponding to the delimiter mode in effect for a connection for formatted input/output. If there is no1 The scalar-default-char-variable in the DIRECT= specifier is assigned the value YES if DIRECT is included inconnection or if the connection is not for formatted input/output, the scalar-default-char-variable is assigned the
value UNDEFINED.
<IP_ADDRESS> DIRECT= specifier in the INQUIRE statement
the set of allowed access methods for the file, NO if DIRECT is not included in the set of allowed access methods1 The scalar-default-char-variable in the ENCODING= specifier is assigned the value UTF-8 if the connection isfor the file, and UNKNOWN if the processor is unable to determine whether DIRECT is included in the set of
allowed access methods for the file or if the unit identified by file-unit-number is not connected to a file.
<IP_ADDRESS> ENCODING= specifier in the INQUIRE statement
for formatted input/output with an encoding form of UTF-8, and is assigned the value UNDEFINED if the1 Execution of an INQUIRE by file statement causes the scalar-logical-variable in the EXIST= specifier to beconnection is for unformatted input/output. If there is no connection, it is assigned the value UTF-8 if the
processor is able to determine that the encoding form of the file is UTF-8; if the processor is unable to determine
the encoding form of the file or if the unit identified by file-unit-number is not connected to a file, the variable is
assigned the value UNKNOWN.
NOTE 12.58
The value assigned could be something other than UTF-8, UNDEFINED, or UNKNOWN if the processor
supports other specific encoding forms (e.g. UTF-16BE).
<IP_ADDRESS> EXIST= specifier in the INQUIRE statement
assigned the value true if there exists a file with the specified name; otherwise, false is assigned. Execution of an1 The scalar-default-char-variable in the FORM= specifier is assigned the value FORMATTED if the connectionINQUIRE by unit statement causes true to be assigned if the specified unit exists; otherwise, false is assigned.
<IP_ADDRESS> FORM= specifier in the INQUIRE statement
is for formatted input/output, and is assigned the value UNFORMATTED if the connection is for unformatted1 The scalar-default-char-variable in the FORMATTED= specifier is assigned the value YES if FORMATTED isinput/output. If there is no connection, it is assigned the value UNDEFINED.
<IP_ADDRESS> FORMATTED= specifier in the INQUIRE statement
included in the set of allowed forms for the file, NO if FORMATTED is not included in the set of allowed forms1 The value of the expression specified in the ID= specifier shall be the identifier of a pending data transfer operationfor the file, and UNKNOWN if the processor is unable to determine whether FORMATTED is included in the
set of allowed forms for the file or if the unit identified by file-unit-number is not connected to a file.
<IP_ADDRESS> ID= specifier in the INQUIRE statement
for the specified unit. This specifier interacts with the PENDING= specifier (<IP_ADDRESS>).1 The scalar-default-char-variable in the NAME= specifier is assigned the value of the name of the file if the file<IP_ADDRESS> NAME= specifier in the INQUIRE statement
has a name; otherwise, it becomes undefined. The value assigned shall be suitable for use as the value of the2 The case of the characters assigned to scalar-default-char-variable is processor dependent.file-name-expr in the FILE= specifier in an OPEN statement.
256 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
NOTE 12.59
If this specifier appears in an INQUIRE by file statement, its value is not necessarily the same as the name
given in the FILE= specifier.
The processor could assign a file name qualified by a user identification, device, directory, or other relevant
information.
<IP_ADDRESS> NAMED= specifier in the INQUIRE statement1 The scalar-logical-variable in the NAMED= specifier is assigned the value true if the file has a name; otherwise,
it is assigned the value false.1 The scalar-int-variable in the NEXTREC= specifier is assigned the value n + 1, where n is the record number of<IP_ADDRESS> NEXTREC= specifier in the INQUIRE statement
the last record read from or written to the connection for direct access. If there is a connection but no records have1 Execution of an INQUIRE by file statement causes the scalar-int-variable in the NUMBER= specifier to bebeen read or written since the connection, the scalar-int-variable is assigned the value 1. If there is no connection,
the connection is not for direct access, or the position is indeterminate because of a previous error condition, the
scalar-int-variable becomes undefined. If there are pending data transfer operations for the specified unit, the
value assigned is computed as if all the pending data transfers had already completed.
<IP_ADDRESS> NUMBER= specifier in the INQUIRE statement
assigned the value of the external unit number of the unit that is connected to the file. If more than one unit1 Execution of an INQUIRE by file statement causes the scalar-logical-variable in the OPENED= specifier to beon an image is connected to the file, which of the connected external unit numbers is assigned to the scalar-int-
variable is processor dependent. If there is no unit connected to the file, the value −1 is assigned. Execution of
an INQUIRE by unit statement causes the scalar-int-variable to be assigned the value of file-unit-number.
<IP_ADDRESS> OPENED= specifier in the INQUIRE statement
assigned the value true if the file specified is connected to a unit; otherwise, false is assigned. Execution of an1 The scalar-default-char-variable in the PAD= specifier is assigned the value YES or NO, corresponding to theINQUIRE by unit statement causes the scalar-logical-variable to be assigned the value true if the specified unit
is connected to a file; otherwise, false is assigned.
<IP_ADDRESS> PAD= specifier in the INQUIRE statement
pad mode in effect for a connection for formatted input/output. If there is no connection or if the connection is1 The PENDING= specifier is used to determine whether previously pending asynchronous data transfers arenot for formatted input/output, the scalar-default-char-variable is assigned the value UNDEFINED.
<IP_ADDRESS> PENDING= specifier in the INQUIRE statement
complete. A data transfer operation is previously pending if it is pending at the beginning of execution of the2 If an ID= specifier appears and the specified data transfer operation is complete, then the variable specified inINQUIRE statement.
the PENDING= specifier is assigned the value false and the INQUIRE statement performs the wait operation3 If the ID= specifier is omitted and all previously pending data transfer operations for the specified unit arefor the specified data transfer.
complete, then the variable specified in the PENDING= specifier is assigned the value false and the INQUIRE4 In all other cases, the variable specified in the PENDING= specifier is assigned the value true, no wait operationsstatement performs wait operations for all previously pending data transfers for the specified unit.
⃝c ISO/IEC 2017 – All rights reserved 257
ISO/IEC DIS 1539-1:2017 (E)
are performed, and the previously pending data transfers remain pending after the execution of the INQUIRE1 The scalar-int-variable in the POS= specifier is assigned the number of the file storage unit immediately followingstatement.
NOTE 12.60
The processor has considerable flexibility in defining when it considers a transfer to be complete. Any of
the following approaches could be used:
• The INQUIRE statement could consider an asynchronous data transfer to be incomplete until after
the corresponding wait operation. In this case PENDING= would always return true unless there
were no previously pending data transfers for the unit.
• The INQUIRE statement could wait for all specified data transfers to complete and then always return
false for PENDING=.
• The INQUIRE statement could actually test the state of the specified data transfer operations.
<IP_ADDRESS> POS= specifier in the INQUIRE statement
the current position of a file connected for stream access. If the file is positioned at its terminal position, the1 The scalar-default-char-variable in the POSITION= specifier is assigned the value REWIND if the connectionvariable is assigned a value one greater than the number of the highest-numbered file storage unit in the file.
If there are pending data transfer operations for the specified unit, the value assigned is computed as if all the
pending data transfers had already completed. If there is no connection, the file is not connected for stream
access, or if the position of the file is indeterminate because of previous error conditions, the variable becomes
undefined.
<IP_ADDRESS> POSITION= specifier in the INQUIRE statement
was opened for positioning at its initial point, APPEND if the connection was opened for positioning before its1 The scalar-default-char-variable in the READ= specifier is assigned the value YES if READ is included in theendfile record or at its terminal point, and ASIS if the connection was opened without changing its position.
If there is no connection or if the file is connected for direct access, the scalar-default-char-variable is assigned
the value UNDEFINED. If the file has been repositioned since the connection, the scalar-default-char-variable
is assigned a processor-dependent value, which shall not be REWIND unless the file is positioned at its initial
point and shall not be APPEND unless the file is positioned so that its endfile record is the next record or at its
terminal point if it has no endfile record.
<IP_ADDRESS> READ= specifier in the INQUIRE statement
set of allowed actions for the file, NO if READ is not included in the set of allowed actions for the file, and1 The scalar-default-char-variable in the READWRITE= specifier is assigned the value YES if READWRITE isUNKNOWN if the processor is unable to determine whether READ is included in the set of allowed actions for
the file or if the unit identified by file-unit-number is not connected to a file.
<IP_ADDRESS> READWRITE= specifier in the INQUIRE statement
included in the set of allowed actions for the file, NO if READWRITE is not included in the set of allowed actions1 The scalar-int-variable in the RECL= specifier is assigned the value of the record length of a connection for directfor the file, and UNKNOWN if the processor is unable to determine whether READWRITE is included in the
set of allowed actions for the file or if the unit identified by file-unit-number is not connected to a file.
<IP_ADDRESS> RECL= specifier in the INQUIRE statement
access, or the value of the maximum record length of a connection for sequential access. If the connection is for1 The scalar-default-char-variable in the ROUND= specifier is assigned the value UP, DOWN, ZERO, NEAREST,formatted input/output, the length is the number of characters for all records that contain only characters of
258 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
default kind. If the connection is for unformatted input/output, the length is measured in file storage units. If
there is no connection, the scalar-int-variable is assigned the value −1, and if the connection is for stream access,
the scalar-int-variable is assigned the value −2.
<IP_ADDRESS> ROUND= specifier in the INQUIRE statement
COMPATIBLE, or PROCESSOR_DEFINED, corresponding to the input/output rounding mode in effect for1 The scalar-default-char-variable in the SEQUENTIAL= specifier is assigned the value YES if SEQUENTIAL isa connection for formatted input/output. If there is no connection or if the connection is not for formatted
input/output, the scalar-default-char-variable is assigned the value UNDEFINED. The processor shall return the
value PROCESSOR_DEFINED only if the behavior of the input/output rounding mode is different from that
of the UP, DOWN, ZERO, NEAREST, and COMPATIBLE modes.
<IP_ADDRESS> SEQUENTIAL= specifier in the INQUIRE statement
included in the set of allowed access methods for the file, NO if SEQUENTIAL is not included in the set of allowed1 The scalar-default-char-variable in the SIGN= specifier is assigned the value PLUS, SUPPRESS, or PRO-access methods for the file, and UNKNOWN if the processor is unable to determine whether SEQUENTIAL is
included in the set of allowed access methods for the file or if the unit identified by file-unit-number is not
connected to a file.
<IP_ADDRESS> SIGN= specifier in the INQUIRE statement
CESSOR_DEFINED, corresponding to the sign mode in effect for a connection for formatted input/output.1 The scalar-int-variable in the SIZE= specifier is assigned the size of the file in file storage units. If the file sizeIf there is no connection, or if the connection is not for formatted input/output, the scalar-default-char-variable
is assigned the value UNDEFINED.
<IP_ADDRESS> SIZE= specifier in the INQUIRE statement
cannot be determined or if the unit identified by file-unit-number is not connected to a file, the variable is assigned2 For a file that may be connected for stream access, the file size is the number of the highest-numbered file storagethe value −1.
unit in the file.3 For a file that may be connected for sequential or direct access, the file size may be different from the number of
storage units implied by the data in the records; the exact relationship is processor dependent.4 If there are pending data transfer operations for the specified unit, the value assigned is computed as if all the
pending data transfers had already completed.1 The scalar-default-char-variable in the STREAM= specifier is assigned the value YES if STREAM is included in<IP_ADDRESS> STREAM= specifier in the INQUIRE statement
the set of allowed access methods for the file, NO if STREAM is not included in the set of allowed access methods1 The scalar-default-char-variable in the UNFORMATTED= specifier is assigned the value YES if UNFORMAT-for the file, and UNKNOWN if the processor is unable to determine whether STREAM is included in the set of
allowed access methods for the file or if the unit identified by file-unit-number is not connected to a file.
<IP_ADDRESS> UNFORMATTED= specifier in the INQUIRE statement
TED is included in the set of allowed forms for the file, NO if UNFORMATTED is not included in the set of1 The scalar-default-char-variable in the WRITE= specifier is assigned the value YES if WRITE is included in theallowed forms for the file, and UNKNOWN if the processor is unable to determine whether UNFORMATTED is
included in the set of allowed forms for the file or if the unit identified by file-unit-number is not connected to a
file.
⃝c ISO/IEC 2017 – All rights reserved 259
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> WRITE= specifier in the INQUIRE statement
set of allowed actions for the file, NO if WRITE is not included in the set of allowed actions for the file, and1 The scalar-int-variable in the IOLENGTH= specifier is assigned the processor-dependent number of file storageUNKNOWN if the processor is unable to determine whether WRITE is included in the set of allowed actions for
the file or if the unit identified by file-unit-number is not connected to a file.
12.10.3 Inquire by output list
units that would be required to store the data of the output list in an unformatted file. The value shall be suitable2 The output list in an INQUIRE statement shall not contain any derived-type list items that require a definedas a RECL= specifier in an OPEN statement that connects a file for unformatted direct access if data will be
read from or written to the file using data transfer statements with an input/output list that specifies transfer of
a sequence of objects having the same types, type parameters, and extents, in the same order as the output list
in the INQUIRE statement.
input/output procedure as described in subclause 12.6.3. If a derived-type list item appears in the output list, the1 The set of input/output error conditions is processor dependent. Except as otherwise specified, when an errorvalue returned for the IOLENGTH= specifier assumes that no defined input/output procedure will be invoked.
12.11 Error, end-of-record, and end-of-file conditions
12.11.1 Occurrence of input/output conditions
condition occurs or is detected is processor dependent.2 An end-of-record condition occurs when a nonadvancing input statement attempts to transfer data from a position
beyond the end of the current record, unless the file is a stream file and the current record is at the end of the3 An end-of-file condition occurs whenfile (an end-of-file condition occurs instead).
• an endfile record is encountered during the reading of a file connected for sequential access,4 An end-of-file condition may occur at the beginning of execution of an input statement. An end-of-file condition• an attempt is made to read a record beyond the end of an internal file, or
• an attempt is made to read beyond the end of a stream file.
also may occur during execution of a formatted input statement when more than one record is required by the1 If an error condition occurs during execution of an input/output statement, the position of the file becomesinteraction of the input list and the format. An end-of-file condition also may occur during execution of a stream
input statement.
12.11.2 Error conditions and the ERR= specifier
indeterminate.2 If an error condition occurs during execution of an input/output statement that contains neither an ERR= nor
IOSTAT= specifier, error termination is initiated. If an error condition occurs during execution of an input/output1 If an end-of-file condition occurs during execution of an input/output statement that contains neither an END=statement that contains either an ERR= specifier or an IOSTAT= specifier then:
(1) processing of the input/output list, if any, terminates;
(2) if the statement is a data transfer statement or the error condition occurs during a wait operation,
all do-variables in the statement that initiated the transfer become undefined;
(3) if an IOSTAT= specifier appears, the stat-variable in the IOSTAT= specifier becomes defined as
specified in 12.11.5;
260 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
(4) if an IOMSG= specifier appears, the iomsg-variable becomes defined as specified in 12.11.6;
(5) if the statement is a READ statement and it contains a SIZE= specifier, the scalar-int-variable in
the SIZE= specifier becomes defined as specified in <IP_ADDRESS>;
(6) if the statement is a READ statement or the error condition occurs in a wait operation for a transfer
initiated by a READ statement, all input items or namelist group objects in the statement that
initiated the transfer become undefined;
(7) if an ERR= specifier appears, a branch to the statement labeled by the label in the ERR= specifier
occurs.
12.11.3 End-of-file condition and the END= specifier
specifier nor an IOSTAT= specifier, error termination is initiated. If an end-of-file condition occurs during1 If an end-of-record condition occurs during execution of an input/output statement that contains neither anexecution of an input/output statement that contains either an END= specifier or an IOSTAT= specifier, and
an error condition does not occur then:
(1) processing of the input list, if any, terminates;
(2) if the statement is a data transfer statement or the end-of-file condition occurs during a wait operation,
all do-variables in the statement that initiated the transfer become undefined;
(3) if the statement is an input statement or the end-of-file condition occurs during a wait operation
for a transfer initiated by an input statement, all input list items or namelist group objects in the
statement that initiated the transfer become undefined;
(4) if the file specified in the input statement is an external record file, it is positioned after the endfile
record;
(5) if an IOSTAT= specifier appears, the stat-variable in the IOSTAT= specifier becomes defined as
specified in 12.11.5;
(6) if an IOMSG= specifier appears, the iomsg-variable becomes defined as specified in 12.11.6;
(7) if an END= specifier appears, a branch to the statement labeled by the label in the END= specifier
occurs.
12.11.4 End-of-record condition and the EOR= specifier
EOR= specifier nor an IOSTAT= specifier, error termination is initiated. If an end-of-record condition occurs1 Execution of an input/output statement containing the IOSTAT= specifier causes the stat-variable in the IO-during execution of an input/output statement that contains either an EOR= specifier or an IOSTAT= specifier,
and an error condition does not occur then:
(1) if the pad mode has the value
(a) YES, the record is padded with blanks to satisfy the effective item (<IP_ADDRESS>.3) and correspond-
ing data edit descriptors that require more characters than the record contains,
(b) NO, the input list item becomes undefined;
(2) processing of the input list, if any, terminates;
(3) if the statement is a data transfer statement or the end-of-record condition occurs during a wait
operation, all do-variables in the statement that initiated the transfer become undefined;
(4) the file specified in the input statement is positioned after the current record;
(5) if an IOSTAT= specifier appears, the stat-variable in the IOSTAT= specifier becomes defined as
specified in 12.11.5;
(6) if an IOMSG= specifier appears, the iomsg-variable becomes defined as specified in 12.11.6;
(7) if a SIZE= specifier appears, the scalar-int-variable in the SIZE= specifier becomes defined as spe-
cified in (<IP_ADDRESS>);
(8) if an EOR= specifier appears, a branch to the statement labeled by the label in the EOR= specifier
occurs.
⃝c ISO/IEC 2017 – All rights reserved 261
ISO/IEC DIS 1539-1:2017 (E)
12.11.5 IOSTAT= specifier
STAT= specifier to become defined with• a zero value if neither an error condition, an end-of-file condition, nor an end-of-record condition occurs,
• the processor-dependent positive integer value of the constant IOSTAT_INQUIRE_INTERNAL_UNIT
from the intrinsic module ISO_FORTRAN_ENV (16.10.2) if a unit number in an INQUIRE statement
identifies an internal file,
• a processor-dependent positive integer value different from IOSTAT_INQUIRE_INTERNAL_UNIT if any
other error condition occurs,
• the processor-dependent negative integer value of the constant IOSTAT_END (<IP_ADDRESS>) from the intrinsic
module ISO_FORTRAN_ENV if an end-of-file condition occurs and no error condition occurs,
• the processor-dependent negative integer value of the constant IOSTAT_EOR (<IP_ADDRESS>) from the intrinsic
module ISO_FORTRAN_ENV if an end-of-record condition occurs and no error condition or end-of-file
condition occurs, or
• a processor-dependent negative integer value different from IOSTAT_EOR and IOSTAT_END, if the IO-
STAT= specifier appears in a FLUSH statement and the processor does not support the flush operation for
the specified unit.
NOTE 12.61
An end-of-file condition can occur only for sequential or stream input and an end-of-record condition can
occur only for nonadvancing input.
For example,
READ (FMT = "(E8.3)", UNIT = 3, IOSTAT = IOSS) X
IF (IOSS < 0) THEN
! Perform end-of-file processing on the file connected to unit 3.
CALL END_PROCESSING
ELSE IF (IOSS > 0) THEN
! Perform error processing
CALL ERROR_PROCESSING
END IF
12.11.6 IOMSG= specifier 1 If an error, end-of-file, or end-of-record condition occurs during execution of an input/output statement, iomsg-
variable is assigned an explanatory message, truncated or padded according to the rules of intrinsic assignment.1 If a unit, or a file connected to a unit, does not have all of the properties required for the execution of certainIf no such condition occurs, the definition status and value of iomsg-variable are unchanged.
12.12 Restrictions on input/output statements
input/output statements, those statements shall not refer to the unit.2 An input/output statement that is executed while another input/output statement is being executed is a recursive
input/output statement. A recursive input/output statement shall not identify an external unit that is identified3 An input/output statement shall not cause the value of any established format specification to be modified.by another input/output statement being executed except that a child data transfer statement may identify its
parent data transfer statement external unit.
4 A recursive input/output statement shall not modify the value of any internal unit except that a recursive WRITE
statement may modify the internal unit identified by that recursive WRITE statement.5 The value of a specifier in an input/output statement shall not depend on the definition or evaluation of any other262 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
specifier in the io-control-spec-list or inquire-spec-list in that statement. The value of an internal-file-variable or6 The value of any subscript or substring bound of a variable that appears in a specifier in an input/outputof a FMT=, ID=, IOMSG=, IOSTAT=, or SIZE= specifier shall not depend on the value of any input-item or
io-implied-do do-variable in the same statement.
statement shall not depend on any input-item, io-implied-do do-variable, or on the definition or evaluation of any7 In a data transfer statement, the variable specified in an IOSTAT=, IOMSG=, or SIZE= specifier, if any, shallother specifier in the io-control-spec-list or inquire-spec-list in that statement.
not be associated with any entity in the data transfer input/output list (12.6.3) or namelist-group-object-list, nor8 In a data transfer statement, if a variable specified in an IOSTAT=, IOMSG=, or SIZE= specifier is an arraywith a do-variable of an io-implied-do in the data transfer input/output list.
element reference, its subscript values shall not be affected by the data transfer, the io-implied-do processing, or9 A variable that may become defined or undefined as a result of its use in a specifier in an INQUIRE statement,the definition or evaluation of any other specifier in the io-control-spec-list.
or any associated entity, shall not appear in another specifier in the same INQUIRE statement.ISO/IEC DIS 1539-1:2017 (E)NOTE 12.62
Restrictions on the evaluation of expressions (10.1.4) prohibit certain side effects.
⃝c ISO/IEC 2017 – All rights reserved 263
(Blank page)
264 c ISO/IEC 2017 – All rights reserved13 Input/output editing
ISO/IEC DIS 1539-1:2017 (E)
13.1 Format specifications 1 A format used in conjunction with a data transfer statement provides information that directs the editing between the internal representation of data and the characters of a sequence of formatted records.2 A format (<IP_ADDRESS>) in a data transfer statement may refer to a FORMAT statement or to a character expression
that contains a format specification. A format specification provides explicit editing information. The format1 Blank characters may precede the initial left parenthesis of the format specification. Additional blank charactersalternatively may be an asterisk (*), which indicates list-directed formatting (13.10). Namelist formatting (13.11)
may be indicated by specifying a namelist-group-name instead of a format.
13.2 Explicit format specification methods
13.2.1 FORMAT statement
R1301 format-stmt is FORMAT format-specification
R1302 format-specification is ( [ format-items ] )
or ( [ format-items, ] unlimited-format-item )
C1301 (R1301) The format-stmt shall be labeled.
may appear at any point within the format specification, with no effect on the interpretation of the format1 A character expression used as a format in a formatted input/output statement shall evaluate to a characterspecification, except within a character string edit descriptor (13.9).
NOTE 13.1
Examples of FORMAT statements are:
5 FORMAT (1PE12.4, I10)
9 FORMAT (I12, /, ’ Dates: ’, 2 (2I3, I5))
13.2.2 Character format specification
string whose leading part is a valid format specification.2 All character positions up to and including the final right parenthesis of the format specification shall be definedNOTE 13.2
The format specification begins with a left parenthesis and ends with a right parenthesis.
at the time the data transfer statement is executed, and shall not become redefined or undefined during the3 If the format is a character array, it is treated as if all of the elements of the array were specified in array elementexecution of the statement. Character positions, if any, following the right parenthesis that ends the format
specification need not be defined and may contain any character data with no effect on the interpretation of the
format specification.
order and were concatenated. However, if a format is a character array element, the format specification shall be1 The integer literal constant r is called a repeat specification.entirely within that array element.
⃝c ISO/IEC 2017 – All rights reserved 265
ISO/IEC DIS 1539-1:2017 (E)
NOTE 13.3
If a character constant is used as a format in data transfer statement, care shall be taken that the value
of the character constant is a valid format specification. In particular, if a format specification delimited
by apostrophes contains a character constant edit descriptor delimited with apostrophes, two apostrophes
shall be written to delimit the edit descriptor and four apostrophes shall be written for each apostrophe
that occurs within the edit descriptor. For example, the text:
2 ISN’T 3
can be written by various combinations of output statements and format specifications:
WRITE (6, 100) 2, 3
100 FORMAT (1X, I1, 1X, ’ISN’’T’, 1X, I1)
WRITE (6, ’(1X, I1, 1X, ’’ISN’’’’T’’, 1X, I1)’) 2, 3
WRITE (6, ’(A)’) ’ 2 ISN’’T 3’
Doubling of internal apostrophes usually can be avoided by using quotation marks to delimit the format
specification and doubling of internal quotation marks usually can be avoided by using apostrophes as
delimiters.
13.3 Form of a format item list
13.3.1 Syntax
R1303 format-items is format-item [ [ , ] format-item ] ...
R1304 format-item is [ r ] data-edit-desc
or control-edit-desc
or char-string-edit-desc
or [ r ] ( format-items )
R1305 unlimited-format-item is * ( format-items )
R1306 r is int-literal-constant
C1302 (R1303) The optional comma shall not be omitted except
• between a P edit descriptor and an immediately following F, E, EN, ES, D, or G edit descriptor
(13.8.5), possibly preceded by a repeat specification,
• before a slash edit descriptor when the optional repeat specification does not appear (13.8.2),
• after a slash edit descriptor, or
• before or after a colon edit descriptor (13.8.3)
C1303 (R1305) An unlimited-format-item shall contain at least one data edit descriptor.
C1304 (R1306) r shall be positive.
C1305 (R1306) A kind parameter shall not be specified for r.
13.3.2 Edit descriptors1 An edit descriptor is a data edit descriptor (data-edit-desc), control edit descriptor (control-edit-desc), or character
string edit descriptor (char-string-edit-desc).2 An I, B, O, Z, F, E, EN, ES, EX, G, L, A, D, or DT edit descriptor indicates the manner of editing.266 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
R1307 data-edit-desc is Iw[. m]
or Bw[. m]
or Ow[. m]
or Zw[. m]
or Fw. d
or Ew. d [Ee]
or EN w . d [ E e ]
or ES w . d [ E e ]
or EX w . d [ E e ]
or Gw[. d [Ee]]
or Lw
or A[w]
or Dw. d
or DT [ char-literal-constant ] [ ( v-list ) ]
R1308 w is int-literal-constant
R1309 m is int-literal-constant
R1310 d is int-literal-constant
R1311 e is int-literal-constant
R1312 v is signed-int-literal-constant
C1306 (R1308) w shall be zero or positive for the I, B, O, Z, D, E, EN, ES, EX, F, and G edit descriptors. w
shall be positive for all other edit descriptors.
C1307 (R1307) For the G edit descriptor, d shall be specified if w is not zero.
C1308 (R1307) For the G edit descriptor, e shall not be specified if w is zero.
C1309 (R1307) A kind parameter shall not be specified for the char-literal-constant in the DT edit descriptor,
or for w, m, d, e, and v.
R1313 control-edit-desc is position-edit-desc3 In k P, k is called the scale factor.or [r ]/
or :
or sign-edit-desc
or k P
or blank-interp-edit-desc
or round-edit-desc
or decimal-edit-desc
R1314 k is signed-int-literal-constant
C1310 (R1314) A kind parameter shall not be specified for k.
R1315 position-edit-desc is Tn4 A T, TL, TR, X, slash, colon, SS, SP, S, P, BN, BZ, RU, RD, RZ, RN, RC, RP, DC, or DP edit descriptoror TL n
or TR n
or nX
R1316 n is int-literal-constant
C1311 (R1316) n shall be positive.
⃝c ISO/IEC 2017 – All rights reserved 267
ISO/IEC DIS 1539-1:2017 (E)
C1312 (R1316) A kind parameter shall not be specified for n.
R1317 sign-edit-desc is SS
or SP
or S
R1318 blank-interp-edit-desc is BN
or BZ
R1319 round-edit-desc is RU
or RD
or RZ
or RN
or RC
or RP
R1320 decimal-edit-desc is DC
or DP
indicates the manner of editing.5 Each rep-char in a character string edit descriptor shall be capable of representation by the processor.R1321 char-string-edit-desc is char-literal-constant
C1313 (R1321) A kind parameter shall not be specified for the char-literal-constant.
6 A character string edit descriptor provides constant data to be output, and is not valid for input. 7 The edit descriptors are without regard to case except within a character string edit descriptor. 13.3.3 Fields1 A field is a part of a record that is read on input or written on output when format control encounters a data
edit descriptor or a character string edit descriptor. The field width is the size in characters of the field.1 The start of formatted data transfer using a format specification initiates format control (<IP_ADDRESS>.3). Each action13.4 Interaction between input/output list and format
of format control depends on information jointly provided by the next edit descriptor in the format specification2 If an input/output list specifies at least one effective item, at least one data edit descriptor shall exist in theand the next effective item in the input/output list, if one exists.
format specification.3 A format specification is interpreted from left to right. The exceptions are format items preceded by a repeatNOTE 13.4
An empty format specification of the form ( ) can be used only if the input/output list has no effective item
(<IP_ADDRESS>). A zero length character item is an effective item, but a zero sized array and an implied DO list
with an iteration count of zero is not.
specification r, and format reversion (described below).4 A format item preceded by a repeat specification is processed as a list of r items, each identical to the format
item but without the repeat specification and separated by commas.5 To each data edit descriptor interpreted in a format specification, there corresponds one effective item specified by268 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
NOTE 13.5
An omitted repeat specification is treated in the same way as a repeat specification whose value is one.
the input/output list (12.6.3), except that an input/output list item of type complex requires the interpretation6 Whenever format control encounters a data edit descriptor in a format specification, it determines whetherof two F, E, EN, ES, D, or G edit descriptors. For each control edit descriptor or character edit descriptor,
there is no corresponding item specified by the input/output list, and format control communicates information
directly with the record.
there is a corresponding effective item specified by the input/output list. If there is such an item, it transmits7 If format control encounters a colon edit descriptor in a format specification and another effective item is notappropriately edited information between the item and the record, and then format control proceeds. If there is
no such item, format control terminates.
specified, format control terminates.8 If format control encounters the rightmost parenthesis of an unlimited format item, control reverts to the leftmost
parenthesis of that unlimited format item. This reversion of format control has no effect on the changeable modes9 If format control encounters the rightmost parenthesis of a complete format specification and another effective(12.5.2).
item is not specified, format control terminates. However, if another effective item is specified, format control1 After each data edit descriptor or character string edit descriptor is processed, the file is positioned after the lastthen reverts to the beginning of the format item terminated by the last preceding right parenthesis that is not
part of a DT edit descriptor. If there is no such preceding right parenthesis, format control reverts to the first
left parenthesis of the format specification. If any reversion occurs, the reused portion of the format specification
shall contain at least one data edit descriptor. If format control reverts to a parenthesis that is preceded by a
repeat specification, the repeat specification is reused. Reversion of format control, of itself, has no effect on
the changeable modes. The file is positioned in a manner identical to the way it is positioned when a slash edit
descriptor is processed (13.8.2).
NOTE 13.6
Example: The format specification:
10 FORMAT (1X, 2(F10.3, I5))
with an output list of
WRITE (10,10) 10.1, 3, 4.7, 1, 12.4, 5, 5.2, 6
produces the same output as the format specification:
10 FORMAT (1X, F10.3, I5, F10.3, I5/F10.3, I5, F10.3, I5)
NOTE 13.7
The effect of an unlimited-format-item is as if its enclosed list were preceded by a very large repeat count.
There is no file positioning implied by unlimited-format-item reversion. This can be used to write what is
commonly called a comma separated value record.
For example,
WRITE( 10, ’( "IARRAY =", *( I0, :, ","))’) IARRAY
produces a single record with a header and a comma separated list of integer values.
⃝c ISO/IEC 2017 – All rights reserved 269
ISO/IEC DIS 1539-1:2017 (E)
13.5 Positioning by format control
character read or written in the current record.2 After each T, TL, TR, or X edit descriptor is processed, the file is positioned as described in <IP_ADDRESS>. After each
slash edit descriptor is processed, the file is positioned as described in <IP_ADDRESS> During formatted stream output, processing of an A edit descriptor can cause file positioning to occur (13.7.4).
4 If format control reverts as described in 13.4, the file is positioned in a manner identical to the way it is positioned when a slash edit descriptor is processed (13.8.2).5 During a read operation, any unprocessed characters of the current record are skipped whenever the next record
is read.1 The decimal symbol is the character that separates the whole and fractional parts in the decimal representation13.6 Decimal symbol
of a real number in an internal or external file. When the decimal edit mode is POINT, the decimal symbol is a2 If the decimal edit mode is COMMA during list-directed input/output, the character used as a value separatordecimal point. When the decimal edit mode is COMMA, the decimal symbol is a comma.
is a semicolon in place of a comma.1 Data edit descriptors cause the conversion of data to or from its internal representation; during formatted stream13.7 Data edit descriptors
13.7.1 Purpose of data edit descriptors
output, the A data edit descriptor may also cause file positioning. On input, the specified variable becomes2 During input from a Unicode file,defined unless an error condition, an end-of-file condition, or an end-of-record condition occurs. On output, the
specified expression is evaluated.
• characters in the record that correspond to an ASCII character variable shall have a position in the ISO3 During input from a non-Unicode file,10646 character collating sequence of 127 or less, and
• characters in the record that correspond to a default character variable shall be representable as default
characters.
• characters in the record that correspond to a character variable shall have the kind of the character variable,4 During output to a Unicode file, all characters transmitted to the record are of ISO 10646 character kind. If aand
• characters in the record that correspond to a numeric or logical variable shall be default characters.
character input/output list item or character string edit descriptor contains a character that is not representable5 During output to a non-Unicode file, characters transmitted to the record as a result of processing a characteras an ISO 10646 character, the result is processor dependent.
string edit descriptor or as a result of evaluating a numeric, logical, or default character data entity, are of default1 The I, B, O, Z, F, E, EN, ES, EX, D, and G edit descriptors may be used to specify the input/output of integer,kind.
270 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
13.7.2 Numeric editing
<IP_ADDRESS> General rules
real, and complex data. The following general rules apply.1 The Iw and Iw.m edit descriptors indicate that the field to be edited occupies w positions, except when w is zero.(1) On input, leading blanks are not significant. When the input field is not an IEEE exceptional
specification or hexadecimal-significand number (<IP_ADDRESS>.2), the interpretation of blanks, other than
leading blanks, is determined by the blank interpretation mode (13.8.6). Plus signs may be omitted.
A field containing only blanks is considered to be zero.
(2) On input, with F, E, EN, ES, EX, D, and G editing, a decimal symbol appearing in the input field
overrides the portion of an edit descriptor that specifies the decimal symbol location. The input field
may have more digits than the processor uses to approximate the value of the datum.
(3) On output with I, F, E, EN, ES, EX, D, and G editing, the representation of a positive or zero
internal value in the field may be prefixed with a plus sign, as controlled by the S, SP, and SS edit
descriptors or the processor. The representation of a negative internal value in the field shall be
prefixed with a minus sign.
(4) On output, the representation is right justified in the field. If the number of characters produced by
the editing is smaller than the field width, leading blanks are inserted in the field.
(5) On output, if an exponent exceeds its specified or implied width using the E, EN, ES, EX, D, or G
edit descriptor, or the number of characters produced exceeds the field width, the processor shall fill
the entire field of width w with asterisks. However, the processor shall not produce asterisks if the
field width is not exceeded when optional characters are omitted.
NOTE 13.8
When the sign mode is PLUS, a plus sign is not optional.
(6) On output, with I, B, O, Z, D, E, EN, ES, EX, F, and G editing, the specified value of the field width
w may be zero. In such cases, the processor selects the smallest positive actual field width that does
not result in a field filled with asterisks. The specified value of w shall not be zero on input.
(7) On output of a real zero value, the digits in the exponent field shall all be zero.
<IP_ADDRESS> Integer editing
When w is zero, the processor selects the field width. On input, w shall not be zero. The specified input/output2 On input, m has no effect.list item shall be of type integer. The G, B, O, and Z edit descriptor also may be used to edit integer data
(<IP_ADDRESS>.1, <IP_ADDRESS>).
3 In the standard form of the input field for the I edit descriptor, the character string is a signed-digit-string (R710), except for the interpretation of blanks. If the input field does not have the standard form and is not acceptable4 The output field for the Iw edit descriptor consists of zero or more leading blanks followed by a minus sign if theto the processor, an error condition occurs.
internal value is negative, or an optional plus sign otherwise, followed by the magnitude of the internal value as5 The output field for the Iw.m edit descriptor is the same as for the Iw edit descriptor, except that the digit-stringa digit-string without leading zeros.
NOTE 13.9
A digit-string always consists of at least one digit.
consists of at least m digits. If necessary, sufficient leading zeros are included to achieve the minimum of m digits.1 The F, E, EN, ES, and D edit descriptors specify the editing of real and complex data. An input/output listThe value of m shall not exceed the value of w, except when w is zero. If m is zero and the internal value is zero,
⃝c ISO/IEC 2017 – All rights reserved 271
ISO/IEC DIS 1539-1:2017 (E)
the output field consists of only blank characters, regardless of the sign control in effect. When m and w are both
zero, and the internal value is zero, one blank character is produced.
<IP_ADDRESS> Real and complex editing
<IP_ADDRESS>.1 General
item corresponding to an F, E, EN, ES, or D edit descriptor shall be real or complex. The G, B, O, and Z edit1 The Fw.d edit descriptor indicates that the field occupies w positions, except when w is zero in which case thedescriptors also may be used to edit real and complex data (<IP_ADDRESS>.2, <IP_ADDRESS>).
<IP_ADDRESS>.2 F editing
processor selects the field width. The fractional part of the field consists of d digits. On input, w shall not be2 A lower-case letter is equivalent to the corresponding upper-case letter in an IEEE exceptional specification orzero.
the exponent in a numeric input field.3 The standard form of the input field is an IEEE exceptional specification, a hexadecimal-significand number, or
consists of a mantissa optionally followed by an exponent. The form of the mantissa is an optional sign, followed4 An exponent containing a D is processed identically to an exponent containing an E.by a string of one or more digits optionally containing a decimal symbol, including any blanks interpreted as
zeros. The d has no effect on input if the input field contains a decimal symbol. If the decimal symbol is omitted,
the rightmost d digits of the string, with leading zeros assumed if necessary, are interpreted as the fractional part
of the value represented. The string of digits may contain more digits than a processor uses to approximate the
value. The form of the exponent is one of the following:
• a sign followed by a digit-string;
• the letter E followed by zero or more blanks, followed by a signed-digit-string;
• the letter D followed by zero or more blanks, followed by a signed-digit-string.
NOTE 13.105 An input field that is an IEEE exceptional specification consists of optional blanks, followed by eitherIf the input field does not contain an exponent, the effect is as if the basic form were followed by an exponent
with a value of −k, where k is the established scale factor (13.8.5).
• an optional sign, followed by the string ’INF’ or the string ’INFINITY’, oroptionally followed by blanks.• an optional sign, followed by the string ’NAN’, optionally followed by zero or more alphanumeric characters
enclosed in parentheses,
6 The value specified by ’INF’ or ’INFINITY’ is an IEEE infinity; this form shall not be used if the processor does not support IEEE infinities for the input variable. The value specified by ’NAN’ is an IEEE NaN; this form shall7 An input field that is a hexadecimal-significand number consists of an optional sign, followed by the hexadecimalnot be used if the processor does not support IEEE NaNs for the input variable. The NaN value is a quiet NaN if
the only nonblank characters in the field are ’NAN’ or ’NAN()’; otherwise, the NaN value is processor dependent.
The interpretation of a sign in a NaN input field is processor dependent.
indicator which is the digit 0 immediately followed by the letter X, followed by a hexadecimal significand followed8 If the input field does not have one of the standard forms, and is not acceptable to the processor, an errorby a hexadecimal exponent. A hexadecimal significand is a string of one or more hexadecimal characters optionally
containing a decimal symbol. The decimal symbol indicates the position of the hexadecimal point; if no decimal
symbol appears, the hexadecimal point implicitly follows the last hexadecimal symbol. A hexadecimal exponent
272 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
is the letter P followed by a (decimal) signed-digit-string. Embedded blanks are not permitted in a hexadecimal-
significand number. The value is equal to the significand multiplied by two raised to the power of the exponent,
negated if the optional sign is minus.
condition occurs.9 For an internal value that is an IEEE infinity, the output field consists of blanks, if necessary, followed by a minus
sign for negative infinity or an optional plus sign otherwise, followed by the letters ’Inf’ or ’Infinity’, right justified10 For an internal value that is an IEEE NaN, the output field consists of blanks, if necessary, followed by thewithin the field. The minimum field width required for output of the form ’Inf’ is 3 if no sign is produced, and
4 otherwise. The minimum field width required for output of the form ’Infinity’ is 8 if no sign is produced, and
9 otherwise. If w is greater than or equal to the minimum required for the form ’Infinity’, the form ’Infinity’ is
output. If w is zero or w is less than the minimum required for the form ’Infinity’ and greater than or equal to
the minimum required for the form ’Inf’, the form ’Inf’ is output. Otherwise (w is greater than zero but less than
the minimum required for any form), the field is filled with asterisks.
letters ’NaN’ and optionally followed by one to w−5 alphanumeric processor-dependent characters enclosed in11 For an internal value that is neither an IEEE infinity nor a NaN, the output field consists of blanks, if necessary,parentheses, right justified within the field. If w is greater than zero and less than 3, the field is filled with
asterisks. If w is zero, the output field is ’NaN’.
NOTE 13.11
The processor-dependent characters following ’NaN’ might convey additional information about that par-
ticular NaN.
followed by a minus sign if the internal value is negative, or an optional plus sign otherwise, followed by a string1 The Ew.d, Dw.d, and Ew.d Ee edit descriptors indicate that the external field occupies w positions, except whenof digits that contains a decimal symbol and represents the magnitude of the internal value, as modified by the
established scale factor and rounded (<IP_ADDRESS>.8) to d fractional digits. Leading zeros are not permitted except
for an optional zero immediately to the left of the decimal symbol if the magnitude of the value in the output
field is less than one. The optional zero shall appear if there would otherwise be no digits in the output field.
<IP_ADDRESS>.3 E and D editing
w is zero in which case the processor selects the field width. The fractional part of the field contains d digits,2 The form and interpretation of the input field is the same as for Fw.d editing (<IP_ADDRESS>.2).unless a scale factor greater than one is in effect. If e is positive the exponent part contains e digits, otherwise it
contains the minimum number of digits required to represent the exponent value. The e has no effect on input.
3 For an internal value that is an IEEE infinity or NaN, the form of the output field is the same as for Fw.d.
4 For an internal value that is neither an IEEE infinity nor a NaN, the form of the output field for a scale factor
of zero isISO/IEC DIS 1539-1:2017 (E)[ ± ] [0].x1 x2 . . . xd exp
where:
• ± signifies a plus sign or a minus sign;
• . signifies a decimal symbol (13.6);
• x1 x2 . . . xd are the d most significant digits of the internal value after rounding (<IP_ADDRESS>.8);
• exp is a decimal exponent having one of the forms specified in table 13.1.
⃝c ISO/IEC 2017 – All rights reserved 273
Table 13.1: E and D exponent forms
Edit Absolute Value Form of
Descriptor of Exponent Exponent1 Ew.d |exp| ≤ 99 E±z1 z2 or ±0z1 z299 < |exp| ≤ 999 ±z1 z2 z3
e
Ew.d Ee with e > 0 |exp| ≤ 10 − 1 E±z1 z2 . . . ze Ew.d E0 any E±z1 z2 . . . zs(1) where each z is a digit, and s is the minimum number of digitsDw.d |exp| ≤ 99 D±z1 z2 or E±z1 z2
or ±0z1 z2
99 < |exp| ≤ 999 ±z1 z2 z3
required to represent the exponent.
5 The sign in the exponent is produced. A plus sign is produced if the exponent value is zero. 6 The scale factor k controls the decimal normalization (13.3.2, 13.8.5). If −d < k ≤ 0, the output field contains exactly |k| leading zeros and d − |k| significant digits after the decimal symbol. If 0 < k < d + 2, the output field1 The EN edit descriptor produces an output field in the form of a real number in engineering notation such thatcontains exactly k significant digits to the left of the decimal symbol and d − k + 1 significant digits to the right
of the decimal symbol. Other values of k are not permitted.
<IP_ADDRESS>.4 EN editing
the decimal exponent is divisible by three and the absolute value of the significand (R715) is greater than or2 The forms of the edit descriptor are ENw.d and ENw.d Ee indicating that the external field occupies w positions,equal to 1 and less than 1000, except when the output value is zero. The scale factor has no effect on output.
except when w is zero in which case the processor selects the field width. The fractional part of the field contains3 The form and interpretation of the input field is the same as for Fw.d editing (<IP_ADDRESS>.2).d digits. If e is positive the exponent part contains e digits, otherwise it contains the minimum number of digits
required to represent the exponent value.
4 For an internal value that is an IEEE infinity or NaN, the form of the output field is the same as for Fw.d. 5 For an internal value that is neither an IEEE infinity nor a NaN, the form of the output field is [ ± ] yyy . x1 x2 . . . xd expwhere:
• ± signifies a plus sign or a minus sign;• yyy are the 1 to 3 decimal digits representative of the most significant digits of the internal value after
rounding (<IP_ADDRESS>.8);
• yyy is an integer such that 1 ≤ yyy < 1000 or, if the output value is zero, yyy = 0;
• . signifies a decimal symbol (13.6);
• x1 x2 . . . xd are the d next most significant digits of the internal value after rounding;
• exp is a decimal exponent, divisible by three, having one of the forms specified in table 13.2.
274 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)Table 13.2: EN exponent forms
Edit Absolute Value Form of
Descriptor of Exponent Exponent1 ENw.d |exp| ≤ 99 E±z1 z2 or ±0z1 z299 < |exp| ≤ 999 ±z1 z2 z3
e
ENw.d Ee with e > 0 |exp| ≤ 10 − 1 E±z1 z2 . . . ze ENw.d E0 any E±z1 z2 . . . zs(1) where each z is a digit, and s is the minimum number of digits
required to represent the exponent.
6 The sign in the exponent is produced. A plus sign is produced if the exponent value is zero. NOTE 13.12Examples:
Internal Value Output field using SS, EN12.3
6.421 6.421E+00
-.5 -500.000E-03
.00217 2.170E-03
4721.3 4.721E+03
<IP_ADDRESS>.5 ES editing 1 The ES edit descriptor produces an output field in the form of a real number in scientific notation such that the absolute value of the significand (R715) is greater than or equal to 1 and less than 10, except when the output2 The forms of the edit descriptor are ESw.d and ESw.d Ee indicating that the external field occupies w positions,value is zero. The scale factor has no effect on output.
except when w is zero in which case the processor selects the field width. The fractional part of the field contains3 The form and interpretation of the input field is the same as for Fw.d editing (<IP_ADDRESS>.2).d digits. If e is positive the exponent part contains e digits, otherwise it contains the minimum number of digits
required to represent the exponent value.
4 For an internal value that is an IEEE infinity or NaN, the form of the output field is the same as for Fw.d.
5 For an internal value that is neither an IEEE infinity nor a NaN, the form of the output field is
[ ± ] y . x1 x2 . . . xd expwhere:
• ± signifies a plus sign or a minus sign;• y is a decimal digit representative of the most significant digit of the internal value after rounding (<IP_ADDRESS>.8);
• . signifies a decimal symbol (13.6);
• x1 x2 . . . xd are the d next most significant digits of the internal value after rounding;
• exp is a decimal exponent having one of the forms specified in table 13.3.
Table 13.3: ES exponent forms
Edit Absolute Value Form of
Descriptor of Exponent Exponent1
ESw.d |exp| ≤ 99 E±z1 z2 or ±0z1 z2
99 < |exp| ≤ 999 ±z1 z2 z3
ESw.d Ee with e > 0 |exp| ≤ 10e − 1 E±z1 z2 . . . ze
ESw.d E0 any E±z1 z2 . . . zs
(1) where each z is a digit, and s is the minimum number of digits
required to represent the exponent.
⃝c ISO/IEC 2017 – All rights reserved 275
ISO/IEC DIS 1539-1:2017 (E) 6 The sign in the exponent is produced. A plus sign is produced if the exponent value is zero. NOTE 13.13Examples:
Internal Value Output field Using SS, ES12.3
6.421 6.421E+00
-.5 -5.000E-01
.00217 2.170E-03
4721.3 4.721E+03
<IP_ADDRESS>.6 EX editing 1 The EX edit descriptor produces an output field in the form of a hexadecimal-significand number. 2 The EXw.d and EXw.dEe edit descriptors indicate that the external field occupies w positions, except when w
is zero in which case the processor selects the field width. The fractional part of the field contains d hexadecimal3 The form and interpretation of the input field is the same as for Fw.d editing (<IP_ADDRESS>.2).digits, except when d is zero in which case the processor selects the number of hexadecimal digits to be the
minimum required so that the output field is equal to the internal value; d shall not be zero if the radix of the
internal value is not a power of two. The hexadecimal point, represented by a decimal symbol, appears after
the first hexadecimal digit. For the form EXw.d, and for EXw.dE0, the exponent part contains the minimum
number of digits needed to represent the exponent; otherwise the exponent contains e digits. The e has no effect
on input. The scale factor has no effect on output.
4 For an internal value that is an IEEE infinity or NaN, the form of the output field is the same as for Fw.d.
5 For an internal value that is neither an IEEE infinity nor a NaN, the form of the output field is
[ ± ] 0X x0 . x1 x2 . . . expwhere:
• ± signifies a plus sign or a minus sign;6 The sign in the exponent is produced. A plus sign is produced if the exponent value is zero.• . signifies a decimal symbol (13.6);
• x0 x1 x2 . . . are the most significant hexadecimal digits of the internal value, after rounding if d is not zero
(<IP_ADDRESS>.8);
• exp is a binary exponent expressed as a decimal integer; for EXw.d and EXw.dE0, the form is P ±z1 . . . zn ,
where n is the minimum number of digits needed to represent exp, and for EXw.dEe with e greater than
zero the form is P ±z1 . . . ze . The choice of binary exponent is processor dependent. If the most significant
binary digits of the internal value are b0 b1 b2 . . ., the binary exponent might make the value of x0 be that of
b0 , b0 b1 , b0 b1 b2 , or b0 b1 b2 b3 .
NOTE 13.14Examples:
Internal value Edit descriptor Possible output with SS in effect
1.375 EX0.1 0X1.6P+0
−15.625 EX14.4E3 -0X1.F400P+003
1048580.0 EX0.0 0X1.00004P+20
2.375 EX0.1 0X2.6P+0
<IP_ADDRESS>.7 Complex editing 1 A complex datum consists of a pair of separate real data. The editing of a scalar datum of complex type is
specified by two edit descriptors each of which specifies the editing of real data. The first edit descriptor specifies1 The input/output rounding mode can be specified by an OPEN statement (12.5.2), a data transfer statement276 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
the editing for the real part; the second specifies it for the imaginary part. The two edit descriptors may be
different. Control and character string edit descriptors may be processed between the edit descriptor for the real
part and the edit descriptor for the imaginary part.
<IP_ADDRESS>.8 Input/output rounding mode
(<IP_ADDRESS>), or an edit descriptor (13.8.7).2 In what follows, the term “decimal value” means the exact decimal number as given by the character string, while
the term “internal value” means the number actually stored in the processor. For example, in dealing with the3 When the input/output rounding mode is UP, the value resulting from conversion shall be the smallest represent-decimal constant 0.1, the decimal value is the mathematical quantity 1/10, which has no exact representation
in binary form. Formatted output of real data involves conversion from an internal value to a decimal value;
formatted input involves conversion from a decimal value to an internal value.
able value that is greater than or equal to the original value. When the input/output rounding mode is DOWN,4 On processors that support IEEE rounding on conversions (17.4), NEAREST shall correspond to round to nearest,the value resulting from conversion shall be the largest representable value that is less than or equal to the original
value. When the input/output rounding mode is ZERO, the value resulting from conversion shall be the value
closest to the original value and no greater in magnitude than the original value. When the input/output rounding
mode is NEAREST, the value resulting from conversion shall be the closer of the two nearest representable values
if one is closer than the other. If the two nearest representable values are equidistant from the original value, it is
processor dependent which one of them is chosen. When the input/output rounding mode is COMPATIBLE, the
value resulting from conversion shall be the closer of the two nearest representable values or the value away from
zero if halfway between them. When the input/output rounding mode is PROCESSOR_DEFINED, rounding
during conversion shall be a processor-dependent default mode, which may correspond to one of the other modes.
as specified in ISO/IEC/IEEE 60559:2011.1 The Bw, Bw.m, Ow, Ow.m, Zw, and Zw.m edit descriptors indicate that the field to be edited occupies wNOTE 13.15
On processors that support IEEE rounding on conversions, the input/output rounding modes COMPAT-
IBLE and NEAREST will produce the same results except when the datum is halfway between the two
representable values. In that case, NEAREST will pick the even value, but COMPATIBLE will pick the
value away from zero. The input/output rounding modes UP, DOWN, and ZERO have the same effect as
those specified in ISO/IEC/IEEE 60559:2011 for round toward +∞, round toward −∞, and round toward
0, respectively.
<IP_ADDRESS> B, O, and Z editing
positions, except when w is zero. When w is zero, the processor selects the field width. On input, w shall not be2 On input, m has no effect.zero. The corresponding input/output list item shall be of type integer, real, or complex.
3 In the standard form of the input field for the B, O, and Z edit descriptors the character string consists of binary,
octal, or hexadecimal digits (as in R765, R766, R767) in the respective input field. The lower-case hexadecimal4 The value is INT (X) if the input list item is of type integer and REAL (X) if the input list item is of type realdigits a through f in a hexadecimal input field are equivalent to the corresponding upper-case hexadecimal digits.
If the input field does not have the standard form, and is not acceptable to the processor, an error condition
occurs.
or complex, where X is a boz-literal-constant that specifies the same bit sequence as the digits of the input field.5 The output field for the Bw, Ow, and Zw descriptors consists of zero or more leading blanks followed by the
internal value in a form identical to the digits of a binary, octal, or hexadecimal constant, respectively, that6 The output field for the Bw.m, Ow.m, and Zw.m edit descriptor is the same as for the Bw, Ow, and Zw editspecifies the same bit sequence but without leading zero bits.
⃝c ISO/IEC 2017 – All rights reserved 277
ISO/IEC DIS 1539-1:2017 (E)
NOTE 13.16
A binary, octal, or hexadecimal constant always consists of at least one digit or hexadecimal digit.
R1322 hex-digit-string is hex-digit [ hex-digit ] ...
descriptor, except that the digit-string or hex-digit-string consists of at least m digits. If necessary, sufficient1 The Lw edit descriptor indicates that the field occupies w positions. The specified input/output list item shallleading zeros are included to achieve the minimum of m digits. The value of m shall not exceed the value of w,
except when w is zero. If m is zero and the internal value consists of all zero bits, the output field consists of