FORTRAN 77 Language Reference

Description

The OPEN statement determines the type of file named, whether the connection specified is legal for the file type (for instance, DIRECT access is illegal for tape and tty devices), and allocates buffers for the connection if the file is on tape or if the subparameter FILEOPT= 'BUFFER= n' is specified. Existing files are never truncated on opening.


Note -

For tape I/O, use the TOPEN() routines.


The following table summarizes the OPEN specifiers:

Table 4-3 OPEN Specifiers Summary

Form: SPECIFIER = Variable 

SPECIFIER 

Value of Variable  

Data Type of Variable 

ACCESS

'APPEND' 'DIRECT' 'SEQUENTIAL'

CHARACTER

ACTION

'READ' 'WRITE' 'READWRITE'

CHARACTER

BLANK

'NULL'

'ZERO'

CHARACTER

ERR

Statement number  

INTEGER

FORM

'FORMATTED' 'UNFORMATTED' 'PRINT'

CHARACTER

FILE *

Filename or '*'

CHARACTER

FILEOPT

'NOPAT' 'BUFFER=n' 'EOF'

CHARACTER

IOSTAT

Error number 

INTEGER

READONLY

RECL

Record length 

INTEGER

STATUS

'OLD' 'NEW' 'UNKNOWN' 'SCRATCH'

CHARACTER

The keywords can be specified in any order.

OPEN Specifier Keywords

The following provides a detailed list of the OPEN specifier keywords:

[UNIT=] u

FILE=fin

If you open a unit that is already open without specifying a file name (or with the previous file name), FORTRAN thinks you are reopening the file to change parameters. The file position is not changed. The only parameters you are allowed to change are BLANK (NULL or ZERO) and FORM (FORMATTED or PRINT). To change any other parameters, you must close, then reopen the file.

If you open a unit that is already open, but you specify a different file name, it is as if you closed with the old file name before the open.

If you open a file that is already open, but you specify a different unit, that is an error. This error is not detected by the ERR= option, however, and the program does not terminate abnormally.

If a file is opened with STATUS='SCRATCH', a temporary file is created and opened. See STATUS=sta.

ACCESS=acc

FORM=fm

RECL=rl

ERR=s

IOSTAT=ios

BLANK=blnk

STATUS=sta

FILEOPT=fopt @

READONLY @

ACTION=act