HP 3000 Manuals

Closing Files [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Programmer's Guide

Closing Files 

Once opened by predefinition or with the OPEN statement, files are closed
either by executing a CLOSE statement or by terminating the program.

Executing the CLOSE Statement 

The CLOSE statement explicitly causes the corresponding unit to be
closed.  The disposition of the file is controlled by the STATUS
specifier in the CLOSE statement, with the exception of STATUS='SCRATCH'
files.  If the status is not specified in the CLOSE statement, named
files default to KEEP (kept as an MPE/iX permanent file) and scratch
files default to DELETE. An error occurs if you attempt to save a scratch
file.


NOTE When a sequential file is closed, the last record written to the file is the last record of the file.
Files opened in the temporary job domain are closed as permanent files. If the FCLOSE fails (such as if the permanent file name already exists), the FCLOSE is attempted again in the temporary domain. An error occurs if the second FCLOSE fails. Terminating a Program All files remaining open when your program terminates are closed either by the FORTRAN 77 library or by the MPE/iX operating system. The disposition of files is determined by the type of program termination. There are two types of termination: normal and error. Normal termination occurs when a program executes a STOP or END statement in the main program. Both statements close all opened files as if a CLOSE statement requesting default disposition had been executed on the corresponding units. Error termination occurs when a program terminates because of errors detected by the FORTRAN 77 library, the Compiler Library, or by the MPE/iX operating system. Errors found by the FORTRAN 77 library (primarily I/O errors) that are not trapped by the ERR or IOSTAT specifiers in the READ and WRITE statements cause error messages to be printed. Errors detected by the Compiler Library (primarily math function errors) or by MPE/iX cause error messages to be printed. Any open files are closed by the MPE/iX operating system, not by the FORTRAN 77 library. When closed by MPE/iX, an FCLOSE with MPE/iX default status (not FORTRAN 77 status) is performed, which closes files in the domain in which they were opened. Because files are always created in the NEW file domain, such an FCLOSE operation causes newly created files to be deleted.


MPE/iX 5.0 Documentation