(j3.2006) Actual argument rank 2 array X(1, 4) associated with dummy rank 1 array - is that allowed ?

Reinhold Bader Reinhold.Bader
Wed Dec 23 06:24:01 EST 2009


Hello,

Toon Moene schrieb:
> 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

The RHS should be Y(I), I guess ...

> 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. 

I'd consider this covered by sequence association. See 12.5.2.11, in particular
para 4. This is also referenced in 12.5.2.4 par. 15, by the way.


>  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 !
> 

Regards
Reinhold



More information about the J3 mailing list