/[MITgcm]/MITgcm/model/src/dynamics.F
ViewVC logotype

Diff of /MITgcm/model/src/dynamics.F

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

revision 1.28 by cnh, Thu Aug 20 19:25:05 1998 UTC revision 1.43 by adcroft, Mon May 24 15:42:23 1999 UTC
# Line 20  C     | ===== Line 20  C     | =====
20  C     | C*P* comments indicating place holders for which code is |  C     | C*P* comments indicating place holders for which code is |
21  C     |      presently being developed.                          |  C     |      presently being developed.                          |
22  C     \==========================================================/  C     \==========================================================/
23          IMPLICIT NONE
24    
25  C     == Global variables ===  C     == Global variables ===
26  #include "SIZE.h"  #include "SIZE.h"
# Line 27  C     == Global variables === Line 28  C     == Global variables ===
28  #include "CG2D.h"  #include "CG2D.h"
29  #include "PARAMS.h"  #include "PARAMS.h"
30  #include "DYNVARS.h"  #include "DYNVARS.h"
31    #include "GRID.h"
32    #ifdef ALLOW_KPP
33    #include "KPPMIX.h"
34    #endif
35    
36  C     == Routine arguments ==  C     == Routine arguments ==
37  C     myTime - Current time in simulation  C     myTime - Current time in simulation
# Line 38  C     myThid - Thread number for this in Line 43  C     myThid - Thread number for this in
43    
44  C     == Local variables  C     == Local variables
45  C     xA, yA                 - Per block temporaries holding face areas  C     xA, yA                 - Per block temporaries holding face areas
46  C     uTrans, vTrans, wTrans - Per block temporaries holding flow transport  C     uTrans, vTrans, rTrans - Per block temporaries holding flow
47  C     wVel                     o uTrans: Zonal transport  C                              transport
48    C     rVel                     o uTrans: Zonal transport
49  C                              o vTrans: Meridional transport  C                              o vTrans: Meridional transport
50  C                              o wTrans: Vertical transport  C                              o rTrans: Vertical transport
51  C                              o wVel:   Vertical velocity at upper and lower  C                              o rVel:   Vertical velocity at upper and
52  C                                        cell faces.  C                                        lower cell faces.
53  C     maskC,maskUp             o maskC: land/water mask for tracer cells  C     maskC,maskUp             o maskC: land/water mask for tracer cells
54  C                              o maskUp: land/water mask for W points  C                              o maskUp: land/water mask for W points
55  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in
# Line 59  C                              o fVer: V Line 65  C                              o fVer: V
65  C                                      is "pipelined" in the vertical  C                                      is "pipelined" in the vertical
66  C                                      so we need an fVer for each  C                                      so we need an fVer for each
67  C                                      variable.  C                                      variable.
68  C     rhoK, rhoKM1   - Density at current level, level above and level below.  C     rhoK, rhoKM1   - Density at current level, level above and level
69    C                      below.
70  C     rhoKP1                                                                    C     rhoKP1                                                                  
71  C     buoyK, buoyKM1 - Buoyancy at current level and level above.  C     buoyK, buoyKM1 - Buoyancy at current level and level above.
72  C     phiHyd         - Hydrostatic part of the potential phi.  C     phiHyd         - Hydrostatic part of the potential phiHydi.
73  C                      In z coords phiHyd is the hydrostatic pressure anomaly  C                      In z coords phiHydiHyd is the hydrostatic
74  C                      In p coords phiHyd is the geopotential surface height anomaly.  C                      pressure anomaly
75  C     iMin, iMax - Ranges and sub-block indices on which calculations  C                      In p coords phiHydiHyd is the geopotential
76  C     jMin, jMax   are applied.  C                      surface height
77    C                      anomaly.
78    C     etaSurfX,      - Holds surface elevation gradient in X and Y.
79    C     etaSurfY
80    C     K13, K23, K33  - Non-zero elements of small-angle approximation
81    C                      diffusion tensor.
82    C     KapGM          - Spatially varying Visbeck et. al mixing coeff.
83    C     KappaRT,       - Total diffusion in vertical for T and S.
84    C     KappaRS          (background + spatially varying, isopycnal term).
85    C     iMin, iMax     - Ranges and sub-block indices on which calculations
86    C     jMin, jMax       are applied.
87  C     bi, bj  C     bi, bj
88  C     k, kUp, kDown, kM1 - Index for layer above and below. kUp and kDown  C     k, kUp,        - Index for layer above and below. kUp and kDown
89  C                          are switched with layer to be the appropriate index  C     kDown, kM1       are switched with layer to be the appropriate
90  C                          into fVerTerm  C                      index into fVerTerm.
91        _RS xA    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
92        _RS yA    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
93        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
94        _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL vTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
95        _RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
96        _RL rVel  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL rVel    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
97        _RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskC   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
98        _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
99        _RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL aTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
100        _RL xTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL xTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
101        _RL cTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL cTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
102        _RL mTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL mTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
103        _RL pTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL pTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
104        _RL fZon  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fZon    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
105        _RL fMer  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fMer    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
106        _RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
107        _RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerS   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
108        _RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerU   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
109        _RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerV   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
110        _RL phiHyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL phiHyd  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
111        _RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokm1  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
112        _RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokp1  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
113        _RL rhok  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhok    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
114        _RL buoyKM1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL buoyKM1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
115        _RL buoyK (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL buoyK   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
116        _RL rhotmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhotmp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
117        _RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL etaSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
118        _RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL etaSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
119        _RL K13   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL K13     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
120        _RL K23   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL K23     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
121        _RL K33   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL K33     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
122        _RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL KapGM   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
123        _RL KappaZT(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nz)        _RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
124        _RL KappaZS(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nz)        _RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
125          _RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
126          _RL KappaRV (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
127    
128        INTEGER iMin, iMax        INTEGER iMin, iMax
129        INTEGER jMin, jMax        INTEGER jMin, jMax
# Line 126  C Line 145  C
145  C       "Calculation of Gs"  C       "Calculation of Gs"
146  C       ===================  C       ===================
147  C       This is where all the accelerations and tendencies (ie.  C       This is where all the accelerations and tendencies (ie.
148  C       physics, parameterizations etc...) are calculated  C       phiHydysics, parameterizations etc...) are calculated
149  C         rVel = sum_r ( div. u[n] )  C         rVel = sum_r ( div. u[n] )
150  C         rho = rho ( theta[n], salt[n] )  C         rho = rho ( theta[n], salt[n] )
151  C         b   = b(rho, theta)  C         b   = b(rho, theta)
# Line 176  C     uninitialised but inert locations. Line 195  C     uninitialised but inert locations.
195          pTerm(i,j)   = 0. _d 0          pTerm(i,j)   = 0. _d 0
196          fZon(i,j)    = 0. _d 0          fZon(i,j)    = 0. _d 0
197          fMer(i,j)    = 0. _d 0          fMer(i,j)    = 0. _d 0
198          DO K=1,nZ          DO K=1,Nr
199           pH (i,j,k)  = 0. _d 0           phiHyd (i,j,k)  = 0. _d 0
200           K13(i,j,k) = 0. _d 0           K13(i,j,k)  = 0. _d 0
201           K23(i,j,k) = 0. _d 0           K23(i,j,k)  = 0. _d 0
202           K33(i,j,k) = 0. _d 0           K33(i,j,k)  = 0. _d 0
203           KappaZT(i,j,k) = 0. _d 0           KappaRT(i,j,k) = 0. _d 0
204             KappaRS(i,j,k) = 0. _d 0
205          ENDDO          ENDDO
206          rhokm1(i,j)  = 0. _d 0          rhoKM1 (i,j) = 0. _d 0
207          rhok  (i,j)  = 0. _d 0          rhok   (i,j) = 0. _d 0
208          rhokp1(i,j)  = 0. _d 0          rhoKP1 (i,j) = 0. _d 0
209          rhotmp(i,j)  = 0. _d 0          rhoTMP (i,j) = 0. _d 0
210          buoyKM1(i,j) = 0. _d 0          buoyKM1(i,j) = 0. _d 0
211          buoyK  (i,j) = 0. _d 0          buoyK  (i,j) = 0. _d 0
212          maskC (i,j)  = 0. _d 0          maskC  (i,j) = 0. _d 0
213         ENDDO         ENDDO
214        ENDDO        ENDDO
215    
216    
217        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
218         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
219    
# Line 202  C--     Set up work arrays that need val Line 223  C--     Set up work arrays that need val
223            rTrans(i,j)   = 0. _d 0            rTrans(i,j)   = 0. _d 0
224            rVel  (i,j,1) = 0. _d 0            rVel  (i,j,1) = 0. _d 0
225            rVel  (i,j,2) = 0. _d 0            rVel  (i,j,2) = 0. _d 0
226            fVerT(i,j,1)  = 0. _d 0            fVerT (i,j,1) = 0. _d 0
227            fVerT(i,j,2)  = 0. _d 0            fVerT (i,j,2) = 0. _d 0
228            fVerS(i,j,1)  = 0. _d 0            fVerS (i,j,1) = 0. _d 0
229            fVerS(i,j,2)  = 0. _d 0            fVerS (i,j,2) = 0. _d 0
230            fVerU(i,j,1)  = 0. _d 0            fVerU (i,j,1) = 0. _d 0
231            fVerU(i,j,2)  = 0. _d 0            fVerU (i,j,2) = 0. _d 0
232            fVerV(i,j,1)  = 0. _d 0            fVerV (i,j,1) = 0. _d 0
233            fVerV(i,j,2)  = 0. _d 0            fVerV (i,j,2) = 0. _d 0
234            phiHyd(i,j,1) = 0. _d 0            phiHyd(i,j,1) = 0. _d 0
235            K13(i,j,1)    = 0. _d 0            K13   (i,j,1) = 0. _d 0
236            K23(i,j,1)    = 0. _d 0            K23   (i,j,1) = 0. _d 0
237            K33(i,j,1)    = 0. _d 0            K33   (i,j,1) = 0. _d 0
238            KapGM(i,j)    = GMkbackground            KapGM (i,j)   = GMkbackground
239           ENDDO           ENDDO
240          ENDDO          ENDDO
241    
# Line 223  C--     Set up work arrays that need val Line 244  C--     Set up work arrays that need val
244          jMin = 1-OLy+1          jMin = 1-OLy+1
245          jMax = sNy+OLy          jMax = sNy+OLy
246    
247    
248          K = 1          K = 1
249          BOTTOM_LAYER = K .EQ. Nz          BOTTOM_LAYER = K .EQ. Nr
250    
251    #ifdef DO_PIPELINED_CORRECTION_STEP
252  C--     Calculate gradient of surface pressure  C--     Calculate gradient of surface pressure
253          CALL CALC_GRAD_ETA_SURF(          CALL CALC_GRAD_ETA_SURF(
254       I       bi,bj,iMin,iMax,jMin,jMax,       I       bi,bj,iMin,iMax,jMin,jMax,
255       O       pSurfX,pSurfY,       O       etaSurfX,etaSurfY,
256       I       myThid)       I       myThid)
   
257  C--     Update fields in top level according to tendency terms  C--     Update fields in top level according to tendency terms
258          CALL CORRECTION_STEP(          CALL CORRECTION_STEP(
259       I       bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myTime,myThid)       I       bi,bj,iMin,iMax,jMin,jMax,K,
260         I       etaSurfX,etaSurfY,myTime,myThid)
261    #ifdef ALLOW_OBCS
262            IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K, myThid )
263    #endif
264          IF ( .NOT. BOTTOM_LAYER ) THEN          IF ( .NOT. BOTTOM_LAYER ) THEN
265  C--      Update fields in layer below according to tendency terms  C--      Update fields in layer below according to tendency terms
266           CALL CORRECTION_STEP(           CALL CORRECTION_STEP(
267       I        bi,bj,iMin,iMax,jMin,jMax,K+1,pSurfX,pSurfY,myTime,myThid)       I        bi,bj,iMin,iMax,jMin,jMax,K+1,
268         I        etaSurfX,etaSurfY,myTime,myThid)
269    #ifdef ALLOW_OBCS
270             IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K+1, myThid )
271    #endif
272          ENDIF          ENDIF
273    #endif
274  C--     Density of 1st level (below W(1)) reference to level 1  C--     Density of 1st level (below W(1)) reference to level 1
275    #ifdef  INCLUDE_FIND_RHO_CALL
276          CALL FIND_RHO(          CALL FIND_RHO(
277       I     bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,       I     bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
278       O     rhoKm1,       O     rhoKm1,
279       I     myThid )       I     myThid )
280    #endif
281    
282          IF ( .NOT. BOTTOM_LAYER ) THEN          IF (       (.NOT. BOTTOM_LAYER)
283    #ifdef ALLOW_KPP
284         &       .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing
285    #endif
286         &     ) THEN
287  C--      Check static stability with layer below  C--      Check static stability with layer below
288  C        and mix as needed.  C--      and mix as needed.
289    #ifdef  INCLUDE_FIND_RHO_CALL
290           CALL FIND_RHO(           CALL FIND_RHO(
291       I      bi, bj, iMin, iMax, jMin, jMax, K+1, K, eosType,       I      bi, bj, iMin, iMax, jMin, jMax, K+1, K, eosType,
292       O      rhoKp1,       O      rhoKp1,
293       I      myThid )       I      myThid )
294    #endif
295    #ifdef  INCLUDE_CONVECT_CALL
296           CALL CONVECT(           CALL CONVECT(
297       I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,       I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
298       I       myTime,myIter,myThid)       I       myTime,myIter,myThid)
299    #endif
300  C--      Recompute density after mixing  C--      Recompute density after mixing
301    #ifdef  INCLUDE_FIND_RHO_CALL
302           CALL FIND_RHO(           CALL FIND_RHO(
303       I      bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,       I      bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
304       O      rhoKm1,       O      rhoKm1,
305       I      myThid )       I      myThid )
306    #endif
307          ENDIF          ENDIF
   
