Fortran Programming Guide

Data Type Compatibility

The tables below summarize the data sizes and default alignments for FORTRAN 77 and Fortran 90 data types. In both tables, note the following:

FORTRAN 77 and C Data Types

Table 11-1 shows the sizes and allowable alignments for FORTRAN 77 data types. It assumes no compilation options affecting alignment or promoting default data sizes are applied. (See also the FORTRAN 77 Language Reference Manual).

Table 11-1 Data Sizes and Alignments--(in Bytes) Pass by Reference (f77 and cc)

FORTRAN 77 Data Type 

C Data Type 

Size  

Default Alignment SPARC     x86  

BYTE X

CHARACTER X

CHARACTER*n X

char x

unsigned char x

unsigned char x[n]

1  

1  

1  

COMPLEX X

COMPLEX*8 X

DOUBLE COMPLEX X

COMPLEX*16 X

COMPLEX*32 X

struct {float r,i;} x;

struct {float r,i;} x;

struct {double dr,di;}x;

struct {double dr,di;}x;

struct {long double dr,di;} x;

16 

16 

32 

4  

4  

4/8  

4/8 

4/8/16  

-- 

DOUBLE PRECISION X

REAL X

REAL*4 X

REAL*8 X

REAL*16 X

double x

float x

float x

double x

long double x

16 

4/8  

4  

4  

4/8 

4/8/16 

-- 

INTEGER X

INTEGER*2 X

INTEGER*4 X

INTEGER*8 X

int x

short x

int x

long long int x

4  

2  

4  

LOGICAL X

LOGICAL*1 X

LOGICAL*2 X

LOGICAL*4 X

LOGICAL*8 X

int x

char x

short x

int x

long long int x

4  

1  

2  

4  

SPARC: Fortran 90 and C Data Types

The following table similarly compares the Fortran 90 data types with C.

Table 11-2 Data Sizes and Alignment--(in Bytes) Pass by Reference (f90 and cc)

Fortran 90 Data Type  

C Data Type 

Size 

Alignment  

 CHARACTER x

unsigned char x ;

 1 1
  CHARACTER (LEN=n) x

unsigned char x[n] ;

n 1
 COMPLEX x

struct {float r,i;} x;

 8 4
 

COMPLEX (KIND=4) x

COMPLEX (KIND=8) x

COMPLEX (KIND=16) x

struct {float r,i;} x;

struct {double dr,di;} x;

struct {long double, dr,di;} x;

16 

32 

4  

4/8 

4/8/16 

 DOUBLE COMPLEX x struct {double dr, di;} x;  16 4/8
 DOUBLE PRECISION x

double x ;

 8 4
 REAL x

float x ;

 4 4
 

REAL (KIND=4) x

REAL (KIND=8) x

REAL (KIND=16) x

float x ;

double x ;

long double x ;

16 

4  

4/8 

4/8/16 

 INTEGER x

int x ;

 4 4
 

INTEGER (KIND=1) x

INTEGER (KIND=2) x

INTEGER (KIND=4) x

INTEGER (KIND=8) x

signed char x ;

short x ;

int x ;

long long int x;

4  

 LOGICAL x

int x ;

 4 4
 

LOGICAL (KIND=1) x

LOGICAL (KIND=2) x

LOGICAL (KIND=4) x

LOGICAL (KIND=8) x

signed char x ;

short x ;

int x ;

long long int x;