Fortran Programming Guide

Returning a Simple Data Type

The following example returns a REAL or float value. BYTE, INTEGER, LOGICAL, DOUBLE PRECISION, and REAL*16 are treated in a similar way:

Table 11-13 Functions Returning a REAL or float Value

Fortran calls C 

C calls Fortran 

real ADD1, R, S

external ADD1

R = 8.0

S = ADD1( R )

...

------------------------------

float add1_( pf )

float *pf;

{

float f ;

f = *pf;

f++;

return ( f );

}

float r, s;

extern float fadd1_() ;

r = 8.0;

s = fadd1_( &r );

...

------------------------------

real function fadd1 (p)

real p

fadd1 = p + 1.0

return

end