HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
DATA
Chapter 10 315
If a subscripted array element appears in
var-list
, then the subscript must be a
specification expression.
DATA statements can be interspersed among executable statements. However, they initialize
prior to runtime and, therefore, cannot be used as executable assignment statements.
Fortran 90 extensions
A variable of type other than integer may be initialized with a binary, octal, or hexadecimal
constant. The data type for a constant is determined from the type of the corresponding
variable. The size (in bytes) of the variable determines how many digits of the octal or
hexadecimal constant are used. If the constant lacks enough digits, the value is padded on the
left with zeros. If the constant has too many digits, it is truncated on the left.
An integer, binary, octal, or hexadecimal constant can initialize a character variable of length
one, as long as the value of the constant is in the range 0 to 255.
Examples
The following DATA statement initializes integer, logical, and character variables:
INTEGER i
LOGICAL done
CHARACTER(LEN=5) prompt
DATA i, done, prompt/10, .FALSE., 'Next?'/
The next DATA statement specifies a repetition factor of 3 to assign the value of 2 to all three
elements of array i:
INTEGER, DIMENSION(3) :: i
DATA i/3*2/
The next DATA statement uses two nested implied-DO loops to assign the literal value X to each
element of an array of 50 elements, k(10,5):
CHARACTER, DIMENSION(10,5) :: k
DATA ((k(i,j),i=1,10),j=1,5)/50*'X'/
Related statements
BYTE, CHARACTER, COMPLEX, DOUBLE COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and
REAL
Related concepts
For related information, see the following:
“Initialization expressions” on page 93
Assignment statement” on page 97