
The FORTRAN–Pascal Interface 185
8
Simple Types
The simple types pass in a straightforward way, as follows:
Typeshortreal
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 Pascal function,
RetReal.p
function retreal_(var x: real): real;
begin
retreal_ := x + 1
end; { retreal_ }
The FORTRAN main program,
RetRealmain.f
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
Commentaires sur ces manuels