Derived Type

Purpose

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

Syntax



>>-TYPE--+----------------------------+--type_name-------------><
         | .-,------------------.     |
         | V                    |     |
         '---+----------------+-+--::-'
             '-type_attr_spec-'
 
 

type_attr_speclist
is PRIVATE, PUBLIC, or 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.

type_name cannot be the same as the name of any intrinsic type, except BYTE and DOUBLECOMPLEX, or 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

IBM Copyright 2003