DATA statement

Standard: (F77) (F90) F95 F2003 F2008 Example program


<Syntax>

DATA data-set [ , data-set> ]...

data-set ::= data-object-list / data-value-list /

data-object-list ::= data-object [ , data-object ]...
data-object ::= variable | data-implied-do
data-implied-do ::= ( data-object [ , data-object ]... , do-spec )

data-value-list ::= data-value [ , data-value ]...
data-value ::= [ data-repeat * ] data-constant
data-repeat ::= constant  |  constant-subobject

data-constant ::= literal-constant
| NULL ( )
| structure-constructor
| object
| signed-int-literal-constant
| signed-real-literal-constant

<Semantics>

Initialises the variables (data-objects) to the specified values (data-values). In most cases, it is recommended to initialise each variable in its type declaration statement instead.

Note that from Fortran 90 onwards, this statement implicitly confers the SAVE attribute on each variable.

From Fortran 95 onwards, a pointer can be initialised in a DATA statement to be disassociated, by using a data-constant that is a reference to the NULL intrinsic function.

Prior to Fortran 2008, the expressions in data-implied-do loop limits, and in subscript expressions for a data-object inside a data-implied-do loop, were not permitted to reference intrinsic functions even when the results were constant. From Fortran 2008, these expressions are normal constant expressions and so appropriate intrinsic functions can be referenced therein.

<Related>

NULL intrinsic function, PARAMETER statement, Type declaration statement