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

ASSUME_ALIGNED

General Compiler Directive: Specifies that an entity in memory is aligned.

!DIR$ ASSUME_ALIGNED address1:n1 [, address2:n2]...

address

An array variable. It can be of any data type, kind, or rank > 0. It can be an array component of a variable of derived type or a record field reference, host or use associated, or have the ALLOCATABLE or POINTER attribute.

It cannot be any of the following:

  • An entity in COMMON (or an entity EQUIVALENCEd to something in COMMON)

  • A component of a variable of derived type or a record field reference

  • An entity accessed by use or host association

If it is a module variable, that address is silently ignored.

n

A positive integer constant expression. Its value must be a power of 2 between 1 and 256, that is, 1, 2, 4, 8, 16, 32, 64, 128, 256. It specifies the memory alignment in bytes of address.

The ASSUME_ALIGNED directive must appear after the specification statements section or inside the executable statements section.

If you specify more than one address:n item, they must be separated by a comma.

If address is a Cray POINTER or it has the POINTER attribute, it is the POINTER and not the pointee or the TARGET that is assumed aligned.

If the check assume option is specified and address is not aligned on an n-byte boundary at runtime, an error message is displayed and execution is aborted.

For more information, see the example in the description of the ASSUME directive.

Example

The following example shows the correct placement and usage of the ASSUME_ALIGNED directive:

SUBROUTINE F(A, N) 
  TYPE NODE 
    REAL(KIND=8), POINTER :: A(:,:) 
  END TYPE NODE 
  
  TYPE(NODE), POINTER :: NODES 

  ALLOCATE(NODES) 
  ALLOCATE(NODES%A(1000,1000))

!DIR$ ASSUME_ALIGNED NODES%A(1,1) : 16               
  DO I=1,N 
    NODES%A(1,I) = NODES%A(1,I)+1 
  ENDDO 
…
END

It is illegal to place ASSUME_ALIGNED inside a type definition; for example:

TYPE S
!DIR$ ASSUME_ALIGNED T : 16           ! this is an error
  REAL(8), ALLOCATABLE :: T(:)
END TYPE S