308  C--     Calculate buoyancy  C--     Calculate buoyancy
309          CALL CALC_BUOY(          CALL CALC_BUOYANCY(
310       I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,       I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,
311       O      buoyKm1,       O      buoyKm1,
312       I      myThid )       I      myThid )
313    C--     Integrate hydrostatic balance for phiHyd with BC of
314  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0  C--     phiHyd(z=0)=0
315          CALL CALC_PHI_HYD(          CALL CALC_PHI_HYD(
316       I      bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1,       I      bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1,
317       U      phiHyd,       U      phiHyd,
318       I      myThid )       I      myThid )
319    
320          DO K=2,Nz          DO K=2,Nr
321             BOTTOM_LAYER = K .EQ. Nr
322           BOTTOM_LAYER = K .EQ. Nz  #ifdef DO_PIPELINED_CORRECTION_STEP
323           IF ( .NOT. BOTTOM_LAYER ) THEN           IF ( .NOT. BOTTOM_LAYER ) THEN
324  C--       Update fields in layer below according to tendency terms  C--       Update fields in layer below according to tendency terms
325            CALL CORRECTION_STEP(            CALL CORRECTION_STEP(
326       I         bi,bj,iMin,iMax,jMin,jMax,K+1,pSurfX,pSurfY,myTime,myThid)       I         bi,bj,iMin,iMax,jMin,jMax,K+1,
327         I         etaSurfX,etaSurfY,myTime,myThid)
328    #ifdef ALLOW_OBCS
329              IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K+1, myThid )
330    #endif
331           ENDIF           ENDIF
332    #endif
333  C--      Density of K level (below W(K)) reference to K level  C--      Density of K level (below W(K)) reference to K level
334    #ifdef  INCLUDE_FIND_RHO_CALL
335           CALL FIND_RHO(           CALL FIND_RHO(
336       I      bi, bj, iMin, iMax, jMin, jMax,  K, K, eosType,       I      bi, bj, iMin, iMax, jMin, jMax,  K, K, eosType,
337       O      rhoK,       O      rhoK,
338       I      myThid )       I      myThid )
339    #endif
340           IF ( .NOT. BOTTOM_LAYER ) THEN           IF (       (.NOT. BOTTOM_LAYER)
341    #ifdef ALLOW_KPP
342         &       .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing
343    #endif
344         &      ) THEN
345  C--       Check static stability with layer below and mix as needed.  C--       Check static stability with layer below and mix as needed.
346  C--       Density of K+1 level (below W(K+1)) reference to K level.  C--       Density of K+1 level (below W(K+1)) reference to K level.
347    #ifdef  INCLUDE_FIND_RHO_CALL
348            CALL FIND_RHO(            CALL FIND_RHO(
349       I       bi, bj, iMin, iMax, jMin, jMax,  K+1, K, eosType,       I       bi, bj, iMin, iMax, jMin, jMax,  K+1, K, eosType,
350       O       rhoKp1,       O       rhoKp1,
351       I       myThid )       I       myThid )
352    #endif
353    #ifdef  INCLUDE_CONVECT_CALL
354            CALL CONVECT(            CALL CONVECT(
355       I        bi,bj,iMin,iMax,jMin,jMax,K+1,rhoK,rhoKp1,       I        bi,bj,iMin,iMax,jMin,jMax,K+1,rhoK,rhoKp1,
356       I        myTime,myIter,myThid)       I        myTime,myIter,myThid)
357    #endif
358  C--       Recompute density after mixing  C--       Recompute density after mixing
359    #ifdef  INCLUDE_FIND_RHO_CALL
360            CALL FIND_RHO(            CALL FIND_RHO(
361       I       bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,       I       bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
362       O       rhoK,       O       rhoK,
363       I       myThid )       I       myThid )
364    #endif
365           ENDIF           ENDIF
   
