- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Will the local data inFortran's pure subroutines ever "cross wires" due to parallel read-modify-write in different threads?
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're using /parallel or OpenMP that is coded properly, there should not be a problem. Pure routines really aren't anything special in this regard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I have an OMP PARALLEL DO loop. The loop index is used to specify a different element of an array. Only that specific element is passed into the pure subroutine. So all the affected data from outside the pure subroutine is preperly segreated by thread.
The real question is - does the locally declared data in the called subroutine need to have OMP directives to prevent interaction between threads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By default,. all variables are "automatic" (stack allocated) when OpenMP is used. So unless you did something that woild force static allocation (SAVE or initialization), nothing should need to be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does the POINTER attribute cause a variable to be STATIC when there is no initialization?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does theTARGET attribute cause a variable to be STATIC when there is no initialization?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No. The only thing that forces static allocation for local variables is the SAVE attribute, either explicit or implicit. The only way you get SAVE implicitly is with initialization.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page