- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have trouble finding documentation or examples that deal with OpenMP threading of code with derived types. Can anyone recommend a good online resource or a book that covers this well?
Right now, I am trying to clarify what OpenMP3.0 directives & clauses can be used with derived types. I have read a gfortran bug report* stating that OpenMP3.0 does not specify behaviour when derived types with allocatable components are encountered. Is this correct? I didn't find this in the OpenMP3.0 specs. What's a reliable source of information on this?
In my case, I was trying to use FIRSTPRIVATE on variables of a derived type with allocatable components. Ifort (11.1.069) didn't complain during compilation, but the runtime behaviour was wrong.
If this isn't allowed, would it be possible to get ifort to give a warning or error at compile time?
*URL link feature of the forum is broken - this link is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38724#c5
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What you might be trying to do is ambiguous at best. Assume your derived type has some scalars and an allocatable array, and a pointer. While it may be clear that FIRSTPRIVATE should copy the scalars, what do you expect from the array and pointer?
a) copy of the array descriptor (and reference to same memory with aliases and without TARGET)
b) an empty array descriptor (where you must allocate)
c) and array descriptor auto-allocated to original array size then copy made there of
d) same issue of a, b, c) with pointer which may point to scalar or array.
Try breaking up
!$OMP PARALLEL DO ...
to
!$OMP PARALLEL
(construct your private copy here the way you want it (no ambiguity))
!$OMP DO ...
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your answer. I have since given up on using FIRSTPRIVATE, and instead am using PRIVATE for those objects and explicitely allocating memory to them in the threaded region, exactly as you suggested.
It turns out I am dealing with exactly the situation you described. My derived type has a few scalars, a REAL allocatable array and and a COMPLEX pointer array pointing to the REAL allocatable array thanks to C_F_POINTER trickery. I understand that what I was trying to do was ambiguous, although I was hoping for something like your option c).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm told that the OpenMP 3.0 standard does not addressthe new language features introduced in Fortran 2003 (this includes allocatable components of derived types, as well as all sorts of object oriented features). Since an allocatable component of a derived type may itself be a derived type array with allocatable components, the potential complications go even beyond what Jim pointed out.
gfortran simply emits an error if a firstprivate entity has an allocatable component; (pointer components, which predate Fortran 2003, are allowed). Intel Fortran does not emit an error, but it looks like the firstprivate clause is ignored, and the allocatable component is treated as shared. I will submit a request to generate an error message as you suggest.
It seems like your options are either to use fixed dimension arrays as components of derived types, in order to use firstprivate, or to allocate and initializeyourself theallocatablecomponents of a derived type that has been declared as private,as Jim suggests.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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