Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Derived Types

For a derived type to be interoperable with C, you must specify the BIND attribute:

type, BIND(C) :: MyType

Additionally, each component must have an interoperable type and interoperable type parameters, must not be a pointer, and must not be allocatable. This allows Fortran and C types to correspond:

typedef struct {
  int m, n;
  float r;
} MyCtype

The previous example is interoperable with the following:

use, intrinsic :: ISO_C_BINDING
type, BIND(C) :: MyFtype
integer(C_INT) :: i, j
real(C_FLOAT) :: s
end type MyFtype

The following restrictions apply to a derived type specified with the BIND attribute:

  • It cannot have the SEQUENCE attribute.

  • It cannot be an extended type.

  • It cannot have type-bound procedures.