2.2.5.1 Arrangement of Records in Storage

Compaq Fortran 77 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. No gaps are left between elements. A record array is stored in a similar fashion, with no gaps between array elements.


Note
On Alpha processors, you can naturally align data by specifying the compiler option ALIGN. By default, the compiler issues a warning for data that is not naturally aligned. For more information on natural alignment and ALIGN, see your user manual.

Examples

The following examples contain structure declarations, RECORD statements, and diagrams of the resulting records as they are stored in memory.

The following example shows a basic structure declaration and RECORD statement:

Source Code

STRUCTURE /STRA/
  CHARACTER*1 CHR
  INTEGER*4 INT
END STRUCTURE
 . . .
RECORD /STRA/ REC,AREC(2)

Figure 2-2 shows the memory diagram of record REC for packed records, while Figure 2-3 shows the memory diagram of record REC for naturally aligned records (Alpha only).

Figure 2-2 Memory Diagram of REC for Packed Records

Figure 2-3 Memory Diagram of REC for Naturally Aligned Records (Alpha only)

Figure 2-4 shows the memory diagram of record array AREC for packed records, while Figure 2-5 shows the memory diagram of record array AREC for naturally aligned records (Alpha only).

Figure 2-4 Memory Diagram of AREC for Packed Records

Figure 2-5 Memory Diagram of AREC for Naturally Aligned Records (Alpha only)

The following example includes a substructure:

Source Code

STRUCTURE /STRB/
  REAL*8 FLT
  RECORD /STRA/ STR(2)
END STRUCTURE
 . . .
RECORD /STRB/ NRD

Figure 2-6 shows the memory diagram of record NRD for packed records, while Figure 2-7 shows the memory diagram of record NRD for naturally aligned records (Alpha only).

Figure 2-6 Memory Diagram of NRD for Packed Records

Figure 2-7 Memory Diagram of NRD for Naturally Aligned Records (Alpha only)

The following example shows how unions cause the storage of the associated mapped fields to be overlaid:

Source Code

STRUCTURE /STR/
  INTEGER*4 TAG

  UNION
    MAP
      REAL*4 FLT
      CHARACTER*2 CHR
    END MAP
    MAP
      INTEGER*2 INT
    END MAP
  END UNION

  LOGICAL*1 LOG
END STRUCTURE

Figure 2-8 shows a memory diagram of the mapped fields.

Figure 2-8 Memory Diagram of Mapped Fields

For More Information:

For details on compiler options that control alignment of RECORD data blocks, see your user manual.


Previous Page Next Page Table of Contents