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.
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-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).
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).
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.
For details on compiler options that control alignment of RECORD data blocks, see your user manual.