Aleksandar
> Standard experts:
>
> As I was reading the F2x draft I stumbled accross something which I am
> pretty sure is the same as in F95 and that is confusing: restrictions
> (if any) on dummy procedure arguments with TARGET attribute (12.4.17 in
> 007R2). The standard says that the values of the entity associated with
> a dummy parameter shall only be modified through the dummy argument,
> *unless* it is a POINTER or a TARGET+other properties. This in "plain"
> words means "ordinary" arguments cannot be aliased (or will be assumed
> non-aliased when the compiler translates and optimizes the procedure).
>
> According to this, in the following routine:
>
> subroutine my_routine(a,b)
> real, dimension(:), intent(out), TARGET :: a, b
> ...
> a=a+b ! Can a and b safely be assumed non-aliased?!?
> end subroutine my_routine
>
> can the compiler optimize well the statement a=a+b (i.e. assume
> non-overlap and do not create do any temporary array results or such).
> As I am reading 12.4.1.7, it seems the answer is no, but really this
> makes no sense.
You are correct, the answer is no. You may find 5.7.2 and 5.7.3 of
Metcalf and Reid helpful, where we explain the issues.
> TARGET does imply that the variable may be changed by a
> pointer to it. But in no way does it imply that it can be aliased with
> another TARGET (non-pointer) variable. So in my limited view a and b
> should be assumed non-aliased by the compiler. I may be missing
> something or misunderstanding the whole thing though, so please clarify.
The rules are designed to cover whether the compiler is allowed, not
allowed, or permitted to perform copy-in/copy-out on an argument.
In your example, this is not permitted since a pointer may be pointing
to the actual argument. The rules were changed by an interpretation
of Fortran 90 that was debated long and hard. You would have prefered
the original rules.
Given that copying is not allowed in this situation, the committee took
the view that aliasing should be allowed, as in the direct use of the
arrays.
Hope this helps,
John.
|