02.07.2014 Views

Intel(R) Fortran Language Reference (online version)

Intel(R) Fortran Language Reference (online version)

Intel(R) Fortran Language Reference (online version)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5 <strong>Intel</strong> <strong>Fortran</strong> <strong>Language</strong> <strong>Reference</strong><br />

— When a binary, octal, or hexadecimal constant is assigned to a variable or array element,<br />

the number of digits that can be assigned depends on the data type of the data item. If the<br />

constant contains fewer digits than the capacity of the variable or array element, the<br />

constant is extended on the left with zeros. If the constant contains more digits than can<br />

be stored, the constant is truncated on the left.<br />

• If the constant and the variable are both of character type, the following con<strong>version</strong> occurs:<br />

— If the length of the constant is less than the length of the variable, the rightmost character<br />

positions of the variable are initialized with blank characters.<br />

— If the length of the constant is greater than the length of the variable, the character<br />

constant is truncated on the right.<br />

• If the constant is of numeric type and the variable is of character type, the following<br />

restrictions apply:<br />

— The character variable must have a length of one character.<br />

— The constant must be an integer, binary, octal, or hexadecimal constant, and must have a<br />

value in the range 0 through 255.<br />

When the constant and variable conform to these restrictions, the variable is initialized with<br />

the character that has the ASCII code specified by the constant. (This lets you initialize a<br />

character object to any 8-bit ASCII code.)<br />

If the constant is a Hollerith or character constant, and the variable is a numeric variable or<br />

numeric array element, the number of characters that can be assigned depends on the data<br />

type of the data item.<br />

If the Hollerith or character constant contains fewer characters than the capacity of the<br />

variable or array element, the constant is extended on the right with blank characters. If the<br />

constant contains more characters than can be stored, the constant is truncated on the right.<br />

Examples<br />

The following example shows the three ways that DATA statements can initialize array element<br />

values:<br />

DIMENSION A(10,10)<br />

DATA A/100*1.0/ ! initialization by name<br />

DATA A(1,1), A(10,1), A(3,3) /2*2.5, 2.0/ ! initialization by element<br />

DATA ((A(I,J), I=1,5,2), J=1,5) /15*1.0/ ! initialization by implied-DO list<br />

The following example shows DATA statements containing structure components:<br />

TYPE EMPLOYEE<br />

INTEGER ID<br />

CHARACTER(LEN=40) NAME<br />

END TYPE EMPLOYEE<br />

5-26

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

Saved successfully!

Ooh no, something went wrong!