Intel® Fortran Compiler 16.0 User and Reference Guide

Type Extension

Type extension lets you create new derived types by extending pre-existing derived types.

Any derived type can be extended using the EXTENDS keyword, except for types with the SEQUENCE or BIND(C) attributes. SEQUENCE types and BIND(C) types (as well as intrinsic types) are non-extensible.

The extended type either inherits or overrides each type-bound procedure of the parent type. An overriding procedure must be compatible with the parent procedure; in particular, each dummy argument must have the same type except for the passed-object dummy argument which must have the new type. A type-bound procedure that is declared to be NON_OVERRIDABLE cannot be overridden during type extension.

The extended type inherits all the components and parameters of the parent type and they are known by the same name. The extended type can also specify additional components.

For example, consider the following derived-type definition:

TYPE PERSON_INFO
  INTEGER :: AGE
  CHARACTER (LEN = 60) :: NAME
END TYPE PERSON_INFO

Derived type PERSON_INFO (the parent type) can be extended to create a new type as follows:

TYPE, EXTENDS (PERSON_INFO) :: EMPLOYEE_DATA
  INTEGER :: ID
  REAL :: SALARY
END TYPE EMPLOYEE_DATA

Extended type EMPLOYEE_DATA inherits all the components in type PERSON_INFO, as well as additional components ID and SALARY.

See Also