/[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.8 by cnh, Mon May 25 20:05:55 1998 UTC revision 1.51 by heimbach, Wed Jun 21 20:46:31 2000 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    
3  #include "CPP_EEOPTIONS.h"  #include "CPP_OPTIONS.h"
4    
5        SUBROUTINE DYNAMICS(myTime, myIter, myThid)        SUBROUTINE DYNAMICS(myTime, myIter, myThid)
6  C     /==========================================================\  C     /==========================================================\
# 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    c
24    c     changed: Patrick Heimbach heimbach@mit.edu 6-Jun-2000
25    c              - computation of ikey wrong for nTx,nTy > 1
26    c                and/or nsx,nsy > 1: act1 and act2 were
27    c                mixed up.
28    
29          IMPLICIT NONE
30    
31  C     == Global variables ===  C     == Global variables ===
32  #include "SIZE.h"  #include "SIZE.h"
# Line 27  C     == Global variables === Line 34  C     == Global variables ===
34  #include "CG2D.h"  #include "CG2D.h"
35  #include "PARAMS.h"  #include "PARAMS.h"
36  #include "DYNVARS.h"  #include "DYNVARS.h"
37    #include "GRID.h"
38    
39    #ifdef ALLOW_AUTODIFF_TAMC
40    #include "tamc.h"
41    #include "tamc_keys.h"
42    #endif
43    
44  C     == Routine arguments ==  C     == Routine arguments ==
45  C     myTime - Current time in simulation  C     myTime - Current time in simulation
46  C     myIter - Current iteration number in simulation  C     myIter - Current iteration number in simulation
47  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
       INTEGER myThid  
48        _RL myTime        _RL myTime
49        INTEGER myIter        INTEGER myIter
50          INTEGER myThid
51    
52  C     == Local variables  C     == Local variables
53  C     xA, yA                 - Per block temporaries holding face areas  C     xA, yA                 - Per block temporaries holding face areas
54  C     uTrans, vTrans, wTrans - Per block temporaries holding flow transport  C     uTrans, vTrans, rTrans - Per block temporaries holding flow
55  C                              o uTrans: Zonal transport  C                              transport
56    C     rVel                     o uTrans: Zonal transport
57  C                              o vTrans: Meridional transport  C                              o vTrans: Meridional transport
58  C                              o wTrans: Vertical transport  C                              o rTrans: Vertical transport
59    C                              o rVel:   Vertical velocity at upper and
60    C                                        lower cell faces.
61  C     maskC,maskUp             o maskC: land/water mask for tracer cells  C     maskC,maskUp             o maskC: land/water mask for tracer cells
62  C                              o maskUp: land/water mask for W points  C                              o maskUp: land/water mask for W points
63  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in
# Line 57  C                              o fVer: V Line 73  C                              o fVer: V
73  C                                      is "pipelined" in the vertical  C                                      is "pipelined" in the vertical
74  C                                      so we need an fVer for each  C                                      so we need an fVer for each
75  C                                      variable.  C                                      variable.
76  C     iMin, iMax - Ranges and sub-block indices on which calculations  C     rhoK, rhoKM1   - Density at current level, level above and level
77  C     jMin, jMax   are applied.  C                      below.
78    C     rhoKP1                                                                  
79    C     buoyK, buoyKM1 - Buoyancy at current level and level above.
80    C     phiHyd         - Hydrostatic part of the potential phiHydi.
81    C                      In z coords phiHydiHyd is the hydrostatic
82    C                      pressure anomaly
83    C                      In p coords phiHydiHyd is the geopotential
84    C                      surface height
85    C                      anomaly.
86    C     etaSurfX,      - Holds surface elevation gradient in X and Y.
87    C     etaSurfY
88    C     KappaRT,       - Total diffusion in vertical for T and S.
89    C     KappaRS          (background + spatially varying, isopycnal term).
90    C     iMin, iMax     - Ranges and sub-block indices on which calculations
91    C     jMin, jMax       are applied.
92  C     bi, bj  C     bi, bj
93  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
94  C                          are switched with layer to be the appropriate index  C     kDown, kM1       are switched with layer to be the appropriate
95  C                          into fVerTerm  C                      index into fVerTerm.
96        _RS xA    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
97        _RS yA    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
98        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
99        _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL vTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
100        _RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
101        _RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rVel    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
102        _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskC   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
103        _RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
104        _RL xTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL aTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
105        _RL cTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL xTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
106        _RL mTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL cTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
107        _RL pTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL mTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
108        _RL fZon  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL pTerm   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
109        _RL fMer  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fZon    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
110        _RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fMer    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
111        _RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
112        _RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerS   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
113        _RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerU   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
114        _RL pH    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL fVerV   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
115        _RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL phiHyd  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
116        _RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokm1  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
117        _RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokp1  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
118        _RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhok    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
119        _RL K13   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL buoyKM1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
120        _RL K23   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL buoyK   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
121        _RL K33   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL rhotmp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
122        _RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL etaSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
123          _RL etaSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
124          _RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
125          _RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
126          _RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
127          _RL KappaRV (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
128          _RL sigmaX  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
129          _RL sigmaY  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
130          _RL sigmaR  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
131    
132    #ifdef INCLUDE_CONVECT_CALL
133          _RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
134    #endif
135    
136        INTEGER iMin, iMax        INTEGER iMin, iMax
137        INTEGER jMin, jMax        INTEGER jMin, jMax
138        INTEGER bi, bj        INTEGER bi, bj
139        INTEGER i, j        INTEGER i, j
140        INTEGER k, kM1, kUp, kDown        INTEGER k, kM1, kUp, kDown
141          LOGICAL BOTTOM_LAYER
142    
143    #ifdef ALLOW_AUTODIFF_TAMC
144          INTEGER    isbyte
145          PARAMETER( isbyte = 4 )
146    
147          INTEGER act1, act2, act3, act4
148          INTEGER max1, max2, max3
149          INTEGER iikey, kkey
150          INTEGER maximpl
151    #endif
152    
153    C---    The algorithm...
154    C
155    C       "Correction Step"
156    C       =================
157    C       Here we update the horizontal velocities with the surface
158    C       pressure such that the resulting flow is either consistent
159    C       with the free-surface evolution or the rigid-lid:
160    C         U[n] = U* + dt x d/dx P
161    C         V[n] = V* + dt x d/dy P
162    C
163    C       "Calculation of Gs"
164    C       ===================
165    C       This is where all the accelerations and tendencies (ie.
166    C       phiHydysics, parameterizations etc...) are calculated
167    C         rVel = sum_r ( div. u[n] )
168    C         rho = rho ( theta[n], salt[n] )
169    C         b   = b(rho, theta)
170    C         K31 = K31 ( rho )
171    C         Gu[n] = Gu( u[n], v[n], rVel, b, ... )
172    C         Gv[n] = Gv( u[n], v[n], rVel, b, ... )
173    C         Gt[n] = Gt( theta[n], u[n], v[n], rVel, K31, ... )
174    C         Gs[n] = Gs( salt[n], u[n], v[n], rVel, K31, ... )
175    C
176    C       "Time-stepping" or "Prediction"
177    C       ================================
178    C       The models variables are stepped forward with the appropriate
179    C       time-stepping scheme (currently we use Adams-Bashforth II)
180    C       - For momentum, the result is always *only* a "prediction"
181    C       in that the flow may be divergent and will be "corrected"
182    C       later with a surface pressure gradient.
183    C       - Normally for tracers the result is the new field at time
184    C       level [n+1} *BUT* in the case of implicit diffusion the result
185    C       is also *only* a prediction.
186    C       - We denote "predictors" with an asterisk (*).
187    C         U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] )
188    C         V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] )
189    C         theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
190    C         salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
191    C       With implicit diffusion:
192    C         theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
193    C         salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
194    C         (1 + dt * K * d_zz) theta[n] = theta*
195    C         (1 + dt * K * d_zz) salt[n] = salt*
196    C---
197    
198    #ifdef ALLOW_AUTODIFF_TAMC
199    C--   dummy statement to end declaration part
200          ikey = 1
201    #endif
202    
203  C--   Set up work arrays with valid (i.e. not NaN) values  C--   Set up work arrays with valid (i.e. not NaN) values
204  C     These inital values do not alter the numerical results. They  C     These inital values do not alter the numerical results. They
# Line 114  C     uninitialised but inert locations. Line 218  C     uninitialised but inert locations.
218          pTerm(i,j)   = 0. _d 0          pTerm(i,j)   = 0. _d 0
219          fZon(i,j)    = 0. _d 0          fZon(i,j)    = 0. _d 0
220          fMer(i,j)    = 0. _d 0          fMer(i,j)    = 0. _d 0
221          DO K=1,nZ          DO K=1,Nr
222           pH (i,j,k)  = 0. _d 0           phiHyd (i,j,k)  = 0. _d 0
223           K13(i,j,k) = 0. _d 0           KappaRU(i,j,k) = 0. _d 0
224           K23(i,j,k) = 0. _d 0           KappaRV(i,j,k) = 0. _d 0
225           K33(i,j,k) = 0. _d 0           sigmaX(i,j,k) = 0. _d 0
226             sigmaY(i,j,k) = 0. _d 0
227             sigmaR(i,j,k) = 0. _d 0
228          ENDDO          ENDDO
229          rhokm1(i,j)  = 0. _d 0          rhoKM1 (i,j) = 0. _d 0
230          rhokp1(i,j)  = 0. _d 0          rhok   (i,j) = 0. _d 0
231            rhoKP1 (i,j) = 0. _d 0
232            rhoTMP (i,j) = 0. _d 0
233            buoyKM1(i,j) = 0. _d 0
234            buoyK  (i,j) = 0. _d 0
235            maskC  (i,j) = 0. _d 0
236         ENDDO         ENDDO
237        ENDDO        ENDDO
238    
239    
240    #ifdef ALLOW_AUTODIFF_TAMC
241    C--   HPF directive to help TAMC
242    !HPF$ INDEPENDENT
243    #endif
244    
245        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
246    
247    #ifdef ALLOW_AUTODIFF_TAMC
248    C--    HPF directive to help TAMC
249    !HPF$  INDEPENDENT, NEW (rTrans,rVel,fVerT,fVerS,fVerU,fVerV
250    !HPF$&                  ,phiHyd,
251    !HPF$&                  ,utrans,vtrans,maskc,xA,yA
252    !HPF$&                  ,KappaRT,KappaRS,KappaRU,KappaRV
253    !HPF$&                  )
254    #endif
255    
256         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
257    
258  C--     Boundary condition on hydrostatic pressure is pH(z=0)=0  #ifdef ALLOW_AUTODIFF_TAMC
259              act1 = bi - myBxLo(myThid)
260              max1 = myBxHi(myThid) - myBxLo(myThid) + 1
261    
262              act2 = bj - myByLo(myThid)
263              max2 = myByHi(myThid) - myByLo(myThid) + 1
264    
265              act3 = myThid - 1
266              max3 = nTx*nTy
267    
268              act4 = ikey_dynamics - 1
269    
270              ikey = (act1 + 1) + act2*max1
271         &                      + act3*max1*max2
272         &                      + act4*max1*max2*max3
273    #endif
274    
275    C--     Set up work arrays that need valid initial values
276          DO j=1-OLy,sNy+OLy          DO j=1-OLy,sNy+OLy
277           DO i=1-OLx,sNx+OLx           DO i=1-OLx,sNx+OLx
278            pH(i,j,1) = 0. _d 0            rTrans(i,j)   = 0. _d 0
279            K13(i,j,1) = 0. _d 0            rVel  (i,j,1) = 0. _d 0
280            K23(i,j,1) = 0. _d 0            rVel  (i,j,2) = 0. _d 0
281            K33(i,j,1) = 0. _d 0            fVerT (i,j,1) = 0. _d 0
282            KapGM(i,j) = 0. _d 0            fVerT (i,j,2) = 0. _d 0
283              fVerS (i,j,1) = 0. _d 0
284              fVerS (i,j,2) = 0. _d 0
285              fVerU (i,j,1) = 0. _d 0
286              fVerU (i,j,2) = 0. _d 0
287              fVerV (i,j,1) = 0. _d 0
288              fVerV (i,j,2) = 0. _d 0
289              phiHyd(i,j,1) = 0. _d 0
290           ENDDO           ENDDO
291          ENDDO          ENDDO
292    
293  C--     Set up work arrays that need valid initial values          DO k=1,Nr
294          DO j=1-OLy,sNy+OLy           DO j=1-OLy,sNy+OLy
295           DO i=1-OLx,sNx+OLx            DO i=1-OLx,sNx+OLx
296            wTrans(i,j)  = 0. _d 0  #ifdef INCLUDE_CONVECT_CALL
297            fVerT(i,j,1) = 0. _d 0             ConvectCount(i,j,k) = 0.
298            fVerT(i,j,2) = 0. _d 0  #endif
299            fVerS(i,j,1) = 0. _d 0             KappaRT(i,j,k) = 0. _d 0
300            fVerS(i,j,2) = 0. _d 0             KappaRS(i,j,k) = 0. _d 0
301            fVerU(i,j,1) = 0. _d 0            ENDDO
           fVerU(i,j,2) = 0. _d 0  
           fVerV(i,j,1) = 0. _d 0  
           fVerV(i,j,2) = 0. _d 0  
