HP Fortran Programmer's Reference (September 2007)

I/O and file handling
Syntax of I/O statements
Chapter 8224
The implied-DO loop is generally used to transmit arrays and array elements, as in the
following:
INTEGER :: b(10)
PRINT *, (b(i), i = 1,10)
If b has been initialized with the values 1 through 10 in order, the PRINT statement will
produce the following output:
1 2 3 4 5 6 7 8 9 10
If an nonsubscripted array name occurs in the list, the entire array is transmitted at each
iteration. For example:
REAL :: x(3)
PRINT *, (x, i=1, 2)
If x has been initialized to be [ 1 2 3 ], the output will be:
1.0 2.0 3.0 1.0 2.0 3.0
The list can contain expressions that use the index value. For example:
REAL :: x(10) = (/.1, .2, .3, .4, .5, .6, .7, .8, .9, 1 /)
PRINT *, (i*2, x(i*2), i = 1, 5)
print the numbers
2 .2 4 .4 6 .6 8 .8 10 1
Implied-DO loops can also be nested. The form of a nested implied-DO loop in an I/O statement
is:
(((
list
,
index1
=
init1
,
limit1
,
step1
),
index2
=
init2
,
limit2
,
step2
) ...
indexN
=
initN
,
limitN
,
stepN
)
Nested implied-DO loops follow the same rules as do other nested DO loops. For example, given
the following statements:
REAL :: a(2,2)
a(1,1) = 1
a(2,1) = 2
a(1,2) = 3
a(2,2) = 4
WRITE(6,*)((a(i,j),i=1,2),j=1,2)
the output will be:
1.0 2.0 3.0 4.0
The first, or nested DO loop, is completed once for each execution of the outer loop.