Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

COLLAPSE Clause

Parallel Directive Clause: Specifies how many loops are associated with a loop construct.

Syntax

COLLAPSE (n)

n

Must be a constant positive scalar integer expression.

If n is greater than one, the iterations of all associated loops are collapsed into one larger iteration, which is then divided according to the SCHEDULE clause. The sequential execution of the iterations in all associated loops determines the order of the iterations in the collapsed iteration. The associated loops must be perfectly nested, that is, there must be no intervening code or any OpenMP* directive between any two loops.

The iteration count for each associated loop is computed before entry to the outermost loop. If execution of any associated loop changes any of the values used to compute any of the iteration counts, then the behavior is unspecified. The integer kind used to compute the iteration count for the collapsed loop is implementation defined.

If COLLAPSE is not specified, the only loop that is associated with the loop construct is the one that immediately follows the construct.

At most one COLLAPSE clause can appear in a directive that allows the clause.

See Nested DO Constructs for restrictions on perfectly nested loops using COLLAPSE.

If more than one loop is associated with a TASKLOOP construct, then the iterations of all associated loops are collapsed into one larger iteration space that is then divided according to the specifications in the GRAINSIZE and NUM_TASKS clauses. The sequential execution of the iterations in all associated loops determines the order of the iterations in the collapsed iteration space.