HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
STRUCTURE (extension)
Chapter 10470
Nested records
A
field-def
can be a record declaration, known as a nested record. See “RECORD
(extension)” on page 448 for information about record declarations.) A nested record
declaration must use a structure that has already been defined. The following code first
defines the structure date. It then declares the structure event, which contains the nested
record when of structure date:
STRUCTURE /date/
BYTE :: month, day
INTEGER :: year
END STRUCTURE
STRUCTURE /event/
CHARACTER :: what, where
RECORD /date/ when
END STRUCTURE
A structure definition can also declare an array of nested records. For example, the following
code defines the structure calendar, which contains a 100-element array of records of
structure event:
STRUCTURE /calendar/
! number of events
INTEGER(KIND=2) :: event_count
RECORD /event/ events(100) ! array of event records
END STRUCTURE
Unions
A
field-def
can be a union—a form of nested structure in which two or more map blocks
share memory space. The UNION and MAP statements together define a union. The syntax of a
union definition is:
UNION
map-block
map-block
...
END UNION
where map-block is defined by a MAP statement and one or more field definitions. All map
blocks within the enclosing UNION statement share the same memory space in a record. The
syntax for defining a map block is:
MAP
field-def
...
END MAP
where
field-def
can be one of the following: