Intel® Fortran Compiler 17.0 Developer Guide and Reference

Default Initialization

Default initialization occurs if initialization appears in a derived-type component definition.

The specified initialization of the component will apply even if the definition is PRIVATE.

Default initialization applies to dummy arguments with INTENT(OUT). It does not imply the derived-type component has the SAVE attribute.

Explicit initialization in a type declaration statement overrides default initialization.

To specify default initialization of an array component, use a constant expression that includes one of the following:

Pointers can have an association status of associated, disassociated, or undefined. If no default initialization status is specified, the status of the pointer is undefined. To specify disassociated status for a pointer component, use =>NULL( ). To default initialize a pointer component as associated with the target T, use => T.

Examples

You do not have to specify initialization for each component of a derived type. For example:

  TYPE REPORT
    CHARACTER (LEN=20) REPORT_NAME
    INTEGER DAY
    CHARACTER (LEN=3) MONTH
    INTEGER :: YEAR = 1995        ! Only component with default
  END TYPE REPORT                 !      initialization

Consider the following:

  TYPE (REPORT), PARAMETER :: NOV_REPORT = REPORT ("Sales", 15, "NOV", 1996)

In this case, the explicit initialization in the type declaration statement overrides the YEAR component of NOV_REPORT.

The default initial value of a component can also be overridden by default initialization specified in the type definition. For example:

  TYPE MGR_REPORT
    TYPE (REPORT) :: STATUS = NOV_REPORT
    INTEGER NUM
  END TYPE MGR_REPORT
  TYPE (MGR_REPORT) STARTUP

In this case, the STATUS component of STARTUP gets its initial value from NOV_REPORT, overriding the initialization for the YEAR component.

See Also