10.07.2015 Views

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Fortran</strong> Data Typesp1 and p2are the pointer variables corresponding to v1 and v2. A pointer variable may not be an array.<strong>The</strong> pointer is an integer variable containing the address of a pointer-based variable. <strong>The</strong>storage located by the pointer variable is defined by the pointer-based variable (for example,array, data type, etc.). A reference to a pointer-based variable appears in <strong>Fortran</strong> statementslike a normal variable reference (for example, a local variable, a COMMON block variable,or a dummy variable). When the based variable is referenced, the address to which it refers isalways taken from its associated pointer (that is, its pointer variable is dereferenced).<strong>The</strong> pointer-based variable does not have an address until its corresponding pointer is defined.<strong>The</strong> pointer is defined in one of the following ways:‣ By assigning the value of the LOC function.‣ By assigning a value defined in terms of another pointer variable.‣ By dynamically allocating a memory area for the based variable. If a pointer-based variableis dynamically allocated, it may also be freed.<strong>The</strong> following code illustrates the use of pointers:REAL XC(10)COMMON IC, XCPOINTER (P, I)POINTER (Q, X(5))P = LOC(IC)I = 0 ! IC gets 0P = LOC(XC)Q = P + 20 ! same as LOC(XC(6))X(1) = 0 ! XC(6) gets 0ALLOCATE (X) ! Q locates an allocated memory area2.11.1. Restrictions<strong>The</strong> following restrictions apply to the POINTER statement:‣ No storage is allocated when a pointer-based variable is declared.‣ If a pointer-based variable is referenced, its pointer variable is assumed to be defined.‣ A pointer-based variable may not appear in the argument list of a SUBROUTINE orFUNCTION and may not appear in COMMON, EQUIVALENCE, DATA, NAMELIST, orSAVE statements.‣ A pointer-based variable can be adjusted only in a SUBROUTINE or FUNCTIONsubprogram.If a pointer-based variable is an adjustable array, it is assumed that the variables in thedimension declarators are defined with an integer value at the time the SUBROUTINE orFUNCTION is called.For a variable which appears in a pointer-based variable's adjustable declarator, modifyingits value during the execution of the SUBROUTINE or FUNCTION does not modify thebounds of the dimensions of the pointer-based array.‣ A pointer-based variable is assumed not to overlap with another pointer-based variable.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!