FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-19
CLOSE Statement
Considerations
•
Use of the CLOSE statement
You do not need to include the CLOSE statement in the program unit which 
opened the file. 
After you have disconnected a unit using the CLOSE statement, you can reconnect 
the unit within the same program to the same or to a different file.
A CLOSE statement that refers to a unit that does not exist or that has no file 
connected to it has no effect.
When a program terminates normally, FORTRAN automatically disconnects any 
units that you have not explicitly closed.
•
Error conditions
If you specify label, and an error occurs during the CLOSE operation, the 
CLOSE statement terminates, the file position becomes indeterminate, and 
FORTRAN transfers control to the statement identified by label. If you specified 
ios, you can determine the error that occurred by analyzing ios.
If you specify ios, but not label, and an error occurs during the CLOSE 
operation, your program continues executing with the statement that follows the 
CLOSE statement. You can analyze ios to determine the error that occurred, if 
any.
If you do not specify ios or label, and an error occurs, FORTRAN terminates 
your program and displays a run-time diagnostic message.
•
STATUS = stat
The file disposition specifier, STATUS = stat, determines the status of the file 
after it is disconnected from the specified unit. If you do not include a status 
specifier, one of the following occurs:
°
If you opened the file with STATUS = 'SCRATCH', FORTRAN deletes the file.
°
FORTRAN always deletes temporary files when the open count for the file 
reaches zero.
For all other types of files, FORTRAN keeps the file. If you specify STATUS = 
'DELETE', FORTRAN returns file system error 12, “File in Use,” if your process or 
another process has the file associated with unit open.
•
The STACK specifier
When a fault-tolerant program is being run, execution of a CLOSE statement 
automatically checkpoints program environment information.
If you specify STACK = 'YES' (the default value), FORTRAN checkpoints the 
memory stack from the initial L register setting to the current S register setting (top 
of stack), the corresponding portion of the extended memory stack (if any), and the 










