Hi,
You would need to check the generated code to see
whether changing a --> (a) causes a copy. (Better,
time the routine in your actual code to see whether
there's any difference.)
Changing the actual arguments to pointers misses the point of the restrictions:
If an entity is known by more than one name within the called procedure,
it cannot be changed within that procedure.
Changing the dummy arguments to pointers may result in slower code.
Do you know for a fact that changing a --> (a) causes
a bigger performance hit that declaring the dummy arguments
to be pointers would?
Verify that you must make obfuscating repairs before doing so!
On Dec 9, 2011, at 15:19 , Oliver Fuhrer wrote:
> Hi all,
>
> Thanks for all the insightfull answers. I understand the solution of calling sub( (a), a ), but it kind of takes the point away of passing in a both as input and output, which is to avoid an extra copy of a (in the real code a is rather large). I also deduce from the replies, that simply chaning INTENT(OUT) to INTENT(INOUT) is will not give me a legal code. So it seems that the only way out is to declare a and b as POINTERs, correct? Is it sufficient to do that simply inside the subroutine sub, or do I have to change the whole call tree and definition of the argument to sub to being a pointer?
>
> Kind regards,
> Oli
> ________________________________________
> From: Fortran 90 List [[log in to unmask]] on behalf of Dan Nagle [[log in to unmask]]
> Sent: Thursday, December 08, 2011 2:26 PM
> To: [log in to unmask]
> Subject: Re: INTENT?
>
> Hi,
>
> On Dec 8, 2011, at 05:29 , Oliver Fuhrer wrote:
>
> Harvey Richardson's answer is correct,
> as is NAG's compiler.
>
> You can change the code to
>
>> program test
>> implicit none
>> real :: a
>> a=1.0
>> call sub(a,a)
>
> call sub( (a), a)
>
>> write(*,*) a
>> end program test
>
> Since a is changed in sub, it must be known
> by only one name within sub.
>
> Placing the intent( in) actual argument in parenthesis
> makes it an expression. It is nonstandard to store
> to a dummy argument that is associated with an expression.
> But it is argument associated, in this case, with an intent( in)
> dummy argument, so you aren't storing to it anyway.
>
> An expression whose value happens to be a, and a, are two
> distinct things.
>
> Sorry this is a bit technical, but you asked. :-)
>
> --
> Cheers!
>
> Dan Nagle
--
Cheers!
Dan Nagle
|