302           ENDDO           ENDDO
303          ENDDO          ENDDO
304    
# Line 159  C--     Set up work arrays that need val Line 307  C--     Set up work arrays that need val
307          jMin = 1-OLy+1          jMin = 1-OLy+1
308          jMax = sNy+OLy          jMax = sNy+OLy
309    
310    
311            K = 1
312            BOTTOM_LAYER = K .EQ. Nr
313    
314    #ifdef DO_PIPELINED_CORRECTION_STEP
315  C--     Calculate gradient of surface pressure  C--     Calculate gradient of surface pressure
316          CALL GRAD_PSURF(          CALL CALC_GRAD_ETA_SURF(
317       I       bi,bj,iMin,iMax,jMin,jMax,       I       bi,bj,iMin,iMax,jMin,jMax,
318       O       pSurfX,pSurfY,       O       etaSurfX,etaSurfY,
319       I       myThid)       I       myThid)
   
320  C--     Update fields in top level according to tendency terms  C--     Update fields in top level according to tendency terms
321          CALL TIMESTEP(          CALL CORRECTION_STEP(
322       I       bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid)       I       bi,bj,iMin,iMax,jMin,jMax,K,
323         I       etaSurfX,etaSurfY,myTime,myThid)
324    
325    #ifdef ALLOW_OBCS
326            IF (openBoundaries) THEN
327    #ifdef ALLOW_AUTODIFF_TAMC
328    CADJ STORE uvel (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
329    CADJ STORE vvel (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
330    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
331    CADJ STORE salt(:,:,k,bi,bj)   = comlev1_2d, key = ikey, byte = isbyte
332    #endif
333               CALL APPLY_OBCS1( bi, bj, K, myThid )
334            END IF
335    #endif
336    
337            IF ( .NOT. BOTTOM_LAYER ) THEN
338    C--      Update fields in layer below according to tendency terms
339             CALL CORRECTION_STEP(
340         I        bi,bj,iMin,iMax,jMin,jMax,K+1,
341         I        etaSurfX,etaSurfY,myTime,myThid)
342    #ifdef ALLOW_OBCS
343             IF (openBoundaries) THEN
344    #ifdef ALLOW_AUTODIFF_TAMC
345    CADJ STORE uvel (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
346    CADJ STORE vvel (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
347    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
348    CADJ STORE salt(:,:,k,bi,bj)   = comlev1_2d, key = ikey, byte = isbyte
349    #endif
350                CALL APPLY_OBCS1( bi, bj, K+1, myThid )
351             END IF
352    #endif
353            ENDIF
354    #endif
355  C--     Density of 1st level (below W(1)) reference to level 1  C--     Density of 1st level (below W(1)) reference to level 1
356    #ifdef  INCLUDE_FIND_RHO_CALL
357    #ifdef ALLOW_AUTODIFF_TAMC
358    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
359    CADJ STORE salt (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
360    #endif
361          CALL FIND_RHO(          CALL FIND_RHO(
362       I     bi, bj, iMin, iMax, jMin, jMax, 1, 1, 'LINEAR',       I     bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
363       O     rhoKm1,       O     rhoKm1,
364       I     myThid )       I     myThid )
365  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0  #endif
366          CALL CALC_PH(  
367       I      bi,bj,iMin,iMax,jMin,jMax,1,rhoKm1,rhoKm1,          IF (       (.NOT. BOTTOM_LAYER)
368       U      pH,       &     ) THEN
369    C--      Check static stability with layer below
370    C--      and mix as needed.
371    #ifdef  INCLUDE_FIND_RHO_CALL
372    #ifdef ALLOW_AUTODIFF_TAMC
373    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
374    CADJ STORE salt (:,:,k,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
375    #endif
376             CALL FIND_RHO(
377         I      bi, bj, iMin, iMax, jMin, jMax, K+1, K, eosType,
378         O      rhoKp1,
379       I      myThid )       I      myThid )
380    #endif
381    
382          DO K=2,Nz  #ifdef  INCLUDE_CONVECT_CALL
383  C--     Update fields in Kth level according to tendency terms  
384          CALL TIMESTEP(  #ifdef ALLOW_AUTODIFF_TAMC
385       I       bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid)  CADJ STORE rhoKm1(:,:)  = comlev1_2d, key = ikey, byte = isbyte
386  C--     Density of K-1 level (above W(K)) reference to K level  CADJ STORE rhoKp1(:,:)  = comlev1_2d, key = ikey, byte = isbyte
387          CALL FIND_RHO(  #endif
388       I     bi, bj, iMin, iMax, jMin, jMax,  K-1, K, 'LINEAR',           CALL CONVECT(
389       O     rhoKm1,       I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
390       I     myThid )       U       ConvectCount,
391  C--     Density of K level (below W(K)) reference to K level       I       myTime,myIter,myThid)
392          CALL FIND_RHO(  #ifdef ALLOW_AUTODIFF_TAMC
393       I     bi, bj, iMin, iMax, jMin, jMax,  K, K, 'LINEAR',  CADJ STORE theta(:,:,k+1,bi,bj),theta(:,:,k,bi,bj)
394       O     rhoKp1,  CADJ &     = comlev1_2d, key = ikey, byte = isbyte
395       I     myThid )  CADJ STORE salt (:,:,k+1,bi,bj),salt (:,:,k,bi,bj)
396  C--     Calculate iso-neutral slopes for the GM/Redi parameterisation  CADJ &     = comlev1_2d, key = ikey, byte = isbyte
397          CALL CALC_ISOSLOPES(  #endif
398    
399    #endif
400    
401    C--      Implicit Vertical Diffusion for Convection
402             IF (ivdc_kappa.NE.0.) CALL CALC_IVDC(
403         I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
404         U       ConvectCount, KappaRT, KappaRS,
405         I       myTime,myIter,myThid)
406    CRG: do we need do store STORE KappaRT, KappaRS ?
407    
408    C--      Recompute density after mixing
409    #ifdef  INCLUDE_FIND_RHO_CALL
410             CALL FIND_RHO(
411         I      bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
412         O      rhoKm1,
413         I      myThid )
414    #endif
415            ENDIF
416    C--     Calculate buoyancy
417            CALL CALC_BUOYANCY(
418         I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,
419         O      buoyKm1,
420         I      myThid )
421    C--     Integrate hydrostatic balance for phiHyd with BC of
422    C--     phiHyd(z=0)=0
423            CALL CALC_PHI_HYD(
424         I      bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1,
425         U      phiHyd,
426         I      myThid )
427            CALL GRAD_SIGMA(
428       I            bi, bj, iMin, iMax, jMin, jMax, K,       I            bi, bj, iMin, iMax, jMin, jMax, K,
429       I            rhoKm1, rhoKp1,       I            rhoKm1, rhoKm1, rhoKm1,
430       O            K13, K23, K33, KapGM,       O            sigmaX, sigmaY, sigmaR,
431       I            myThid )       I            myThid )
432  C--     Calculate static stability and mix where convectively unstable  
433          CALL CONVECT(  C--     Start of downward loop
434       I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,          DO K=2,Nr
435       I      myTime,myIter,myThid)  
436  C--     Density of K-1 level (above W(K)) reference to K-1 level  #ifdef ALLOW_AUTODIFF_TAMC
437          CALL FIND_RHO(           kkey = (ikey-1)*(Nr-2+1) + (k-2) + 1
438       I     bi, bj, iMin, iMax, jMin, jMax,  K-1, K-1, 'LINEAR',  #endif
439       O     rhoKm1,  
440       I     myThid )           BOTTOM_LAYER = K .EQ. Nr
441  C--     Density of K level (below W(K)) referenced to K level  
442          CALL FIND_RHO(  #ifdef DO_PIPELINED_CORRECTION_STEP
443       I     bi, bj, iMin, iMax, jMin, jMax,  K, K, 'LINEAR',           IF ( .NOT. BOTTOM_LAYER ) THEN
444       O     rhoKp1,  C--       Update fields in layer below according to tendency terms
445       I     myThid )            CALL CORRECTION_STEP(
446  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0       I         bi,bj,iMin,iMax,jMin,jMax,K+1,
447          CALL CALC_PH(       I         etaSurfX,etaSurfY,myTime,myThid)
448       I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,  #ifdef ALLOW_OBCS
449       U      pH,            IF (openBoundaries) THEN
450    #ifdef ALLOW_AUTODIFF_TAMC
451    CADJ STORE uvel (:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
452    CADJ STORE vvel (:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
453    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
454    CADJ STORE salt(:,:,k,bi,bj)   = comlev1_2d, key = ikey, byte = isbyte
455    #endif
456                 CALL APPLY_OBCS1( bi, bj, K+1, myThid )
457              END IF
458    #endif
459             ENDIF
460    #endif
461    
462    C--      Density of K level (below W(K)) reference to K level
463    #ifdef  INCLUDE_FIND_RHO_CALL
464    #ifdef ALLOW_AUTODIFF_TAMC
465    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
466    CADJ STORE salt (:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
467    #endif
468             CALL FIND_RHO(
469         I      bi, bj, iMin, iMax, jMin, jMax,  K, K, eosType,
470         O      rhoK,
471       I      myThid )       I      myThid )
472    #endif
473             IF (       (.NOT. BOTTOM_LAYER)
474         &      ) THEN
475    C--       Check static stability with layer below and mix as needed.
476    C--       Density of K+1 level (below W(K+1)) reference to K level.
477    #ifdef  INCLUDE_FIND_RHO_CALL
478    #ifdef ALLOW_AUTODIFF_TAMC
479    CADJ STORE theta(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
480    CADJ STORE salt (:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
481    #endif
482              CALL FIND_RHO(
483         I       bi, bj, iMin, iMax, jMin, jMax,  K+1, K, eosType,
484         O       rhoKp1,
485         I       myThid )
486    #endif
487    
488    #ifdef ALLOW_AUTODIFF_TAMC
489    CADJ STORE rhok  (:,:)   = comlev1_3d, key = kkey, byte = isbyte
490    CADJ STORE rhoKm1(:,:)   = comlev1_3d, key = kkey, byte = isbyte
491    CADJ STORE rhoKp1(:,:)   = comlev1_3d, key = kkey, byte = isbyte
492    #endif
493    
494    #ifdef  INCLUDE_CONVECT_CALL
495              CALL CONVECT(
496         I        bi,bj,iMin,iMax,jMin,jMax,K+1,rhoK,rhoKp1,
497         U        ConvectCount,
498         I        myTime,myIter,myThid)
499    #ifdef ALLOW_AUTODIFF_TAMC
500    CADJ STORE theta(:,:,k+1,bi,bj),theta(:,:,k,bi,bj)
501    CADJ &     = comlev1_3d, key = kkey, byte = isbyte
502    CADJ STORE salt (:,:,k+1,bi,bj),salt (:,:,k,bi,bj)
503    CADJ &     = comlev1_3d, key = kkey, byte = isbyte
504    #endif
505    #endif
506    
507    C--      Implicit Vertical Diffusion for Convection
508             IF (ivdc_kappa.NE.0.) THEN
509                CALL CALC_IVDC(
510         I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
511         U       ConvectCount, KappaRT, KappaRS,
512         I       myTime,myIter,myThid)
513    CRG: do we need do store STORE KappaRT, KappaRS ?
514             END IF
515    
516    C--       Recompute density after mixing
517    #ifdef  INCLUDE_FIND_RHO_CALL
518              CALL FIND_RHO(
519         I       bi, bj, iMin, iMax, jMin, jMax, K, K, eosType,
520         O       rhoK,
521         I       myThid )
522    #endif
523             ENDIF
524    C--      Calculate buoyancy
525             CALL CALC_BUOYANCY(
526         I       bi,bj,iMin,iMax,jMin,jMax,K,rhoK,
527         O       buoyK,
528         I       myThid )
529    C--      Integrate hydrostatic balance for phiHyd with BC of
530    C--      phiHyd(z=0)=0
531             CALL CALC_PHI_HYD(
532         I        bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyK,
533         U        phiHyd,
534         I        myThid )
535    C--      Calculate iso-neutral slopes for the GM/Redi parameterisation
536    #ifdef  INCLUDE_FIND_RHO_CALL
537             CALL FIND_RHO(
538         I        bi, bj, iMin, iMax, jMin, jMax, K-1, K, eosType,
539         O        rhoTmp,
540         I        myThid )
541    #endif
542             CALL GRAD_SIGMA(
543         I             bi, bj, iMin, iMax, jMin, jMax, K,
544         I             rhoK, rhotmp, rhoK,
545         O             sigmaX, sigmaY, sigmaR,
546         I             myThid )
547    
548    
549             DO J=jMin,jMax
550              DO I=iMin,iMax
551    #ifdef  INCLUDE_FIND_RHO_CALL
552               rhoKm1 (I,J) = rhoK(I,J)
553    #endif
554               buoyKm1(I,J) = buoyK(I,J)
555              ENDDO
556             ENDDO
557            ENDDO
558    C--     end of k loop
559    
560    #ifdef ALLOW_GMREDI
561    #ifdef ALLOW_AUTODIFF_TAMC
562    CADJ STORE rhoTmp(:,:)  = comlev1_3d, key = kkey, byte = isbyte
563    CADJ STORE rhok  (:,:)  = comlev1_3d, key = kkey, byte = isbyte
564    CADJ STORE rhoKm1(:,:)  = comlev1_3d, key = kkey, byte = isbyte
565    #endif
566            DO K=1, Nr
567             IF (use_GMRedi) CALL GMREDI_CALC_TENSOR(
568         I             bi, bj, iMin, iMax, jMin, jMax, K,
569         I             sigmaX, sigmaY, sigmaR,
570         I             myThid )
571          ENDDO          ENDDO
572    #endif
573    
574    #ifdef ALLOW_AUTODIFF_TAMC
575    CADJ STORE theta(:,:,:,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
576    CADJ STORE salt (:,:,:,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
577    CADJ STORE uvel (:,:,:,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
578    CADJ STORE vvel (:,:,:,bi,bj)  = comlev1_2d, key = ikey, byte = isbyte
579    #endif
580    
581    #ifdef ALLOW_KPP
582    C--     Compute KPP mixing coefficients
583            CALL TIMER_START('KPP_CALC               [DYNAMICS]', myThid)
584            CALL KPP_CALC(
585         I               bi, bj, myTime, myThid )
586            CALL TIMER_STOP ('KPP_CALC               [DYNAMICS]', myThid)
587    #endif
588    
589    C--     Start of upward loop
590            DO K = Nr, 1, -1
591    
         DO K = Nz, 1, -1  
592           kM1  =max(1,k-1)   ! Points to level above k (=k-1)           kM1  =max(1,k-1)   ! Points to level above k (=k-1)
593           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
594           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
595    
596           iMin = 1-OLx+2           iMin = 1-OLx+2
597           iMax = sNx+OLx-1           iMax = sNx+OLx-1
598           jMin = 1-OLy+2           jMin = 1-OLy+2
599           jMax = sNy+OLy-1           jMax = sNy+OLy-1
600    
601    #ifdef ALLOW_AUTODIFF_TAMC
602             kkey = (ikey-1)*(Nr-1+1) + (k-1) + 1
603    #endif
604    
605    #ifdef ALLOW_AUTODIFF_TAMC
606    CADJ STORE rvel  (:,:,kDown)  = comlev1_3d, key = kkey, byte = isbyte
607    CADJ STORE rTrans(:,:)        = comlev1_3d, key = kkey, byte = isbyte
608    CADJ STORE KappaRT(:,:,:)     = comlev1_3d, key = kkey, byte = isbyte
609    CADJ STORE KappaRS(:,:,:)     = comlev1_3d, key = kkey, byte = isbyte
610    #endif
611    
612  C--      Get temporary terms used by tendency routines  C--      Get temporary terms used by tendency routines
613           CALL CALC_COMMON_FACTORS (           CALL CALC_COMMON_FACTORS (
614       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
615       O        xA,yA,uTrans,vTrans,wTrans,maskC,maskUp,       O        xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp,
616       I        myThid)       I        myThid)
617    
618  C--      Calculate accelerations in the momentum equations  #ifdef ALLOW_OBCS
619           CALL CALC_MOM_RHS(          IF (openBoundaries) THEN
620       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,           CALL APPLY_OBCS3( bi, bj, K, Kup, rTrans, rVel, myThid )
621       I        xA,yA,uTrans,vTrans,wTrans,maskC,          ENDIF
622       I        pH,  #endif
623       U        aTerm,xTerm,cTerm,mTerm,pTerm,  
624       U        fZon, fMer, fVerU, fVerV,  #ifdef  INCLUDE_CALC_DIFFUSIVITY_CALL
625    C--      Calculate the total vertical diffusivity
626             CALL CALC_DIFFUSIVITY(
627         I        bi,bj,iMin,iMax,jMin,jMax,K,
628         I        maskC,maskUp,
629         O        KappaRT,KappaRS,KappaRU,KappaRV,
630       I        myThid)       I        myThid)
631    #endif
632    C--      Calculate accelerations in the momentum equations
633             IF ( momStepping ) THEN
634              CALL CALC_MOM_RHS(
635         I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
636         I         xA,yA,uTrans,vTrans,rTrans,rVel,maskC,
637         I         phiHyd,KappaRU,KappaRV,
638         U         aTerm,xTerm,cTerm,mTerm,pTerm,
639         U         fZon, fMer, fVerU, fVerV,
640         I         myTime, myThid)
641    #ifdef ALLOW_AUTODIFF_TAMC
642    #ifdef INCLUDE_CD_CODE
643             ELSE
644                DO j=1-OLy,sNy+OLy
645                   DO i=1-OLx,sNx+OLx
646                      guCD(i,j,k,bi,bj) = 0.0
647                      gvCD(i,j,k,bi,bj) = 0.0
648                   END DO
649                END DO
650    #endif
651    #endif
652             ENDIF
653  C--      Calculate active tracer tendencies  C--      Calculate active tracer tendencies
654           CALL CALC_GT(           IF ( tempStepping ) THEN
655       I        bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,            CALL CALC_GT(
656       I        xA,yA,uTrans,vTrans,wTrans,maskUp,       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
657       I        K13,K23,K33,KapGM,       I         xA,yA,uTrans,vTrans,rTrans,maskUp,maskC,
658       U        aTerm,xTerm,fZon,fMer,fVerT,       I         KappaRT,
659       I        myThid)       U         aTerm,xTerm,fZon,fMer,fVerT,
660  Cdbg     CALL CALC_GS(       I         myTime, myThid)
661  Cdbg I        bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,           ENDIF
662  Cdbg I        xA,yA,uTrans,vTrans,wTrans,maskUp,           IF ( saltStepping ) THEN
663  Cdbg I        K13,K23,K33,KapGM,            CALL CALC_GS(
664  Cdbg U        aTerm,xTerm,fZon,fMer,fVerS,       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
665  Cdbg I        myThid)       I         xA,yA,uTrans,vTrans,rTrans,maskUp,maskC,
666         I         KappaRS,
667         U         aTerm,xTerm,fZon,fMer,fVerS,
668         I         myTime, myThid)
669             ENDIF
670    #ifdef ALLOW_OBCS
671    C--      Calculate future values on open boundaries
672             IF (openBoundaries) THEN
673    Caja      CALL CYCLE_OBCS( K, bi, bj, myThid )
674              CALL SET_OBCS( K, bi, bj, myTime+deltaTclock, myThid )
675             ENDIF
676    #endif
677    C--      Prediction step (step forward all model variables)
678             CALL TIMESTEP(
679         I       bi,bj,iMin,iMax,jMin,jMax,K,
680         I       myIter, myThid)
681    #ifdef ALLOW_OBCS
682    C--      Apply open boundary conditions
683             IF (openBoundaries) THEN
684    #ifdef ALLOW_AUTODIFF_TAMC
685    CADJ STORE gunm1(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
686    CADJ STORE gvnm1(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
687    CADJ STORE gwnm1(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
688    #endif
689                CALL APPLY_OBCS2( bi, bj, K, myThid )
690             END IF
691    #endif
692    C--      Freeze water
693             IF (allowFreezing) THEN
694    #ifdef ALLOW_AUTODIFF_TAMC
695    CADJ STORE gTNm1(:,:,k,bi,bj)  = comlev1_3d, key = kkey, byte = isbyte
696    #endif
697                CALL FREEZE( bi, bj, iMin, iMax, jMin, jMax, K, myThid )
698             END IF
699    
700    #ifdef DIVG_IN_DYNAMICS
701    C--      Diagnose barotropic divergence of predicted fields
702             CALL CALC_DIV_GHAT(
703         I       bi,bj,iMin,iMax,jMin,jMax,K,
704         I       xA,yA,
705         I       myThid)
706    #endif /* DIVG_IN_DYNAMICS */
707    
708          ENDDO  C--      Cumulative diagnostic calculations (ie. time-averaging)
709    #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE
710             IF (taveFreq.GT.0.) THEN
711              CALL DO_TIME_AVERAGES(
712         I                           myTime, myIter, bi, bj, K, kUp, kDown,
713         I                           rVel, ConvectCount,
714         I                           myThid )
715             ENDIF
716    #endif
717    
718    
719            ENDDO ! K
720    
721    #ifdef ALLOW_AUTODIFF_TAMC
722               maximpl = 6
723               iikey = (ikey-1)*maximpl
724    #endif
725    
726    C--     Implicit diffusion
727            IF (implicitDiffusion) THEN
728    
729             IF (tempStepping) THEN
730    #ifdef ALLOW_AUTODIFF_TAMC
731                idkey = iikey + 1
732    #endif
733                CALL IMPLDIFF(
734         I         bi, bj, iMin, iMax, jMin, jMax,
735         I         deltaTtracer, KappaRT,recip_HFacC,
736         U         gTNm1,
737         I         myThid )
738             END IF
739    
740             IF (saltStepping) THEN
741    #ifdef ALLOW_AUTODIFF_TAMC
742             idkey = iikey + 2
743    #endif
744                CALL IMPLDIFF(
745         I         bi, bj, iMin, iMax, jMin, jMax,
746         I         deltaTtracer, KappaRS,recip_HFacC,
747         U         gSNm1,
748         I         myThid )
749             END IF
750    
751            ENDIF ! implicitDiffusion
752    
753    C--     Implicit viscosity
754            IF (implicitViscosity) THEN
755    
756             IF (momStepping) THEN
757    #ifdef ALLOW_AUTODIFF_TAMC
758             idkey = iikey + 3
759    #endif
760              CALL IMPLDIFF(
761         I         bi, bj, iMin, iMax, jMin, jMax,
762         I         deltaTmom, KappaRU,recip_HFacW,
763         U         gUNm1,
764         I         myThid )
765    #ifdef ALLOW_AUTODIFF_TAMC
766             idkey = iikey + 4
767    #endif
768              CALL IMPLDIFF(
769         I         bi, bj, iMin, iMax, jMin, jMax,
770         I         deltaTmom, KappaRV,recip_HFacS,
771         U         gVNm1,
772         I         myThid )
773    
774    #ifdef INCLUDE_CD_CODE
775    
776    #ifdef ALLOW_AUTODIFF_TAMC
777             idkey = iikey + 5
778    #endif
779              CALL IMPLDIFF(
780         I         bi, bj, iMin, iMax, jMin, jMax,
781         I         deltaTmom, KappaRU,recip_HFacW,
782         U         vVelD,
783         I         myThid )
784    #ifdef ALLOW_AUTODIFF_TAMC
785            idkey = iikey + 6
786    #endif
787              CALL IMPLDIFF(
788         I         bi, bj, iMin, iMax, jMin, jMax,
789         I         deltaTmom, KappaRV,recip_HFacS,
790         U         uVelD,
791         I         myThid )
792    
793    #endif
794    
795             ENDIF ! momStepping
796            ENDIF ! implicitViscosity
797    
798         ENDDO         ENDDO
799        ENDDO        ENDDO
800    
801  !dbg  write(0,*) 'dynamics: pS',minval(cg2d_x),maxval(cg2d_x)  C     write(0,*) 'dynamics: pS ',minval(cg2d_x(1:sNx,1:sNy,:,:)),
802  !dbg  write(0,*) 'dynamics: U',minval(uVel(1:sNx,1:sNy,:,:,:)),  C    &                           maxval(cg2d_x(1:sNx,1:sNy,:,:))
803  !dbg &                         maxval(uVel(1:sNx,1:sNy,:,:,:))  C     write(0,*) 'dynamics: U  ',minval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.),
804  !dbg  write(0,*) 'dynamics: V',minval(vVel(1:sNx,1:sNy,:,:,:)),  C    &                           maxval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.)
805  !dbg &                         maxval(vVel(1:sNx,1:sNy,:,:,:))  C     write(0,*) 'dynamics: V  ',minval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.),
806  !dbg  write(0,*) 'dynamics: gT',minval(gT(1:sNx,1:sNy,:,:,:)),  C    &                           maxval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.)
807  !dbg &                         maxval(gT(1:sNx,1:sNy,:,:,:))  C     write(0,*) 'dynamics: rVel(1) ',
808  !dbg  write(0,*) 'dynamics: T',minval(Theta(1:sNx,1:sNy,:,:,:)),  C    &            minval(rVel(1:sNx,1:sNy,1),mask=rVel(1:sNx,1:sNy,1).NE.0.),
809  !dbg &                         maxval(Theta(1:sNx,1:sNy,:,:,:))  C    &            maxval(rVel(1:sNx,1:sNy,1),mask=rVel(1:sNx,1:sNy,1).NE.0.)
810  !dbg  write(0,*) 'dynamics: pH',minval(pH/(Gravity*Rhonil)),  C     write(0,*) 'dynamics: rVel(2) ',
811  !dbg &                          maxval(pH/(Gravity*Rhonil))  C    &            minval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.),
812    C    &            maxval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.)
813    C     write(0,*) 'dynamics: gT ',minval(gT(1:sNx,1:sNy,:,:,:)),
814    C    &                           maxval(gT(1:sNx,1:sNy,:,:,:))
815    C     write(0,*) 'dynamics: T  ',minval(Theta(1:sNx,1:sNy,:,:,:)),
816    C    &                           maxval(Theta(1:sNx,1:sNy,:,:,:))
817    C     write(0,*) 'dynamics: gS ',minval(gS(1:sNx,1:sNy,:,:,:)),
818    C    &                           maxval(gS(1:sNx,1:sNy,:,:,:))
819    C     write(0,*) 'dynamics: S  ',minval(salt(1:sNx,1:sNy,:,:,:)),
820    C    &                           maxval(salt(1:sNx,1:sNy,:,:,:))
821    C     write(0,*) 'dynamics: phiHyd ',minval(phiHyd/(Gravity*Rhonil),mask=phiHyd.NE.0.),
822    C    &                           maxval(phiHyd/(Gravity*Rhonil))
823    C     CALL PLOT_FIELD_XYZRL( gU, ' GU exiting dyanmics ' ,
824    C    &Nr, 1, myThid )
825    C     CALL PLOT_FIELD_XYZRL( gV, ' GV exiting dyanmics ' ,
826    C    &Nr, 1, myThid )
827    C     CALL PLOT_FIELD_XYZRL( gS, ' GS exiting dyanmics ' ,
828    C    &Nr, 1, myThid )
829    C     CALL PLOT_FIELD_XYZRL( gT, ' GT exiting dyanmics ' ,
830    C    &Nr, 1, myThid )
831    C     CALL PLOT_FIELD_XYZRL( phiHyd, ' phiHyd exiting dyanmics ' ,
832    C    &Nr, 1, myThid )
833    
834    
835        RETURN        RETURN
836        END        END

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.22