Fortran Programming Guide

STOREBACK(varlist)

A STOREBACK variable or array is one whose value is computed in a DOALL loop. The computed value can be used after the termination of the loop. In other words, the last loop iteration values of storeback scalars and arrays may be visible outside of the DOALL loop.

Example: Specify the loop index variable as storeback:


C$PAR DOALL PRIVATE(x), STOREBACK(x,i)
      do i = 1, n
        x = ...
      end do
      ... = i
      ... = x

In the preceding example, both the variables x and i are STOREBACK variables, even though both variables are private to the i loop.

There are some potential problems for STOREBACK, however.

The STOREBACK operation occurs at the last iteration of the explicitly parallelized loop, even if this is the same iteration that last updates the value of the STOREBACK variable or array.

Example: STOREBACK variable potentially different from the serial version:


C$PAR DOALL PRIVATE(x), STOREBACK(x)
      do i = 1, n
        if (...) then
            x = ...
        end if
      end do
      print *,x

In the preceding example, the value of the STOREBACK variable x that is printed out might not be the same as that printed out by a serial version of the i loop. In the explicitly parallelized case, the processor that processes the last iteration of the i loop (when i = n) and performs the STOREBACK operation for x, might not be the same processor that currently contains the last updated value of x. The compiler issues a warning message about these potential problems.

In an explicitly parallelized loop, arrays are not treated by default as STOREBACK, so include them in the list varlist if such a storeback operation is desired--for example, if the arrays have been declared as private.