Variables of a given type should be declared in type declaration statements at the start of a program unit. A simplified syntax follows,
< type > [,
< attribute-list >]:
:
< variable-list > [ =< value > ]
The :
:
is actually optional, however, it does no harm to use it,
moreover,
if < attribute-list > or =< value > are present then the :
:
is obligatory.
The following are all valid declarations,
REAL :: x INTEGER :: i,j LOGICAL, POINTER :: ptr REAL, DIMENSION(10,10) :: y, z(10) DOUBLE PRECISION, DIMENSION(0:9,0:9) :: w
The DIMENSION attribute declares a array, this can be overridden as with z which is declared as a 1D array with 10 elements.
< attribute-list > represents a list of attributes such as PARAMETER, SAVE, INTENT, POINTER, TARGET, DIMENSION, (for arrays) or visibility attributes. An object may be given more than one attribute per declaration but some cannot be mixed (such as PARAMETER and POINTER).
Return to corresponding overview page