(j3.2006) DO CONCURRENT question

Robert Corbett robert.corbett
Wed Nov 21 18:42:59 EST 2012

On 11/21/12 15:16, Bill Long wrote:
> On 11/21/12 4:18 PM, Robert Corbett wrote:
>> On 11/21/12 12:53, Bill Long wrote:
>>> On 11/21/12 1:13 PM, Lionel, Steve wrote:
>>>> DO CONCURRENT (I = 1:N)
>>>> BLOCK
>>>> REAL :: T
>>>> T = A(I) + B(I)
>>>> C(I) = T + SQRT(T)
>>>> 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."
> How would you deal with the case where one of these variables is
> declared PRIVATE in an OpenMP region?  Seems like you would do the same
> thing here.

No.  A private variable in OpenMP is local only in the construct
to which the private directive applies.  If the construct calls
a subprogram that accesses the same variable, it accesses the
original variable, not the local copy.  The private directive has
an effect similar to that of the BLOCK construct shown in
Note 8.11.

Bob Corbett

More information about the J3 mailing list