(j3.2006) DO CONCURRENT question
Robert Corbett
robert.corbett
Wed Nov 21 17:18:48 EST 2012
On 11/21/12 12:53, Bill Long wrote:
>
> On 11/21/12 1:13 PM, Lionel, Steve wrote:
>> I am puzzled by some wording in the standard regarding DO CONCURRENT and
>> hope one or more of you can shed some light on it.
>>
>> 8.1.6.7, page 178, lines 5-7 say:
>>
>> 5 A variable that is referenced in an iteration shall either be
>> previously defined during that iteration, or
>>
>> 6 shall not be defined or become undefined during any other iteration. A
>> variable that is defined or becomes
>>
>> 7 undefined by more than one iteration becomes undefined when the loop
>> terminates.
>>
>> It then goes on to show in note 8.11:
>>
>> A variable that is effectively local to each iteration of a DO
>> CONCURRENT construct can be declared in
>>
>> a BLOCK construct within it. For example:
>>
>> DO CONCURRENT (I = 1:N)
>>
>> BLOCK
>>
>> REAL :: T
>>
>> T = A(I) + B(I)
>>
>> C(I) = T + SQRT(T)
>>
>> END BLOCK
>>
>> END DO
>>
>> If the BLOCK were removed, so that T was a procedure scope variable, why
>> wouldn?t ?previously defined during that iteration? be sufficient to
>> effectively make T local to each iteration, negating the need here for
>> BLOCK? Or am I misreading this?
> No. You are right that the BLOCK is not technically needed here. What
> it does is remove any issue concerning T "becomes undefined when the
> loop terminates" since (this) T does not even exist at the end of the
> loop.
>
> Cheers,
> Bill
>
What about the case of module variables, variables in common,
and variables from an enclosing scoping unit? They will not
be easy to "localize."
Bob Corbett
More information about the J3
mailing list