在OMP块中调用的子例程内部的OMP变量减少

时间:2019-04-02 02:40:54

标签: multithreading parallel-processing fortran

我的一个例程中有一个由该指针指向的变量:

complex(dp), pointer :: Pkc(:,:)=>NULL()

我也在同一例程中分配它:

call MIO_Allocate(Pkc,[1,1,1],[ptsTot,nAt,2],'Pkc','diag')

在此例程中,我在OMP区域内使用它:

!$OMP PARALLEL DO PRIVATE(iee, ie, unfoldedK), REDUCTION(+:Ake1, Ake2, Ake), &  
!$OMP& SHARED(Pkc, KptsG, E, Kpts, AkeGaussian1, AkeGaussian2, AkeGaussian, nAt, nspin, is, ucell, gcell, H0, maxNeigh, hopp, NList, Nneigh, neighCell, gaussian, Epts) 
  do ik=1,ptsTot ! K loop
  ...
  call DiagSpectralWeightWeiKuInequivalentInequivalent(nAt,nspin,is,Pkc(ik,:,:),E(:,is),Kpts(:,ik),unfoldedK(:),ucell,gcell,H0,maxNeigh,hopp,NList,Nneigh,neighCell)
  ...
  end do
!$OMP END PARALLEL DO

所调用的新例程由以下位置给出

subroutineDiagSpectralWeightWeiKu(N,ns,is,PkcLoc,E,K,KG,cell,H0,maxN,hopp,N List,Nneigh,neighCell)
...
complex(dp), intent(out) :: PkcLoc(N,2)
...
do j=1,N ! These are the eigenvectors with band index J
do in=1,N
PkcLoc(j,1) = PkcLoc(j,1) + exp(-cmplx_i*dot_product(KG, RtsVec(in,:))) * Hts(in,j)
end do
end do
...
end subroutine DiagSpectralWeightWeiKuInequivalent

在执行OMP时,如何确保PkcLoc获得正确的行为?我遇到了一些细分错误,我认为是与PkcLoc上缺少REDUCTION有关。

有关如何解决此问题的任何建议?

我找到了这个thread,,但是就我而言,do循环位于被调用的子例程之外。

0 个答案:

没有答案
相关问题