/[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.5 by adcroft, Mon May 4 16:32:10 1998 UTC revision 1.18 by adcroft, Wed Jun 10 16:05:39 1998 UTC
# Line 2  C $Header$ Line 2  C $Header$
2    
3  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
4    
5        SUBROUTINE DYNAMICS(myThid)        SUBROUTINE DYNAMICS(myTime, myIter, myThid)
6  C     /==========================================================\  C     /==========================================================\
7  C     | SUBROUTINE DYNAMICS                                      |  C     | SUBROUTINE DYNAMICS                                      |
8  C     | o Controlling routine for the explicit part of the model |  C     | o Controlling routine for the explicit part of the model |
# Line 25  C     == Global variables === Line 25  C     == Global variables ===
25  #include "SIZE.h"  #include "SIZE.h"
26  #include "EEPARAMS.h"  #include "EEPARAMS.h"
27  #include "CG2D.h"  #include "CG2D.h"
28    #include "PARAMS.h"
29  #include "DYNVARS.h"  #include "DYNVARS.h"
30    
31  C     == Routine arguments ==  C     == Routine arguments ==
32    C     myTime - Current time in simulation
33    C     myIter - Current iteration number in simulation
34  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
35        INTEGER myThid        INTEGER myThid
36          _RL myTime
37          INTEGER myIter
38    
39  C     == Local variables  C     == Local variables
40  C     xA, yA                 - Per block temporaries holding face areas  C     xA, yA                 - Per block temporaries holding face areas
41  C     uTrans, vTrans, wTrans - Per block temporaries holding flow transport  C     uTrans, vTrans, wTrans - Per block temporaries holding flow transport
42  C                              o uTrans: Zonal transport  C     wVel                     o uTrans: Zonal transport
43  C                              o vTrans: Meridional transport  C                              o vTrans: Meridional transport
44  C                              o wTrans: Vertical transport  C                              o wTrans: Vertical transport
45    C                              o wVel:   Vertical velocity at upper and lower
46    C                                        cell faces.
47  C     maskC,maskUp             o maskC: land/water mask for tracer cells  C     maskC,maskUp             o maskC: land/water mask for tracer cells
48  C                              o maskUp: land/water mask for W points  C                              o maskUp: land/water mask for W points
49  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in  C     aTerm, xTerm, cTerm    - Work arrays for holding separate terms in
# Line 63  C                          into fVerTerm Line 70  C                          into fVerTerm
70        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
71        _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72        _RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
73          _RL wVel  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
74        _RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
75        _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
76        _RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
# Line 79  C                          into fVerTerm Line 87  C                          into fVerTerm
87        _RL pH    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)        _RL pH    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)
88        _RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
89        _RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
90          _RL rhotmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
91        _RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
92        _RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
93          _RL K13   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)
94          _RL K23   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)
95          _RL K33   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz)
96          _RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
97          _RL KappaZT(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nz)
98          _RL KappaZS(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nz)
99    
100        INTEGER iMin, iMax        INTEGER iMin, iMax
101        INTEGER jMin, jMax        INTEGER jMin, jMax
102        INTEGER bi, bj        INTEGER bi, bj
103        INTEGER i, j        INTEGER i, j
104        INTEGER k, kM1, kUp, kDown        INTEGER k, kM1, kUp, kDown
105    
106    C---    The algorithm...
107    C
108    C       "Correction Step"
109    C       =================
110    C       Here we update the horizontal velocities with the surface
111    C       pressure such that the resulting flow is either consistent
112    C       with the free-surface evolution or the rigid-lid:
113    C         U[n] = U* + dt x d/dx P
114    C         V[n] = V* + dt x d/dy P
115    C
116    C       "Calculation of Gs"
117    C       ===================
118    C       This is where all the accelerations and tendencies (ie.
119    C       physics, parameterizations etc...) are calculated
120    C         w = sum_z ( div. u[n] )
121    C         rho = rho ( theta[n], salt[n] )
122    C         K31 = K31 ( rho )
123    C         Gu[n] = Gu( u[n], v[n], w, rho, Ph, ... )
124    C         Gv[n] = Gv( u[n], v[n], w, rho, Ph, ... )
125    C         Gt[n] = Gt( theta[n], u[n], v[n], w, K31, ... )
126    C         Gs[n] = Gs( salt[n], u[n], v[n], w, K31, ... )
127    C
128    C       "Time-stepping" or "Prediction"
129    C       ================================
130    C       The models variables are stepped forward with the appropriate
131    C       time-stepping scheme (currently we use Adams-Bashforth II)
132    C       - For momentum, the result is always *only* a "prediction"
133    C       in that the flow may be divergent and will be "corrected"
134    C       later with a surface pressure gradient.
135    C       - Normally for tracers the result is the new field at time
136    C       level [n+1} *BUT* in the case of implicit diffusion the result
137    C       is also *only* a prediction.
138    C       - We denote "predictors" with an asterisk (*).
139    C         U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] )
140    C         V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] )
141    C         theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
142    C         salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
143    C       With implicit diffusion:
144    C         theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
145    C         salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
146    C         (1 + dt * K * d_zz) theta[n] = theta*
147    C         (1 + dt * K * d_zz) salt[n] = salt*
148    C---
149    
150  C--   Set up work arrays with valid (i.e. not NaN) values  C--   Set up work arrays with valid (i.e. not NaN) values
151  C     These inital values do not alter the numerical results. They  C     These inital values do not alter the numerical results. They
152  C     just ensure that all memory references are to valid floating  C     just ensure that all memory references are to valid floating
# Line 107  C     uninitialised but inert locations. Line 167  C     uninitialised but inert locations.
167          fMer(i,j)    = 0. _d 0          fMer(i,j)    = 0. _d 0
168          DO K=1,nZ          DO K=1,nZ
169           pH (i,j,k)  = 0. _d 0           pH (i,j,k)  = 0. _d 0
170             K13(i,j,k) = 0. _d 0
171             K23(i,j,k) = 0. _d 0
172             K33(i,j,k) = 0. _d 0
173             KappaZT(i,j,k) = 0. _d 0
174          ENDDO          ENDDO
175          rhokm1(i,j)  = 0. _d 0          rhokm1(i,j)  = 0. _d 0
176          rhokp1(i,j)  = 0. _d 0          rhokp1(i,j)  = 0. _d 0
177         ENDDO          rhotmp(i,j)  = 0. _d 0
178        ENDDO          maskC (i,j)  = 0. _d 0
 C--   Set up work arrays that need valid initial values  
       DO j=1-OLy,sNy+OLy  
        DO i=1-OLx,sNx+OLx  
         wTrans(i,j)  = 0. _d 0  
         fVerT(i,j,1) = 0. _d 0  
         fVerT(i,j,2) = 0. _d 0  
         fVerS(i,j,1) = 0. _d 0  
         fVerS(i,j,2) = 0. _d 0  
         fVerU(i,j,1) = 0. _d 0  
         fVerU(i,j,2) = 0. _d 0  
         fVerV(i,j,1) = 0. _d 0  
         fVerV(i,j,2) = 0. _d 0  
