/[MITgcm]/MITgcm/pkg/mom_vecinv/mom_vecinv.F
ViewVC logotype

Diff of /MITgcm/pkg/mom_vecinv/mom_vecinv.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.60 by jmc, Thu Nov 23 00:45:21 2006 UTC revision 1.66 by jmc, Sun Mar 18 22:24:01 2012 UTC
# Line 4  C $Name$ Line 4  C $Name$
4  #include "MOM_VECINV_OPTIONS.h"  #include "MOM_VECINV_OPTIONS.h"
5    
6        SUBROUTINE MOM_VECINV(        SUBROUTINE MOM_VECINV(
7       I        bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown,       I        bi,bj,k,iMin,iMax,jMin,jMax,
8       I        KappaRU, KappaRV,       I        KappaRU, KappaRV,
9       U        fVerU, fVerV,       I        fVerUkm, fVerVkm,
10         O        fVerUkp, fVerVkp,
11       O        guDiss, gvDiss,       O        guDiss, gvDiss,
12       I        myTime, myIter, myThid)       I        myTime, myIter, myThid )
13  C     /==========================================================\  C     *==========================================================*
14  C     | S/R MOM_VECINV                                           |  C     | S/R MOM_VECINV                                           |
15  C     | o Form the right hand-side of the momentum equation.     |  C     | o Form the right hand-side of the momentum equation.     |
16  C     |==========================================================|  C     *==========================================================*
17  C     | Terms are evaluated one layer at a time working from     |  C     | Terms are evaluated one layer at a time working from     |
18  C     | the bottom to the top. The vertically integrated         |  C     | the bottom to the top. The vertically integrated         |
19  C     | barotropic flow tendency term is evluated by summing the |  C     | barotropic flow tendency term is evluated by summing the |
# Line 23  C     | for the diffusion equation bc wi Line 24  C     | for the diffusion equation bc wi
24  C     | form produces a diffusive flux that does not scale with  |  C     | form produces a diffusive flux that does not scale with  |
25  C     | open-area. Need to do something to solidfy this and to   |  C     | open-area. Need to do something to solidfy this and to   |
26  C     | deal "properly" with thin walls.                         |  C     | deal "properly" with thin walls.                         |
27  C     \==========================================================/  C     *==========================================================*
28        IMPLICIT NONE        IMPLICIT NONE
29    
30  C     == Global variables ==  C     == Global variables ==
# Line 44  C     == Global variables == Line 45  C     == Global variables ==
45  #endif  #endif
46    
47  C     == Routine arguments ==  C     == Routine arguments ==
48  C     fVerU  :: Flux of momentum in the vertical direction, out of the upper  C     bi,bj   :: current tile indices
49  C     fVerV  :: face of a cell K ( flux into the cell above ).  C     k       :: current vertical level
50  C     guDiss :: dissipation tendency (all explicit terms), u component  C     iMin,iMax,jMin,jMax :: loop ranges
51  C     gvDiss :: dissipation tendency (all explicit terms), v component  C     fVerU   :: Flux of momentum in the vertical direction, out of the upper
52  C     bi, bj, iMin, iMax, jMin, jMax - Range of points for which calculation  C     fVerV   :: face of a cell K ( flux into the cell above ).
53  C                                      results will be set.  C     fVerUkm :: vertical viscous flux of U, interface above (k-1/2)
54  C     kUp, kDown                     - Index for upper and lower layers.  C     fVerVkm :: vertical viscous flux of V, interface above (k-1/2)
55  C     myThid :: my Thread Id number  C     fVerUkp :: vertical viscous flux of U, interface below (k+1/2)
56    C     fVerVkp :: vertical viscous flux of V, interface below (k+1/2)
57    
58    C     guDiss  :: dissipation tendency (all explicit terms), u component
59    C     gvDiss  :: dissipation tendency (all explicit terms), v component
60    C     myTime  :: current time
61    C     myIter  :: current time-step number
62    C     myThid  :: my Thread Id number
63          INTEGER bi,bj,k
64          INTEGER iMin,iMax,jMin,jMax
65        _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
66        _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
67        _RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerUkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
68        _RL fVerV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerVkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
69          _RL fVerUkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
70          _RL fVerVkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
71        _RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72        _RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
       INTEGER kUp,kDown  
73        _RL     myTime        _RL     myTime
74        INTEGER myIter        INTEGER myIter
75        INTEGER myThid        INTEGER myThid
       INTEGER bi,bj,iMin,iMax,jMin,jMax  
76    
77  #ifdef ALLOW_MOM_VECINV  #ifdef ALLOW_MOM_VECINV
78    
# Line 93  C     == Local variables == Line 103  C     == Local variables ==
103        _RL viscAh_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL viscAh_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
104        _RL viscA4_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL viscA4_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
105        _RL viscA4_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL viscA4_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
106  C     i,j,k  :: Loop counters  C     i,j    :: Loop counters
107        INTEGER i,j,k        INTEGER i,j
108  C     xxxFac - On-off tracer parameters used for switching terms off.  C     xxxFac :: On-off tracer parameters used for switching terms off.
109        _RL  ArDudrFac        _RL  ArDudrFac
110        _RL  ArDvdrFac        _RL  ArDvdrFac
111        _RL  sideMaskFac        _RL  sideMaskFac
# Line 116  C--   only the kDown part of fverU/V is Line 126  C--   only the kDown part of fverU/V is
126  C--   the kUp is still required  C--   the kUp is still required
127  C--   In the case of mom_fluxform Kup is set as well  C--   In the case of mom_fluxform Kup is set as well
128  C--   (at least in part)  C--   (at least in part)
129        fVerU(1,1,kUp) = fVerU(1,1,kUp)        fVerUkm(1,1) = fVerUkm(1,1)
130        fVerV(1,1,kUp) = fVerV(1,1,kUp)        fVerVkm(1,1) = fVerVkm(1,1)
131  #endif  #endif
132    
133  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
# Line 156  C--   (at least in part) Line 166  C--   (at least in part)
166            offsets(i) = 0            offsets(i) = 0
167          ENDDO          ENDDO
168          offsets(3) = k          offsets(3) = k
169  C       write(*,*) 'offsets = ',(offsets(i),i=1,9)  c       write(*,*) 'offsets = ',(offsets(i),i=1,9)
170        ENDIF        ENDIF
171  #endif /*  ALLOW_MNC  */  #endif /*  ALLOW_MNC  */
172    
173  C     Initialise intermediate terms  C--   Initialise intermediate terms
174        DO J=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
175         DO I=1-OLx,sNx+OLx         DO i=1-OLx,sNx+OLx
176          vF(i,j)    = 0.          vF(i,j)    = 0.
177          vrF(i,j)   = 0.          vrF(i,j)   = 0.
178          uCf(i,j)   = 0.          uCf(i,j)   = 0.
# Line 176  C     Initialise intermediate terms Line 186  C     Initialise intermediate terms
186          vort3(i,j) = 0.          vort3(i,j) = 0.
187          omega3(i,j)= 0.          omega3(i,j)= 0.
188          KE(i,j)    = 0.          KE(i,j)    = 0.
189  c       hDiv(i,j)  = 0.  C-    need to initialise hDiv for MOM_VI_DEL2UV(call FILL_CS_CORNER_TR_RL)
190            hDiv(i,j)  = 0.
191          viscAh_Z(i,j) = 0.          viscAh_Z(i,j) = 0.
192          viscAh_D(i,j) = 0.          viscAh_D(i,j) = 0.
193          viscA4_Z(i,j) = 0.          viscA4_Z(i,j) = 0.
# Line 236  C--    For viscous term, compute horizon Line 247  C--    For viscous term, compute horizon
247  C      and mask relative vorticity (free-slip case):  C      and mask relative vorticity (free-slip case):
248    
249  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
250  CADJ STORE vort3(:,:) =  CADJ STORE vort3(:,:) =
251  CADJ &     comlev1_bibj_k, key = imomkey, byte = isbyte  CADJ &     comlev1_bibj_k, key = imomkey, byte = isbyte
252  #endif  #endif
253    
# Line 247  CADJ &     comlev1_bibj_k, key = imomkey Line 258  CADJ &     comlev1_bibj_k, key = imomkey
258         CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid)         CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid)
259    
260  C-     account for no-slip / free-slip BC:  C-     account for no-slip / free-slip BC:
261         DO j=1-Oly,sNy+Oly         DO j=1-OLy,sNy+OLy
262          DO i=1-Olx,sNx+Olx          DO i=1-OLx,sNx+OLx
263            IF ( hFacZ(i,j).EQ.0. ) THEN            IF ( hFacZ(i,j).EQ.0. ) THEN
264              vort3(i,j)  = sideMaskFac*vort3(i,j)              vort3(i,j)  = sideMaskFac*vort3(i,j)
265              strain(i,j) = sideMaskFac*strain(i,j)              strain(i,j) = sideMaskFac*strain(i,j)
# Line 272  C      Calculate del^2 u and del^2 v for Line 283  C      Calculate del^2 u and del^2 v for
283           CALL MOM_CALC_HDIV(bi,bj,k,2,del2u,del2v,dStar,myThid)           CALL MOM_CALC_HDIV(bi,bj,k,2,del2u,del2v,dStar,myThid)
284           CALL MOM_CALC_RELVORT3(bi,bj,k,           CALL MOM_CALC_RELVORT3(bi,bj,k,
285       &                          del2u,del2v,hFacZ,zStar,myThid)       &                          del2u,del2v,hFacZ,zStar,myThid)
286             IF ( writeDiag ) THEN
287               CALL WRITE_LOCAL_RL( 'del2u', 'I10', 1, del2u,
288         &                           bi,bj,k, myIter, myThid )
289               CALL WRITE_LOCAL_RL( 'del2v', 'I10', 1, del2v,
290         &                           bi,bj,k, myIter, myThid )
291               CALL WRITE_LOCAL_RL( 'dStar', 'I10', 1, dStar,
292         &                           bi,bj,k, myIter, myThid )
293               CALL WRITE_LOCAL_RL( 'zStar', 'I10', 1, zStar,
294         &                           bi,bj,k, myIter, myThid )
295             ENDIF
296         ENDIF         ENDIF
297    
298  C-    Strain diagnostics:  C-    Strain diagnostics:
# Line 297  C---   Calculate dissipation terms for U Line 318  C---   Calculate dissipation terms for U
318  C      in terms of tension and strain  C      in terms of tension and strain
319         IF (useStrainTensionVisc) THEN         IF (useStrainTensionVisc) THEN
320  C        mask strain as if free-slip since side-drag is computed separately  C        mask strain as if free-slip since side-drag is computed separately
321           DO j=1-Oly,sNy+Oly           DO j=1-OLy,sNy+OLy
322            DO i=1-Olx,sNx+Olx            DO i=1-OLx,sNx+OLx
323              IF ( hFacZ(i,j).EQ.0. ) strain(i,j) = 0. _d 0              IF ( hFacZ(i,j).EQ.0. ) strain(i,j) = 0. _d 0
324            ENDDO            ENDDO
325           ENDDO           ENDDO
# Line 334  C     Eddy component of vertical flux (i Line 355  C     Eddy component of vertical flux (i
355  C     Combine fluxes  C     Combine fluxes
356         DO j=jMin,jMax         DO j=jMin,jMax
357          DO i=iMin,iMax          DO i=iMin,iMax
358           fVerU(i,j,kDown) = ArDudrFac*vrF(i,j)           fVerUkp(i,j) = ArDudrFac*vrF(i,j)
359          ENDDO          ENDDO
360         ENDDO         ENDDO
361    
362  C--   Tendency is minus divergence of the fluxes  C--   Tendency is minus divergence of the fluxes
363         DO j=2-Oly,sNy+Oly-1         DO j=2-OLy,sNy+OLy-1
364          DO i=2-Olx,sNx+Olx-1          DO i=2-OLx,sNx+OLx-1
365           guDiss(i,j) = guDiss(i,j)           guDiss(i,j) = guDiss(i,j)
366       &   -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)       &   -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)
367       &   *recip_rAw(i,j,bi,bj)       &   *recip_rAw(i,j,bi,bj)
368       &  *(       &   *( fVerUkp(i,j) - fVerUkm(i,j) )*rkSign
      &    fVerU(i,j,kDown) - fVerU(i,j,kUp)  
      &   )*rkSign  
369          ENDDO          ENDDO
370         ENDDO         ENDDO
371        ENDIF        ENDIF
# Line 399  C     Eddy component of vertical flux (i Line 418  C     Eddy component of vertical flux (i
418  C     Combine fluxes -> fVerV  C     Combine fluxes -> fVerV
419         DO j=jMin,jMax         DO j=jMin,jMax
420          DO i=iMin,iMax          DO i=iMin,iMax
421           fVerV(i,j,kDown) = ArDvdrFac*vrF(i,j)           fVerVkp(i,j) = ArDvdrFac*vrF(i,j)
422          ENDDO          ENDDO
423         ENDDO         ENDDO
424    
# Line 408  C--   Tendency is minus divergence of th Line 427  C--   Tendency is minus divergence of th
427          DO i=iMin,iMax          DO i=iMin,iMax
428           gvDiss(i,j) = gvDiss(i,j)           gvDiss(i,j) = gvDiss(i,j)
429       &   -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)       &   -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)
430       &    *recip_rAs(i,j,bi,bj)       &   *recip_rAs(i,j,bi,bj)
431       &  *(       &   *( fVerVkp(i,j) - fVerVkm(i,j) )*rkSign
      &    fVerV(i,j,kDown) - fVerV(i,j,kUp)  
      &   )*rkSign  
