The FORTRAN–Pascal Interface
191
8
Fixed Arrays
For a fixed-array parameter, pass the same type and size by reference:
The FORTRAN subroutine,
FixVec.f
subroutine FixVec ( V, Sum )
integer Sum
integer V(0:8)
integer i
Sum = 0
do 2 i = 0, 8
2 Sum = Sum + V(i)
return
end
The Pascal main program,
FixVecmain.p
program FixVecmain(output);
type
VecTyp = array [0..8] of integer;
var
V: VecTyp := [1, 2, 3, 4, 5, 6, 7, 8, 9];
Sum: integer;
procedure fixvec(var XV: VecTyp; var XSum: integer);
external fortran;
begin
fixvec(V, Sum);
writeln(Sum: 4)
end. { FixVecmain }
The commands to compile and
execute
FixVec.f
and
FixVecmain.p
hostname% f77 -c FixVec.f
FixVec.f:
fixvec:
hostname% pc FixVec.o FixVecmain.p -lpfc -lF77
hostname% a.out
45
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......