VMS Help  —  FORTRAN  Statements  Type declaration
  Explicitly specifies the properties of data objects or functions.

  Type declarations must precede all executable statements, can be
  declared only once, and cannot be used to change the type of a
  symbolic name that has already been implicitly assumed to be
  another type.

  Type declaration statements can initialize data in the same way as
  the DATA statement:  by having values, bounded by slashes, listed
  immediately after the symbolic name of the entity.

1  –  Numeric

  Statement format:

     type[*n] [[,att]...::] v [*n][/clist/][,v [*n][/clist/]]...

     type   Is any of the following data type specifiers:

            BYTE (equivalent to INTEGER*1)  DOUBLE PRECISION
            LOGICAL                         COMPLEX
            INTEGER                         DOUBLE COMPLEX
            REAL

     n      Is an integer that specifies (in bytes) the length
            of "v".  It overrides the length that is implied by
            the data type.

            The value of n must specify an acceptable length
            for the type of "v" (see the HP Fortran for OpenVMS
            Language Reference Manual).  BYTE, DOUBLE PRECISION,
            and DOUBLE COMPLEX data types have one acceptable
            length; thus, for these data types, the "n" specifier
            is invalid.

            If an array declarator is used, the "n" specifier
            must be positioned immediately after the array name.

     att    Is one of the following attribute specifiers:

            ALLOCATABLE       POINTER
            AUTOMATIC         PRIVATE
            DIMENSION         PUBLIC
            EXTERNAL          SAVE
            INTENT            STATIC
            INTRINSIC         TARGET
            OPTIONAL          VOLATILE
            PARAMETER

     v      Is the name of a data object or function.  It can
            optionally be followed by:

            o An array specification, if the object is an array
            o A character length, if the object is of type
              character
            o An initialization expression or, for pointer
              objects, =>NULL()

     clist  Is a list of constants, as in a DATA statement.  If
            "v" is the symbolic name of a constant, the "clist"
            cannot be present.

  A numeric data type declaration statement can define arrays by
  including array specifications in the list.

  A numeric type declaration statement can assign initial values to
  variables or arrays if it specifies a list of constants (the
  "clist").  The specified constants initialize only the variable or
  array that immediately precedes them.  The "clist" cannot have more
  than one item unless it initializes an array.  When the "clist"
  initializes an array, it must contain a value for every element in
  the array.

  If =>NULL() appears for a pointer, the pointer's initial
  association status is disassociated.

  In a function declaration, an array must be a deferred-shape array
  if it has the POINTER attribute; otherwise, it must be an
  explicit-shape array.

  The double colon separator (::) is required only if the declaration
  contains an attribute specifier or an initialization expression;
  otherwise it is optional.

  The same attribute must not appear more than once in a given type
  declaration statement, and an entity cannot be given the same
  attribute more than once in a scoping unit.

  If the PARAMETER attribute is specified, the declaration must
  contain an initialization expression.

  The following objects cannot be initialized in a type declaration
  statement:

   o  A dummy argument

   o  A function result

   o  An object in a named common block (unless the type declaration
      is in a block data program unit)

   o  An object in blank common

   o  An allocatable array

   o  A pointer

   o  An external name

   o  An intrinsic name

   o  An automatic object

   o  An object that has the AUTOMATIC attribute

2  –  Character

  Format:

     CHARACTER[*len[,] [[,att]...::] v[*len] [/clist/]
                                     [,v[*len] [/clist/]]...

     len    Is an unsigned integer constant, an integer constant
            expression enclosed in parentheses, or an asterisk (*)
            enclosed in parentheses.  The value of "len" specifies
            the length of the character data elements.

     att    Is one of the following attribute specifiers:

            ALLOCATABLE       POINTER
            AUTOMATIC         PRIVATE
            DIMENSION         PUBLIC
            EXTERNAL          SAVE
            INTENT            STATIC
            INTRINSIC         TARGET
            OPTIONAL          VOLATILE
            PARAMETER

     v      Is the symbolic name of a constant, variable, array,
            statement function or function subprogram, or array
            specification. The name can optionally be followed by
            a data type length specifier (*len or *(*)).

     clist  Is a list of constants, as in a DATA statement.  If
            "v" is the symbolic name of a constant, "clist" must
            not be present.

  If you use CHARACTER*len, "len" is the default length specification
  for that list.  If an item in that list does not have a length
  specification, the item's length is "len".  However, if an item
  does have a length specification, it overrides the default length
  specified in CHARACTER*len.

  When an asterisk length specification *(*) is used for a function
  name or dummy argument, it assumes the length of the corresponding
  function reference or actual argument.  Similarly, when an asterisk
  length specification is used for the symbolic name of a constant,
  the name assumes the length of the actual constant it represents.
  For example, STRING assumes a 9-byte length in the following
  statements:

     CHARACTER*(*) STRING
     PARAMETER (STRING = 'VALUE IS:')

  The length specification must range from 1 to 65535.  If no length
  is specified, a length of 1 is assumed.

  Character type declaration statements can define arrays if they
  include array specifications in their list.  The array
  specification goes first if both an array specification and a
  length are specified.

  A character type declaration statement can assign initial values to
  variables or arrays if it specifies a list of constants (the
  clist).  The specified constants initialize only the variable or
  array that immediately precedes them.  The "clist" cannot have more
  than one element unless it initializes an array.  When the "clist"
  initializes an array, it must contain a value for every element in
  the array.

  In a function declaration, an array must be a deferred-shape array
  if it has the POINTER attribute; otherwise, it must be an
  explicit-shape array.

  The double colon separator (::) is required only if the declaration
  contains an attribute specifier or an initialization expression;
  otherwise it is optional.

  The same attribute must not appear more than once in a given type
  declaration statement, and an entity cannot be given the same
  attribute more than once in a scoping unit.

  If the PARAMETER attribute is specified, the declaration must
  contain an initialization expression.

  The following objects cannot be initialized in a type declaration
  statement:

   o  A dummy argument

   o  A function result

   o  An object in a named common block (unless the type declaration
      is in a block data program unit)

   o  An object in blank common

   o  An allocatable array

   o  A pointer

   o  An external name

   o  An intrinsic name

   o  An automatic object

   o  An object that has the AUTOMATIC attribute

                                 NOTE

          The CHARACTER*len form for a CHARACTER  declaration
          is obsolescent in Fortran 95.  VSI Fortran flags
          obsolescent features, but fully supports them.
Close Help