HP Fortran Programmer's Reference (September 2007)

Data types and data objects
Derived types
Chapter 5 127
If a component is an array, an array constructor must appear in
expression-list
that
satisfies the array. For more information about array constructors, see “Array
constructors” on page 75.
If a component is a pointer, the corresponding expression in
expression-list
must
evaluate to an allowable target.
Alignment of derived-type objects
Derived type objects have the same alignment as the component that has the most restrictive
alignment requirement. (This rule also applies to records.) To ensure natural alignment, the
compiler may add padding to each element in an array of derived type.
The following illustrates the alignment of an array of derived type. The definition of the
derived type includes the SEQUENCE statement to ensure the order in which components are
laid out in memory is the same as in the definition. The SEQUENCE statement has no effect on
alignment:
! definition of a derived type
TYPE t
SEQUENCE
CHARACTER(LEN=7) :: c
INTEGER(2) :: i2
REAL(8) :: r8
REAL(4) :: r4
END TYPE t
! declaration of an array variable of derived type
TYPE (t), DIMENSION(5) :: ta
Each element of t is allocated storage as shown in Table 5-4. The first component of t starts at
an address that is a multiple of 8. The four trailing padding bytes are necessary to preserve
the alignment of r8 in each element of the array.
Table 5-4 Example of structure storage
Component Byte offset Length
c 07
i2 82
r8 16 8
r4 24 4
padding 28 4