HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
TYPE (declaration)
Chapter 10482
must be preceded by the double colon.
Description
The TYPE declaration statement specifies the type and attributes of derived-type objects. A
derived-type object may be an array, which may be deferred shape (pointer or allocatable),
assumed shape (dummy argument), or assumed size (dummy argument).
Assignment is intrinsically defined for each derived type but may be redefined by the user.
Operators appropriate to a derived type may be defined by procedures with the appropriate
interfaces.
When a derived-type object is used as a procedure argument, the types of the associated
actual and dummy arguments must be the same. For sequence derived types different
physical type definitions may be used for the actual and dummy arguments, as long as both
type definitions specify identical type names, components, and component order. For
nonsequenced types the same physical type definition must be used, typically accessed via
host or use association, for both the actual and dummy arguments.
Examples
! Weather is a simple derived type with two
! character components and two integer components.
TYPE Weather
CHARACTER(LEN=32) Place
INTEGER High_temp, Low_temp
CHARACTER(LEN=16) Conditions
END TYPE Weather
TYPE (Weather) July(num_ws, 31)
! A two-dimensional Weather array for July
July(:,:) % Low_temp = -40
! Initialize all low temps in July
TYPE Polar
! Polar is a derived type with two real components that cannot be
! directly accessed in Polar objects outside the module
PRIVATE
REAL rho, theta
END TYPE Polar
! Point is a derived type with three components, one of which is
! itself of derived type
TYPE Point
REAL x, y
TYPE (Polar) p
END TYPE Point
TYPE (Polar) r, q(500)
! Two variables of type Polar