Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

common block problem in openmp Fortran

$
0
0
my code is:

 program
 ...
 ! Loop which I want to parallelize
 !$OMP parallel DO
 I = 1, N
 ...
 call FORD(i,j)
  ...
 !$OMP END parallel DO
 end program

  subroutine FORD(i,j)
  logical servo,genflg,lapflg
  dimension c(nvarc)
  dimension zl(3),zg(3),v1(3,3),v2(3,3),rn(3),
 .          rcg1(3),rcg2(3),ru1(3),ru2(3),
 .          rott1(3),rott2(3),velr(3),dt(3),
 .          dfs(3),ftu(3),fnr(3),amomet(3
  common /contact/ iab11,iab22,xx2,yy2,zz2,
 .                 ra1,rb1,rc1,ra2,rb2,rc2,
 .                 v1,v2,
 .                 xg1,yg1,zg1,xg2,yg2,zg2
  common /ellip/ b1,c1,f1,g1,h1,d1,
 .               b2,c2,f2,g2,h2,p2,q2,r2,d2
  common /root/ root1,root2
  common /tab1/
 .       itype(ndim1),nconti(5),nvarc,
 .       nconta,nconta1
  common /bal1/
 .       ra(5),rb(5),rc(5),
 .       amomen(ndim),fwall(6),press(3),wmomet(6,2),
 .       rot(ndim),ttheta(ndim*3),rstp(ndim*3),forces(ndim),
 .       ssampl(3,3),edserv(3,3),tdisp(ndim),adisp(ndim),vel(ndim),
 .       del(3),xmax(3)

CALL CONDACT(genflg,lapflg)
return
end subroutine

SUBROUTINE CONDACT(genflg,lapflg)
implicit double precision (a-h,o-z)
logical rflag,dflag,error,gmvflg,grvflg,ctrlflg,depflg
  parameter (ndim1 = 20002)
  parameter (ndim = 3*ndim1)
  parameter (nkmm = 9000000)
  parameter (nkwall = 50000)
  character*4 hed
  logical genflg,lapflg,fast
  dimension v1(3,3),v2(3,3)
  common /contact/ iab11,iab22,xx2,yy2,zz2,
 .                 ra1,rb1,rc1,ra2,rb2,rc2,
 .                 v1,v2,
 .                 xg1,yg1,zg1,xg2,yg2,zg2
  common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2
  common /switch/ nk
  common /root/ root1,root2
  common /nroot/ rt(5),nrt
  common /bal2/xmax(3)

 call function f(x)
 C
 C......
 C

 RETURN
 END

  function f(x)
  implicit double precision (a-h,o-z)
  common /contact/ iab11,iab22,xx2,yy2,zz2,
 .                 ra1,rb1,rc1,ra2,rb2,rc2,
 .                 v1,v2,
 .                 xg1,yg1,zg1,xg2,yg2,zg2
  common /ellip/ b1,c1,f1,g1,h1,d1,
 .               b2,c2,f2,g2,h2,p2,q2,r2,d2
  common /switch/ nk
  common /nroot/ rt(5),nrt
  dimension a(3,3),b(3),v1(3,3),v2(3,3)
  ..
  ..
  ..
  ..
  end

 

my question is inside the parallel loop, does all variable (within common block or outside of common block) in each subroutine are private? 1. If not, should I use threadprivate for the common blocks and private the variables in each subroutine after declaration? 2. Each thread passes through 2 subroutine and one function. Subroutines has some same common block and variables. if I use threadprivate common blocks for each subroutine, how do the variable values pass through the entire program for a single thread. Any help will be appreciated. Thanks.


Viewing all articles
Browse latest Browse all 3108


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>