366  C--      Calculate buoyancy  C--      Calculate buoyancy
367           CALL CALC_BUOY(           CALL CALC_BUOYANCY(
368       I       bi,bj,iMin,iMax,jMin,jMax,K,rhoK,       I       bi,bj,iMin,iMax,jMin,jMax,K,rhoK,
369       O       buoyK,       O       buoyK,
370       I       myThid )       I       myThid )
371    C--      Integrate hydrostatic balance for phiHyd with BC of
372  C--      Integrate hydrostatic balance for pH with BC of pH(z=0)=0  C--      phiHyd(z=0)=0
373           CALL CALC_PHI_HYD(           CALL CALC_PHI_HYD(
374       I       bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyK,       I        bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyK,
375       U       phiHyd,       U        phiHyd,
376       I       myThid )       I        myThid )
377  C--      Calculate iso-neutral slopes for the GM/Redi parameterisation  C--      Calculate iso-neutral slopes for the GM/Redi parameterisation
378    #ifdef  INCLUDE_FIND_RHO_CALL
379           CALL FIND_RHO(           CALL FIND_RHO(
380       I      bi, bj, iMin, iMax, jMin, jMax, K-1, K, eosType,       I        bi, bj, iMin, iMax, jMin, jMax, K-1, K, eosType,
381       O      rhoTmp,       O        rhoTmp,
382       I      myThid )       I        myThid )
383    #endif
384    #ifdef  INCLUDE_CALC_ISOSLOPES_CALL
385           CALL CALC_ISOSLOPES(           CALL CALC_ISOSLOPES(
386       I             bi, bj, iMin, iMax, jMin, jMax, K,       I        bi, bj, iMin, iMax, jMin, jMax, K,
387       I             rhoKm1, rhoK, rhotmp,       I        rhoKm1, rhoK, rhotmp,
388       O             K13, K23, K33, KapGM,       O        K13, K23, K33, KapGM,
389       I             myThid )       I        myThid )
390    #endif
391           DO J=jMin,jMax           DO J=jMin,jMax
392            DO I=iMin,iMax            DO I=iMin,iMax
393    #ifdef  INCLUDE_FIND_RHO_CALL
394             rhoKm1 (I,J) = rhoK(I,J)             rhoKm1 (I,J) = rhoK(I,J)
395    #endif
396             buoyKm1(I,J) = buoyK(I,J)             buoyKm1(I,J) = buoyK(I,J)
397            ENDDO            ENDDO
398           ENDDO           ENDDO
   
