--On Monday, March 22, 2004 1:19 PM -0600 Renchi Raju
<[log in to unmask]> wrote:
> integer :: a(10)
> call mysub(a(2:))
>
> subroutine mysub(b)
> integer :: b(9)
> ....
> case a:
> subroutine mysub(b)
> integer :: b(8)
> ....
>
> case b:
> subroutine mysub(b)
> integer :: b(10)
> ..
>
> i am banking on case (a) being legal.
Yes, case a is legal. I recommend against it for several reasons, but it
is legal.
the case (b) is just a curiosity
> question. all three compile and run with two compilers (intel fortran and
> ibm xlf) with array bounds checking. i'm surprised that case (b) worked, i
> would have expected it be illegal.
It is illegal, but compilers aren't required to check it and it doesn't
surprise me that some don't. Note that just because they don't diagnose it
doesn't mean that they will work correctly in all cases either. Even if
you tested one case, that doesn't mean all other cases would work.
> PS: i know, i can use assumed-shape array, but i want to use adjustable
> bounds, because i need to redimension my arrays at different points.
I'm not sure exactly how that follows, but I guess that's up to you.
Be aware that by using anything other than assumed shape (or pointer)
dummies, you are asking for several problems. One is that, as you
noticed, error checking may be degraded. Another is that you may find
that the compiler makes temporary copies of your arrays, which can be
a performance killer; compilers have gotten better about not making copies
needlessly, but in some cases they don't really have an option.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|