Associate blocks in parallel regions

Associate blocks in parallel regions

I've recently been making quite a lot of use of the F2003 'associate block' facility to simply some of my code, for example:

do j=firstrow, lastrow                           
       associate (fb => fbs(j),   lb => lbs(j))
                cos_phi(fb:lb,j) = sqrt(1d0 - sin_phi(fb:lb,j)**2)
       end associate
end do


This works really well, saves a lot of typing, and makes the code a great deal more readable without the overhead of copying into local variables or using pointers.

Until, that is, I try to put the above loop into an OpenMP parallel region, and then it fails with some really exotic errors. The errors go away if I remove the 'associate' structure and give all the variables their full names, so it is definitely the associate block which is causing the problem rather than some other aspect of my parallelization.

Is this intended behaviour, or is it a bug?


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think I've found my answer here. It looks like this is a situation not satisfactorily dealt with by the OpenMP standard, and so for the time being I'll just have to go back to either typing the variable names out in full or using local variables or pointers instead.

Leave a Comment

Please sign in to add a comment. Not a member? Join today