In a data transfer statement, a simple list of items takes the following form:
The variable must not be an assumed-size array, unless one of the following appears in the last dimension: a subscript, a vector subscript, or a section subscript specifying an upper bound.
Any expression must not attempt further I/O operations on the same logical unit. For example, it must not refer to a function subprogram that performs I/O on the same logical unit.
The data transfer statement assigns values to (or transfers values from) the list items in the order in which the items appear, from left to right.
When multiple array names are used in the I/O list of an unformatted input or output statement, only one record is read or written, regardless of how many array name references appear in the list.
The following example shows a simple I/O list:
When you use an array name reference in an I/O list, an input statement reads enough data to fill every item of the array. An output statement writes all of the values in the array.
WRITE (6,10) J, K(3), 4, (L+4)/2, N
Data transfer begins with the initial item of the array and proceeds in the order of subscript progression, with the leftmost subscript varying most rapidly. The following statement defines a two-dimensional array:
If the name ARRAY appears with no subscripts in a READ statement, that statement assigns values from the input record(s) to ARRAY(1,1), ARRAY(2,1), ARRAY(3,1), ARRAY(1,2), and so on through ARRAY(3,3).
An input record contains the following values:
The following example shows how variables in the I/O list can be used in array subscripts later in the list:
When the READ statement is executed, the first input value is assigned to J and the second to K, establishing the subscript values for ARRAY(J,K). The value 721.73 is then assigned to ARRAY(1,3). Note that the variables must appear before their use as array subscripts.
DIMENSION ARRAY(3,3) ... READ (1,30) J, K, ARRAY(J,K)
Consider the following derived-type definition and structure declaration:
The following statements are equivalent:
TYPE EMPLOYEE INTEGER ID CHARACTER(LEN=40) NAME END TYPE EMPLOYEE ... TYPE(EMPLOYEE) :: CONTRACT ! A structure of type EMPLOYEE
READ *, CONTRACT READ *, CONTRACT%ID, CONTRACT%NAME
For More Information:
For details on the general rules for I/O lists, see Section 10.2.2.