Derived Type

Purpose

The Derived Type statement is the first statement of a derived-type definition.

Syntax

Read syntax diagramSkip visual syntax diagram>>-TYPE--+-------------------------+--type_name----------------><
         +-::----------------------+
         '-,type_attribute_list ::-'
 
type_attribute
is PRIVATE, PUBLIC, BIND(C), .
type_name
is the name of the derived type

Rules

PRIVATE or PUBLIC can only be specified if the derived-type definition is within the specification part of a module. Only one of PRIVATE or PUBLIC may be specified.

BIND(C) explicitly defines the Fortran derived type as interoperable with a C type. The components must be of interoperable types. (See Interoperability of types for additional information.) A derived type with the BIND attribute cannot be a SEQUENCE type. A component of a derived type with the BIND attribute must have interoperable type and type parameters, and cannot have the POINTER or ALLOCATABLE attribute.

The type_name must not be the same as the name of any intrinsic type, except BYTE and DOUBLECOMPLEX. The type_name must also not be the name of any other accessible derived type.

If a label is specified on the Derived Type statement, the label belongs to the scoping unit of the derived-type definition.

If the corresponding END TYPE statement specifies a name, it must be the same as type_name.

Examples

MODULE ABC
  TYPE, PRIVATE :: SYSTEM      ! Derived type SYSTEM can only be accessed
    SEQUENCE                   !   within module ABC
    REAL :: PRIMARY
    REAL :: SECONDARY
    CHARACTER(20), DIMENSION(5) :: STAFF
  END TYPE
END MODULE

Related information