FORTRAN Reference Manual

Language Elements
FORTRAN Reference Manual528615-001
2-25
Equivalencing RECORD Fields
RECORD. You cannot equivalence character and numeric variables in declarations
outside of a RECORD.
?GUARDIAN OPEN
RECORD file
INTEGER*2 name(12)
CHARACTER namestring * 24
EQUIVALENCE (name, namestring)
END RECORD
file^namestring = '$data subvol myfile '
CALL open (file^name, n, %2001)
If two fields of different sizes are equivalenced within a RECORD, the next field begins
after the larger of the two equivalenced fields. For example, in the RECORD
declaration:
RECORD stock
REAL open, high, low, close
REAL price (4)
EQUIVALENCE (price, open)
END RECORD
the field STOCK^HIGH is not in the same location as the second element of the
STOCK^PRICE array, but instead follows the fourth element of the STOCK^PRICE
array. Figure 2-3 illustrates how the fields of the STOCK RECORD are allocated in
memory.
Figure 2-3. Memory Allocation for Equivalenced Fields in a RECORD
Price (1)
VST0203.vsd
Price (2) Price (3) Price (4)
closeopen low
high
RECORD stock
REAL open high, low ,cose
REAL price (4)
EQUIVALENCE (price, open)
END RECORD