- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page