FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-93
READ Statement
°
In a UNIT compiler directive, as in
UNIT (5, INPUT)
For more information about using unit 5 as a shared file, see the OPEN Statement
on page 7-70.
•
If a READ statement causes unit 5 to be implicitly opened and your program is
running as a NonStop process, the FORTRAN run-time library does a stack
checkpoint to the backup process as a part of the implicit open.
•
End-of-file condition
If you specify endlbl, and the read operation encounters an end of file, the READ
statement terminates and FORTRAN transfers control to the statement identified
by endlbl. If you also specify ios, it will have a value of -1.
If you specify ios, but not endlbl, and the read operation encounters an end of
file, your program continues executing with the statement that follows the READ
statement. You can analyze ios to determine the error that occurred. ios will
have a value of -1 for an end-of-file condition.
If you do not specify ios or endlbl, and the read operation encounters an end of
file, FORTRAN terminates your program and displays a run-time diagnostic
message.
•
Error conditions
If you specify lbl, and an error occurs during the read operation, the READ
statement terminates, the file position becomes indeterminate, and FORTRAN
transfers control to the statement identified by lbl. If you also specify ios, you
can determine the error that occurred by analyzing ios.
If you specify ios, but not lbl, and an error occurs during the read operation,
your program continues executing with the statement that follows the READ
statement. You can analyze ios to determine the error that occurred, if any.
If you do not specify ios or lbl, and an error occurs, FORTRAN terminates your
program and displays a run-time diagnostic message.
Examples
READ (4,*) firstname, age
READ (UNIT=4, PROMPT= ' Enter part no. ',FMT=*) partnum
READ (infile, 400, ERR=30, END=500, REC=numrec)
+ ( array(k), k=1, stop)










