XL Fortran for AIX 8.1

Language Reference

COLLAPSE

Purpose

The COLLAPSE directive reduces an entire array dimension to a single element by specifying that only the element in the lower bound of an array dimension is accessible. If you do not specify a lower bound, the default lower bound is one.

Used with discretion, the COLLAPSE directive can facilitate an increase in performance by reducing repetitive memory access associated with multiple-dimension arrays.

Format



>>-COLLAPSE--(--collapse_array_list--)-------------------------><
 
 

where collapse_array is:



>>-array_name--(--expression_list--)---------------------------><
 
 

where expression_list is a comma separated list of expression.

array name
is the array name.

expression
is a constant scalar integer expression. You may only specify positive integer values.

Rules

The COLLAPSE directive must contain at least one array.

The COLLAPSE directive applies only to the scoping unit in which it is specified. The declarations of arrays contained in a COLLAPSE directive must appear in the same scoping unit as the directive. An array that is accessible in a scoping unit by use or host association must not specified in a COLLAPSE directive in that scoping unit.

The lowest value you can specify in expression_list is one. The highest value must not be greater than the number of dimensions in the corresponding array.

A single scoping unit can contain multiple COLLAPSE declarations, though you can only specify an array once for a particular scoping unit.

You can not specify an array in both a COLLAPSE directive and an EQUIVALENCE statement.

You can not use the COLLAPSE directive with arrays that are components of derived types.

If you apply both the COLLAPSE and SUBSCRIPTORDER directives to an array, you must specify the SUBSCRIPTORDER directive first.

The COLLAPSE directive applies to:

Examples

Example 1: In the following example, the COLLAPSE directive is applied to the explicit-shape arrays A and B. Referencing A(m,2:100,2:100) and B(m,2:100,2:100) in the inner loops, become A(m,1,1) and B(m,1,1).

!IBM* COLLAPSE(A(2,3),B(2,3))
      REAL*8 A(5,100,100), B(5,100,100), c(5,100,100)
 
      DO I=1,100
       DO J=1,100
        DO M=1,5
           A(M,J,I) = SIN(C(M,J,I))
           B(M,J,I) = COS(C(M,J,I))
        END DO
        DO M=1,5
         DO N=1,M
            C(M,J,I) = C(M,J,I) + A(N,J,I)*B(6-N,J,I)
         END DO
        END DO
       END DO
      END DO
      END
 

Related Information

For more information on the SUBSCRIPTORDER directive, seeSUBSCRIPTORDER


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]