Fixed arrays – HP SunSoft Pascal 4.0 User Manual

Page 215

Advertising
background image

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

Advertising