Intel fortran-80 6.2.2CLOSE Statement, Opening A Connected Unit, Unit Specifier, CLOSE close-list

Models: fortran-80

1 130
Download 130 pages 742 b
Page 68
Image 68
6.2.1.11 Opening A Connected Unit

Input/Output

FORTRAN-SO

6.2.1.11 Opening A Connected Unit

The OPEN statement can be specified for a unit already connected to an existing file. That existing file is assumed to be the value of 'fname' if the FILE specifier is not included in the OPEN 'open-list.'

If the file to be connected is the same as the connected file, the effect of OPEN depends on whether or not the file was preconnected. If the file was not precon- nected, or if it was preconnected and has already been referenced by an I/O state- ment, only the BLANK specifier (and RECL for sequential files) may differ from existing attributes. If the file was preconnected, but no I/O has been performed on the file, the propetties specified in the OPEN statement become the properties of connection. Subsequent OPEN statements can change only the BLANKS and RECL attributes as described above.

If the file to be connected is not the same as the file already connected, the currently connected file is closed and the new file is opened with this unit. The connected file is deleted if it was previously opened with status 'SCRATCH', but is not deleted if its status is 'OLD', 'NEW', or 'UNKNOWN'.

If a file is already connected to a unit, no OPEN statement connecting that file to a different unit can be executed.

6.2.2CLOSE Statement

The CLOSE statement is used to disconnect a particular file from a unit. Its format

IS

CLOSE (close-list)

where 'close-list' is a list of specifiers separated by commas. The list of specifiers is:

[UNIT =] unit

U nit specifier

IOSTAT = stname

I/O status specifier

ERR = stl

Error specifier

STATUS = stat

File disposition specifier

The unit specifier must be present; all other specifiers are optional and can be specified only once.

The IOSTAT and ERR specifiers have the same interpretation as in sections 6.2.1.2 and 6.2.1. 3, respectively. The UNIT and STATUS specifiers are described in the following sections.

6.2.2.1 Unit Specifier

The unit specifier has the same interpretation as in section 6.2.1.1. Execution of the CLOSE statement containing this specifier need not occur in the same program unit as its corresponding OPEN statement, however. If the specified file does not exist, CLOSE has no effect.

Once a unit has been disconnected by the CLOSE statement, it may be reconnected to the same file or a different file within the same program. Similarly, once a file has been disconnected, it may be reconnected to the same or a different unit, so long as the file still exists.

Example:

CLOSE (3, IOSTAT= ERRFLG, ERR= 1020)

6-8

Page 68
Image 68
Intel fortran-80 manual 6.2.2CLOSE Statement, Opening A Connected Unit, Unit Specifier, CLOSE close-list