multithreading - Private and public variables inside a module and a a subroutine in OpenMP -


i trying parallelize complicated simulation code used oil field calculations.

my question is, if can declare variable or allocatable arrays , few subroutines in module, use module in module/subroutine contains parallel region, variables , arrays considered private each thread (i.e. have separate copies of variables , changes made variables in thread won't seen other threads) or they'll shared?

like this:

module m2 implicit none integer :: global contains      subroutine s2()         implicit none         integer :: tid         tid = ! calculation     end subroutine s2 end module m2  module m1     use m2     implicit none contains     subroutine s1         !$omp parallel             i=1, 9                 call s2()             end         !$omp end parallel     end subroutine s1 end module m1 

will tid , global private or shared?

any appreciated!

module variables shared in openmp unless use threadprivate directive. see difference between openmp threadprivate , private detailed description of threadprivate. global shared.

the local variable tid declared in subroutine , called parallel region. therefore private unless has save attribute.

(note initialization integer :: tid = 0 adds save implicitly, careful.)


Comments