FORTRAN Reference Manual

Introduction to File I/O in the HP NonStop
Environment
FORTRAN Reference Manual528615-001
5-27
Using Implied DO Lists
Using Implied DO Lists
An implied DO list has the following form:
( [(]... ar-nam1( var1 [, var2 ]... )
[, ar-nam2( var1 [, var2 ]... ) ]... ,
var1 = iexp1, fexp1°[, incr1 ] )
[, var2 = iexp2, fexp2°[, incr2°] ) ]...
ar-name
is the name of an array.
var
is an integer, real, or double precision control variable. It must be a simple variable,
not an array element or a RECORD component.
iexp
is an expression that specifies the initial value of each var.
fexp
is an expression that specifies the final value of each var.
incr
is an expression that specifies the increment value of each var. The default value
for incr is 1.
You can specify a DO list both in DATA statements and in data transfer statements.
The following example uses an implied DO list to initialize the array INVENTORY to 0:
DATA (inventory(i), i = 1, 25) / 25 * 0 /
You can use an implied DO list to initialize partial arrays. For example, the following
DATA statement initializes the first 10 elements and the last 10 elements of the array
PAY(30) to 0:
INTEGER pay(30)
DATA (pay(k), k = 1,10), (pay(k), k = 21,30) /20 * 0/
You can read the elements of multidimensional arrays using an implied DO list. For
example, the following READ statement reads all elements of the two-dimensional
array A:
INTEGER a(2, 4)
READ(10,100) ((a(i,j), i = 1,2), j = 1,4)