Intel® Fortran Compiler 18.0 Developer Guide and Reference

ATTRIBUTES ALIGN

The ATTRIBUTES directive option ALIGN specifies the byte alignment for variables and for allocatable or pointer components of derived types.

!DIR$ ATTRIBUTES ALIGN: n:: object

n

Is the number of bytes for the minimum alignment boundary.

For allocatable objects, the boundary value must be a power of 2, such as 1, 2, 4, 8, 16, 32, 64, 128, and so on. n must have a value between 1 and 2097152 == 2**21 == 2MB on Linux* and macOS* systems, and between 1 and 8192 == 2**13 == 8KB on Windows* systems.

For non-allocatable objects, the boundary value must be a power of 2 between 1 and 64 on Windows systems, between 1 and 65536 == 2**16 == 64KB on Linux systems, or between 1 and 4096 == 2**12 == 4KB on macOS* systems.

object

Is the variable or the allocatable or pointer component of a derived type to be aligned.

Objects that can be aligned by this directive include static local variables, automatic variables, module variables, dynamically allocated arrays, allocatable array components of derived types, and the start of common blocks. This directive cannot be used to align variables within common blocks

If you specify directive !DIR$ ATTRIBUTES ALIGN on an object with the ALLOCATABLE or POINTER attribute, an ALLOCATE statement will attempt to use that alignment when the memory is allocated.

For allocatable or pointer components of derived types, the directive must appear within the derived-type TYPE…END TYPE block.

If the TYPE is an extended type, the directive cannot reference a component in the parent type.

Example

Consider the following:

TYPE EXAMPLE 
!DIR$ ATTRIBUTES ALIGN : 64 :: R_alloc 
REAL, ALLOCATABLE :: R_alloc ( : ) 
REAL :: R_scalar 
INTEGER :: I_nonalloc(25) 
END TYPE EXAMPLE  

TYPE (EXAMPLE) :: MyVar  

ALLOCATE (MyVar%R_alloc(1000))   ! Memory is allocated aligned at a 64-byte boundary

Note that it is valid to give the ALIGN:64 attribute to component R_alloc, but not to component R_scalar or to component I_nonalloc.

The following example shows that the name of a common block may optionally be enclosed in slashes:

!DIR$ ATTRIBUTES ALIGN: n :: /common_name/

See Also