399          ENDDO ! K          ENDDO ! K
400    
401          DO K = Nz, 1, -1  #ifdef ALLOW_KPP
402    C--     Compute KPP mixing coefficients
403            IF (usingKPPmixing) THEN
404             CALL TIMER_START('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]'
405         I          , myThid)
406             CALL KVMIX(
407         I               bi, bj, myTime, myThid )
408             CALL TIMER_STOP ('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]'
409         I        , myThid)
410            ENDIF
411    #endif
412    
413            DO K = Nr, 1, -1
414    
415           kM1  =max(1,k-1)   ! Points to level above k (=k-1)           kM1  =max(1,k-1)   ! Points to level above k (=k-1)
416           kUp  =1+MOD(k+1,2) ! Cycles through 1,2 to point to layer above           kUp  =1+MOD(k+1,2) ! Cycles through 1,2 to point to layer above
417           kDown=1+MOD(k,2)   ! Cycles through 2,1 to point to current layer           kDown=1+MOD(k,2)   ! Cycles through 2,1 to point to current layer
# Line 353  C--      Calculate iso-neutral slopes fo Line 423  C--      Calculate iso-neutral slopes fo
423  C--      Get temporary terms used by tendency routines  C--      Get temporary terms used by tendency routines
424           CALL CALC_COMMON_FACTORS (           CALL CALC_COMMON_FACTORS (
425       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
426       O        xA,yA,uTrans,vTrans,wTrans,wVel,maskC,maskUp,       O        xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp,
427       I        myThid)       I        myThid)
428    #ifdef  INCLUDE_CALC_DIFFUSIVITY_CALL
429  C--      Calculate the total vertical diffusivity  C--      Calculate the total vertical diffusivity
430           CALL CALC_DIFFUSIVITY(           CALL CALC_DIFFUSIVITY(
431       I        bi,bj,iMin,iMax,jMin,jMax,K,       I        bi,bj,iMin,iMax,jMin,jMax,K,
432       I        maskC,maskUp,KapGM,K33,       I        maskC,maskUp,KapGM,K33,
433       O        KappaZT,KappaZS,       O        KappaRT,KappaRS,KappaRU,KappaRV,
434       I        myThid)       I        myThid)
435    #endif
436  C--      Calculate accelerations in the momentum equations  C--      Calculate accelerations in the momentum equations
437           IF ( momStepping ) THEN           IF ( momStepping ) THEN
438            CALL CALC_MOM_RHS(            CALL CALC_MOM_RHS(
439       I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
440       I         xA,yA,uTrans,vTrans,wTrans,wVel,maskC,       I         xA,yA,uTrans,vTrans,rTrans,rVel,maskC,
441       I         phiHyd,       I         phiHyd,KappaRU,KappaRV,
442       U         aTerm,xTerm,cTerm,mTerm,pTerm,       U         aTerm,xTerm,cTerm,mTerm,pTerm,
443       U         fZon, fMer, fVerU, fVerV,       U         fZon, fMer, fVerU, fVerV,
444       I         myThid)       I         myTime, myThid)
445           ENDIF           ENDIF
   
