Intel® Fortran Compiler 16.0 User and Reference Guide

Rules for List-Directed Sequential READ Statements

List-directed, sequential READ statements translate data from character to binary form by using the data types of the corresponding I/O list item to determine the form of the data. The translated data is then assigned to the entities in the I/O list in the order in which they appear, from left to right.

If a slash ( / ) is encountered during execution, the READ statement is terminated, and any remaining input list items are unchanged.

If the file is connected for unformatted I/O, list-directed data transfer is prohibited.

List-Directed Records

A list-directed external record consists of a sequence of values and value separators. A value can be any of the following:

A value separator is any number of blanks, or a comma or slash, preceded or followed by any number of blanks. When any of these appear in a character constant, they are considered part of the constant, not value separators.

The end of a record is equivalent to a blank character, except when it occurs in a character constant. In this case, the end of the record is ignored, and the character constant is continued with the next record (the last character in the previous record is immediately followed by the first character of the next record).

Blanks at the beginning of a record are ignored unless they are part of a character constant continued from the previous record. In this case, the blanks at the beginning of the record are considered part of the constant.

Examples

Suppose the following statements are specified:

  CHARACTER*14 C
  DOUBLE PRECISION T
  COMPLEX D,E
  LOGICAL L,M
  READ (1,*) I,R,D,E,L,M,J,K,S,T,C,A,B

Then suppose the following external record is read:

  4 6.3 (3.4,4.2), (3, 2 ), T,F,,3*14.6,'ABC,DEF/GHI''JK'/

The following values are assigned to the I/O list items:

I/O List Item

Value Assigned

I

4

R

6.3

D

(3.4,4.2)

E

(3.0,2.0)

L

.TRUE.

M

.FALSE.

J

Unchanged

K

14

S

14.6

T

14.6D0

C

ABC,DEF/GHI' JK

A

Unchanged

B

Unchanged

The following example shows list-directed input and output:

 REAL    a
 INTEGER i
 COMPLEX c
 LOGICAL up, down
 DATA a /2358.2E-8/, i /91585/, c /(705.60,819.60)/
 DATA up /.TRUE./, down /.FALSE./
 OPEN (UNIT = 9, FILE = 'listout', STATUS = 'NEW')
 WRITE  (9, *) a, i
 WRITE  (9, *) c, up, down
 REWIND (9)
 READ   (9, *) a, i
 READ   (9, *) c, up, down
 WRITE  (*, *) a, i
 WRITE  (*, *) c, up, down
 END

The preceding program produces the following output:

   2.3582001E-05     91585
  (705.6000,819.6000) T F

See Also