HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

12.5.23 READWRITE Specifier

The READWRITE specifier asks whether a file can be both read and written to. It takes the following form:

  • READWRITE = rdwr

rdwr

Is a scalar default character variable that is assigned one of the following values:
' YES ' If the file can be both read and written to
' NO ' If the file cannot be both read and written to
' UNKNOWN ' If the processor cannot determine whether the file can be both read and written to

12.5.24 RECL Specifier

The RECL specifier asks the maximum record length for a file. It takes the following form:

  • RECL = rcl

rcl

Is a scalar integer variable that is assigned a value as follows:

The assigned value is expressed in 4-byte units if a file is currently (or was previously) connected for unformatted data transfer; otherwise, the value is expressed in bytes.

12.5.25 RECORDTYPE Specifier

The RECORDTYPE specifier asks which type of records are in a file. It takes the following form:

  • RECORDTYPE = rtype

rtype

Is a scalar default character variable that is assigned one of the following values:
' FIXED ' If the file is connected for fixed-length records
' VARIABLE ' If the file is connected for variable-length records
' SEGMENTED ' If the file is connected for unformatted sequential data transfer using segmented records
' STREAM ' If the file's records are terminated with a carriage return and line feed
' STREAM_CR ' If the file's records are terminated with only a carriage return
' STREAM_LF ' If the file's records are terminated with only a line feed
' UNKNOWN ' If the processor cannot determine the record type

12.5.26 SEQUENTIAL Specifier

The SEQUENTIAL specifier asks whether a file is connected for sequential access. It takes the following form:

  • SEQUENTIAL = seq

seq

Is a scalar default character variable that is assigned one of the following values:
' YES ' If the file is connected for sequential access
' NO ' If the file is not connected for sequential access
' UNKNOWN ' If the processor cannot determine whether the file is connected for sequential access

12.5.27 UNFORMATTED Specifier

The UNFORMATTED specifier asks whether a file is connected for unformatted data transfer. It takes the following form:

  • UNFORMATTED = unf

unf

Is a scalar default character variable that is assigned one of the following values:
' YES ' If the file is connected for unformatted data transfer
' NO ' If the file is not connected for unformatted data transfer
' UNKNOWN ' If the processor cannot determine whether the file is connected for unformatted data transfer

12.5.28 WRITE Specifier

The WRITE specifier asks whether a file can be written to. It takes the following form:

  • WRITE = wr

wr

Is a scalar default character variable that is assigned one of the following values:
' YES ' If the file can be written to
' NO ' If the file cannot be written to
' UNKNOWN ' If the processor cannot determine whether the file can be written to

12.6 OPEN Statement

The OPEN statement connects an external file to a unit, creates a new file and connects it to a unit, creates a preconnected file, or changes certain properties of a connection.

The OPEN statement takes the following form:

  • OPEN ([UNIT=]io-unit [,FILE=name] [,ERR=label] [,IOSTAT=i-var], slist)

io-unit

Is an external unit specifier.

name

Is a character or numeric expression specifying the name of the file to be connected. For more information, see Section 12.6.14.

label

Is the label of the branch target statement that receives control if an error occurs.

i-var

Is a scalar integer variable that is defined as a positive integer if an error occurs and zero if no error occurs.

slist

Is one or more OPEN specifiers in the form specifier=value or specifier. Each specifier can appear only once.

The OPEN specifiers and their acceptable values are summarized in Table 12-1.

