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> 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.ExampleREAL 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 a dynamically! allocated memory areaRestrictions<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 thevariables in the dimension declarator(s) are defined with an integer value at the timethe SUBROUTINE or FUNCTION is called. For a variable which appears in a pointerbasedvariable's adjustable declarator, modifying its value during the execution of theSUBROUTINE or FUNCTION does not modify the bounds of the dimensions of the pointerbasedarray.‣ A pointer-based variable is assumed not to overlap with another pointer-based variable.3.16. PROTECTED<strong>The</strong> PROTECTED statement protects a module variable against modification from outside themodule in which it was declared.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 54

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

Saved successfully!

Ooh no, something went wrong!