Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

I/O Lists

In a data transfer statement, the I/O list specifies the entities whose values will be transferred. An input list is made up of implied-do lists and simple lists of variables (except for assumed-size arrays). An output list is made up of implied-do lists, expressions, and simple lists of variables (except for assumed-size arrays).

In input statements, the I/O list cannot contain constants and expressions because these do not specify named memory locations that can be referenced later in the program.

However, constants and expressions can appear in the I/O lists for output statements because the compiler can use temporary memory locations to hold these values during the execution of the I/O statement.

If an input item is a pointer, it must be currently associated with a definable target; data is transferred from the file to the associated target. If an output item is a pointer, it must be currently associated with a target; data is transferred from the target to the file.

If an input or output item is an array, it is treated as if the elements (if any) were specified in array element order. For example, if ARRAY_A is an array of shape (2,1), the following input statements are equivalent:

  READ *, ARRAY_A
  READ *, ARRAY_A(1,1), ARRAY_A(2,1)

However, no element of that array can affect the value of any expression in the input list, nor can any element appear more than once in an input list. For example, the following input statements are invalid:

  INTEGER  B(50)
  ...
  READ *, B(B)
  READ *, B(B(1):B(10))

If an input or output item is an allocatable array, it must be currently allocated.

If an input or output item is a derived type, the following rules apply:

  • Any derived-type component must be in the scoping unit containing the I/O statement.

  • The derived type must not have a pointer component.

  • In a formatted I/O statement, a derived type is treated as if all of the components of the structure were specified in the same order as in the derived-type definition.

  • In an unformatted I/O statement, a derived type is treated as a single object.