Arranging Data Items in Compaq Fortran Record Structures

Record structures are a Compaq language extension to the FORTRAN 77, Fortran 90, and Fortran 95 Standards. Record structures use the RECORD statement and optionally the STRUCTURE statement, which are also Compaq Fortran language extensions. The order of data items in a STRUCTURE statement determine the order in which the data items are stored.

Compaq Fortran stores a record in memory as a linear sequence of values, with the record's first element in the first storage location and its last element in the last storage location. Unless you specify /align:norecords, padding bytes are added if needed to ensure data fields are naturally aligned.

The following example contains a structure declaration, a RECORD statement, and diagrams of the resulting records as they are stored in memory:

  STRUCTURE /STRA/
    CHARACTER*1 CHR
    INTEGER*4 INT
  END STRUCTURE
    .
    .
    .
  RECORD /STRA/ REC

The following figure shows the memory diagram of record REC for naturally aligned records.

Memory Diagram of REC for Naturally Aligned Records