Next:
Scalarization of the Up: FORALL-ELSEFORALL Construct Previous: General Form of

## Interpretation of the FORALL Construct

Execution of a FORALL construct consists of the following steps:

1. Evaluation in any order of the subscript and stride expressions in the forall-triplet-spec-list. The set of valid combinations of index-name values is then the cartesian product of the sets defined by these triplets.
2. Evaluation of the scalar-mask-expr for all valid combinations of index-name values. The mask elements may be evaluated in any order. One set of active combinations of index-name values is the subset of the valid combinations for which the mask evaluates to true and a second one is the subset of the valid combinations for which the mask evaluates to false.
3. Execute forall-body-stmts in the order they appear for the set of the valid combination of index-name for which mask was evaluated to true in the step 2. Each statement is executed completely (that is, for all active combinations of index-name values) according to the following interpretation:
1. Assignment statements, pointer assignment statements, and array assignment statements (i.e. statements in the forall-assignment category) evaluate the right-hand side expr and any left-and side subscripts for all active index-name values, then assign those results to the corresponding left-hand side references.
2. FORALL statements and FORALL constructs first evaluate the subscript and stride expressions in the forall-triplet-spec-list for all active combinations of the outer FORALL constructs. The set of valid combinations of index-names for the inner FORALL is then the union of the sets defined by these bounds and strides for each active combination of the outer index-names. The scalar mask expression is then evaluated for all valid combinations of the inner FORALL's index-names to produce the set(s) of active combinations, as in step 2. If there is no scalar mask expression, it is assumed to be always true. Each statement in the inner FORALL is then executed for each valid combination (of the inner FORALL), recursively following the interpretations given in this section.
4. Execute elseforall-body-stmts for the set of active index-name for which the mask was evaluated to false in the step 2, the same way as in 3.

If the scalar mask expression is omitted, it is as if it were present with the value true. In that case ELSEFORALL statement is not allowed.

A single assignment or array assignment statement in a forall-construct must obey the same restrictions as a forall-assignment in a simple forall-stmt. (Note that the lowest level of nested statements must always be an assignment statement.) For example, an assignment may not cause the same array element to be assigned more than once. Different statements may, however, assign to the same array element, and assignments made in one statement may affect the execution of a later statement.

Next:
Scalarization of the Up: FORALL-ELSEFORALL Construct Previous: General Form of

paula@erc.msstate.edu
Thu May 5 15:11:02 CDT 1994