The OPEN specifiers are described individually in the following sections. The control specifiers that can be specified in an OPEN statement (UNIT, ERR, and IOSTAT) are discussed in Section 10.2.1.

)
Table 12-1 OPEN Statement Specifiers and Values
Specifier Values Function Default
ACCESS ' SEQUENTIAL '
' DIRECT '
' KEYED '
' APPEND '
Access mode ' SEQUENTIAL '
ACTION ' READ '
' WRITE '
' READWRITE '
File access ' READWRITE '
ASSOCIATEVARIABLE var Next direct access record No default
BLANK ' NULL '
' ZERO '
Interpretation of blanks ' NULL '
BLOCKSIZE n_expr Physical block size System default
BUFFERCOUNT n_expr Number of I/O buffers System default
BUFFERED ' YES '
' NO '
Buffering for WRITE operations ' NO '
CARRIAGECONTROL ' FORTRAN '
' LIST '
' NONE '
Print control Formatted:
' FORTRAN '
Unformatted:
' NONE '
CONVERT ' LITTLE_ENDIAN '
' BIG_ENDIAN '
' CRAY '
' FDX '
' FGX '
' IBM '
' VAXD '
' VAXG '
' NATIVE '
Numeric format specification ' NATIVE '
DEFAULTFILE c_expr Default file
specification
Current working directory
DELIM ' APOSTROPHE '
' QUOTE '
' NONE '
Delimiter for character constants ' NONE '
DISPOSE
(or DISP)
' KEEP ' or ' SAVE '
' DELETE '
' PRINT '
' PRINT/DELETE '
' SUBMIT '
' SUBMIT/DELETE '
File disposition at close ' KEEP '
ERR label Error transfer control No default
EXTENDSIZE n_expr File allocation increment Volume or system default
FILE
(or NAME)
c_expr File specification
(file name)
FORnnn.DAT 1
FORM ' FORMATTED '
' UNFORMATTED '
Format type Depends on ACCESS setting
INITIALSIZE n_expr File allocation No default
IOSTAT var I/O status No default
KEY (e1:e2[:dt[:dr]],...) Key field definitions CHARACTER
ASCENDING
MAXREC n_expr Direct access record limit No limit
NOSPANBLOCKS No value Records do not span blocks No default
ORGANIZATION ' SEQUENTIAL '
' RELATIVE '
' INDEXED '
File organization ' SEQUENTIAL '
PAD ' YES '
' NO '
Record padding ' YES '
POSITION ' ASIS '
' REWIND '
' APPEND '
File positioning ' ASIS '
READONLY No value Write protection No default
RECL
(or RECORDSIZE)
n_expr Record length Depends on
RECORDTYPE,
ORGANIZATION,
and FORM settings
RECORDTYPE ' FIXED '
' VARIABLE '
' SEGMENTED '
' STREAM '
' STREAM_CR '
' STREAM_LF '
Record type Depends on
ORGANIZATION, ACCESS, and
FORM settings
SHARED No value File sharing allowed No default 2
STATUS
(or TYPE)
' OLD '
' NEW '
' SCRATCH '
' REPLACE '
' UNKNOWN '
File status at open ' UNKNOWN ' 3
UNIT n_expr Logical unit number No default; an io-unit must be specified
USEROPEN func User program option No default


1nnn is the unit number (with leading zeros, if necessary).
2For information on file sharing, see the HP Fortran for OpenVMS User Manual.
3The default differs under certain conditions (see Section 12.6.29).

Key to Values
c _expr: A scalar default character expression
dr: A direction, ASCENDING or DESCENDING
dt: A data type, INTEGER or CHARACTER
e1: The first byte position of a key
e2: The last byte position of a key
func: An external function
label: A statement label
n _expr: A scalar numeric expression
var: A scalar integer variable

Rules and Behavior

The control specifiers ([UNIT=]io-unit, ERR=label, and IOSTAT=i-var) and OPEN specifiers can appear anywhere within the parentheses following OPEN. However, if the UNIT specifier is omitted, the io-unit must appear first in the list.

Specifier values that are scalar numeric expressions can be any integer or real expression. The value of the expression is converted to integer data type before it is used in the OPEN statement.

Only one unit at a time can be connected to a file, but multiple OPENs can be performed on the same unit. If an OPEN statement is executed for a unit that already exists, the following occurs:


Previous Next Contents Index