In a data transfer statement, an implied-do list acts as though it were a part of an I/O statement within a DO loop. It takes the following form:
The implied-do loop is initiated, executed, and terminated in the same way as a DO construct.
The list is the range of the implied-do loop. Items in that list can refer to do-var, but they must not change the value of do-var.
Two nested implied-do lists must not have the same (or an associated) DO variable.
Use an implied-do list to do the following:
If the I/O statement containing an implied-do list terminates abnormally (with an END, EOR, or ERR branch or with an IOSTAT value other than zero), the DO variable becomes undefined.
The following two output statements are equivalent:
The following example shows nested implied-do lists. Execution of the innermost list is repeated most often:
WRITE (3,200) (A,B,C, I=1,3) ! An implied-do list WRITE (3,200) A,B,C,A,B,C,A,B,C ! A simple item list
The inner DO loop is executed 10 times for each iteration of the outer loop; the second subscript (L) advances from 1 through 10 for each increment of the first subscript (K). This is the reverse of the normal array element order. Note that K is incremented by 2, so only the odd-numbered rows of the array are output.
WRITE (6,150) ((FORM(K,L), L=1,10), K=1,10,2)
In the following example, the entire list of the implied-do list (P(1), Q(1,1), Q(1,2)...,Q(1,10)) are read before I is incremented to 2:
The following example uses fixed subscripts and subscripts that vary according to the implied-do list:
READ (5,999) (P(I), (Q(I,J), J=1,10), I=1,5)
Input values are assigned to BOX(1,1) through BOX(1,10), but other elements of the array are not affected.
READ (3,5555) (BOX(1,J), J=1,10)
The following example shows how a DO variable can be output directly:
Integers 1 through 20 are written.
WRITE (6,1111) (I, I=1,20)
For More Information: