subroutine momtum_hs(m,n) use mod_xc ! HYCOM communication interface use mod_pipe ! HYCOM debugging interface use mod_tides ! HYCOM tides #if defined (NERSC_VERSION) use mod_common_ice ! #if defined (WAVES_DRIFT) ! !TW: where to add wave stress (after testing) ! use mod_common_wavesice,only:taux_wav_ocn,tauy_wav_ocn ! #endif #endif implicit none c include 'common_blocks.h' c integer m,n c c --- ----------------------------------------- c --- hydrostatic equation (and surface stress) c --- ----------------------------------------- c logical, parameter :: lpipe_momtum=.false. !usually .false. real, parameter :: dragw_rho=0.00536*1026.0 !ice-ocean drag from CICE c real, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) :: & stress,stresx,stresy,dpmx,thkbop,oneta, & vis2u,vis4u,vis2v,vis4v,vort, & wgtia,wgtib,wgtja,wgtjb, & dl2u,dl2uja,dl2ujb,dl2v,dl2via,dl2vib, & tclmn,tclpn !see momtum4 common/momtumr4/ stress,stresx,stresy,dpmx,thkbop,oneta, & vis2u,vis4u,vis2v,vis4v,vort, & wgtia,wgtib,wgtja,wgtjb, & dl2u,dl2uja,dl2ujb,dl2v,dl2via,dl2vib, & tclmn,tclpn !see momtum4 save /momtumr4/ c real dpdn,dpup,q,simo,uimo,vimo,dpsur,psur,usur,vsur, & sumdp,sumth integer i,j,k,l,mbdy,hlstep #if defined (NERSC_VERSION) real :: faci #endif c * real*8 wtime * external wtime * real*8 wtime1(10),wtime2(20,kdm),wtimes c include 'stmt_fns.h' c mbdy = 6 c call xctilr(pu( 1-nbdy,1-nbdy,2 ),1, kk, 6,6, halo_us) call xctilr(pv( 1-nbdy,1-nbdy,2 ),1, kk, 6,6, halo_vs) call xctilr(dpmixl(1-nbdy,1-nbdy, m),1, 1, 6,6, halo_ps) call xctilr(dp( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_ps) call xctilr(dpu( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_us) call xctilr(dpv( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_vs) call xctilr(pbavg( 1-nbdy,1-nbdy,1 ),1, 3, 6,6, halo_ps) call xctilr(dpoldm(1-nbdy,1-nbdy,1 ),1, kk, 6,6, halo_ps) call xctilr(saln( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps) call xctilr(temp( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps) call xctilr(th3d( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps) c c --- tidal forcing c if(tidflg.eq.2) then hlstep=0 call tides_force(hlstep) endif c c --- hydrostatic equation (and surface stress) c * wtime1( 1) = wtime() c c --- rhs: th3d.m, temp.m, saln.m, p, pbavg.m c --- lhs: thstar, p, oneta, montg c margin = mbdy c !$OMP PARALLEL DO PRIVATE(j,l,k,i) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do l=1,isp(j) do i=max(1-margin,ifp(j,l)),min(ii+margin,ilp(j,l)) sumdp = 0.0 sumth = 0.0 do k=1,kk if (kapref.ne.0) then !thermobaric c c --- sigma-star is virtual potential density, as defined in c --- Sun et.al. (1999), 'Inclusion of thermobaricity in c --- isopycnic-coordinate ocean models', JPO 29 pp 2719-2729. c c --- use upper interface pressure in converting sigma to sigma-star. c --- to avoid density variations in layers intersected by bottom c if (kapref.gt.0) then thstar(i,j,k,1)=th3d(i,j,k,m) & +kappaf(temp(i,j,k,m), & saln(i,j,k,m), & p(i,j,k), & kapref) else thstar(i,j,k,1)=th3d(i,j,k,m) & +kappaf(temp(i,j,k,m), & saln(i,j,k,m), & p(i,j,k), & 2) thstar(i,j,k,2)=th3d(i,j,k,m) & +kappaf(temp(i,j,k,m), & saln(i,j,k,m), & p(i,j,k), & kapi(i,j)) endif !kapref else !non-thermobaric thstar(i,j,k,1)=th3d(i,j,k,m) endif !thermobaric:else c p(i,j,k+1)=p(i,j,k)+dp(i,j,k,m) c if (sshflg.ne.0) then sumth = sumth + dp(i,j,k,m)*th3d(i,j,k,m) sumdp = sumdp + dp(i,j,k,m) endif !sshflg enddo !k c if (sshflg.ne.0) then sumth = sumth / max( sumdp, onemm ) !vertical mean of th3d sumdp = sumdp*qonem * g !depth(m) * g steric(i,j) = sshgmn(i,j) + & (sshgmn(i,j) + sumdp) * & (thmean(i,j) - sumth) / & (1000.0+thbase+sumth) endif !sshflg c c --- store (1+eta) (= p_total/p_prime) in -oneta- oneta(i,j)=1.+pbavg(i,j,m)/p(i,j,kk+1) c c --- m_prime in lowest layer: montg(i,j,kk,1)=psikk(i,j,1)+ & ( p(i,j,kk+1)*(thkk(i,j,1)-thstar(i,j,kk,1)) & -pbavg(i,j,m)*(thstar(i,j,kk,1)+thbase) )*thref**2 if (kapref.eq.-1) then montg(i,j,kk,2)=psikk(i,j,2)+ & ( p(i,j,kk+1)*(thkk(i,j,2)-thstar(i,j,kk,2)) & -pbavg(i,j,m)*(thstar(i,j,kk,2)+thbase) )*thref**2 endif !kapref.eq.-1 c c --- m_prime in remaining layers: do k=kk-1,1,-1 montg(i,j,k,1)=montg(i,j,k+1,1)+p(i,j,k+1)*oneta(i,j) & *(thstar(i,j,k+1,1)-thstar(i,j,k,1))*thref**2 if (kapref.eq.-1) then montg(i,j,k,2)=montg(i,j,k+1,2)+p(i,j,k+1)*oneta(i,j) & *(thstar(i,j,k+1,2)-thstar(i,j,k,2))*thref**2 endif !kapref.eq.-1 enddo !k c c --- srfhgt (used diagnostically, in mxmyaij and for tidal SAL). if (kapref.ne.-1) then montg1(i,j) = montg(i,j,1,1) else montg1(i,j) = skap(i,j) *montg(i,j,1,1) + & (1.0-skap(i,j))*montg(i,j,1,2) endif !kapref srfhgt(i,j) = montg1(i,j) + thref*pbavg(i,j,m) c cdiag if (sshflg.ne.0) then cdiag if (itest.gt.0 .and. jtest.gt.0) then cdiag write (lp,'(i9,2i5,3x,a,2f12.6,f12.2)') cdiag& nstep,itest+i0,jtest+j0, cdiag& 'sssh =', cdiag& steric(i,j),sshgmn(i,j),sumdp cdiag write (lp,'(i9,2i5,3x,a,3f12.6)') cdiag& nstep,itest+i0,jtest+j0, cdiag& 'thmn =', cdiag& sumth,thmean(i,j),1000.0+thbase+sumth cdiag write (lp,'(i9,2i5,3x,a,3f12.6)') cdiag& nstep,itest+i0,jtest+j0, cdiag& 'ssh =', cdiag& srfhgt(i,j),steric(i,j),srfhgt(i,j)-steric(i,j) cdiag endif !test cdiag endif !sshflg c c --- tidal corrections, note that these are not part of montg c --- but are included here to simplify the pressure gradient if (tidflg.gt.0 .and. sshflg.eq.0) then !tides do k=1,kk montg(i,j,k,1)=montg(i,j,k,1) & -g*etide(i,j)-tidsal*srfhgt(i,j) if (kapref.eq.-1) then montg(i,j,k,2)=montg(i,j,k,2) & -g*etide(i,j)-tidsal*srfhgt(i,j) endif !kapref.eq.-1 enddo !k elseif (tidflg.gt.0 .and. sshflg.ne.0) then !tides do k=1,kk montg(i,j,k,1)=montg(i,j,k,1) & -g*etide(i,j) & -tidsal*(srfhgt(i,j)-steric(i,j)) if (kapref.eq.-1) then montg(i,j,k,2)=montg(i,j,k,2) & -g*etide(i,j) & -tidsal*(srfhgt(i,j)-steric(i,j)) endif !kapref.eq.-1 enddo !k endif !tides (sshflg) enddo !i enddo !l enddo !j !$OMP END PARALLEL DO c * wtime1( 2) = wtime() call dpudpv(dpu(1-nbdy,1-nbdy,1,m), & dpv(1-nbdy,1-nbdy,1,m), & p,depthu,depthv, max(0,margin-1)) * wtime1( 3) = wtime() c c --- account for temporal smoothing of mid-time dpmixl. calculate the vertical c --- excursions of the coordinates immediately above and below the mixed c --- layer base, then vertically interpolate this motion to dpmixl(i,j,m) c if(hybrid .and. mxlkta) then c c --- rhs: dpoldm, dpmixl.m c --- lhs: util1, util2 c margin = mbdy c !$OMP PARALLEL DO PRIVATE(j,l,i,k,dpup,dpdn,q) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do l=1,isp(j) do i=max(1-margin,ifp(j,l)),min(ii+margin,ilp(j,l)) util1(i,j)=0. util2(i,j)=0. enddo !i do k=1,kk do i=max(1-margin,ifp(j,l)),min(ii+margin,ilp(j,l)) util1(i,j)=util2(i,j) util2(i,j)=util2(i,j)+dpoldm(i,j,k) if (util2(i,j).ge.dpmixl(i,j,m).and. & util1(i,j).lt.dpmixl(i,j,m) ) then dpup=p(i,j,k )-util1(i,j) dpdn=p(i,j,k+1)-util2(i,j) q=(util2(i,j)-dpmixl(i,j,m))/max(onemm,dpoldm(i,j,k)) dpmixl(i,j,m)=dpmixl(i,j,m)+(dpdn+q*(dpup-dpdn)) endif enddo !i enddo !k enddo !l enddo !j !$OMP END PARALLEL DO endif c c --- -------------- c --- surface stress c --- -------------- c if (windf) then margin = 0 c !$OMP PARALLEL DO PRIVATE(j,l,i,k,dpsur,psur,usur,vsur,uimo,vimo,simo !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do l=1,isp(j) do i=max(1-margin,ifp(j,l)),min(ii+margin,ilp(j,l)) if (wndflg.eq.2) then ! tau on p grid surtx(i,j)=( taux(i,j,l0)*w0+taux(i,j,l1)*w1 & +taux(i,j,l2)*w2+taux(i,j,l3)*w3) surty(i,j)=( tauy(i,j,l0)*w0+tauy(i,j,l1)*w1 & +tauy(i,j,l2)*w2+tauy(i,j,l3)*w3) else ! tau on u&v grids - NOT RECOMMEDED surtx(i,j)=( (taux(i,j,l0)+taux(i+1,j,l0))*w0 & +(taux(i,j,l1)+taux(i+1,j,l1))*w1 & +(taux(i,j,l2)+taux(i+1,j,l2))*w2 & +(taux(i,j,l3)+taux(i+1,j,l3))*w3)*0.5 surty(i,j)=( (tauy(i,j,l0)+tauy(i,j+1,l0))*w0 & +(tauy(i,j,l1)+tauy(i,j+1,l1))*w1 & +(tauy(i,j,l2)+tauy(i,j+1,l2))*w2 & +(tauy(i,j,l3)+tauy(i,j+1,l3))*w3)*0.5 endif #if defined(NERSC_VERSION) c --- Use Stress directly from EVP model. Current averaging has c --- already been taken care of there. c --- TODO: Apparently tauxice and tauyice must be on p-grid now c --- TODO: check this in ice model faci=ficem(i,j) surtx(i,j)=surtx(i,j)*(1.-faci) + faci*0.5* & (tauxice(i,j)+tauxice(i+1,j )) surty(i,j)=surty(i,j)*(1.-faci) + faci*0.5* & (tauyice(i,j)+tauyice(i ,j+1)) #else if (iceflg.eq.2 .and. si_c(i,j).gt.0.0) then c --- average currents over top 10m usur = 0.0 vsur = 0.0 psur = 0.0 do k= 1,kk dpsur = min( dp(i,j,k,n), max( 0.0, tenm - psur ) ) usur = usur + dpsur*(u(i,j,k,n)+u(i+1,j,k,n)) vsur = vsur + dpsur*(v(i,j,k,n)+v(i,j+1,k,n)) psur = psur + dpsur if (dpsur.eq.0.0) then exit endif enddo !k usur = 0.5*( usur/psur + ubavg(i, j,n) + & ubavg(i+1,j,n) ) vsur = 0.5*( vsur/psur + vbavg(i,j, n) + & vbavg(i,j+1,n) ) c allow for ice-ocean stress uimo = si_u(i,j) - usur vimo = si_v(i,j) - vsur simo = sqrt( uimo**2 + vimo**2 ) surtx(i,j)=(1.0-si_c(i,j))*surtx(i,j) + & si_c(i,j) *dragw_rho*simo*uimo surty(i,j)=(1.0-si_c(i,j))*surty(i,j) + & si_c(i,j) *dragw_rho*simo*vimo endif !ice-ocean stress #endif /* defined NERSC_VERSION */ enddo !i enddo !l enddo !j !$OMP END PARALLEL DO c call xctilr(surtx,1,1, 6,6, halo_ps) call xctilr(surty,1,1, 6,6, halo_ps) endif !windf c return end c subroutine momtum(m,n) use mod_xc ! HYCOM communication interface use mod_pipe ! HYCOM debugging interface use mod_tides ! HYCOM tides implicit none c include 'common_blocks.h' c integer m,n c c --- ------------------------------------------------------ c --- momentum equations (2nd order version) c c --- Enstrophy conserving advection scheme (Sadourney, 1975) c c --- diffusion is Laplacian and/or biharmonic, both with c --- "constant" and deformation dependent coefficients. c c --- hydrostatic equation and surface stress via momtum_hs c --- ------------------------------------------------------ c logical, parameter :: lpipe_momtum=.false. !usually .false. c real, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) :: & stress,stresx,stresy,dpmx,thkbop,oneta, & vis2u,vis4u,vis2v,vis4v,vort, & wgtia,wgtib,wgtja,wgtjb, & dl2u,dl2uja,dl2ujb,dl2v,dl2via,dl2vib, & tclmn,tclpn !see momtum4 common/momtumr4/ stress,stresx,stresy,dpmx,thkbop,oneta, & vis2u,vis4u,vis2v,vis4v,vort, & wgtia,wgtib,wgtja,wgtjb, & dl2u,dl2uja,dl2ujb,dl2v,dl2via,dl2vib, & tclmn,tclpn !see momtum4 save /momtumr4/ c integer ifirst save ifirst c real dpia,dpib,dpja,dpjb,vis2a,vis4a,vis2b,vis4b, & scuya,scuyb,scvxa,scvxb,vmag,dall,adrlim, & dpxy,ptopl,pbotl,cutoff,qcutoff,h1,q,deform,aspy2,aspx2, & dt1inv,phi,plo,pbop,pthkbl,ubot,vbot,pstres, & dmontg,dthstr,dragu,dragv,qdpu,qdpv,dpthin integer i,ia,ib,j,ja,jb,k,ka,l,mbdy c * real*8 wtime * external wtime * real*8 wtime1(10),wtime2(20,kdm),wtimes c character text*12 integer, save, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) :: & mask c real hfharm,a,b include 'stmt_fns.h' c c --- harmonic mean divided by 2 hfharm(a,b)=a*b/(a+b) c data ifirst / 0 / c mbdy = 6 c call xctilr(u( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_uv) call xctilr(v( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_vv) call xctilr(ubavg(1-nbdy,1-nbdy,1 ),1, 3, 6,6, halo_uv) call xctilr(vbavg(1-nbdy,1-nbdy,1 ),1, 3, 6,6, halo_vv) call xctilr(uflx( 1-nbdy,1-nbdy,1 ),1, kk, 6,6, halo_uv) call xctilr(vflx( 1-nbdy,1-nbdy,1 ),1, kk, 6,6, halo_vv) c if (ifirst.eq.0) then ifirst=1 c --- setup zero fill. margin = mbdy c do j=1-margin,jj+margin do i=1-margin,ii+margin vis2u(i,j)=0.0 vis4u(i,j)=0.0 vis2v(i,j)=0.0 vis4v(i,j)=0.0 dl2u( i,j)=0.0 dl2v( i,j)=0.0 enddo !i enddo !j endif c c --- --------------------------------------- c --- hydrostatic equation and surface stress c --- --------------------------------------- c call momtum_hs(m,n) c c +++ ++++++++++++++++++ c +++ momentum equations c +++ ++++++++++++++++++ c * wtime1( 4) = wtime() c c --- rhs: p, u.n+, v.n+, ubavg.n+, vbavg.n+, depthv+, pvtrop+ c --- rhs: dpmixl.m+, taux+, dpu, depthu+, dpv, tauy+ c --- lhs: util1, util2, drag, ubrhs, stresx, vbrhs, stresy c if (drglim.gt.0.0) then adrlim = drglim else adrlim = 0.125 endif dt1inv = 1./delt1 c margin = mbdy - 1 c !$OMP PARALLEL DO PRIVATE(j,l,i,k, !$OMP& phi,plo,pbop,ubot,vbot,vmag,dall,pstres) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin c do l=1,isp(j) do i=max(1-margin,ifp(j,l)),min(ii+margin,ilp(j,l)) c c --- bottom drag (standard bulk formula) c --- bottom stress is applied over thickness dp00 for the kpp bottom c --- b.l. just as for the surface b.l. otherwise, bottom stress is c --- applied over thickness thkbot c if (mxlkpp .and. bblkpp) then thkbop(i,j)=dp00 !bottom stress applied over this thknss else thkbop(i,j)=thkbot*onem !bottom stress applied over this thknss endif c c --- the bottom stress term is estimated using velocity averaged over the c --- bottom boundary layer. this thickness is dpbbl for the kpp boundary c --- layer; otherwise, it is thkbop ubot=0.0 vbot=0.0 if (mxlkpp .and. bblkpp) then pthkbl=max(dpbbl(i,j),thkbop(i,j)) !thknss of bot. b.l. else pthkbl=thkbop(i,j) !thknss of bot. b.l. endif pbop=p(i,j,kk+1)-pthkbl !top of bot. b.l. phi =max(p(i,j,1),pbop) do k=1,kk plo =phi ! max(p(i,j,k),pbop) phi =max(p(i,j,k+1),pbop) ubot=ubot + (u(i,j,k,n)+u(i+1,j,k,n))*(phi-plo) vbot=vbot + (v(i,j,k,n)+v(i,j+1,k,n))*(phi-plo) enddo !k ubot=ubot/min(pthkbl,p(i,j,kk+1)) & + (ubavg(i,j,n)+ubavg(i+1,j,n)) vbot=vbot/min(pthkbl,p(i,j,kk+1)) & + (vbavg(i,j,n)+vbavg(i,j+1,n)) vmag=0.5*sqrt(ubot**2+vbot**2) dall=cb*(vmag+cbar) !no tidal drag drag(i,j)=dall/min(thkbop(i,j)*qonem,depths(i,j)) if (mxlkpp .and. bblkpp) then ustarb(i,j)=sqrt(dall*vmag) endif c c --- tidal bottom drag c util6(i,j)=thkdrg*onem !bottom stress applied over this thknss util5(i,j)=dragrh(i,j)/min(util6(i,j)*qonem,depths(i,j)) enddo !i enddo !l c c --- store r.h.s. of barotropic u/v eqn. in -ubrhs,vbrhs- c --- time-interpolate wind stress c do l=1,isu(j) do i=max(1-margin,ifu(j,l)),min(ii+margin,ilu(j,l)) ubrhs(i,j)= & (vbavg(i ,j, m)*depthv(i ,j) & +vbavg(i ,j+1,m)*depthv(i ,j+1) & +vbavg(i-1,j, m)*depthv(i-1,j) & +vbavg(i-1,j+1,m)*depthv(i-1,j+1)) & *(pvtrop(i,j)+pvtrop(i,j+1))*.125 c if (windf) then if(hybrid .and. mxlkrt) then pstres=0.5*(dpmixl(i,j,m)+dpmixl(i-1,j,m)) else pstres=dpu(i,j,1,m) endif c --- units of surtx are N/m^2 (i.e. Pa) stresx(i,j)=(surtx(i,j)+surtx(i-1,j))*0.5*g & /(pstres*thref) else ! no taux stresx(i,j)=0. endif !windf:else enddo !i enddo !l do l=1,isv(j) do i=max(1-margin,ifv(j,l)),min(ii+margin,ilv(j,l)) vbrhs(i,j)= & -(ubavg(i, j ,m)*depthu(i,j ) & +ubavg(i+1,j ,m)*depthu(i+1,j ) & +ubavg(i, j-1,m)*depthu(i,j-1) & +ubavg(i+1,j-1,m)*depthu(i+1,j-1)) & *(pvtrop(i,j)+pvtrop(i+1,j))*.125 c if (windf) then if(hybrid .and. mxlkrt) then pstres=0.5*(dpmixl(i,j,m)+dpmixl(i,j-1,m)) else pstres=dpv(i,j,1,m) endif c --- units of surty are N/m^2 (i.e. Pa) stresy(i,j)=(surty(i,j)+surty(i,j-1))*0.5*g & /(pstres*thref) else ! no tauy stresy(i,j)=0. endif !windf:else enddo !i enddo !l enddo !j !$OMP END PARALLEL DO c if (lpipe .and. lpipe_momtum) then c --- compare two model runs. write (text,'(a9,i3)') 'uba.n n=',n call pipe_compare(ubavg(1-nbdy,1-nbdy,n),iu,text) write (text,'(a9,i3)') 'vba.n n=',n call pipe_compare(vbavg(1-nbdy,1-nbdy,n),iv,text) write (text,'(a9,i3)') 'drag k=',0 call pipe_compare(drag,ip,text) endif c c --- the old momeq2.f starts here c dpthin = 0.001*onemm h1 = tenm !used in lateral weighting of hor.pres.grad. cutoff = 0.5*onem qcutoff = 1.0/cutoff c * wtime1( 5) = wtime() c c --- rhs: 0.0 c --- lhs: util1, util2 c * margin = mbdy - 2 c !$OMP PARALLEL DO PRIVATE(j,i) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do i=1-margin,ii+margin c --- spatial weighting function for pressure gradient calculation: util1(i,j)=0. util2(i,j)=0. enddo !i enddo !j c do 9 k=1,kk c c --- store total (barotropic plus baroclinic) flow at old and mid time in c --- -utotn,vtotn- and -utotm,vtotm- respectively. store minimum thickness c --- values for use in pot.vort. calculation in -dpmx-. c * wtime2( 1,k) = wtime() c c --- rhs: dpmx, dp.m+ c --- lhs: dpmx c * margin = mbdy - 2 c do i=1-margin,ii+margin dpmx(i,1-margin)=2.*cutoff enddo !i !$OMP PARALLEL DO PRIVATE(j,i) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do i=1-margin,ii+margin dpmx(i,j+1)=2.*cutoff enddo !i do l=1,isu(j) do i=max(1-margin,ifu(j,l)),min(ii+margin,ilu(j,l)) dpmx(i,j+1)=max(dpmx(i,j+1),dp(i,j,k,m)+dp(i-1,j,k,m)) enddo !i enddo !l enddo !j c * wtime2( 2,k) = wtime() c c --- rhs: ubavg.m, ubavg.n, dp.m+, dpu c --- lhs: utotm, utotn, uflux, dpmx, pu c * margin = mbdy - 2 c !$OMP PARALLEL DO PRIVATE(j,l,i) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do l=1,isu(j) c i=ifu(j,l)-1 if (i.ge.1-margin) then if (iuopn(i,j).ne.0) then utotm(i,j)=u(i+1,j,k,m)+ubavg(i,j,m) utotn(i,j)=u(i+1,j,k,n)+ubavg(i,j,n) uflux(i,j)=utotm(i,j)*max(dp(i,j,k,m),cutoff) endif endif i=ilu(j,l)+1 if (i.le.ii+margin) then if (iuopn(i,j).ne.0) then utotm(i,j)=u(i-1,j,k,m)+ubavg(i,j,m) utotn(i,j)=u(i-1,j,k,n)+ubavg(i,j,n) uflux(i,j)=utotm(i,j)*max(dp(i-1,j,k,m),cutoff) endif endif c do i=max(1-margin,ifu(j,l)),min(ii+margin,ilu(j,l)) dpmx(i,j)=max(dpmx(i,j),dp(i,j,k,m)+dp(i-1,j,k,m)) utotm(i,j)=u(i,j,k,m)+ubavg(i,j,m) utotn(i,j)=u(i,j,k,n)+ubavg(i,j,n) uflux(i,j)=utotm(i,j)*max(dpu(i,j,k,m),cutoff) pu(i,j,k+1)=pu(i,j,k)+dpu(i,j,k,m) enddo !i enddo !l enddo !j !$OMP END PARALLEL DO c * wtime2( 3,k) = wtime() c c --- rhs: vbavg.m, vbavg.n, dp.m+, dpv c --- lhs: vtotm, vtotn, vflux, dpmx, pv c * margin = mbdy - 2 c do i=1-margin,ii+margin do l=1,jsv(i) j=jfv(i,l)-1 if (j.ge.1-margin) then if (ivopn(i,j).ne.0) then vtotm(i,j)=v(i,j+1,k,m)+vbavg(i,j,m) vtotn(i,j)=v(i,j+1,k,n)+vbavg(i,j,n) vflux(i,j)=vtotm(i,j)*max(dp(i,j,k,m),cutoff) endif endif j=jlv(i,l)+1 if (j.le.jj+margin) then if (ivopn(i,j).ne.0) then vtotm(i,j)=v(i,j-1,k,m)+vbavg(i,j,m) vtotn(i,j)=v(i,j-1,k,n)+vbavg(i,j,n) vflux(i,j)=vtotm(i,j)*max(dp(i,j-1,k,m),cutoff) endif endif enddo !l enddo !i c * wtime2( 4,k) = wtime() !$OMP PARALLEL DO PRIVATE(j,l,i) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin do l=1,isv(j) do i=max(1-margin,ifv(j,l)),min(ii+margin,ilv(j,l)) dpmx(i ,j)=max(dpmx(i ,j),dp(i,j,k,m)+dp(i,j-1,k,m)) dpmx(i+1,j)=max(dpmx(i+1,j),dp(i,j,k,m)+dp(i,j-1,k,m)) vtotm(i,j)=v(i,j,k,m)+vbavg(i,j,m) vtotn(i,j)=v(i,j,k,n)+vbavg(i,j,n) vflux(i,j)=vtotm(i,j)*max(dpv(i,j,k,m),cutoff) pv(i,j,k+1)=pv(i,j,k)+dpv(i,j,k,m) enddo !i enddo !l enddo !j c c --- define auxiliary velocity fields (via,vib,uja,ujb) to implement c --- sidewall friction along near-vertical bottom slopes. wgtja,wgtjb,wgtia, c --- wgtib indicate the extent to which a sidewall is present. c * wtime2( 5,k) = wtime() c c --- rhs: pu, depthu+, utotn+, wgtja c --- lhs: wgtja, wgtjb, uja, ujb, dl2u c --- rhs: pv, depthv+, vtotn+, wgtia c --- lhs: wgtia, wgtib, via, vib, dl2v c --- rhs: vtotm, vort+, corio+, dp.m+, dpmx+, vtotn c --- lhs: vort, potvor, defor2 c * margin = mbdy - 2 c !$OMP PARALLEL DO PRIVATE(j,ja,jb,l,i,ia,ib,aspy2,aspx2) !$OMP& SCHEDULE(STATIC,jblk) do j=1-margin,jj+margin c --- assume margin to properly commute pressure torque from layer to layer c> Jul. 2000 - loop reordering and logic changes for OpenMP c> Aug. 2000 - loop 117 executed only when hybrid vertical coordinate is used c> Oct. 2001 - replaced biharm with veldf[24] and visco[24] c> Sep. 2004 - kapref selects one of three thermobaric reference states c> Jun. 2006 - split out momtum_hs, for initial ssh calculation c> Nov. 2006 - inserted volume-force for tide c> Apr. 2007 - added drglim, implicit or CFL-limited explicit bottom drag c> Apr. 2007 - added dragrh, linear tidal drag based on bottom roughness c> Apr. 2007 - btrlfr: moved [uvp]bavg assignment to barotp c> Jun. 2007 - added momtum4 c> Nov 2009 - several bugfixes to momtum4