XL Fortran for AIX 8.1

Language Reference

POINTER (Fortran 90)

Purpose

The POINTER attribute designates objects as pointer variables.

The term pointer refers to objects with the Fortran 90 POINTER attribute. The integer POINTER statement provides details on what was documented in previous versions of XL Fortran as the POINTER statement; these pointers are now referred to as integer pointers.

Format



>>-POINTER--+----+---------------------------------------------->
            '-::-'
 
   .-,-----------------------------------------------.
   V                                                 |
>----object_name--+--------------------------------+-+---------><
                  '-(--deferred_shape_spec_list--)-'
 
 

deferred_shape_spec
is a colon (:), where each colon represents a dimension

Rules

object_name refers to a data object or function result. If object_name is declared elsewhere in the scoping unit with the DIMENSION attribute, the array specification must be a deferred_shape_spec_list.

object_name must not appear in an integer POINTER, NAMELIST, or EQUIVALENCE statement. If object_name is a component of a derived-type definition, any variables declared with that type cannot be specified in an EQUIVALENCE, DATA, or NAMELIST statement.

Pointer variables can appear in common blocks and block data program units.

+-------------------------------IBM Extension--------------------------------+

To ensure that Fortran 90 pointers are thread-specific, do not specify either the SAVE or STATIC attribute for the pointer. These attributes are either specified explicitly by the user, or implicitly through the use of the -qsave compiler option. Note, however, that if a non-static pointer is used in a pointer assignment statement where the target is static, all references to the pointer are, in fact, references to the static, shared target.

+----------------------------End of IBM Extension----------------------------+

An object having a component with the POINTER attribute can itself have the TARGET, INTENT, or ALLOCATABLE attibutes, although it cannot appear in a data transfer statement.

Attributes Compatible with the POINTER Attribute


  • AUTOMATIC
  • DIMENSION
  • INTENT

  • OPTIONAL
  • PRIVATE
  • PUBLIC

  • SAVE
  • STATIC
  • VOLATILE

These attributes apply only to the pointer itself, not to any associated targets, except for the DIMENSION attribute, which applies to associated targets.

Examples

Example1:

INTEGER, POINTER :: PTR(:)
INTEGER, TARGET :: TARG(5)
PTR => TARG                  ! PTR is associated with TARG and is
                             !   assigned an array specification of (5)
 
PTR(1) = 5                   ! TARG(1) has value of 5
PRINT *, FUNC()
CONTAINS
  REAL FUNCTION FUNC()
    POINTER :: FUNC          ! Function result is a pointer
 
       
  ·
  ·
  ·
END FUNCTION END

+-------------------------------IBM Extension--------------------------------+

Example 2: Fortran 90 pointers and threadsafing

FUNCTION MYFUNC(ARG)                ! MYPTR is thread-specific.
INTEGER, POINTER :: MYPTR           !  every thread that invokes
                                    !  'MYFUNC' will allocate a
ALLOCATE(MYPTR)                     !  new piece of storage that
MYPTR = ARG                         !  is only accessible within

  ·
  ·
  ·
! that thread. ANYVAR = MYPTR END FUNCTION

+----------------------------End of IBM Extension----------------------------+

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]