179         ENDDO         ENDDO
180        ENDDO        ENDDO
181    
182        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
183         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
184    
185  C--   Boundary condition on hydrostatic pressure is pH(z=0)=0  C--     Set up work arrays that need valid initial values
186          DO j=1-OLy,sNy+OLy          DO j=1-OLy,sNy+OLy
187           DO i=1-OLx,sNx+OLx           DO i=1-OLx,sNx+OLx
188              wTrans(i,j)  = 0. _d 0
189              wVel  (i,j,1) = 0. _d 0
190              wVel  (i,j,2) = 0. _d 0
191              fVerT(i,j,1) = 0. _d 0
192              fVerT(i,j,2) = 0. _d 0
193              fVerS(i,j,1) = 0. _d 0
194              fVerS(i,j,2) = 0. _d 0
195              fVerU(i,j,1) = 0. _d 0
196              fVerU(i,j,2) = 0. _d 0
197              fVerV(i,j,1) = 0. _d 0
198              fVerV(i,j,2) = 0. _d 0
199            pH(i,j,1) = 0. _d 0            pH(i,j,1) = 0. _d 0
200              K13(i,j,1) = 0. _d 0
201              K23(i,j,1) = 0. _d 0
202              K33(i,j,1) = 0. _d 0
203              KapGM(i,j) = 0. _d 0
204           ENDDO           ENDDO
205          ENDDO          ENDDO
206    
# Line 149  C--     Calculate gradient of surface pr Line 216  C--     Calculate gradient of surface pr
216       I       myThid)       I       myThid)
217    
218  C--     Update fields in top level according to tendency terms  C--     Update fields in top level according to tendency terms
219          CALL TIMESTEP(          CALL CORRECTION_STEP(
220       I       bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid)       I       bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid)
221    
222  C Density of 1st level (below W(1)) reference to level 1  C--     Density of 1st level (below W(1)) reference to level 1
223           CALL FIND_RHO(          CALL FIND_RHO(
224       I      bi, bj, iMin, iMax, jMin, jMax, 1, 1, 'LINEAR',       I     bi, bj, iMin, iMax, jMin, jMax, 1, 1, eosType,
225       O      rhoKm1,       O     rhoKm1,
226       I      myThid )       I     myThid )
227  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0
228           CALL CALC_PH(          CALL CALC_PH(
229       I       bi,bj,iMin,iMax,jMin,jMax,1,rhoKm1,rhoKm1,       I      bi,bj,iMin,iMax,jMin,jMax,1,rhoKm1,rhoKm1,
230       U       pH,       U      pH,
231       I       myThid )       I      myThid )
232            DO J=jMin,jMax
233             DO I=iMin,iMax
234              rhoKp1(I,J)=rhoKm1(I,J)
235             ENDDO
236            ENDDO
237    
238          DO K=2,Nz          DO K=2,Nz
239  C--     Update fields in Kth level according to tendency terms  C--     Update fields in Kth level according to tendency terms
240          CALL TIMESTEP(          CALL CORRECTION_STEP(
241       I       bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid)       I       bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid)
242  C Density of K-1 level (above W(K)) reference to K level  C--     Density of K-1 level (above W(K)) reference to K-1 level
243           CALL FIND_RHO(  copt    CALL FIND_RHO(
244       I      bi, bj, iMin, iMax, jMin, jMax,  K-1, K, 'LINEAR',  copt I     bi, bj, iMin, iMax, jMin, jMax,  K-1, K-1, eosType,
245       O      rhoKm1,  copt O     rhoKm1,
246       I      myThid )  copt I     myThid )
247  C Density of K level (below W(K)) reference to K level  C       rhoKm1=rhoKp1
248           CALL FIND_RHO(          DO J=jMin,jMax
249       I      bi, bj, iMin, iMax, jMin, jMax,  K, K, 'LINEAR',           DO I=iMin,iMax
250       O      rhoKp1,            rhoKm1(I,J)=rhoKp1(I,J)
251       I      myThid )           ENDDO
252            ENDDO
253    C--     Density of K level (below W(K)) reference to K level
254            CALL FIND_RHO(
255         I     bi, bj, iMin, iMax, jMin, jMax,  K, K, eosType,
256         O     rhoKp1,
257         I     myThid )
258    C--     Density of K-1 level (above W(K)) reference to K level
259            CALL FIND_RHO(
260         I     bi, bj, iMin, iMax, jMin, jMax,  K-1, K, eosType,
261         O     rhotmp,
262         I     myThid )
263    C--     Calculate iso-neutral slopes for the GM/Redi parameterisation
264            CALL CALC_ISOSLOPES(
265         I            bi, bj, iMin, iMax, jMin, jMax, K,
266         I            rhoKm1, rhoKp1, rhotmp,
267         O            K13, K23, K33, KapGM,
268         I            myThid )
269  C--     Calculate static stability and mix where convectively unstable  C--     Calculate static stability and mix where convectively unstable
270           CALL CONVECT(          CALL CONVECT(
271       I       bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,myThid)       I      bi,bj,iMin,iMax,jMin,jMax,K,rhotmp,rhoKp1,
272  C Density of K-1 level (above W(K)) reference to K-1 level       I      myTime,myIter,myThid)
273           CALL FIND_RHO(  C--     Density of K-1 level (above W(K)) reference to K-1 level
274       I      bi, bj, iMin, iMax, jMin, jMax,  K-1, K-1, 'LINEAR',          CALL FIND_RHO(
275       O      rhoKm1,       I     bi, bj, iMin, iMax, jMin, jMax,  K-1, K-1, eosType,
276       I      myThid )       O     rhoKm1,
277  C Density of K level (below W(K)) referenced to K level       I     myThid )
278           CALL FIND_RHO(  C--     Density of K level (below W(K)) referenced to K level
279       I      bi, bj, iMin, iMax, jMin, jMax,  K, K, 'LINEAR',          CALL FIND_RHO(
280       O      rhoKp1,       I     bi, bj, iMin, iMax, jMin, jMax,  K, K, eosType,
281       I      myThid )       O     rhoKp1,
282         I     myThid )
283  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0  C--     Integrate hydrostatic balance for pH with BC of pH(z=0)=0
284           CALL CALC_PH(          CALL CALC_PH(
285       I       bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,       I      bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,
286       U       pH,       U      pH,
287       I       myThid )       I      myThid )
288    
289          ENDDO ! K          ENDDO ! K
290    
291    C--     Initial boundary condition on barotropic divergence integral
292            DO j=1-OLy,sNy+OLy
293             DO i=1-OLx,sNx+OLx
294              cg2d_b(i,j,bi,bj) = 0. _d 0
295             ENDDO
296            ENDDO
297    
298          DO K = Nz, 1, -1          DO K = Nz, 1, -1
299           kM1  =max(1,k-1)   ! Points to level above k (=k-1)           kM1  =max(1,k-1)   ! Points to level above k (=k-1)
300           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
# Line 210  C--     Integrate hydrostatic balance fo Line 307  C--     Integrate hydrostatic balance fo
307  C--      Get temporary terms used by tendency routines  C--      Get temporary terms used by tendency routines
308           CALL CALC_COMMON_FACTORS (           CALL CALC_COMMON_FACTORS (
309       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
310       O        xA,yA,uTrans,vTrans,wTrans,maskC,maskUp,       O        xA,yA,uTrans,vTrans,wTrans,wVel,maskC,maskUp,
311       I        myThid)       I        myThid)
312    
313  C--      Calculate accelerations in the momentum equations  C--      Calculate the total vertical diffusivity
314           CALL CALC_MOM_RHS(           CALL CALC_DIFFUSIVITY(
315       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I        bi,bj,iMin,iMax,jMin,jMax,K,
316       I        xA,yA,uTrans,vTrans,wTrans,maskC,       I        maskC,maskUp,KapGM,K33,
317       I        pH,       O        KappaZT,KappaZS,
      U        aTerm,xTerm,cTerm,mTerm,pTerm,  
      U        fZon, fMer, fVerU, fVerV,  
318       I        myThid)       I        myThid)
319    
320    C--      Calculate accelerations in the momentum equations
321             IF ( momStepping ) THEN
322              CALL CALC_MOM_RHS(
323         I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
324         I         xA,yA,uTrans,vTrans,wTrans,wVel,maskC,
325         I         pH,
326         U         aTerm,xTerm,cTerm,mTerm,pTerm,
327         U         fZon, fMer, fVerU, fVerV,
328         I         myThid)
329             ENDIF
330    
331  C--      Calculate active tracer tendencies  C--      Calculate active tracer tendencies
332           CALL CALC_GT(           IF ( tempStepping ) THEN
333       I        bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,            CALL CALC_GT(
334       I        xA,yA,uTrans,vTrans,wTrans,maskUp,       I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
335       U        aTerm,xTerm,fZon,fMer,fVerT,       I         xA,yA,uTrans,vTrans,wTrans,maskUp,
336       I        myThid)       I         K13,K23,KappaZT,KapGM,
337  Cdbg     CALL CALC_GS(       U         aTerm,xTerm,fZon,fMer,fVerT,
338  Cdbg I        bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,       I         myThid)
339  Cdbg I        xA,yA,uTrans,vTrans,wTrans,maskUp,           ENDIF
340  Cdbg U        aTerm,xTerm,fZon,fMer,fVerS,           IF ( saltStepping ) THEN
341  Cdbg I        myThid)            CALL CALC_GS(
342         I         bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown,
343         I         xA,yA,uTrans,vTrans,wTrans,maskUp,
344         I         K13,K23,KappaZS,KapGM,
345         U         aTerm,xTerm,fZon,fMer,fVerS,
346         I         myThid)
347             ENDIF
348    
349    C--      Prediction step (step forward all model variables)
350             CALL TIMESTEP(
351         I       bi,bj,iMin,iMax,jMin,jMax,K,
352         I       myThid)
353    
354    C--      Diagnose barotropic divergence of predicted fields
355             CALL DIV_G(
356         I       bi,bj,iMin,iMax,jMin,jMax,K,
357         I       xA,yA,
358         I       myThid)
359    
360          ENDDO ! K          ENDDO ! K
361    
362    C--     Implicit diffusion
363            IF (implicitDiffusion) THEN
364             CALL IMPLDIFF( bi, bj, iMin, iMax, jMin, jMax,
365         I                  KappaZT,KappaZS,
366         I                  myThid )
367            ENDIF
368    
369         ENDDO         ENDDO
370        ENDDO        ENDDO
371    
372          write(0,*) 'dynamics: pS ',minval(cg2d_x(1:sNx,1:sNy,:,:)),
373         &                           maxval(cg2d_x(1:sNx,1:sNy,:,:))
374          write(0,*) 'dynamics: U  ',minval(uVel(1:sNx,1:sNy,:,:,:)),
375         &                           maxval(uVel(1:sNx,1:sNy,:,:,:))
376          write(0,*) 'dynamics: V  ',minval(vVel(1:sNx,1:sNy,:,:,:)),
377         &                           maxval(vVel(1:sNx,1:sNy,:,:,:))
378    cblk  write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)),
379    cblk &                           maxval(K13(1:sNx,1:sNy,:))
380    cblk  write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)),
381    cblk &                           maxval(K23(1:sNx,1:sNy,:))
382    cblk  write(0,*) 'dynamics: K33',minval(K33(1:sNx,1:sNy,:)),
383    cblk &                           maxval(K33(1:sNx,1:sNy,:))
384          write(0,*) 'dynamics: gT ',minval(gT(1:sNx,1:sNy,:,:,:)),
385         &                           maxval(gT(1:sNx,1:sNy,:,:,:))
386          write(0,*) 'dynamics: T  ',minval(Theta(1:sNx,1:sNy,:,:,:)),
387         &                           maxval(Theta(1:sNx,1:sNy,:,:,:))
388          write(0,*) 'dynamics: gS ',minval(gS(1:sNx,1:sNy,:,:,:)),
389         &                           maxval(gS(1:sNx,1:sNy,:,:,:))
390          write(0,*) 'dynamics: S  ',minval(salt(1:sNx,1:sNy,:,:,:)),
391         &                           maxval(salt(1:sNx,1:sNy,:,:,:))
392    cblk  write(0,*) 'dynamics: pH ',minval(pH/(Gravity*Rhonil)),
393    cblk &                           maxval(pH/(Gravity*Rhonil))
394    
395        RETURN        RETURN
396        END        END

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.22