Catherine Moroney writes:
> I had understood this to mean that if I have the following bit of code
> (below), that the original array bounds would be preserved in the
> subroutine sub1. But, when I try it out (SGI MIPS compiler, v7.3)
> it thinks that the array has bounds of (1:11,1:9).
[sample elided]
That's because your dummy argument is not a pointer.
If the dummy is a pointer, then it picks up the bounds (not just the
shape) of the actual argument, which must also be a pointer.
If the dummy argument is not a pointer (or an allocatable with the
TR), then it does not pick up bounds - just shape. It does not
matter that the actual is a pointer.
Recall that you can use a pointer basically anywhere that you can
use a non-pointer. The pointer is automatically "dereferenced"
and you end up really using it's target. That's what happens in
your code - you really are passing the target of the pointer, not
the pointer itself, as the actual argument. The only way you could
pass the pointer itself (complete with bounds), would be if the
dummy were a pointer.
Of course, using pointers just so bounds will be passed seems like
a pretty big hammer. And it forces you to use pointers all over
(because once you declare the dummy as a pointer, anythikng that
is passed to it as an actual must also be a pointer). I don't
think I'd change eveything to pointers just to get bounds passing.
But if that's what you want...
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|