FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-74
OPEN Statement
If you compile your program with ENV COMMON, your program can share access
to unit 5 and unit 6 with modules written in languages other than FORTRAN. Your
FORTRAN routines can share access to standard input (accessed through unit 5)
and standard output (accessed through unit 6) with routines in your process written
in other languages if:
°
The file name for the unit is the same as the file name specified in—or defaults
to—the name in the TACL IN (unit 5) or OUT (unit 6) run-option when you
run your program.
°
MODE is 'INPUT' for unit 5, 'OUTPUT' for unit 6.
°
STATUS is 'UNKNOWN' or not specified.
°
SYNCDEPTH is 0, 1, or unspecified.
°
ACCESS is 'SEQUENTIAL' or unspecified.
°
The file name is not all blanks.
°
The device type is either not yet known or, if known, is a process, a terminal, a
printer (if unit 6), or an unstructured or entry-sequenced disk file.
°
PROTECT matches the PROTECT specifier of all previous opens to the same
shared file by routines written in other languages in your process. If you do not
specify the PROTECT specifier, its default is the value specified on a previous
OPEN, or is device dependent if you do not specify it and this is the first open
of the specified file (fn).
The preceding values are the defaults for each of the OPEN option specifiers
except MODE, for which the default value is 'I-O'. Therefore, you must specify an
appropriate value for MODE when you open a file that you want to share. If you do
not specify MODE when you open unit 5 or unit 6 and you do not specify it in a
TACL ASSIGN command or a FORTRAN UNIT directive, your FORTRAN routines
will not take advantage of the file sharing features of the COMMON environment.
STATUS specifier
The default is 'UNKNOWN'.
If you specify 'OLD', the file must exist; if you specify 'NEW' the file must not exist.
Successful execution of an OPEN statement with STATUS= 'NEW' creates the
specified file and changes its status to 'OLD'.
If you specify 'SCRATCH' and a file name (FILE = fn), fn can contain only the
names of a node and volume. You cannot specify a subvolume name or a file id if
you specify STATUS = 'SCRATCH'. The unit is connected to a file with a system
assigned temporary name for the duration of the program run or until the program
closes that unit, at which time the file is deleted.
If you specify 'UNKNOWN', and the file exists, it is connected to the specified
unit. If the file does not exist, it is created and connected. In either case, the
status of the file becomes 'OLD'.