8

Simple Types

The simple types pass in a straightforward way, as follows:

The Pascal function,

RetReal.p

The FORTRAN main program, RetRealmain.f

function retreal_(var x: real): real;

begin

retreal_ := x + 1 end; { retreal_ }

double precision r, s, RetReal r = 2.0

s = RetReal( r )

write( *, "(2f4.1)") r, s stop

end

The commands to compile and execute RetReal.p and RetRealmain.f without xl

hostname% pc -c RetReal.p

hostname% f77 RetReal.o RetRealmain.f -lpfc -lpc RetRealmain.f:

MAIN: hostname% a.out 2.0 3.0

Type shortreal

There is no problem with returning a shortreal function value between Pascal and FORTRAN. As in the previous example, it can be passed exactly, with the Pascal shortreal type matching the FORTRAN real type (without -xl).

Procedure Calls: Pascal-FORTRAN

This section parallels “Procedure Calls: FORTRAN-Pascal” on page 168. The comments and restrictions given in that section apply here, also.

The FORTRAN–Pascal Interface

185