8

The commands to compile and execute PassPtr.f and PassPtrmain.p

hostname% f77 -c PassPtr.f

PassPtr.f:

passptr:

hostname% pc PassPtr.o PassPtrmain.p -lpfc -lF77

hostname% a.out 9 9.9

Function Return Values

The FORTRAN function, RetReal.f

The Pascal main program, RetRealmain.p

Function return values match types the same as with parameters, and they pass in much the same way.

Simple Types

The simple types pass in a straightforward way, as in this example:

double precision function retreal ( x ) retreal = x + 1.0

return end

program retrealmain;

var

r, s: real;

function retreal(x: real): real; external fortran;

begin

r := 2.0;

s := retreal(r); writeln(r: 4: 1, s: 4: 1)

end. { retrealmain }

The FORTRAN–Pascal Interface

201