Giampaolo Bottoni wrote:
> [...]
> Since in the "OpenMP Fortran Application Program Interface" modules
> or examples using modules are never quoted, my question is: the use
> of the PRIVATE directive in a module is allowed?
> That is: is allowed what follows ?
> MODULE xxx
> ....some variables declaration...
> REAL(8):: aa,bb,cc
> INTEGER :: dd
> !$OMP PRIVATE(aa,cc,dd)
> CONTAINS
> ....some subroutines...
> END MODULE xxx
> I fear not!
> It is of fundamental importance that this use is allowed but it is
> also necessary to write this statement clearly!
> [...]
I took a look at the OpenMP document. This may be a statement as
clear as possible:
2.6.3 Data environment rules
...
7. ... Common blocks and modules in called routines in the
dynamic extent of a parallel region always have an implicit
SHARED attribute, unless they are THREADPRIVATE common blocks.
It seems to me, it was purposely made that the variables defined in
MODULEs to be limited to SHARED. I am still trying to understand
what could be the implication.
Personally, I don't like the idea of defining local variables in the
data segment of a MODULE. I can see it could be a problem if different
procedures in the same module are invoked in the same parallel region.
E.g., the following code would be wrong under OpenMP:
module snglthrd
private ! not the same OpenMP ``PRIVATE''!
public :: settmp, usetmp
real,save :: tmp
contains
subroutine settmp(a)
tmp=a
end subroutine settmp
subroutine usetmp()
print*,tmp
end subroutine usetmp
end module snglthrd
program multithrd
use snglthrd
real a(8)
do i=1,8
a(i)=i
end do
!omp parallel do shared(a) private(i)
do i=1,8
call settmp(a(i)) ! a race condition?
call usetmp()
end do
!omp end parallel do
end program multithrd
Also, I think the term PRIVATE in OpenMP is conceptually conflicting
with the term PRIVATE in Fortran 90. Shouldn't LOCAL a better choice?
Jing
--
________________________________ _-__-_-_ _-___---
Jing Guo, [log in to unmask], (301)805-8333(o), (301)805-7960(fx)
Data Assimilation Office, Code 910.3, NASA/GSFC, Greenbelt, MD 20771
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|