question about elemental subroutines
Brooks Moses
bmoses@stanford.edu
Mon Apr 24 22:17:00 GMT 2006
Paul Thomas wrote:
> What I tried to ensure in the elemental subroutine dependency checking
> is that:
>
> call nonassign (x(2:3), x(1:2)) returns the same as
> call nonassign (x(3:2:-1), x(2:1:-1)),
>
> when one argument is OUT/INOUT and the other is IN. In the particular
> example under discussion, this is not ensured unless the argument is
> INOUT because the subroutine makes use of the incoming value of that
> argument. Were unititialized variables detected, the illegal cases
> where an attempt is made to use a variable that is undefined would
> be prevented. However, the patch to do this was not accepted.
>
> In light of this discussion, I will reread the standard and check that
> I have done the right thing.
To sort of clarify my earlier post (sorry about these crossing over in
the middle; I hadn't read this reply before writing my previous one), I
would say that all that is required is to ensure that
call nonassign (x(2:3), (x(1:2)))
returns the same as
call nonassign (x(3:2:-1), (x(2:1:-1)))
where the actual IN argument is enclosed in parentheses so as to make it
an expression, not a variable.
I should correct myself, however, on one point: This has nothing to do
with whether the non-expression argument is OUT or INOUT. Thus, the
patch itself appears correct, and I retract my disagreement with it.
However, it does seem odd to me that the patch appears to resolve this
by making a temporary for the INOUT variable rather than the IN
variable, as that requires two copies rather than one.
- Brooks
More information about the Fortran
mailing list