HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
STRUCTURE (extension)
Chapter 10466
At the simplest level,
field-def
can be a type declaration statement. As such,
field-def
has
the same syntax as a standard Fortran 90 type declaration statement, except that the only
attribute that can be specified is the DIMENSION attribute. A variable defined with a type
declaration statement is called a field.
The following code uses simple type declaration statements to define a structure named date
with three fields: month and day of type BYTE, and year of type INTEGER(KIND=2):
STRUCTURE /date/
BYTE :: month, day
INTEGER(KIND=2) :: year
END STRUCTURE
A type declaration statement in a structure definition can optionally define initial values for
the fields. For example:
STRUCTURE /xyz/
REAL :: x = 1.0, y = 2.0, z = 3.0
END STRUCTURE
Thereafter, any record declared of structure xyz will have its x, y, and z fields initially set to
1.0, 2.0, and 3.0 respectively. Consider the following:
RECORD /xyz/ xyz
PRINT *, xyz.x, xyz.y, xyz.z
Even though no values have been assigned to the fields of xyz with an assignment statement,
the above code will display:
1.0 2.0 3.0
Implicit typing is not allowed in a structure definition. For example, the following code would
cause a compile error:
STRUCTURE /dimensions/
x, y, z ! illegal
END STRUCTURE
A correct way to code this would be:
STRUCTURE /dimensions/
REAL(KIND=8) :: x, y, z ! legal
END STRUCTURE
A field type declaration statement can also define an array, as in the following:
STRUCTURE /foo_bar/
INTEGER foo(10)
END STRUCTURE
or, using Fortran 90 syntax: