02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If a subscripted array element appears in var-list, then the subscript must be a<br />

specification expression.<br />

<strong>HP</strong> <strong>Fortran</strong> statements<br />

DATA<br />

DATA statements can be interspersed among executable statements. However, they initialize<br />

prior to runtime and, therefore, cannot be used as executable assignment statements.<br />

<strong>Fortran</strong> 90 extensions<br />

A variable of type other than integer may be initialized with a binary, octal, or hexadecimal<br />

constant. The data type for a constant is determined from the type of the corresponding<br />

variable. The size (in bytes) of the variable determines how many digits of the octal or<br />

hexadecimal constant are used. If the constant lacks enough digits, the value is padded on the<br />

left with zeros. If the constant has too many digits, it is truncated on the left.<br />

An integer, binary, octal, or hexadecimal constant can initialize a character variable of length<br />

one, as long as the value of the constant is in the range 0 to 255.<br />

Examples<br />

The following DATA statement initializes integer, logical, and character variables:<br />

INTEGER i<br />

LOGICAL done<br />

CHARACTER(LEN=5) prompt<br />

DATA i, done, prompt/10, .FALSE., 'Next?'/<br />

The next DATA statement specifies a repetition factor of 3 to assign the value of 2 to all three<br />

elements of array i:<br />

INTEGER, DIMENSION(3) :: i<br />

DATA i/3*2/<br />

The next DATA statement uses two nested implied-DO loops to assign the literal value X to each<br />

element of an array of 50 elements, k(10,5):<br />

CHARACTER, DIMENSION(10,5) :: k<br />

DATA ((k(i,j),i=1,10),j=1,5)/50*'X'/<br />

Related statements<br />

BYTE, CHARACTER, COMPLEX, DOUBLE COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and<br />

REAL<br />

Related concepts<br />

For related information, see the following:<br />

“Initialization expressions” on page 91<br />

“Assignment statement” on page 95<br />

Chapter 10 281

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!