Skip to content

Commit

Permalink
bugfix: openmp private declarations
Browse files Browse the repository at this point in the history
Declare indices of do loops (e.g. i,j,k) as private when using
$OMP PARALLEL DO PRIVATE(...)
  • Loading branch information
TomasTorsvik committed May 13, 2021
1 parent 26db3ed commit fcbc610
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 83 deletions.
12 changes: 6 additions & 6 deletions hamocc/blom2hamocc.F
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ subroutine blom2hamocc(m,n,mm,nn)
c --- calculate pressure at interfaces (necesarry since p has
c --- not been calculated at restart)
c
c$OMP PARALLEL DO PRIVATE(kn)
c$OMP PARALLEL DO PRIVATE(k,kn,l,i)
do j=1,jj
do k=1,kk
kn=k+nn
Expand All @@ -85,7 +85,7 @@ subroutine blom2hamocc(m,n,mm,nn)
c --- 2D fields
c --- ------------------------------------------------------------------
c
c$OMP PARALLEL DO
c$OMP PARALLEL DO PRIVATE(i)
do j=1,jj
do i=1,ii
c
Expand All @@ -102,7 +102,7 @@ subroutine blom2hamocc(m,n,mm,nn)
c --- 3D fields
c --- ------------------------------------------------------------------
c
c$OMP PARALLEL DO PRIVATE(kn,th,s,p1,p2,ldp,pa)
c$OMP PARALLEL DO PRIVATE(k,kn,l,i,th,s,p1,p2,ldp,pa)
do j=1,jj
do k=1,kk
kn=k+nn
Expand Down Expand Up @@ -147,7 +147,7 @@ subroutine blom2hamocc(m,n,mm,nn)
c --- pass tracer fields from ocean model; convert mol/kg -> kmol/m^3
c --- ------------------------------------------------------------------
c
c$OMP PARALLEL DO PRIVATE(kn)
c$OMP PARALLEL DO PRIVATE(k,kn,l,i)
do j=1,jj
do k=1,kk
kn=k+nn
Expand All @@ -169,7 +169,7 @@ subroutine blom2hamocc(m,n,mm,nn)
#ifndef sedbypass
nns=(n-1)*ks
c
c$OMP PARALLEL DO PRIVATE(kn)
c$OMP PARALLEL DO PRIVATE(k,kn,l,i)
c
do j=1,jj
do k=1,ks
Expand All @@ -192,7 +192,7 @@ subroutine blom2hamocc(m,n,mm,nn)
c --- ------------------------------------------------------------------
c
#if defined(BOXATM)
c$OMP PARALLEL DO
c$OMP PARALLEL DO PRIVATE(i)
do j=1,jj
do i=1,ii
atm(i,j,:) = atm2(i,j,n,:)
Expand Down
4 changes: 2 additions & 2 deletions hamocc/carchm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ SUBROUTINE CARCHM(kpie,kpje,kpke,kbnd, &
!$OMP ,atco213,atco214,rco213,rco214,pco213,pco214,frac_aqg &
!$OMP ,frac_dicg,flux13d,flux13u,flux14d,flux14u,dissol13,dissol14 &
#endif
!$OMP )
!$OMP ,j,i)
DO k=1,kpke
DO j=1,kpje
DO i=1,kpie
Expand Down Expand Up @@ -557,7 +557,7 @@ SUBROUTINE CARCHM(kpie,kpje,kpke,kbnd, &
#ifdef cisonew
#ifndef sedbypass
do k=1,ks
!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
do j=1,kpje
do i=1,kpie
if(omask(i,j).gt.0.5) then
Expand Down
2 changes: 1 addition & 1 deletion hamocc/cyano.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ SUBROUTINE CYANO(kpie,kpje,kpke,kbnd,pddpo,omask,ptho)
! it is assumed here that this process is limited to the mixed layer
!
DO k=1,kmle
!$OMP PARALLEL DO PRIVATE(oldocetra,dano3)
!$OMP PARALLEL DO PRIVATE(i,oldocetra,dano3,ttemp,nfixtfac)
DO j=1,kpje
DO i=1,kpie
IF(omask(i,j).gt.0.5) THEN
Expand Down
2 changes: 1 addition & 1 deletion hamocc/dipowa.F90
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ subroutine dipowa(kpie,kpje,kpke,omask)
zcoeflo(ks) = 0.0 ! diffusion coefficient for bottom sediment layer

!$OMP PARALLEL DO &
!$OMP&PRIVATE(bolven,tredsy,sedb1,aprior,iv_oc)
!$OMP&PRIVATE(i,k,iv,l,bolven,tredsy,sedb1,aprior,iv_oc)
j_loop: do j=1,kpje

! calculate bottom ventilation rate for scaling of sediment-water exchange
Expand Down
12 changes: 6 additions & 6 deletions hamocc/hamocc2blom.F
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subroutine hamocc2blom(m,n,mm,nn)
c --- pass tracer fields to ocean model; convert kmol/m^3 -> mol/kg
c --- ------------------------------------------------------------------
c
c$OMP PARALLEL DO PRIVATE(kn)
c$OMP PARALLEL DO PRIVATE(k,kn,l,i)
do j=1,jj
do k=1,kk
kn=k+nn
Expand All @@ -86,7 +86,7 @@ subroutine hamocc2blom(m,n,mm,nn)
nns=(n-1)*ks
mms=(m-1)*ks

c$OMP PARALLEL DO PRIVATE(km,kn)
c$OMP PARALLEL DO PRIVATE(k,km,kn,l,i)
do j=1,jj
do k=1,ks
km=k+mms
Expand All @@ -107,8 +107,8 @@ subroutine hamocc2blom(m,n,mm,nn)
enddo
enddo
c$OMP END PARALLEL DO
c
c$OMP PARALLEL DO PRIVATE(kn)
c
c$OMP PARALLEL DO PRIVATE(k,kn,l,i)
do j=1,jj
do k=1,ks
kn=k+nns
Expand All @@ -129,7 +129,7 @@ subroutine hamocc2blom(m,n,mm,nn)
c --- ------------------------------------------------------------------
c
#if defined(BOXATM)
c$OMP PARALLEL DO
c$OMP PARALLEL DO PRIVATE(i)
do j=1,jj
do i=1,ii ! time smoothing (analog to tmsmt2.F)
atm2(i,j,m,:) = wts1*atm2(i,j,m,:) ! mid timelevel
Expand All @@ -139,7 +139,7 @@ subroutine hamocc2blom(m,n,mm,nn)
enddo
c$OMP END PARALLEL DO
c
c$OMP PARALLEL DO
c$OMP PARALLEL DO PRIVATE(i)
do j=1,jj
do i=1,ii
atm2(i,j,n,:) = atm(i,j,:) ! new time level replaces old time level here
Expand Down
10 changes: 5 additions & 5 deletions hamocc/hamocc4bcm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ SUBROUTINE HAMOCC4BCM(kpie,kpje,kpke,kbnd,kplyear,kplmon,kplday,kldtday,&
!--------------------------------------------------------------------
! Pass net solar radiation
!
!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
DO j=1,kpje
DO i=1,kpie
strahl(i,j)=pfswr(i,j)
Expand All @@ -157,7 +157,7 @@ SUBROUTINE HAMOCC4BCM(kpie,kpje,kpke,kbnd,kplyear,kplmon,kplday,kldtday,&
! Pass atmospheric co2 if coupled to an active atmosphere model
!
#if defined(PROGCO2) || defined(DIAGCO2)
!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
DO j=1,kpje
DO i=1,kpie
atm(i,j,iatmco2)=patmco2(i,j)
Expand Down Expand Up @@ -203,7 +203,7 @@ SUBROUTINE HAMOCC4BCM(kpie,kpje,kpke,kbnd,kplyear,kplmon,kplday,kldtday,&

do l=1,nocetra
do K=1,kpke
!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
do J=1,kpje
do I=1,kpie
if (OMASK(I,J) .gt. 0.5 ) then
Expand Down Expand Up @@ -312,7 +312,7 @@ SUBROUTINE HAMOCC4BCM(kpie,kpje,kpke,kbnd,kplyear,kplmon,kplday,kldtday,&
!--------------------------------------------------------------------
! Pass co2 flux. Convert unit from kmol/m^2 to kg/m^2/s.

!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
DO j=1,kpje
DO i=1,kpie
if(omask(i,j) .gt. 0.5) pflxco2(i,j)=-44.*atmflx(i,j,iatmco2)/dtbgc
Expand All @@ -324,7 +324,7 @@ SUBROUTINE HAMOCC4BCM(kpie,kpje,kpke,kbnd,kplyear,kplmon,kplday,kldtday,&
!--------------------------------------------------------------------
! Pass dms flux. Convert unit from kmol/m^2 to kg/m^2/s.

!$OMP PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i)
DO j=1,kpje
DO i=1,kpie
if(omask(i,j) .gt. 0.5) pflxdms(i,j)=-62.13*atmflx(i,j,iatmdms)/dtbgc
Expand Down
Loading

0 comments on commit fcbc610

Please sign in to comment.