type mytype integer:: i real*8 :: a(3) end type mytypeTo create a variable of type
type (mytype) varAn array of
mytypecan also be created.
type (mytype) stuff(3)Elements of derived types are accessed with the "%" operator. For instance,
var%i = 3 var%a(1) = 4.0d0 stuff(1)%a(2) = 8.0d0The real power of derived types comes with the ability to choose bewteen functions (or subroutines) based on the type of their arguments. Different functions can be called by the same name, depending on whether the argument type is real, integer,or even a derived type. Intrinsic Fortran routines have always had this ability, the simplest example being choosing between single and double precision versions of the function. Now it can be extended to user's routines and defined data types as well. See the example in the section on intefaces for subroutines .
The compiler is free to store the constitutients of a derived type
how it chooses. To force the derived type to be stored contiguously,
sequence keyword. For example,
type mytype sequence integer:: i real*8 :: a(3) end type mytypeThe IBM compiler seems to require this keyword if a derived type is the argument of a subroutine or function.