- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to call an internal subroutine from inside a PARALLEL DO loop? Specifically, the loop variable and others declared PRIVATE (by openmp clause) are referenced in the internal subroutine. My experiments so far with XLF, Gfortran, and IVF say no. Looking for confirmation or advice to make it work.
Al Greynolds
www.ruda.com
Al Greynolds
www.ruda.com
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - AlGreynolds
Is it possible to call an internal subroutine from inside a PARALLEL DO loop? Specifically, the loop variable and others declared PRIVATE (by openmp clause) are referenced in the internal subroutine. My experiments so far with XLF, Gfortran, and IVF say no. Looking for confirmation or advice to make it work.
Al Greynolds
www.ruda.com
Al Greynolds
www.ruda.com
Hi Al,
I will have to check the OMP spec, but I can see where this would be a real problem. Let's take a case where your program declares the loop index I as integer. In the DO loop, you declare I as PRIVATE.
Ok, assume your internal procedure uses I from host association, that is, it uses I from the host program. At compile time, the compiler has to bind this I to an address. It will bind to the address for I that the main program is using, the master thread is it were, it has no way to know that I will be coming from a dynamic address within a parallel region. So my suspicion is that since internal procedures bind to addresses at compile time, I really doubt that this is allowed or advised.
I will check the spec though.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I haven't found anything in the spec so far, but it is clear from the spec that the PRIVATE clause sets the scope for the private variables to be within that parallel region. In this way, your private variables are almost 'renamed' within that PRIVATE region and they are not visible outside of this scope.
You can, of course, pass these private variables to the internal procedure as arguments. I did find an example of doing this on the Internet. But I suspect you were hoping for the shorthand way of doing this without having to pass each and every PRIVATE variable as an argument.
ron
You can, of course, pass these private variables to the internal procedure as arguments. I did find an example of doing this on the Internet. But I suspect you were hoping for the shorthand way of doing this without having to pass each and every PRIVATE variable as an argument.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think passing the private variables to the internal subroutine as argumentswould be the safest route.
I can see potential problems with the optimization process in the compiler if/when the internal subroutine is called from outside a parallel region AND called inside a parallel region AND using private variables not passed as arguments.
Jim Dempsey

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