FORALL construct

The FORALL construct performs assignment to groups of subobjects, especially array elements.

Unlike the WHERE construct, FORALL performs assignment to array elements, array sections, and substrings. Also, each assignment within a FORALL construct need not be conformable with the previous one. The FORALL construct can contain nested FORALL statements, FORALL constructs, WHERE statements, and WHERE constructs.

-qxlf2003=autorealloc does not apply to FORALL constructs. No reallocation of allocatable variables occurs during assignment statements inside a FORALL construct.

IBM extension begins The INDEPENDENT directive specifies that the left and right sides of the assignments inside a FORALL construct do not overlap. IBM extension ends

Read syntax diagramSkip visual syntax diagram
>>-FORALL_construct_statement----------------------------------><

Read syntax diagramSkip visual syntax diagram
>>-forall_body-------------------------------------------------><

Read syntax diagramSkip visual syntax diagram
>>-END_FORALL_statement----------------------------------------><

FORALL_construct_statement
See FORALL (Construct) for syntax details.
END_FORALL_statement
See END (Construct) for syntax details.
forall_body
is one or more of the following statements or constructs:
  • forall_assignment
  • WHERE statement (see WHERE)
  • WHERE construct (see WHERE construct)
  • FORALL statement (see FORALL)
  • FORALL construct
forall_assignment
is either assignment_statement or pointer_assignment_statement

Any procedures that are referenced in a forall_body, including one referenced by a defined operation, defined assignment, or finalization must be pure.

If a FORALL statement or construct is nested within a FORALL construct, the inner FORALL statement or construct cannot redefine any index_name used in the outer FORALL construct.

Although no atomic object can be assigned to, or have its association status changed in the same statement more than once, different assignment statements within the same FORALL construct can redefine or reassociate an atomic object. Also, each WHERE statement and assignment statement within a WHERE construct must follow these restrictions.

If a FORALL_construct_name is specified, it must appear in both the FORALL statement and the END FORALL statement. Neither the END FORALL statement nor any statement within the FORALL construct can be a branch target statement.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us