如何在并行区域外使用私有变量的值

时间:2016-01-10 12:43:18

标签: fortran openmp

我有一个与OpenMP并行的fortran代码。这是代码的并行部分:

!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(iconf,d,randx,                   &
!$OMP& randy,randz,unit_cg,theta1,theta2,theta3,fr1,fr2,fr3,Q,          &
!$OMP& plproduct_avg,correlation_term) 

      allocate(randx(num),randy(num),randz(num),unit_cg(num),           &
     &         fr1(num),fr2(num),fr3(num),theta1(order,num),            &
     &         theta2(order,num),theta3(order,num),                     &
     &         Q(nfftdim1,nfftdim2,nfftdim3))


!$OMP DO 

      do 250 iconf = 1,1600
       write(6,*)'configuration number',iconf

       {some calculations}

       do 350 d = 0,int(nfft1/2)
        write(6,*)'correlation term of iconf =',iconf,'d=',d,           &
     &             correlation_term(d,iconf)
350    continue

250   continue

!$OMP END DO

      deallocate(randx,randy,randz,unit_cg,fr1,fr2,fr3,theta1,theta2,   &
     &           theta3,Q)

!$OMP END PARALLEL

很明显,这个循环计算correlation_term(iconf)(它们是私有的)并正确地在输出文件上打印它们。但是当我在并行区域之外使用这些变量时,它们都是零。

如何使用在其外的并行区域中计算的correlation_term(iconf)的值?

0 个答案:

没有答案