Visible to Intel only — GUID: GUID-B494217C-C3A9-4453-BCA4-3AF99FE6B00B
Visible to Intel only — GUID: GUID-B494217C-C3A9-4453-BCA4-3AF99FE6B00B
PACK Directive
General Compiler Directive: Specifies the memory alignment of derived-type items (and record structure items).
!DIR$ PACK[: {1 | 2 | 4 | 8} ]
Items of derived types, unions, and structures are aligned in memory on the smaller of two sizes: the size of the type of the item, or the current alignment setting. The current alignment setting can be 1, 2, 4, or 8 bytes. The default initial setting is 8 bytes (unless compiler option vms or align rec n bytes is specified). By reducing the alignment setting, you can pack variables closer together in memory.
The PACK directive lets you control the packing of derived-type or record structure items inside your program by overriding the current memory alignment setting.
For example, if PACK:1 is specified, all variables begin at the next available byte, whether odd or even. Although this slightly increases access time, no memory space is wasted. If PACK:4 is specified, INTEGER(1), LOGICAL(1), and all character variables begin at the next available byte, whether odd or even. INTEGER(2) and LOGICAL(2) begin on the next even byte; all other variables begin on 4-byte boundaries.
If the PACK directive is specified without a number, packing reverts to the compiler option setting (if any), or the default setting of 8.
The directive can appear anywhere in a program before the derived-type definition or record structure definition. It cannot appear inside a derived-type or record structure definition.
! Use 4-byte packing for this derived type
! Note PACK is used outside of the derived type definition
!DIR$ PACK:4
TYPE pair
INTEGER a, b
END TYPE
! revert to default or compiler option
!DIR$ PACK