HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

The ERR and IOSTAT specifiers from any previously executed OPEN statement have no effect on any currently executing OPEN statement. If an error occurs, no file is opened or created.

Secondary operating system messages do not display when IOSTAT is specified. To display these messages, remove IOSTAT or use a platform-specific method. (For more information, see the HP Fortran for OpenVMS User Manual.)

Examples

You can specify character values at run time by substituting a character expression for a specifier value in the OPEN statement. The character value can contain trailing blanks but not leading or embedded blanks; for example:


CHARACTER*7 QUAL /' '/ 
... 
IF (exp) QUAL = '/DELETE' 
  OPEN (UNIT=1, STATUS='NEW', DISP='SUBMIT'//QUAL) 

The following statement creates a new sequential formatted file on unit 1 with the default file name FOR001.DAT:


OPEN (UNIT=1, STATUS='NEW', ERR=100) 

The following statement creates a 50-block direct access file for temporary storage. The file is deleted at program termination.


OPEN (UNIT=3, STATUS='SCRATCH', ACCESS='DIRECT',              & 
     INITIALSIZE=50, RECL=64) 

The following statement creates a file on magnetic tape with a large block size for efficient processing:


 OPEN (UNIT=I, FILE='MTA0:MYDATA.DAT', BLOCKSIZE=8192, 
1     STATUS='NEW', ERR=14, RECL=1024, 
1     RECORDTYPE='FIXED') 

The following statement opens the file (created in the previous example) for input:


 OPEN (UNIT=I, FILE='MTA0:MYDATA.DAT', READONLY, 
1     STATUS='OLD', RECL=1024, RECORDTYPE='FIXED', 
1     BLOCKSIZE=8192) 

The following statement uses the file name supplied by the user and the default file specification supplied by the DEFAULTFILE specifier to define the file specification for an existing file:


 TYPE *, 'ENTER NAME OF DOCUMENT' 
 ACCEPT *, DOC 
 OPEN (UNIT=1, FILE=DOC, DEFAULTFILE='[ARCHIVE].TXT', 
1     STATUS='OLD') 

For More Information:

12.6.1 ACCESS Specifier

The ACCESS specifier indicates the access method for the connection of the file. It takes the following form:

  • ACCESS = acc

acc

Is a scalar default character expression that evaluates to one of the following values:
' DIRECT ' Indicates direct access.
' SEQUENTIAL ' Indicates sequential access.
' KEYED ' Indicates keyed access.
' APPEND ' Indicates sequential access, but the file is positioned at the end-of-file record.

The default is ' SEQUENTIAL ' .

12.6.2 ACTION Specifier

The ACTION specifier indicates the allowed I/O operations for the file connection. It takes the following form:

  • ACTION = act

act

Is a scalar default character expression that evaluates to one of the following values:
' READ ' Indicates that only READ statements can refer to this connection.
' WRITE ' Indicates that only WRITE, DELETE, and ENDFILE statements can refer to this connection.
' READWRITE ' Indicates that READ, WRITE, DELETE, and ENDFILE statements can refer to this connection.

The default is ' READWRITE ' .

12.6.3 ASSOCIATEVARIABLE Specifier

The ASSOCIATEVARIABLE specifier indicates a variable that is updated after each direct access I/O operation, to reflect the record number of the next sequential record in the file. It takes the following form:

  • ASSOCIATEVARIABLE = asv

asv

Is a scalar integer variable. It cannot be a dummy argument to the routine in which the OPEN statement appears.

Direct access READs, direct access WRITEs, and the FIND, DELETE, and REWRITE statements can affect the value of asv.

This specifier is valid only for direct access; it is ignored for other access modes.

12.6.4 BLANK Specifier

The BLANK specifier indicates how blanks are interpreted in a file. It takes the following form:

  • BLANK = blnk

blnk

Is a scalar default character expression that evaluates to one of the following values:
' NULL ' Indicates all blanks are ignored, except for an all-blank field (which has a value of zero).
' ZERO ' Indicates all blanks (other than leading blanks) are treated as zeros.

The default is ' NULL ' (for explicitly OPENed files, preconnected files, and internal files). If you specify compiler option /NOF77 (or OPTIONS /NOF77), the default is ' ZERO ' .

If the BN or BZ edit descriptors are specified for a formatted input statement, they supersede the default interpretation of blanks.

For More Information:

On the BN and BZ edit descriptors, see Section 11.4.4.

12.6.5 BLOCKSIZE Specifier

The BLOCKSIZE specifier specifies the physical I/O transfer size for the file. It takes the following form:

  • BLOCKSIZE = bks

bks

Is a scalar numeric expression. If necessary, the value is converted to integer data type before use.

For magnetic tape files, the value of bks specifies the physical record size in the range 18 to 32767 bytes. The default value is 2048 bytes.

For sequential disk files, the value of bks is rounded up to an integral number of 512-byte blocks and used to specify multiblock transfers. The number of blocks transferred can be 1 to 127; it is determined by RMS defaults.

For relative and indexed files, the value of bks is rounded up to an integral number of 512-byte blocks, and is used to specify the RMS bucket size in the range 1 to 63 blocks. The default is the smallest value capable of holding a single record.

For More Information:

12.6.6 BUFFERCOUNT Specifier

The BUFFERCOUNT specifier indicates the number of buffers to be associated with the unit for multibuffered I/O. It takes the following form:

  • BUFFERCOUNT = bc

bc

Is a scalar numeric expression in the range 1 through 127. If necessary, the value is converted to integer data type before use.

The BLOCKSIZE specifier determines the size of each buffer. For example, if BUFFERCOUNT=3 and BLOCKSIZE=2048, the total number of bytes allocated for buffers is 3*2048, or 6144.

If you do not specify BUFFERCOUNT or you specify zero for bc, the process or system default is assumed.

For More Information:

12.6.7 BUFFERED Specifier

The BUFFERED specifier indicates run-time library behavior following WRITE operations. It takes the following form:

  • BUFFERED = bf

bf

Is a scalar default character expression that evaluates to one of the following values:
' NO ' Requests that the run-time library send output data to the file system after each WRITE operation.
' YES ' Requests that the run-time library accumulate output data in its internal buffer, possibly across several WRITE operations, before the data is sent to the file system.

Buffering may improve run-time performance for output-intensive applications.

The default is ' NO ' .

BUFFERED has no effect. The operating system automatically performs buffering, which can be affected by the values of the BUFFERCOUNT and BUFFERSIZE keywords when the file is opened.

12.6.8 CARRIAGECONTROL Specifier

The CARRIAGECONTROL specifier indicates the type of carriage control used when a file is printed. It takes the following form:

  • CARRIAGECONTROL = cc

cc

Is a scalar default character expression that evaluates to one of the following values:
' FORTRAN ' Indicates normal Fortran interpretation of the first character.
' LIST ' Indicates one line feed between records.
' NONE ' Indicates no carriage control processing.

The default for formatted files is ' FORTRAN ' . The default for unformatted files, is ' NONE ' .

12.6.9 CONVERT Specifier

The CONVERT specifier indicates a nonnative numeric format for unformatted data. It takes the following form:

  • CONVERT = fm

fm

Is a scalar default character expression that evaluates to one of the following values:
' LITTLE_ENDIAN ' 1 Little endian integer data 2 and IEEE floating-point data. 3
' BIG_ENDIAN ' 1 Big endian integer data 2 and IEEE floating-point data. 3
' CRAY ' Big endian integer data 2 and CRAY floating-point data of size REAL(8) or COMPLEX(8).
' FDX ' Little endian integer data 2 and VAX floating-point data of format F_floating for REAL(4) or COMPLEX(4), D_floating for size REAL(8) or COMPLEX(8), and IEEE X_floating for REAL(16) or COMPLEX(16).
' FGX ' Little endian integer data 2 and VAX floating-point data of format F_floating for REAL(4) or COMPLEX(4), G_floating for size REAL(8) or COMPLEX(8), and IEEE X_floating for REAL(16) or COMPLEX(16).
' IBM ' Big endian integer data 2 and IBM System\370 floating-point data of size REAL(4) or COMPLEX(4) (IBM short 4), and size REAL(8) or COMPLEX(8) (IBM long 8).
' VAXD ' Little endian integer data 2 and VAX floating-point data of format F_floating for size REAL(4) or COMPLEX(4), D_floating for size REAL(8) or COMPLEX(8), and H_floating for REAL(16) or COMPLEX(16).
' VAXG ' Little endian integer data 2 and VAX floating-point data of format F_floating for size REAL(4) or COMPLEX(4), G_floating for size REAL(8) or COMPLEX(8), and H_floating for REAL(16) or COMPLEX(16).
' NATIVE ' No data conversion. This is the default.

1INTEGER(1) data is the same for little endian and big endian.
2Of the appropriate size: INTEGER(1), INTEGER(2), INTEGER(4), or INTEGER(8)
3Of the appropriate size and type: REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), or COMPLEX(16)

