next up previous

4.1 Array Operations     continued...

The index-variable is a scalar integer variable serving as an iterative index in exactly the same manner as implied-do loops in Fortran 77 I/O statements. One simple application of an implied-do in an array constructor is to generate any iota sequence. For example, the array constructor
     (/(k, k=1,n)/)
generates the vector whose element values are 1,2,3,4,5,n; if n is 4 the result is identical to (/1,2,3,4/). As another example, a vector of a million alternating ones and zeros,
     (/1,0,1,0,1,0,1,$\ldots$/), can be specified with (/ (1,0, j=1,500000) /).

The implied-do simply replicates the list the specified number of times, and if the index-variable is an operand in an expression in the expression-list, each replication of that item uses the corresponding value of the index-variable. The items in the implied-do expression-list may be any of the three forms allowed in the array constructor itself-scalar expressions, implied-do constructs, and array expressions. The two examples above used only simple scalar expressions in the implied-do lists.