You can also pass entire arrays, not just individual elements, as arguments. Why in the world would you want to do that?
Let's try to get you thinking in this direction. Try to imagine some useful functions and subroutines that would take arrays as arguments. Remember: a function should return a value without modifying its arguments, and a subroutine does not return a value but usually modifies one or more arguments.
Click here for some possibilities
Actually, the third example above is a bad example, because functions may not return arrays as results. What approach can you take if you want to implement the third example anyway?
The key idea is that any changes made to an array in a subroutine will be apparent at the point of call.
Let's take a look at a subroutine that implements possibility (c) above, as subsequently modified. Look at ``aparm2.f'' (or view it directly). Compile and run it.
Here are a few things to notice:
Try modifying ``aparm2.f'' so that it computes the sum of the corresponding elements of A and B instead of the product.
Hamlet Project