FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-32
ENDFILE Statement
If you specify ios, but not lbl, and an error occurs while writing the end of file,
your program continues executing with the statement that follows the ENDFILE
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.
Using an ENDFILE statement with EDIT format files
An ENDFILE statement deletes all lines in the file following the line last read or
written.
After an ENDFILE statement, an INQUIRE statement’s NEXTREC option returns a
value of -2 as the last record number for an EDIT format file.
If you last opened the EDIT format file with ACCESS ='DIRECT', the ENDFILE
statement has no effect.
You cannot write an endfile record to an EDIT format file if your program runs as a
NonStop process.
If you specify the ENV COMMON and NONSTOP directives, you cannot write an
endfile record to an EDIT format file, even if your program is not running as a
NonStop process.
If you write an endfile record to unit 6 and you have not already established a
connection for the unit, ENDFILE implicitly opens the unit using default
parameters. If you specify ENV COMMON and you write an endfile record to unit
6, your FORTRAN routines share access to standard output with routines written in
other languages only if the access mode for the unit is OUTPUT. However, the
default access mode for unit 6 is I-O. If you want to share access to the file
connected to unit 6, you must set the unit’s access mode to OUTPUT before you
execute the ENDFILE statement. You can set the access mode:
°
In a FORTRAN OPEN statement, as in
OPEN( 6, MODE = 'OUTPUT')
°
In a TACL ASSIGN command, as in
ASSIGN FT006, , OUTPUT
°
In a UNIT compiler directive, as in
UNIT (6, OUTPUT)
For more information about using unit 6 as a shared file, see the OPEN Statement
on page 7-70.
If an ENDFILE statement causes unit 6 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.