You can use CONVERT to specify multiple formats in a single program, usually one format for each specified unit number.

When reading a nonnative format, the nonnative format on disk is converted to native format in memory. If a converted nonnative value is outside the range of the native data type, a run-time message appears.

There are other ways to specify numeric format for unformatted files: you can specify an OpenVMS logical name, the command line qualifier /CONVERT, or OPTIONS/CONVERT. The following shows the order of precedence:
Method Used Precedence
OpenVMS logical name Highest
OPEN (CONVERT=) .
OPTIONS/CONVERT .
The /CONVERT qualifier Lowest

The /CONVERT qualifier and OPTIONS/CONVERT affect all unit numbers used by the program, while logical names and OPEN (CONVERT=) affect specific unit numbers.

The following example shows how to code the OPEN statement to read unformatted CRAY numeric data from unit 15, which might be processed and possibly written in native little endian format to unit 20:


 OPEN (CONVERT='CRAY', FILE='graph3.dat', FORM='UNFORMATTED', 
1     UNIT=15) 
     . 
     . 
     . 
 OPEN (FILE='graph3_native.dat', FORM='UNFORMATTED', UNIT=20) 

For More Information:

12.6.10 DEFAULTFILE Specifier

The DEFAULTFILE specifier indicates a default file specification string. It takes the following form:

  • DEFAULTFILE = def

