
168 Pascal 4.0 User’s Guide
8
Procedure Calls: FORTRAN-Pascal
Here are examples of how a FORTRAN main program calls a Pascal procedure.
Variable Parameters
Pascal passes all var parameters by reference, FORTRAN’s default.
Simple Types without the –xl Option
With var parameters, simple types match.
The Pascal procedure, Samp.p.
Note the procedure definition.
The procedure name in the
procedure statement is in
lowercase with a trailing
underscore (_). This format is
required to match the conventions
of the FORTRAN compiler. var
parameters are used to match
FORTRAN defaults.
procedure samp_(var i: integer; var r: real);
begin
i := 9;
r := 9.9
end; { samp_ }
The FORTRAN main program,
Sampmain.f. Note the
procedure declaration and call.
FORTRAN converts to lowercase
by default; you do not explicitly
give the underscore (_).
integer i
double precision d
call Samp ( i, d )
write( *, '(I2, F4.1)') i, d
stop
end
The commands to compile and
execute Samp.p and
Sampmain.f
hostname% pc -c Samp.p
hostname% f77 Samp.o Sampmain.f -lpfc -lpc
Sampmain.f:
MAIN:
hostname% a.out
9 9.9
Kommentare zu diesen Handbüchern