IntelĀ® Fortran Compiler 18.0 Developer Guide and Reference

Parameterized TYPE Statements

A derived type-spec (see Type Declarations) in a parameterized type declaration has the general form:

type-name [ ( type-param-spec-list ) ]

type-name

Is an accessible derived type.

type-param-spec-list

Is one or more of the following separate by commas:

[ keyword = ] type-param-value

keyword

Is the name of a type parameter for the type type-name.

type-param-value

Is a scalar integer expression or an asterisk "*" or a colon ":".

A type-param-spec-list must appear only if the type is parameterized. There must be at most one type-param-spec corresponding to each parameter of the type. If a type parameter does not have a default value, there must be a type-param-spec corresponding to that type parameter.

The following topics in this section include cumulative examples demonstrating various kinds of parameterized TYPE statements.

Examples

Consider the following:

TYPE matrix (k, d1, d2)
  INTEGER, KIND :: k = kind (0.0)                  ! k has a default value
  INTEGER (selected_int_kind (12)), LEN :: d1, d2  ! Non-default kind for d1
  REAL (k) :: element (d1 ,d2)
END TYPE
! dim is an integer variable 
TYPE(matrix(k = KIND(0d0), d1=200+5, d2=dim)) :: my_matrix1
! k has a default value and so the type-param-spec can be omitted
TYPE(matrix(d1=2*dim, d2=dim)) :: my_matrix2
TYPE(matrix(KIND(0d0), :, :)), pointer :: my_deferred_matrix
TYPE(matrix(KIND(0d0), *, *)) :: my_assumed_matrix

Each keyword must be the name of one of the parameters of the type. Similar to keyword arguments in procedure calls, "keyword=" can be omitted only if "keyword=" has been omitted for each preceding type parameter. If a keyword appears, the value corresponds to the type parameter named by the keyword. If keywords do not appear, the value corresponds to type parameters in type parameter order. If necessary, the value is converted according to the rules of intrinsic assignment to a value of the same kind as the type parameter.

See Also