Technical data
50
Chapter 3: Fortran Program Interfaces
Example
The following example shows how a Pascal routine must specify the length
of a character string (which is only implied in a Fortran call).
Fortran call to SAM
C SAM IS A ROUTINE WRITTEN IN FORTRAN
EXTERNAL F
CHARACTER*7 S
INTEGER B(3)
…
CALL SAM (F, B(1), S)
<– Length of S is implicit.
Pascal call to SAM
PROCEDURE F_; EXTERNAL;
S: ARRAY[1..7] OF CHAR;
B: ARRAY[1..3] OF INTEGER;
…
SAM_ (F, B[1], S, 7);
<– Length of S is explicit.
Execution-Time Considerations
Pascal checks certain variables for errors at execution time, whereas Fortran
does not. For example, in a Pascal program, when a reference to an array
exceeds its bounds, the error is flagged (if run-time checks are not
suppressed). Use the f77 –c option if you want a Fortran program to detect
similar errors when you pass data to it from a Pascal program.
Array Handling
Fortran stores arrays in column-major order, where the leftmost subscripts
vary the fastest. Pascal, however, stores arrays in row-major order, with the
rightmost subscript varying the fastest. Also, the default lower bound for
arrays in Fortran is 1. Pascal has no default; the lower bound must be
explicitly specified. Here is an example of the various layouts:










