Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
4 Views

DO CONCURRENT documentation

Hi,

Not sure this was already addressed or not. I was currently focusing on adding some parallelization to my code so I went to the DO CONCURRENT construct. The documentation tells us that :

A variable that is referenced in an iteration must be previously defined during that iteration, or it must not be defined or become undefined during any other iteration.

However, the sample code which is provided seems to break this rule:

   REAL :: Q
   DO CONCURRENT (I = 1:N)
      Q = B(I) + C(I)
      D(I) = Q + SIN(Q) + 2
   END DO

Is Q not a variable which is (re)defined at each iteration of the loop (second part of the comment)?

Best regards,

Phil.

0 Kudos
2 Replies
Highlighted
Beginner
4 Views

Hi,

Hi,

This may be a matter of understanding the "or" in the reference quoted.  Variable Q in the example matches the first part of your reference text: "... must be previously defined during that iteration...", which it is on code line 3, so ignore the part following the "or". Also, Q will become undefined after the DO CONCURRENT loop, since the 2019 compiler documentation also states right after the statement you referenced: 
"A variable that is defined or becomes undefined by more than one iteration becomes undefined when the loop terminates."

Best,

Andi

 

0 Kudos
Highlighted
New Contributor II
4 Views

Hi Andreas,

Hi Andreas,

Thanks for your answer. I thought that the sample code had been checked before being added to the documentation but the comment is not very clear for its second part (an example of such invalid code could also be helpful).

Best regards,

Phil.

0 Kudos