我有几个关于在 Fortran 并行编程中使用公共块的问题。
我的子程序有共同的块。我是否必须在并行执行区域中声明所有公共块和线程私有?
他们如何传递信息?我想为每个线程单独的公共时钟,并希望它们通过并行区域的末端传递信息。它发生在这里吗?
我的
Ford
子例程更改了公共块中的一些变量,并且Condact
子例程再次覆盖它们,但该函数使用来自Condact
子例程的值。第二个子例程和函数是否从每个线程的前一个子例程中复制变量?program ... ! Loop which I want to parallelize !$OMP parallel DO !do I need to declear all common block and threadprivate them here? I = 1, N ... call FORD(i,j) ... !$OMP END parallel DO end program subroutine FORD(i,j) dimension zl(3),zg(3) common /ellip/ b1,c1,f1,g1,h1,d1, . b2,c2,f2,g2,h2,p2,q2,r2,d2 common /root/ root1,root2 !$OMP threadprivate (/ellip/,/root/) !this subroutine rewrite values of b1, c1 and f1 variable. CALL CONDACT(genflg,lapflg) return end subroutine SUBROUTINE CONDACT(genflg,lapflg) common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2 !$OMP threadprivate (/ellip/) ! this subroutine rewrite b1, c1 and f1 again call function f(x) RETURN END function f(x) common /ellip/ b1,c1,f1,g1,h1,d1, . b2,c2,f2,g2,h2,p2,q2,r2,d2 !$OMP threadprivate (/ellip/) ! here the function uses the value of b1, c1, f1 from CONDAT subroutine. end