446  C--      Calculate active tracer tendencies  C--      Calculate active tracer tendencies
447           IF ( tempStepping ) THEN           IF ( tempStepping ) THEN
448            CALL CALC_GT(            CALL CALC_GT(
449       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
450       I         xA,yA,uTrans,vTrans,wTrans,maskUp,maskC,       I         xA,yA,uTrans,vTrans,rTrans,maskUp,maskC,
451       I         K13,K23,KappaZT,KapGM,       I         K13,K23,KappaRT,KapGM,
452       U         aTerm,xTerm,fZon,fMer,fVerT,       U         aTerm,xTerm,fZon,fMer,fVerT,
453       I         myThid)       I         myTime, myThid)
454           ENDIF           ENDIF
455           IF ( saltStepping ) THEN           IF ( saltStepping ) THEN
456            CALL CALC_GS(            CALL CALC_GS(
457       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
458       I         xA,yA,uTrans,vTrans,wTrans,maskUp,maskC,       I         xA,yA,uTrans,vTrans,rTrans,maskUp,maskC,
459       I         K13,K23,KappaZS,KapGM,       I         K13,K23,KappaRS,KapGM,
460       U         aTerm,xTerm,fZon,fMer,fVerS,       U         aTerm,xTerm,fZon,fMer,fVerS,
461       I         myThid)       I         myTime, myThid)
462           ENDIF           ENDIF
   
