HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
DATA
Chapter 10314
Procedure names
val-list
is a list of constant values, separated by commas. Each constant in the list
represents a value to be assigned to the corresponding variable in
var-list
.
A constant value can be optionally repeated by preceding the constant with
a repetition factor. The syntax of a repeated constant is:
r
*
val
where
r
is a positive integer specifying the number of times that
val
, the
constant value, is to be specified.
Description
The DATA statement initializes variables local to a program unit before the program unit
begins execution. Initialization occurs as follows:
The var-list is expanded to form a sequence of scalar variables, and the val-list is expanded to
form a sequence of scalar constants. The number of items in each expanded sequence must be
the same, and there must be a one-to-one correspondence between the items in the two
expanded lists. The variables in the expanded sequence of var-list are initialized on the basis
of the correspondence.
If
var-list
contains an array name, the expanded sequence of constants must contain a
constant for every element in the array.
A zero-sized array or an implied-DO list with an iteration count of zero in
var-list
contributes no variables to the expanded sequence of variables. However, a zero-length
character variable does contribute a variable to the list.
If a constant is of any numeric or logical type, the corresponding variable can be of any
numeric type. If an object is of derived type, the corresponding constant must be of the same
type. If the type of the constant does not agree with the type of the variable, type conversion is
performed, as described in Table 4-5.
Variables can be initialized with binary, octal, or hexadecimal constants.
A variable or array element must not appear in a DATA statement more than once. If two
variables share the same storage space through an EQUIVALENCE statement, only one can
appear in a DATA statement. If a substring of a character variable or other array element
appears in a DATA statement, no overlapping substring (including the entire variable or array
element) can appear in any DATA statement.
The length of a character constant and the declared length of its corresponding character
variable need not be the same. If the constant is shorter than the variable, blank characters
are placed in the remaining positions. If the constant is longer than the variable, the constant
is truncated from the right until it is the same length as the variable