VMS Help  —  FORTRAN  Compatibility Features, HP Fortran POINTER
  This POINTER statement (formerly the Compaq Fortran POINTER
  statement) is different from the Fortran 95/90 POINTER statement.
  This POINTER statement establishes pairs of variables and pointers,
  in which each pointer contains the address of its paired variable.
  Statement format:

     POINTER ((pointer,pointee) [,(pointer,pointee)]...

     pointer  Is a variable whose value is used as the
              address of the pointee.

     pointee  Is a variable, array, array declarator, record
              structure, record array, or record array
              specification.

  The following are rules and behavior for the "pointer" argument:

   o  Two pointers can have the same value, so pointer aliasing is
      allowed.

   o  When used directly, a pointer is treated like an integer
      variable.  A pointer occupies two numeric storage units, so it
      is a 64-bit quantity (INTEGER*8).

   o  A pointer cannot be a pointee.

   o  A pointer cannot appear in an ASSIGN statement and cannot have
      the following attributes:

         ALLOCATABLE  PARAMETER
         EXTERNAL     POINTER
         INTRINSIC    TARGET

      A pointer can appear in a DATA statement with integer literals
      only.

   o  Integers can be converted to pointers, so you can point to
      absolute memory locations.

   o  A pointer variable cannot be declared to have any other data
      type.

   o  A pointer cannot be a function return value.

   o  You can give values to pointers by doing the following:

       -  Retrieve addresses by using the LOC intrinsic function (or
          %LOC built-in function)

       -  Allocate storage for an object by using the MALLOC
          intrinsic function or LIB$GET_VM

          For example:

             Using %LOC:                   Using MALLOC:

             integer i(10)                 integer i(10)
             integer i1 (10) /10*10/       pointer (p,i)
             pointer (p,i)                 p = malloc (40)
             p = %loc (i1)                 i(2) = i(2) + 1
             i(2) = i(2) + 1

             Using LIB$GET_VM:

             INTEGER I(10)
             INTEGER LIB$GET_VM, STATUS
             POINTER (P,I)
             STATUS = LIB$GET_VM(P,40)
             IF (.NOT. STATUS) CALL EXIT(STATUS)
             I(2) = I(2) + 1

          The value in a pointer is used as the pointee's base
          address.

  The following are rules and behavior for the "pointee" argument:

   o  A pointee is not allocated any storage.  References to a
      pointee look to the current contents of its associated pointer
      to find the pointee's base address.

   o  A pointee can appear in only one POINTER statement.

   o  A pointee array can have fixed, adjustable, or assumed
      dimensions.

   o  A pointee cannot appear in a COMMON, DATA, EQUIVALENCE, or
      NAMELIST statement and cannot have the following attributes:

         ALLOCATABLE    POINTER
         AUTOMATIC      SAVE
         INTENT         STATIC
         OPTIONAL       TARGET
         PARAMETER

   o  A pointee cannot be a dummy argument.

   o  A pointee cannot be a function return value.

   o  A pointee cannot be a record field or an array element.

   o  A pointee cannot be zero-sized.

   o  A pointee cannot be an automatic object.

   o  A pointee cannot be the name of a generic interface block.

   o  If a pointee is of derived type, it must be of sequence type.
Close Help