Van Snyder asked:
>How do J3, WG5 and vendors feel about adding something like "It has the
Well, if you want to find out how J3 and WG5 feel, posting to comp-fortran-90
would not be top of my list of things to do - the WG5 list would seem to be
more effective.
Van also asked:
[Why cannot RESHAPE produce something with the TARGET attribute?]
This is simply completely wrong-headed. Producing something with the TARGET
attribute would not help in any way at all. A function reference is an
***EXPRESSION*** it is not a variable.
For instance, the following code is standard-conforming and guaranteed to
print "ok" (well, assuming integer values of 42 are not out of range etc.):
PROGRAM blechh
REAL x(1)
x(1) = 42
CALL weird(x,RESHAPE(x,(/1,1,1/)))
IF (x(1)/=-10) STOP 'FAIL 2'
PRINT *,'ok'
CONTAINS
SUBROUTINE weird(a,b)
REAL a(:),b(:,:,:)
a = -10
IF (ANY(b/=42)) STOP 'FAIL'
END SUBROUTINE
END
Note that the second argument is an expression, so the RESHAPEd X is a
***copy***, dummy argument B is absolutely *NOT* associated with the
variable X in any way.
It doesn't matter how many TARGET attributes you put in there, the fact is
that RESHAPE is a function call that produces an array result. It is not
a "view" of an object. Not making a copy for a RESHAPE when a valid Fortran
program cannot tell the difference is simply an optimisation - and an
optimisation that cannot be done if you can tell the difference - i.e. an
optimisation that quite frequently cannot be done! If your program is
invalid (which it was) you should count yourself lucky it did not start WW3,
just producing strange results instead.
BTW, there are plenty of RESHAPE calls where the copy cannot be optimised
away even in the absence of a way to check whether the original variable
is associated with it: e.g. when the source array is assumed-shape or a
pointer, when the PAD argument is used, when the ORDER argument is used
(sometimes), etc.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|