463  C--      Prediction step (step forward all model variables)  C--      Prediction step (step forward all model variables)
464           CALL TIMESTEP(           CALL TIMESTEP(
465       I       bi,bj,iMin,iMax,jMin,jMax,K,       I       bi,bj,iMin,iMax,jMin,jMax,K,
466       I       myThid)       I       myThid)
467    #ifdef ALLOW_OBCS
468    C--      Apply open boundary conditions
469             IF (openBoundaries) CALL APPLY_OBCS2( bi, bj, K, myThid )
470    #endif
471    C--      Freeze water
472             IF (allowFreezing)
473         &   CALL FREEZE( bi, bj, iMin, iMax, jMin, jMax, K, myThid )
474  C--      Diagnose barotropic divergence of predicted fields  C--      Diagnose barotropic divergence of predicted fields
475           CALL DIV_G(           CALL CALC_DIV_GHAT(
476       I       bi,bj,iMin,iMax,jMin,jMax,K,       I       bi,bj,iMin,iMax,jMin,jMax,K,
477       I       xA,yA,       I       xA,yA,
478       I       myThid)       I       myThid)
479    
480  C--      Cumulative diagnostic calculations (ie. time-averaging)  C--      Cumulative diagnostic calculations (ie. time-averaging)
481  #ifdef ALLOW_DIAGNOSTICS  #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE
482           IF (taveFreq.GT.0.) THEN           IF (taveFreq.GT.0.) THEN
483            CALL DO_TIME_AVERAGES(            CALL DO_TIME_AVERAGES(
484       I                           myTime, myIter, bi, bj, K, kUp, kDown,       I                           myTime, myIter, bi, bj, K, kUp, kDown,
485       I                           K13, K23, wVel, KapGM,       I                           K13, K23, rVel, KapGM,
486       I                           myThid )       I                           myThid )
487           ENDIF           ENDIF
488  #endif  #endif
# Line 417  C--      Cumulative diagnostic calculati Line 491  C--      Cumulative diagnostic calculati
491    
492  C--     Implicit diffusion  C--     Implicit diffusion
493          IF (implicitDiffusion) THEN          IF (implicitDiffusion) THEN
494           CALL IMPLDIFF( bi, bj, iMin, iMax, jMin, jMax,           IF (tempStepping) CALL IMPLDIFF(
495       I                  KappaZT,KappaZS,       I         bi, bj, iMin, iMax, jMin, jMax,
496       I                  myThid )       I         deltaTtracer, KappaRT,recip_HFacC,
497          ENDIF       U         gTNm1,
498         I         myThid )
499             IF (saltStepping) CALL IMPLDIFF(
500         I         bi, bj, iMin, iMax, jMin, jMax,
501         I         deltaTtracer, KappaRS,recip_HFacC,
502         U         gSNm1,
503         I         myThid )
504             IF (momStepping) THEN
505              CALL IMPLDIFF(
506         I         bi, bj, iMin, iMax, jMin, jMax,
507         I         deltaTmom, KappaRU,recip_HFacW,
508         U         gUNm1,
509         I         myThid )
510              CALL IMPLDIFF(
511         I         bi, bj, iMin, iMax, jMin, jMax,
512         I         deltaTmom, KappaRV,recip_HFacS,
513         U         gVNm1,
514         I         myThid )
515    #ifdef INCLUDE_CD_CODE
516              CALL IMPLDIFF(
517         I         bi, bj, iMin, iMax, jMin, jMax,
518         I         deltaTmom, KappaRU,recip_HFacW,
519         U         vVelD,
520         I         myThid )
521              CALL IMPLDIFF(
522         I         bi, bj, iMin, iMax, jMin, jMax,
523         I         deltaTmom, KappaRV,recip_HFacS,
524         U         uVelD,
525         I         myThid )
526    #endif
527             ENDIF ! momStepping
528            ENDIF ! implicitDiffusion
529    
530         ENDDO         ENDDO
531        ENDDO        ENDDO
# Line 431  C     write(0,*) 'dynamics: U  ',minval( Line 536  C     write(0,*) 'dynamics: U  ',minval(
536  C    &                           maxval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.)  C    &                           maxval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.)
537  C     write(0,*) 'dynamics: V  ',minval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.),  C     write(0,*) 'dynamics: V  ',minval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.),
538  C    &                           maxval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.)  C    &                           maxval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.)
539  C     write(0,*) 'dynamics: wVel(1) ',  C     write(0,*) 'dynamics: rVel(1) ',
540  C    &            minval(wVel(1:sNx,1:sNy,1),mask=wVel(1:sNx,1:sNy,1).NE.0.),  C    &            minval(rVel(1:sNx,1:sNy,1),mask=rVel(1:sNx,1:sNy,1).NE.0.),
541  C    &            maxval(wVel(1:sNx,1:sNy,1),mask=wVel(1:sNx,1:sNy,1).NE.0.)  C    &            maxval(rVel(1:sNx,1:sNy,1),mask=rVel(1:sNx,1:sNy,1).NE.0.)
542  C     write(0,*) 'dynamics: wVel(2) ',  C     write(0,*) 'dynamics: rVel(2) ',
543  C    &            minval(wVel(1:sNx,1:sNy,2),mask=wVel(1:sNx,1:sNy,2).NE.0.),  C    &            minval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.),
544  C    &            maxval(wVel(1:sNx,1:sNy,2),mask=wVel(1:sNx,1:sNy,2).NE.0.)  C    &            maxval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.)
545  cblk  write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)),  cblk  write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)),
546  cblk &                           maxval(K13(1:sNx,1:sNy,:))  cblk &                           maxval(K13(1:sNx,1:sNy,:))
547  cblk  write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)),  cblk  write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)),
# Line 451  C     write(0,*) 'dynamics: gS ',minval( Line 556  C     write(0,*) 'dynamics: gS ',minval(
556  C    &                           maxval(gS(1:sNx,1:sNy,:,:,:))  C    &                           maxval(gS(1:sNx,1:sNy,:,:,:))
557  C     write(0,*) 'dynamics: S  ',minval(salt(1:sNx,1:sNy,:,:,:)),  C     write(0,*) 'dynamics: S  ',minval(salt(1:sNx,1:sNy,:,:,:)),
558  C    &                           maxval(salt(1:sNx,1:sNy,:,:,:))  C    &                           maxval(salt(1:sNx,1:sNy,:,:,:))
559  C     write(0,*) 'dynamics: pH ',minval(pH/(Gravity*Rhonil),mask=ph.NE.0.),  C     write(0,*) 'dynamics: phiHyd ',minval(phiHyd/(Gravity*Rhonil),mask=phiHyd.NE.0.),
560  C    &                           maxval(pH/(Gravity*Rhonil))  C    &                           maxval(phiHyd/(Gravity*Rhonil))
561    C     CALL PLOT_FIELD_XYZRL( gU, ' GU exiting dyanmics ' ,
562    C    &Nr, 1, myThid )
563    C     CALL PLOT_FIELD_XYZRL( gV, ' GV exiting dyanmics ' ,
564    C    &Nr, 1, myThid )
565    C     CALL PLOT_FIELD_XYZRL( gS, ' GS exiting dyanmics ' ,
566    C    &Nr, 1, myThid )
567    C     CALL PLOT_FIELD_XYZRL( gT, ' GT exiting dyanmics ' ,
568    C    &Nr, 1, myThid )
569    C     CALL PLOT_FIELD_XYZRL( phiHyd, ' phiHyd exiting dyanmics ' ,
570    C    &Nr, 1, myThid )
571    
572    
573        RETURN        RETURN
574        END        END

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.22