(j3.2006) If SIZE(B) > SIZE(A), what part of B does RESHAPE(B, SHAPE(A)) contain, if both A, B are rank N arrays ?
Toon Moene
toon
Fri Dec 9 15:19:37 EST 2011
On 12/09/2011 09:13 PM, Robert Corbett wrote:
> The intrinsic RESHAPE does not do what you want. The code you
> presented can be simplified. Try
>
> A = B( : SIZE(A, 1) - LBOUND(B, 1) + 1, &
> : SIZE(A, 2) - LBOUND(B, 2) + 1, &
> : SIZE(A, 3) - LBOUND(B, 3) + 1, &
> : SIZE(A, 4) - LBOUND(B, 4) + 1)
>
> OSS Fortran will have an easier time generating code for the
> revised version. I suspect other compilers will as well.
Thanks - and as a bonus, it gets rid of the auxiliary array ISHAPE
(which I wouldn't have needed if the SHAPE intrinsic had an optional DIM
argument).
--
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/; weather: http://moene.org/~hirlam/
Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news
More information about the J3
mailing list