next up previous

4.2 Array Sections     continued...

The implied-do form is more extensible and, for large sections, considerable more compact than explicit lists. Implied-do constructs are also useful for regularly-spaced but noncontiguous vector subscripts. For example,

Q((/(k,k=1,5,2)/),2) = Q((/1,3,5/),2) = (/11,45,56/)
The implied-do form is common enough that a more readable shorthand notation, called a ``triplet subscript", is also provided for the indexed-do control triplet.

A triplet subscript is just the indexed-do control values, separated by colons rather than commas, with the last one (the increment or stride value) optional. Thus using triplet notation the above four examples may be written (much more clearly!) as:

A further simplification is provided in that if the initial triplet value is omitted the lower bound of that dimension is assumed, and if the second triplet value is omitted the upper bound of that dimension is assumed. Thus the most compact way of expressing these four sections is:

The form Q(:,:) is a section that is in fact the entire array , which explains an example early in this section. (Note that Q(:,:) also has the form of an assumed-shape dummy argument declaration; there is no ambiguity, however, because if this notation appears in an array expression it always represents an array section.)