Next: Solving the Problem
Up: More Arrays as Arguments
Previous: Array Sizes
Why didn't Fortran tell us when we accessed beyond the bounds of the
array in the subroutine? Think about this carefully.
Click here for the answer
Can you design an experiment to determine whether Fortran will do array
bounds checking within a subroutine, just as it does in the main
program?
Click here for the answer
What happens now when we run the program?
Click here for the answer
So here's our problem in a nutshell:
- This version of Fortran does indeed warn us when we access outside
the declared bounds of an array in a subroutine or a function.
- However, Fortran does not require that the declared bounds of a
dummy array (in a subroutine or function) be the same as the declared
bounds of the actual array (that appears in the function or subroutine
call). (The checking program will, however, give us appropriate
warnings.)
We can now see that our problem is to arrange that the declared bounds of all
dummy and actual arrays be exactly the same. Unfortunately, this is impossible
to do if we continue to use the approach embodied in ``aparm2.f''. Why is
that?
Click here for the answer
Next: Solving the Problem
Up: More Arrays as Arguments
Previous: Array Sizes
Hamlet Project
hamlet@cs.utah.edu