24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

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.

<strong>FORTRAN</strong> Statements<br />

Example:<br />

CHARACTER*30 MSG<br />

LOGICAL TRUE<br />

REAL X, Y(10)<br />

DATA X/1.0/, TRUE/.TRUE./, MSG/’ENTER DATA’/<br />

DATA Y/10*5/<br />

An implied-DO list in a DATA statement has the following form:<br />

where:<br />

( dlist, i = m1, m2[, m3] )<br />

dlist<br />

i<br />

m1,m2,m3<br />

is a list of array element names and implied-DO lists.<br />

is the name of an integer variable called the implied-DO-variable.<br />

are each integer constant expressions. The expressions may contain<br />

implied-DO-variables of other implied-DO lists that have this implied-DO list in their<br />

ranges.<br />

The range of the implied-DO list is the list dlist. An iteration count and the value of the<br />

implied-DO-variable are computed from m1,m2 and m3 in the same way as for a DO-loop except that the<br />

iteration count must be positive. An implied-DO-variable does not affect the definition of a variable by the<br />

same name in the same program unit. An implied-DO list is processed as follows. Each item in the<br />

implied-DO list is processed once for each iteration with the appropriate substitution of values for any<br />

occurrence of the implied-DO-variable. The following example initializes the upper right triangle of the<br />

array A.<br />

Example:<br />

DIMENSION A(5,5)<br />

DATA ((A(I,J),J=1,I),I=1,5)/15*0/<br />

Dummy arguments, functions, and entities in blank common are not allowed in nlist. Entities in a<br />

named common block can be initialized only within a block data subprogram.<br />

The following extensions to data initialization are supported by <strong>Open</strong> <strong>Watcom</strong> <strong>FORTRAN</strong> <strong>77</strong>.<br />

1. Character constants can initialize a variable of any type. If the item in nlist is of numeric<br />

type and is being initialized with character data, the size of the item in nlist is the maximum<br />

number of characters that can be stored in the space allocated for that item. The rules for<br />

initializing such items, are the same as for items of type character. See the chapter entitled<br />

"Names, Data Types and Constants" on page 151 for the number of bytes required for a<br />

particular data type.<br />

Example:<br />

INTEGER I,J<br />

DATA I/’AA’/,J/’123456’/<br />

In the previous example, I and J each occupy 4 character storage units. I will be initialized<br />

with the characters AA followed by 2 blank characters. J will be initialized with the characters<br />

1234. Note the the character constant initializing J is truncated on the right to the number of<br />

character storage units occupied by J.<br />

DATA Statement 39

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

Saved successfully!

Ooh no, something went wrong!