Simple types with the –xl option, Type shortreal, Arrays – HP SunSoft Pascal 4.0 User Manual

Page 206: Conformant arrays

Advertising
background image

182

Pascal 4.0 User’s Guide

8

Simple Types with the

–xl

Option

With the

-xl

option, match Pascal

real

with FORTRAN

real

and Pascal

integer

with FORTRAN

integer*2

.

You can pass by value using the

%VAL()

feature of FORTRAN.

Type

shortreal

Unlike C, there is no problem with passing

shortreal

value parameters

between Pascal and FORTRAN. They can be passed exactly as in the previous
example, with the Pascal

shortreal

type matching the FORTRAN

real

type.

Arrays

Since FORTRAN cannot pass arrays by value, it cannot pass strings of
characters, fixed arrays, or

univ

arrays by value.

Conformant Arrays

Although Pascal generally passes all value parameters on the stack, the
exception is value-conformant array parameters, which are handled by
creating a copy in the caller environment and passing a pointer to the copy. In
addition, the bounds of the array must be passed. See “Conformant Arrays”
on page 173.

This example is the same as the one in the earlier section, except that the

var

prefix is deleted.

The commands to compile and
execute

SimVal.p

and

SimValmain.f

hostname% pc -c SimVal.p

hostname% f77 SimVal.o SimValmain.f -lpfc -lpc

SimValmain.f:

MAIN:

hostname% a.out

args=111111(If nth digit=1, arg n OK)

Advertising