<Syntax> |
|
|
|
READ format [ , input-list ]
READ ( ci-spec [ , ci-spec ]... ) [ input-list ]
format ::= * | label | expr
unit ::= * | variable | expr
input-list ::= input-item [ , input-item ]...
input-item ::= variable | ( input-list , do-spec )
The possible ci-specs are listed in the table below, together with their meaning.
The UNIT= ci-spec is required.
The UNIT= keyword and equals sign may be omitted if it is the first ci-spec.
If UNIT= was omitted, the FMT= keyword and equals sign may be omitted if it is the second ci-spec,
or the NML= keyword and equals sign may be omitted if it is the second ci-spec.
|
|
|
|
|
|
<Semantics> |
|
|
|
The READ statement reads one or more records, or partial records, from the specified unit.
Each ci-spec is listed in the table below.
If unit is *, the input is from the standard input unit (usually the keyboard);
if it is a character variable, the input is from that variable;
if it is an integer expr, the input is from the external unit with that number, which must be non-negative.
If format is present, the READ is a formatted READ;
if format is *, list-directed formatting is used;
if format is a label, that FORMAT statement is used;
if format is a character expression, that expression is interpreted as an explicit format.
The READ is also a formatted READ if Namelist is present, in which case namelist formatting is used.
Specifier |
Argument |
Meaning |
Values |
[ UNIT = ] |
unit |
Unit to read from |
|
[ FMT = ] |
format |
Formatting |
|
ADVANCE= |
Character |
Advancing input? |
'YES', 'NO' |
ASYNCHRONOUS= |
Character |
Async i/o? |
'YES', 'NO' |
BLANK= |
Character |
Blanks are? |
'NULL', 'ZERO' |
DECIMAL= |
Character |
Decimal edit mode |
'COMMA', 'POINT' |
END= |
Label |
Branch on end of file |
|
EOR= |
Label |
Branch on end of record |
|
ERR= |
Label |
Branch on error |
|
ID= |
Integer |
Pending i/o identifier |
|
IOMSG= |
Character |
Error message |
|
IOSTAT= |
Integer |
I/O status value |
|
[ NML= ] |
Namelist |
Namelist formatting |
|
PAD= |
Character |
Padding mode |
'YES', 'NO' |
POS= |
Integer |
File storage position |
Positive |
REC= |
Integer |
Record number |
Positive |
ROUND= |
Character |
Rounding mode |
'COMPATIBLE', 'DOWN', 'NEAREST', 'PROCESSOR_DEFINED', 'UP', 'ZERO' |
SIZE= |
Integer |
Number of characters read |
|
The ADVANCE= specifier is only allowed for external files.
If the NML= specifier appears, no format is allowed.
The EOR= and SIZE= specifiers are only allowed in conjunction with ADVANCE='NO'.
The REC= specifier is only allowed for a direct access file.
In Fortran 2003, the BLANK=, DECIMAL=, PAD= and ROUND= specifiers control the initial edit modes for that READ;
if omitted, the default is taken from the OPEN.
The IOMSG= specifier sets its variable to an error message if an error occurs.
The POS= specifier is only allowed for stream files, and specifies the file storage position at which to start reading.
The ID= specifier is only allowed in conjunction with ASYNCHRONOUS='YES', and sets the variable to an identifier for that asynchronous i/o
(this variable can then be used in an ID= specifier in INQUIRE).
|
|
|
|
|
|
<Related> |
|
|
|
ADVANCE= specifier,
ASYNCHRONOUS= specifier,
BACKSPACE statement,
CLOSE statement,
DECIMAL= specifier,
ENDFILE statement,
END= specifier,
EOR= specifier,
ERR= specifier,
FORMAT statement,
ID= specifier,
INQUIRE statement,
IOMSG= specifier,
IOSTAT= specifier,
NAMELIST statement,
NML= specifier,
OPEN statement,
PRINT statement,
REWIND statement,
ROUND= specifier,
SIZE= specifier,
UNIT= specifier,
WRITE statement |
|
|