What is pointer ?

What are Pointers?
Pointer is a type of variable which stores other variables called
A pointer is a new type of variable which may reference the data stored by other variables (called targets) or areas of dynamically allocated memory. Pointers have been included in Fortran 90, but not in the usual way as in most other languages, with pointer as a specific data type.
Pointers provide:
A flexible alternative to allocatable arrays.
The tools to create and manipulate dynamic data structures.
Pointers and targets:
It is useful to have variables where the space referenced by the variable can be changed as well as the values stored in that space.
The pointer often uses less space than the target.
reference to the pointer will in general be a reference to the target.
A POINTER is a variable declared with the POINTER attribute.
        REAL, POINTER :: P
        REAL, DIMENSION(:,:), POINTER :: Pt
The first declaration specifies that the name P is a pointer to a scalar REAL target; the second specifies that Pt is a pointer to a rank 2 array of reals. Pointers cannot point to literals.
From the above statements we have:
the declaration fixes the type, kind and rank of any possible target.
pointers to arrays are always declared with deferred-shape array specifications.
the rank of a target is fixed but the shape may vary.
Scroll to Top