next up previous contents
Next: NEW Variables Up: Visualization of INDEPENDENT Directives Previous: Visualization of INDEPENDENT Directives


DO i = 2, 99
  A(I) = B(I-1) + B(I) + B(I+1)

This is one of the simplest examples of an INDEPENDENT loop. (For simplicity, all examples in this section assume there is no storage or sequence association between any variables used in the code.) Every iteration assigns to a different location in the A array, thus satisfying the first condition above. Since no elements of A are used on the right-hand side, no location that is assigned in the loop is also read, thus satisfying the second condition. Note, however, that many elements of B are used repeatedly; this is allowed by the definition of INDEPENDENT. This loop is INDEPENDENT regardless of the values of the variables involved.

FORALL ( I=2:N ) A(I) = B(I-1) + B(I) + B(I+1)

This example is equivalent in all respects to the first example.

DO I=1, 100
  A(P(I)) = B(I)

This INDEPENDENT directive asserts that the array P does not have any repeated entries (else they would cause interference when A was assigned). The DO loop is therefore equivalent to the Fortran statement

A(P(1:100)) = B(1:100)