VMS Help
FORTRAN, Compatibility Features

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

  Compaq Fortran provides the following language features to aid
  compatibility with other versions of Fortran:

   o  The DEFINE FILE, ENCODE, DECODE, and FIND statements

   o  A NOF77 interpretation of the EXTERNAL statement

   o  Octal forms of integer constants

   o  An alternative syntax for the PARAMETER statement

   o  The VIRTUAL statement

   o  An alternative syntax for bit constants

   o  An alternative syntax for a record specifier

  These language features are particularly useful in transporting
  older Fortran programs to a VAX system.  However, you should avoid
  using them in new programs on these systems, and in new programs
  for which portability to other FORTRAN-77 implementations is
  important.

  1 - DEFINE_FILE

  The DEFINE FILE statement establishes the size and structure of
  files with relative organization and associates them with a logical
  unit number.  The DEFINE FILE statement is comparable to the OPEN
  statement (in situations where you can use the OPEN statement, it
  is the preferable mechanism for creating and opening files).
  Statement format:

     DEFINE FILE u(m, n, U, asv) [,u(m, n, U, asv)]...

     u    Is an integer constant or variable that specifies the
          logical unit number.

     m    Is an integer constant or variable that specifies the
          number of records in the file.

     n    Is an integer constant or variable that specifies the
          length of each record in 16-bit words (2 bytes).

     U    Specifies that the file is unformatted (binary); this
          is the only acceptable entry in this position.

     asv  Is an integer variable, called the associated variable
          of the file.  At the end of each direct access I/O
          operation, the record number of the next higher numbered
          record in the file is assigned to "asv"; "asv" must not
          be a dummy argument.

  The DEFINE FILE statement specifies that a file containing "m"
  fixed-length records, each composed of n 16-bit words, exists (or
  is to exist) on the specified logical unit.  The records in the
  file are numbered sequentially from 1 through "m".

  A DEFINE FILE statement must be executed before the first direct
  access I/O statement referring to the specified file, even though
  the DEFINE FILE statement does not itself open the file.  The file
  is actually opened when the first direct access I/O statement for
  the unit is executed.

  If this I/O statement is a WRITE statement, a new relative
  organization file is created.  If it is a READ or FIND statement,
  an existing file is opened, unless the specified file does not
  exist.  If a file does not exist, an error occurs.

  2 - ENCODE and DECODE

  The ENCODE and DECODE statements transfer data between variables or
  arrays in internal storage.  The ENCODE statement translates data
  from internal (binary) form to character form.  Inversely, the
  DECODE statement translates data from character to internal form.
  These statements are comparable to using internal files in
  formatted sequential WRITE and READ statements, respectively.
  Statement format:

     ENCODE (c,f,b [,IOSTAT=ios] [,ERR=s]) [list]
     DECODE (c,f,b [,IOSTAT=ios] [,ERR=s]) [list]

     c      Is an integer expression.  In the ENCODE statement,
            "c" is the number of characters (in bytes) to be
            translated to character form.  In the DECODE statement,
            "c" is the number of characters to be translated to
            internal form.

     f      Is a format identifier.  An error occurs if more than
            one record is specified.

     b      Is a scalar or array reference. If b is an array
            reference, its elements are processed in the
            order of subscript progression. The data type of "b"
            determines the number of characters that ENCODE or
            DECODE can process.

            In the ENCODE statement, "b" receives the characters
            after translation to external form.  If less than "c"
            characters are received, the remaining character
            positions are filled with blank characters.

            In the DECODE statement, "b" contains the characters
            to be translated to internal form.

     ios    Is an integer scalar memory reference that is defined
            as a positive integer if an error occurs, and zero
            if no error occurs.

     s      Is the label of an executable statement.

     list   Is an I/O list.

            In the ENCODE statement, the "list" contains the data
            to be translated to character form.  In the DECODE
            statement, the "list" receives the data after
            translation to internal form.

            The interaction between the format specifier and the
            I/O list is the same as for a formatted I/O statement.

  3 - FIND

  The FIND statement positions a direct access file at a particular
  record and sets the associated variable of the file to that record
  number.  It is comparable to a direct access READ statement with no
  I/O list, and can open an existing file.  No data transfer takes
  place.  Statement format:

     FIND (u'r [,ERR=s] [,IOSTAT=ios])
     FIND ([UNIT=]u, REC=r [,ERR=s] [,IOSTAT=ios])

     u     Is a logical unit number.  It must refer to a
           relative organization file.

     r     Is the direct access record number.  It cannot
           be less than one or greater than the number of
           records defined for the file.

     s     Is the label of the executable statement that
           receives control if an error occurs.

     ios   Is an integer variable or integer array element
           that is defined as a positive integer if an error
           occurs, and as a zero if no error occurs.

  4 - NOF77_EXTERNAL

  If you specify the /NOF77 qualifier, you get an interpretation of
  the EXTERNAL statement that aids compatibility with older versions
  of Fortran.  (The ANSI FORTRAN-77 interpretation is incompatible
  with the previous standard and previous Compaq implementations.)

  The NOF77 interpretation combines the functionality of the
  INTRINSIC statement with that of the EXTERNAL statement discussed
  under the Help topic:  Statements EXTERNAL.

  The NOF77 EXTERNAL statement lets you use subprograms as arguments
  to other subprograms.  The subprograms to be used as arguments can
  be either user-supplied procedures or Fortran library functions.
  Statement format:

     EXTERNAL [*]v [,[*]v]...

     v  Is the symbolic name of a subprogram or the name of
        a dummy argument associated with the symbolic name
        of a subprogram.

     *  Specifies that a user-supplied function is to be used
        instead of a Fortran library function having the same
        name.

  The NOF77 EXTERNAL statement declares that each symbolic name in
  its list is an external procedure name.  Such a name can then be
  used as an actual argument to a subprogram, which in turn can use
  the corresponding dummy argument in a function reference or CALL
  statement.

  However, used as an argument, a complete function reference
  represents a value, not a subprogram name.

  5 - Octal Notation

  Octal forms of integer constants allow compatibility with PDP-11
  FORTRAN.  Statement format:

     "nn

     nn  Is a string of digits in the range 0 to 7 (for
         example "107).

  Integer constants in octal form have integer data type and are
  treated as integers.

  6 - PARAMETER

  This statement is similar to the one discussed in Help topic:
  Statements PARAMETER; they both assign a symbolic name to a
  constant.  However, this PARAMETER statement differs from the other
  one in the following two ways:  its list is not bounded with
  parentheses; and the form of the constant, rather than implicit or
  explicit typing of the symbolic name, determines the data type of
  the variable.  Statement format:

     PARAMETER p=c [,p=c]...

     p  Is a symbolic name.

     c  Is a constant, the symbolic name of a constant, or a
        compile-time constant expression.

  7 - VIRTUAL

  The VIRTUAL statement is included for compatibility with PDP-11
  FORTRAN.  It has the same form and effect as the DIMENSION
  statement (see Help Topic:  Statements DIMENSION).

  8 - Bit Constant Syntax

  In Compaq Fortran, you can use the following alternative syntax for
  binary, octal, and hexadecimal constants:

                  Alternative Syntax   Equivalent
                  ------------------   ----------
     Binary       B'0..1'              '0..1'B
     Octal        O'0..7'              '0..7'O
     Hexadecimal  X'0..F' or Z'0..F'   '0..F'X or '0..F'Z

  9 - Record Specifier Syntax

  In Compaq Fortran, you can specify the following form for a record
  specifier:

     'r

     r  Is a numeric expression with a value that represents
        the position of the record to be accessed using direct
        access I/O.  The value must be greater than or equal to 1,
        and less than or equal to the maximum number of records
        allowed in the file. If necessary, a record number is
        converted to integer data type before being used.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.