[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

12.6.26 RECORDSIZE Specifier

RECORDSIZE is a nonstandard synonym for RECL (see Section 12.6.25).

12.6.27 RECORDTYPE Specifier

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


  • RECORDTYPE = typ

typ

Is a scalar default character expression that evaluates to one of the following values:
' FIXED ' Indicates fixed-length records.
' VARIABLE ' Indicates variable-length records.
' SEGMENTED ' Indicates segmented records.
' STREAM ' Indicates stream-type variable length records.
' STREAM_CR ' Indicates stream-type variable length records, terminated with a carriage-return.
' STREAM_LF ' Indicates stream-type variable length records, terminated with a line feed.

When you open a file, default record types are as follows:

' FIXED ' For relative or indexed files
' FIXED ' For direct access sequential files
' VARIABLE ' For formatted sequential access files
' SEGMENTED ' For unformatted sequential access files

A segmented record is a logical record consisting of one or more variable-length records (segments). The logical record can span several physical records. Only unformatted sequential-access files with sequential organization can have segmented records; ' SEGMENTED ' must not be specified for any other file type.

Files containing segmented records can be accessed only by unformatted sequential data transfer statements.

Normally, if you do not use the RECORDTYPE specifier when you are accessing an existing file, the record type of the file is used. However, if the file is an unformatted sequential-access file with sequential organization and variable-length records, the default record type is ' SEGMENTED ' .

If you use the RECORDTYPE specifier when you are accessing an existing file, the type that you specify must match the type of the existing file.

If an output statement does not specify a full record for a file containing fixed-length records, the following occurs:

  • In formatted files, the record is filled with blanks
  • In unformatted files, the record is filled with zeros

For More Information:

On record types and file organization, see the HP Fortran for OpenVMS User Manual.

12.6.28 SHARED Specifier

The SHARED specifier indicates that the file is connected for shared access by more than one program executing simultaneously. It takes the following form:


  • SHARED

For More Information:

On file sharing, see the HP Fortran for OpenVMS User Manual.

12.6.29 STATUS Specifier

The STATUS specifier indicates the status of a file when it is opened. It takes the following form:


  • STATUS = sta

sta

Is a scalar default character expression that evaluates to one of the following values:
' OLD ' Indicates an existing file.
' NEW ' Indicates a new file; if the file already exists, an error occurs. Once the file is created, its status changes to ' OLD ' .
' SCRATCH ' Indicates a new file that is unnamed (called a scratch file). When the file is closed or the program terminates, the scratch file is deleted.
' REPLACE ' Indicates the file replaces another. If the file to be replaced exists, it is deleted and a new file is created with the same name. If the file to be replaced does not exist, a new file is created and its status changes to ' OLD ' .
' UNKNOWN ' Indicates the file may or may not exist. If the file does not exist, a new file is created (using the next highest available version number) and its status changes to ' OLD ' .

The default is ' UNKNOWN ' . However, if you implicitly open a file using WRITE or you specify compiler option /NOF77 (or OPTIONS /NOF77), the default value is ' NEW ' . If you implicitly open a file using READ, the default value is ' OLD ' .

Scratch files (STATUS= ' SCRATCH ' ) are created on your default disk (SYS$DISK) and are not placed in a directory or given a name that is externally visible. To indicate a different device, use the FILE specifier.

Note

The STATUS specifier can also appear in CLOSE statements to indicate the file's status after it is closed. However, in CLOSE statements the STATUS values are the same as those listed for the DISPOSE specifier (see Section 12.6.12).

12.6.30 TYPE Specifier

TYPE is a nonstandard synonym for STATUS (see Section 12.6.29).

12.6.31 USEROPEN Specifier

The USEROPEN specifier indicates a user-written external function that controls the opening of the file. It takes the following form:


  • USEROPEN = function-name

function-name

Is the name of the user-written function to receive control.

The function must be declared in a previous EXTERNAL statement; if it is typed, it must be of type INTEGER(4) (INTEGER*4).

The USEROPEN specifier lets experienced users use additional features of the operating system that are not normally available in Fortran.

For More Information:

On user-supplied functions to use with USEROPEN, including examples, see the HP Fortran for OpenVMS User Manual.

12.7 REWIND Statement

The REWIND statement positions a sequential or direct access file at the beginning of the file (the initial point). It takes one of the following forms:


  • REWIND ([UNIT=]io-unit [,ERR=label] [,IOSTAT=i-var])
  • REWIND io-unit

io-unit

Is an external unit specifier.

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.

Rules and Behavior

The unit number must refer to a file on disk or magnetic tape, and the file must be open for sequential, direct, or append access.

If a REWIND is done on a direct access file, the NEXTREC specifier is assigned a value of 1.

A REWIND statement must not be specified for a file that is open for or keyed access.

If a file is already positioned at the initial point, a REWIND statement has no effect.

If a REWIND statement is specified for a unit that is not open, it has no effect.

Examples

The following statement repositions the file connected to I/O unit 3 to the beginning of the file:


REWIND 3

Consider the following statement:


REWIND (UNIT=9, IOSTAT=IOS, ERR=10)

This statement positions the file connected to unit 9 at the beginning of the file. If an error occurs, control is transferred to the statement labeled 10, and a positive integer is stored in variable IOS.

For More Information:

  • On the UNIT control specifier, see Section 10.2.1.1.
  • On the ERR control specifier, see Section 10.2.1.8.
  • On the IOSTAT control specifier, see Section 10.2.1.7.
  • On record position, advancement, and transfer, see the HP Fortran for OpenVMS User Manual.

12.8 UNLOCK Statement

The UNLOCK statement frees a record in an indexed, relative, or sequential file that was locked by a previous READ statement.

The UNLOCK statement takes one of the following forms:


  • UNLOCK ([UNIT=]io-unit [,ERR=label] [,IOSTAT=i-var])
  • UNLOCK io-unit

io-unit

Is an external unit specifier.

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.

If no record is locked, the UNLOCK statement has no effect.

Examples

The following statement frees any record previously read and locked in the file connected to I/O unit 4:


UNLOCK 4

Consider the following statement:


UNLOCK (UNIT=9, IOSTAT=IOS, ERR=10)

This statement frees any record previously read and locked in the file connected to unit 9. If an error occurs, control is transferred to the statement labeled 10, and a positive integer is stored in variable IOS.

For More Information:

  • On the UNIT control specifier, see Section 10.2.1.1.
  • On the ERR control specifier, see Section 10.2.1.8.
  • On the IOSTAT control specifier, see Section 10.2.1.7.
  • On shared files and locked records, see the HP Fortran for OpenVMS User Manual.


Chapter 13
Compilation Control Statements

In addition to specifying options on the compiler command line, you can specify the following statements in a program unit to influence compilation:

  • DICTIONARY statement ( Section 13.1)
    Extracts records from the Common Data Dictionary (CDD) and converts them into HP Fortran STRUCTURE declarations.
  • INCLUDE statement ( Section 13.2)
    Incorporates external source code into programs.
  • OPTIONS statement ( Section 13.3)
    Sets options usually specified in the compiler command line. OPTIONS statement settings override command line options.

13.1 DICTIONARY Statement

The DICTIONARY statement incorporates common data dictionary (CDD) data definitions into the current HP Fortran source program during compilation. The statement can occur any place in a Fortran source program where a STRUCTURE statement can occur.

The DICTIONARY statement takes the following form:


  • DICTIONARY 'cdd-path [/[NO]LIST]'

cdd-path

Is interpreted as the full or relative pathname of a CDD object.

/[NO]LIST

Controls whether the source code representation of the resulting structure declaration is listed in a compilation source listing. The default is /NOLIST. /LIST and /NOLIST must be spelled completely.

Rules and Behavior

There are two types of CDD pathnames: full and relative. Their form must conform to the rules for forming CDD pathnames.

A full CDD pathname begins with CDD$TOP and specifies the given names of all its descendants; it is a complete path to the record definition. Multiple descendant names are separated by periods.

A relative CDD pathname begins with any generation name other than CDD$TOP and specifies the given names of the descendants after that point. A relative path comes into existence when a default directory is established with a logical name.

Examples

In the following example, the logical name definition specifies the beginning of the CDD pathname. So, a relative pathname specifies the remainder of the path to the record definition:


$ DEFINE CDD$DEFAULT CDD$TOP.FOR

The following examples show how a CDD pathname beginning with CDD$TOP overrides the default CDD pathname. Consider a record with the pathname CDD$TOP.SALES.JONES.SALARY. If you define CDD$DEFAULT to be CDD$TOP.SALES.JONES, you can then specify a relative pathname; for example:


DICTIONARY 'SALARY'

You can also specify this as a full pathname, for example:


DICTIONARY 'CDD$TOP.SALES.JONES.SALARY'

For More Information:

On CDD pathnames, see Using CDD/Repository on VMS Systems.

13.2 INCLUDE Statement

The INCLUDE statement directs the compiler to stop reading statements from the current file and read statements in an included file or text module.

The INCLUDE statement takes one of the following forms:


  • INCLUDE 'file-name [/[NO]LIST] '
  • INCLUDE '[text-lib] (module-name) [/[NO]LIST]'

file-name

Is a character string specifying the name of the file to be included; it must not be a named constant.

The form of the file name must be acceptable to the operating system, as described in your system documentation.

/[NO]LIST

Specifies whether the incorporated code is to appear in the compilation source listing. In the listing, a number precedes each incorporated statement. The number indicates the "include" nesting depth of the code. The default is /NOLIST. /LIST and /NOLIST must be spelled completely.

text-lib

Is a character string specifying the file name of the text library to be searched.

The form of the file name must be acceptable to the operating system, as described in your system documentation.

module-name

Is a character string specifying the name of the text library module to be included. The name of the text module must be enclosed in parentheses. It can contain any alphanumeric character and the special characters dollar sign ($) and underscore (_).

The length of the file name must be acceptable to the operating system, as described in your system documentation.

Rules and Behavior

An INCLUDE statement can appear anywhere within a scoping unit. The statement can span more than one source line, but no other statement can appear on the same line. The source line cannot be labeled.

An included file or text module cannot begin with a continuation line, and each Fortran statement must be completely contained within a single file.

An included file or text module can contain any source text, but it cannot begin or end with an incomplete Fortran statement.

The included statements, when combined with the other statements in the compilation, must satisfy the statement-ordering restrictions shown in Figure 2-1.

Included files or text modules can contain additional INCLUDE statements, but they must not be recursive. INCLUDE statements can be nested until system resources are exhausted.

When the included file or text module completes execution, compilation resumes with the statement following the INCLUDE statement.

When including files that contain datatype declarations, it is recommended that such declarations explicitly specify the kind of the datatype. If an explicit kind is omitted, the declarations will be interpreted according to the command-line options in effect when the file is included, which may result in unintended behavior.

Examples

In Example 13-1, a file named COMMON.FOR (in the current working directory) is included and read as input.

Example 13-1 Including Text from a File

Main Program File                COMMON.FOR File

PROGRAM
  INCLUDE 'COMMON.FOR'           INTEGER, PARAMETER :: M=100
  REAL, DIMENSION(M) :: Z        REAL, DIMENSION(M) :: X, Y
  CALL CUBE                      COMMON X, Y
  DO I = 1, M
    Z(I) = X(I) + SQRT(Y(I))
    ...
  END DO
END

SUBROUTINE CUBE
  INCLUDE 'COMMON.FOR'
  DO I=1,M
    X(I) = Y(I)**3
  END DO
  RETURN
END

The file COMMON.FOR defines a named constant M, and defines arrays X and Y as part of blank common.

For More Information:

  • On compiler options, see the HP Fortran for OpenVMS User Manual.
  • On using text libraries, see the HP Fortran for OpenVMS User Manual.

13.3 OPTIONS Statement

The OPTIONS statement overrides or confirms the compiler options in effect for a program unit. It takes the following form:


  • OPTIONS option [option...]

option

Is one of the following:

  • /CHECK =
    • ALL
    • [NO]BOUNDS
    • [NO]OVERFLOW
    • [NO]UNDERFLOW
    • NONE
  • /NOCHECK
  • /CONVERT =
    • BIG_ENDIAN
    • CRAY
    • FDX
    • FGX
    • IBM
    • LITTLE_ENDIAN
    • NATIVE
    • VAXD
    • VAXG
  • /[NO]EXTEND_SOURCE
  • /[NO]F77
  • /FLOAT =
    • D_FLOAT
    • G_FLOAT
    • IEEE_FLOAT
  • /[NO]G_FLOATING
  • /[NO]I4
  • /[NO]RECURSIVE

Note that an option must always be preceded by a slash (/).

Some OPTIONS statement options are equivalent to compiler options.

Rules and Behavior

The OPTIONS statement must be the first statement in a program unit, preceding the PROGRAM, SUBROUTINE, FUNCTION, MODULE, and BLOCK DATA statements.

OPTIONS statement options override compiler options, but only until the end of the program unit for which they are defined. If you want to override compiler options in another program unit, you must specify the OPTIONS statement before that program unit.

Examples

The following are valid OPTIONS statements:


OPTIONS /CHECK=ALL/F77

OPTIONS /I4

For More Information:

On compiler options, see the HP Fortran for OpenVMS User Manual.


Previous Next Contents Index