432          ENDDO          ENDDO
433         ENDDO         ENDDO
434        ENDIF        ENDIF
# Line 475  C---+----1----+----2----+----3----+----4 Line 492  C---+----1----+----2----+----3----+----4
492    
493  C---  Prepare for Advection & Coriolis terms:  C---  Prepare for Advection & Coriolis terms:
494  C-    Mask relative vorticity and calculate absolute vorticity  C-    Mask relative vorticity and calculate absolute vorticity
495        DO j=1-Oly,sNy+Oly        DO j=1-OLy,sNy+OLy
496         DO i=1-Olx,sNx+Olx         DO i=1-OLx,sNx+OLx
497           IF ( hFacZ(i,j).EQ.0. ) vort3(i,j) = 0.           IF ( hFacZ(i,j).EQ.0. ) vort3(i,j) = 0.
498         ENDDO         ENDDO
499        ENDDO        ENDDO
# Line 536  C- jmc: change it to keep the Coriolis t Line 553  C- jmc: change it to keep the Coriolis t
553    
554        IF (momAdvection) THEN        IF (momAdvection) THEN
555  C--   Horizontal advection of relative (or absolute) vorticity  C--   Horizontal advection of relative (or absolute) vorticity
556         IF (highOrderVorticity.AND.useAbsVorticity) THEN         IF ( (highOrderVorticity.OR.upwindVorticity)
557         &     .AND.useAbsVorticity ) THEN
558          CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,omega3,r_hFacZ,          CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,omega3,r_hFacZ,
559       &                         uCf,myThid)       &                         uCf,myThid)
560         ELSEIF (highOrderVorticity) THEN         ELSEIF ( (highOrderVorticity.OR.upwindVorticity) ) THEN
561          CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,vort3, r_hFacZ,          CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,vort3, r_hFacZ,
562       &                         uCf,myThid)       &                         uCf,myThid)
563         ELSEIF (useAbsVorticity) THEN         ELSEIF ( useAbsVorticity ) THEN
564          CALL MOM_VI_U_CORIOLIS(bi,bj,K,vFld,omega3,hFacZ,r_hFacZ,          CALL MOM_VI_U_CORIOLIS(bi,bj,K,vFld,omega3,hFacZ,r_hFacZ,
565       &                         uCf,myThid)       &                         uCf,myThid)
566         ELSE         ELSE
# Line 554  C--   Horizontal advection of relative ( Line 572  C--   Horizontal advection of relative (
572           gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+uCf(i,j)           gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+uCf(i,j)
573          ENDDO          ENDDO
574         ENDDO         ENDDO
575         IF (highOrderVorticity.AND.useAbsVorticity) THEN         IF ( (highOrderVorticity.OR.upwindVorticity)
576         &     .AND.useAbsVorticity ) THEN
577          CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,omega3,r_hFacZ,          CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,omega3,r_hFacZ,
578       &                         vCf,myThid)       &                         vCf,myThid)
579         ELSEIF (highOrderVorticity) THEN         ELSEIF ( (highOrderVorticity.OR.upwindVorticity) ) THEN
580          CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,vort3, r_hFacZ,          CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,vort3, r_hFacZ,
581       &                         vCf,myThid)       &                         vCf,myThid)
582         ELSEIF (useAbsVorticity) THEN         ELSEIF ( useAbsVorticity ) THEN
583          CALL MOM_VI_V_CORIOLIS(bi,bj,K,uFld,omega3,hFacZ,r_hFacZ,          CALL MOM_VI_V_CORIOLIS(bi,bj,K,uFld,omega3,hFacZ,r_hFacZ,
584       &                         vCf,myThid)       &                         vCf,myThid)
585         ELSE         ELSE
# Line 656  C--   Bernoulli term Line 675  C--   Bernoulli term
675  C--   end if momAdvection  C--   end if momAdvection
676        ENDIF        ENDIF
677    
678  C--   3.D Coriolis term (horizontal momentum, Eastward component: -f'*w)  C--   3.D Coriolis term (horizontal momentum, Eastward component: -fprime*w)
679        IF ( use3dCoriolis ) THEN        IF ( use3dCoriolis ) THEN
680          CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,uCf,myThid)          CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,uCf,myThid)
681          DO j=jMin,jMax          DO j=jMin,jMax
# Line 700  C--   Set du/dt & dv/dt on boundaries to Line 719  C--   Set du/dt & dv/dt on boundaries to
719        ENDDO        ENDDO
720    
721  #ifdef ALLOW_DEBUG  #ifdef ALLOW_DEBUG
722        IF ( debugLevel .GE. debLevB        IF ( debugLevel .GE. debLevC
723       &   .AND. k.EQ.4 .AND. myIter.EQ.nIter0       &   .AND. k.EQ.4 .AND. myIter.EQ.nIter0
724       &   .AND. nPx.EQ.1 .AND. nPy.EQ.1       &   .AND. nPx.EQ.1 .AND. nPy.EQ.1
725       &   .AND. useCubedSphereExchange ) THEN       &   .AND. useCubedSphereExchange ) THEN
# Line 745  C--   Set du/dt & dv/dt on boundaries to Line 764  C--   Set du/dt & dv/dt on boundaries to
764          CALL DIAGNOSTICS_FILL(guDiss, 'Um_Diss ',k,1,2,bi,bj,myThid)          CALL DIAGNOSTICS_FILL(guDiss, 'Um_Diss ',k,1,2,bi,bj,myThid)
765          CALL DIAGNOSTICS_FILL(gvDiss, 'Vm_Diss ',k,1,2,bi,bj,myThid)          CALL DIAGNOSTICS_FILL(gvDiss, 'Vm_Diss ',k,1,2,bi,bj,myThid)
766         ENDIF         ENDIF
767          CALL DIAGNOSTICS_FILL(gU(1-Olx,1-Oly,k,bi,bj),          CALL DIAGNOSTICS_FILL(gU(1-OLx,1-OLy,k,bi,bj),
768       &                                'Um_Advec',k,1,2,bi,bj,myThid)       &                                'Um_Advec',k,1,2,bi,bj,myThid)
769          CALL DIAGNOSTICS_FILL(gV(1-Olx,1-Oly,k,bi,bj),          CALL DIAGNOSTICS_FILL(gV(1-OLx,1-OLy,k,bi,bj),
770       &                                'Vm_Advec',k,1,2,bi,bj,myThid)       &                                'Vm_Advec',k,1,2,bi,bj,myThid)
771        ENDIF        ENDIF
772  #endif /* ALLOW_DIAGNOSTICS */  #endif /* ALLOW_DIAGNOSTICS */

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.66

  ViewVC Help
Powered by ViewVC 1.1.22