Handling Data Types in Mixed-Language Programming Overview

Even when you have reconciled calling conventions, naming conventions, and methods of data exchange, you must still be concerned with data types, because each language handles them differently.

The following table lists the equivalent data types between Fortran and C:

Equivalent Data Types

Fortran Data Type C Data Type

INTEGER(1)

char

INTEGER(2)

short

INTEGER(4)

int, long

INTEGER(8)

_int64

REAL(4)

float

REAL(8)

double

REAL(16)

---

CHARACTER(1)

unsigned char

CHARACTER*(*)

See Handling Character Strings

COMPLEX(4)

struct complex4 {
float real, imag;
};

COMPLEX(8)

struct complex8 {
double real, imag;
};

COMPLEX(16)

---

All LOGICAL types

Use integer types for C

See these topics:

Handling Numeric, Complex, and Logical Data Types

Handling Fortran Array Pointers and Allocatable Arrays

Handling Intel Fortran Pointers

Handling Arrays and Fortran Array Descriptors

Handling Character Strings

Handling User-Defined Types