In Fortran, a pointer is an alias for another item of data (or a block in the form of an array, a section of an array, or a structure). It is not the address of the item but rather it is an alternative name for the item. This association between a pointer and what it is an alias for, can be changed under program control. As a result, pointers can be used to create structures such as linked lists and trees.
Declaring a pointer
A pointer is declared by giving it a type with the POINTER attribute. The data item for which it is an alias must also be given the TARGET attribute. For example:
Associating a pointer with a target
The combination "=>" is used to associate a pointer with a given item of data. For example:
makes AltX an alias for x and then assigns the value 1.0 to x.
The states of a pointer
A pointer is in one of three states:
It may be undefined. It has been declared but not associated with an item of data.
It may be null. This is a zero state obtained using NULLIFY or the intrinsic function NULL. It is used to explicitly state that the pointer is currently not an alias for any data item (e.g. a terminator for a linked list).
It may be associated. It is currently an alias for some target.
The intrinsic function ASSOCIATED may be used to determine the current state of a pointer.