Derived type parameters (Fortran 2003)
A derived type is parameterized if the DERIVED_TYPE_statement has any type_param_names, or if it inherits any type parameter from its ancestor type. You can define the type parameters for the derived type.
Syntax of a type parameter definition
- kind_selector
- Specifies the kind type parameter for the integer type. See the kind_selector section of INTEGER statement for syntax details.
type_param_decl
Each type_param_name in a type_param_decl must match one of the type_param_name parameters listed in the DERIVED_TYPE_statement. Each type_param_name in the DERIVED_TYPE_statement must be specified once in a type_param_decl in the derived type definition.
A derived type parameter can be one of the following parameters.
- It is a kind type parameter if it is declared with the KIND specifier.
- It is a length type parameter if it is declared with the LEN specifier.
If a type_param_decl has a scalar_int_initialization_expr, the type parameter has a default value specified by the expression.
Example
TYPE general_point (k, dim)
INTEGER, KIND :: k = selected_real_kind(6,70)
INTEGER, LEN :: dim
REAL(k) :: coordinates(dim)
END TYPE general_point
- Type parameter order
- Is the sequence of type parameters of a parameterized derived type. It is used for derived type specifiers (see Type Declaration) that do not use type parameter name keywords.