Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DO CONCURRENT documentation

netphilou31
New Contributor II
467 Views

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
Andreas_Z_
New Contributor I
467 Views

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
netphilou31
New Contributor II
467 Views

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
Reply