In Fortran, a pointer is an alias. The variable it aliases is its target. Pointer variables must have the POINTER attribute; target variables must have either the TARGET attribute or the POINTER attribute. In Fortran 95, pointer variables are strongly typed, and a pointer can only be associated with a target having the same type and kind.
A pointer can only be associated with a variable that has the TARGET attribute or the POINTER attribute. Such an association can be made in one of two ways:
Once an association between pointer and target has been made, any reference to the pointer applies to the target.
A variable can be declared to have the POINTER or TARGET attribute in a type declaration statement or in a POINTER or TARGET statement. When declaring an array to be a pointer, you must declare the array with a deferred shape.
Example:integer, pointer :: a, b(:,:) integer, target :: c a => c ! pointer assignment statement ! a is an alias for c allocate (b(3,2)) ! allocate statement ! an unnamed target for b is ! created with the shape (3,2)
In this example, an explicit association is created between a and c through the pointer assignment statement. Note that a has been previously declared a pointer, c has been previously declared a target, and a and c agree in type, kind, and rank. In the ALLOCATE statement, a target array is allocated and b is made to point to it. The array b was declared with a deferred shape, so that the target array could be allocated with any rank two shape.