Arranging Data Items in Derived-Type Data

Like common blocks, derived-type data may contain multiple data items (members).

Data item components within derived-type data will be naturally aligned on up to 64-bit boundaries, with certain exceptions related to the use of the SEQUENCE statement and DF options.

Compaq Visual Fortran stores a derived data type as a linear sequence of values, as follows:

Consider the following declaration of array CATALOG_SPRING of derived-type PART_DT:

  MODULE DATA_DEFS
    TYPE PART_DT
      INTEGER           IDENTIFIER
      REAL              WEIGHT
      CHARACTER(LEN=15) DESCRIPTION
    END TYPE PART_DT
    TYPE (PART_DT) CATALOG_SPRING(30)
    .
    .
    .
  END MODULE DATA_DEFS

As shown in the following figure, the largest numeric data items are defined first and the character data type is defined last. There are no padding characters between data items and all items are naturally aligned. The trailing padding byte is needed because CATALOG_SPRING is an array; it is inserted by the compiler when the /align:records option is in effect.

Derived-Type Naturally Aligned Data (in CATALOG_SPRING())