(j3.2006) Actual argument rank 2 array X(1, 4) associated with dummy rank 1 array - is that allowed ?
Toon Moene
toon
Wed Dec 23 06:03:31 EST 2009
I came upon a piece of code in our Weather Forecasting system that
roughly did the following:
SUBROUTINE A(X, N)
REAL X(N, 4), Y(N)
...
CALL B(Y, N)
DO I = 1, N
X(I,4) = Y
ENDDO
...
END
SUBROUTINE B(Z, N)
REAL Z(N)
...
DO I = 1, N
Z(I) = ... some expression ...
ENDDO
END
This is of course correct, but probably overly so. I thought it would
be possible to code this as:
SUBROUTINE A(X, N)
REAL X(N, 4)
...
CALL B(X(1,4), N)
...
END
SUBROUTINE B(Z, N)
REAL Z(N)
...
DO I = 1, N
Z(I) = ... some expression ...
ENDDO
END
i.e., without the auxiliary array Y and the copy loop.
Now the hard part is to find where the Standard (I'm looking at N1782)
allows this. The closest that I can find is 12.5.2.4 par. 14 where it
says that for assumed-shape arrays the rank of actual and dummy should
be the same (this almost implies that for non-assumed-shape arrays they
don't have to - then, by virtue of the way arrays are laid out [16.5.3.2
par 2, point 7] Z would correspond to the fourth column of X).
Is this reasoning correct ?
Thanks in advance.
Happy Holidays !
--
Toon Moene - e-mail: toon at moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
At home: http://moene.org/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.5/changes.html
More information about the J3
mailing list