Intel® Fortran Compiler 16.0 User and Reference Guide

Allocating Memory for Parts of Arrays

This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

This topic discusses using the ALLOC modifier with the OFFLOAD set of directives

The ALLOC modifier contains an array section reference. When you specify it, then the allocation on the coprocessor is limited to that shape of array. Only unit stride is allowed in the section. When a section has a rank greater than one, the second and subsequent index expressions must specify all elements at that dimension. The array section must be contiguous.

Data is transferred into that portion of the array specified by the IN or OUT expression. Thus memory allocation and the data transfer can use separate array slice references.

When the lower bound of the first dimension of a section used in the ALLOC modifier is non-zero, then the memory allocation begins with that element. The memory preceding the lower bound is unallocated and should not be referenced by your program. By not referencing it, you enable a smaller section of the array to be transferred to the coprocessor without requiring that the entire array be allocated.

Example

In the following example,
INTEGER :: A (15)
!               8 elements allocated
!               5 data elements transferred starting at element 4
!DIR$ OFFLOAD … IN ( A(4:8) : ALLOC ( (3:10) ) …
…

INTEGER, ALLOCATABLE :: B (:,:)
ALLOCATE (B (5,4))

! On the coprocessor:  16 elements allocated (rows 2 through 5)
!          Shape of array is 5x4, first row is unallocated
!          Data is transferred into row 3 only
!DIR$ OFFLOAD … IN ( B (3, :) : ALLOC ( 2:5, : ) …
…

In the diagram below:

See Also