# align

Tells the compiler how to align certain data items.

## Syntax

Linux: | -align [keyword[, keyword...]] -noalign

macOS: | -align [keyword[, keyword...]] -noalign

Windows: | /align[:keyword[, keyword...]] /noalign

## Arguments

keyword | Specifies the data items to align. Possible values are:
none | Prevents padding bytes anywhere in common blocks and structures.
array n byte | Specifies a starting boundary for arrays.
[no]commons | Affects alignment of common block entities.
[no]dcommons | Affects alignment of common block entities.
[no]qcommons | Affects alignment of common block entities.
[no]zcommons | Affects alignment of common block entities.
[no]records | Affects alignment of derived-type components and fields of record structures.
rec n byte | Specifies a size boundary for derived-type components and fields of record structures.
[no]sequence | Affects alignment of sequenced derived-type components.
all | Adds padding bytes whenever possible to data items in common blocks and structures.

## Default

nocommons | Adds no padding bytes for alignment of common blocks.
nodcommmons | Adds no padding bytes for alignment of common blocks.
noqcommmons | Adds no padding bytes for alignment of common blocks.
nozcommmons | Adds no padding bytes for alignment of common blocks.
records | Aligns derived-type components and record structure fields on default natural boundaries.
nosequence | Causes derived-type components declared with the SEQUENCE statement to be packed, regardless of current alignment rules set by the user.

By default, no padding is added to common blocks but padding is added to structures.

## Description

This option specifies the alignment to use for certain data items. The compiler adds padding bytes to perform the alignment.

Option | Description
--- | ---
align none | Tells the compiler not to add padding bytes anywhere in common blocks or structures. This is the same as specifying noalign.
align array n byte | Aligns the start of arrays on an n-byte boundary. n can be 8, 16, 32, 64, 128, or 256. The default value for n is 8. This affects the starting alignment for all arrays except for arrays in COMMON. Arrays do not have padding between their elements.
align commons | Aligns all common block entities on natural boundaries up to 4 bytes, by adding padding bytes as needed. The align nocommons option adds no padding to common blocks. In this case, unaligned data can occur unless the order of data items specified in the COMMON statement places the largest numeric data item first, followed by the next largest numeric data (and so on), followed by any character data.
align dcommons | Aligns all common block entities on natural boundaries up to 8 bytes, by adding padding bytes as needed. The align nodcommons option adds no padding to common blocks.
align qcommons | Aligns all common block entities on natural boundaries up to 16 bytes, by adding padding bytes as needed. The align noqcommons option adds no padding to common blocks.
align zcommons | Aligns all common block entities on natural boundaries up to 32 bytes, by adding padding bytes as needed. The align nozcommons option adds no padding to common blocks.
align norecords | Aligns components of derived types and fields within record structures on arbitrary byte boundaries with no padding. The align records option requests that multiple data items in record structures and derived-type structures without the SEQUENCE statement be naturally aligned, by adding padding as needed.
align rec n byte | Aligns components of derived types and fields within record structures on the smaller of the size boundary specified (n) or the boundary that will naturally align them. n can be 1, 2, 4, 8, 16, or 32. The default value for n is 8. When you specify this option, each structure member after the first is stored on either the size of the member type or n-byte boundaries, whichever is smaller. For example, to specify 16 bytes as the packing boundary (or alignment constraint) for all structures and unions in the file prog1.f, use the following command: `ifort {-align rec16byte | /align:rec16byte} prog1.f` This option does not affect whether common blocks are naturally aligned or packed.
align sequence | Aligns components of a derived type declared with the SEQUENCE statement (sequenced components) according to the alignment rules that are currently in use. The default alignment rules are to align unsequenced components on natural boundaries. The align nosequence option requests that sequenced components be packed regardless of any other alignment rules. Note that align none implies align nosequence. If you specify an option for standards checking, align sequence is ignored.
align all | Tells the compiler to add padding bytes whenever possible to obtain the natural alignment of data items in common blocks, derived types, and record structures. Specifies align dcommons, align records, align nosequence. This is the same as specifying align with no keyword.

## IDE Equivalent

Visual Studio: Data > Structure Member Alignment (/align:recnbyte)

Data > Alignment of COMMON block entities (/align:[no]commons, /align:[no]dcommons, /align:[no]qcommons, /align:[no]zcommons)

Data > SEQUENCE Types Obey Alignment Rules (/align:[no]sequence)

Data > Default Array Alignment (/align:arraynbyte)

## Alternate Options

align none | Linux and macOS: -noalign Windows: /noalign
align records | Linux and macOS: -align rec16byte, -Zp16 Windows: /align:rec16byte, /Zp16
align norecords | Linux and macOS: -Zp1, -align rec1byte Windows: /Zp1, /align:rec1byte
align rec n byte | Linux and macOS: -Zp{1|2|4|8|16} Windows: /Zp{1|2|4|8|16}
align all | Linux and macOS: -align commons -align dcommons -align records -align nosequence Windows: /align:nocommons,dcommons,records,nosequence

Parent topic: Data Options