Array Arguments

The table below shows the simple correspondence between the type of the Fortran actual argument and the type of the C procedure argument for arrays of types INTEGER, INTEGER*2, REAL, DOUBLE PRECISION, and LOGICAL.

Note
There is no simple correspondence between Fortran automatic, allocatable, adjustable, or assumed size arrays and C arrays. Each of these types of arrays requires a Fortran array descriptor, which is implementation-dependent.

Array Data Type

Fortran Type

C Type

integer x( )

int x[ ];

integer*1 x( )

signed char x[ ];

integer*2 x( )

short x[ ];

integer*4 x( )

long int x[ ];

integer*8 x( )

long long x[ ]; or _int64

real*4 x( )

float x[ ];

real*8 x( )

double x[ ];

real x( )

float x[ ];

real*16 x( )

No equivalent

double precision x( )

double x[ ];

logical*1 x( )

char x[ ];

logical*2 x( )

short int x[ ];

logical*4 x( )

long int x[ ];

logical x( )

int x[ ];

logical*8 x( )

long long x[ ]; or _int64 x[ ];

complex x( )

struct {float real, imag;} [x];

complex *8 x( )

struct {float real, imag;} [x];

complex *16 x( )

struct {double dreal,dimag;} x;

double complex x( )

struct { double dreal,dimag; } [x];

complex(KIND=16) x( )

No equivalent

Note
Be aware that array arguments in the C procedure do not need to be declared as pointers. Arrays are always passed as pointers.

Note
When passing arrays between Fortran and C, be aware of the following semantic differences:   

Example below shows the Fortran code for passing an array argument to C and the corresponding C code.

Example of Array Arguments in Fortran and C

Fortran Code
dimension i(100), x(150)
call array( i, 100, x, 150 )

Corresponding C Code
array ( i, isize, x, xsize )
int i[ ];
float x[ ];
int *isize, *xsize;
{
. . .program text. . .
}