def

Is a character expression indicating a default file specification string.

This specifier can supply a value to the RMS default file specification string for the missing components of a file specification. If you omit the DEFAULTFILE specifier, HP Fortran uses the default value "FORnnn.DAT", where nnn is the unit number with leading zeros.

The default file specification string is used primarily when accepting file specifications interactively. Complete file specifications known to a user program normally appear in the FILE specifier.

You can indicate default values for any one of the following file-specification components:

If you indicate values for any of these components in the FILE specifier, they override any values indicated in the DEFAULTFILE specifier.

For More Information:

On specifying file-specification components, see the OpenVMS Record Management Services Reference Manual.

12.6.11 DELIM Specifier

The DELIM specifier indicates what characters (if any) are used to delimit character constants in list-directed and namelist output. It takes the following form:

  • DELIM = del

del

Is a scalar default character expression that evaluates to one of the following values:
' APOSTROPHE ' Indicates apostrophes delimit character constants. All internal apostrophes are doubled.
' QUOTE ' Indicates quotation marks delimit character constants. All internal quotation marks are doubled.
' NONE ' Indicates character constants have no delimiters. No internal apostrophes or quotation marks are doubled.

The default is ' NONE ' .

The DELIM specifier is only allowed for files connected for formatted data transfer; it is ignored during input.


Previous Next Contents Index