/[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.38 by cnh, Fri Nov 6 22:44:45 1998 UTC revision 1.47 by adcroft, Mon Aug 30 18:29:26 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
38  C     myIter - Current iteration number in simulation  C     myIter - Current iteration number in simulation
39  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
       INTEGER myThid  
40        _RL myTime        _RL myTime
41        INTEGER myIter        INTEGER myIter
42          INTEGER myThid
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
# Line 117  C                      index into fVerTe Line 122  C                      index into fVerTe
122        _RL KapGM   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL KapGM   (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
123        _RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)        _RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
124        _RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)        _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    #ifdef INCLUDE_CONVECT_CALL
129          _RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
130    #endif
131    
132        INTEGER iMin, iMax        INTEGER iMin, iMax
133        INTEGER jMin, jMax        INTEGER jMin, jMax
# Line 193  C     uninitialised but inert locations. Line 204  C     uninitialised but inert locations.
204           K13(i,j,k)  = 0. _d 0           K13(i,j,k)  = 0. _d 0
205           K23(i,j,k)  = 0. _d 0           K23(i,j,k)  = 0. _d 0
206           K33(i,j,k)  = 0. _d 0           K33(i,j,k)  = 0. _d 0
207           KappaRT(i,j,k) = 0. _d 0           KappaRU(i,j,k) = 0. _d 0
208           KappaRS(i,j,k) = 0. _d 0           KappaRV(i,j,k) = 0. _d 0
209          ENDDO          ENDDO
210          rhoKM1 (i,j) = 0. _d 0          rhoKM1 (i,j) = 0. _d 0
211          rhok   (i,j) = 0. _d 0          rhok   (i,j) = 0. _d 0
# Line 232  C--     Set up work arrays that need val Line 243  C--     Set up work arrays that need val
243           ENDDO           ENDDO
244          ENDDO          ENDDO
245    
246            DO k=1,Nr
247             DO j=1-OLy,sNy+OLy
248              DO i=1-OLx,sNx+OLx
249    #ifdef INCLUDE_CONVECT_CALL
250               ConvectCount(i,j,k) = 0.
251    #endif
252               KappaRT(i,j,k) = 0. _d 0
253               KappaRS(i,j,k) = 0. _d 0
254              ENDDO
255             ENDDO
256            ENDDO
257    
258          iMin = 1-OLx+1          iMin = 1-OLx+1
259          iMax = sNx+OLx          iMax = sNx+OLx
260          jMin = 1-OLy+1          jMin = 1-OLy+1
# Line 251  C--     Update fields in top level accor Line 274  C--     Update fields in top level accor
274          CALL CORRECTION_STEP(          CALL CORRECTION_STEP(
275       I       bi,bj,iMin,iMax,jMin,jMax,K,       I       bi,bj,iMin,iMax,jMin,jMax,K,
276       I       etaSurfX,etaSurfY,myTime,myThid)       I       etaSurfX,etaSurfY,myTime,myThid)
277    #ifdef ALLOW_OBCS
278            IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K, myThid )
279    #endif
280          IF ( .NOT. BOTTOM_LAYER ) THEN          IF ( .NOT. BOTTOM_LAYER ) THEN
281  C--      Update fields in layer below according to tendency terms  C--      Update fields in layer below according to tendency terms
282           CALL CORRECTION_STEP(           CALL CORRECTION_STEP(
283       I        bi,bj,iMin,iMax,jMin,jMax,K+1,       I        bi,bj,iMin,iMax,jMin,jMax,K+1,
284       I        etaSurfX,etaSurfY,myTime,myThid)       I        etaSurfX,etaSurfY,myTime,myThid)
285    #ifdef ALLOW_OBCS
286             IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K+1, myThid )
287    #endif
288          ENDIF          ENDIF
289  #endif  #endif
290  C--     Density of 1st level (below W(1)) reference to level 1  C--     Density of 1st level (below W(1)) reference to level 1
# Line 266  C--     Density of 1st level (below W(1) Line 295  C--     Density of 1st level (below W(1)
295       I     myThid )       I     myThid )
296  #endif  #endif
297    
298          IF ( .NOT. BOTTOM_LAYER ) THEN          IF (       (.NOT. BOTTOM_LAYER)
299    #ifdef ALLOW_KPP
300         &       .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing
301    #endif
302         &     ) THEN
303  C--      Check static stability with layer below  C--      Check static stability with layer below
304  C--      and mix as needed.  C--      and mix as needed.
305  #ifdef  INCLUDE_FIND_RHO_CALL  #ifdef  INCLUDE_FIND_RHO_CALL
# Line 278  C--      and mix as needed. Line 311  C--      and mix as needed.
311  #ifdef  INCLUDE_CONVECT_CALL  #ifdef  INCLUDE_CONVECT_CALL
312           CALL CONVECT(           CALL CONVECT(
313       I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,       I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
314         U       ConvectCount,
315       I       myTime,myIter,myThid)       I       myTime,myIter,myThid)
316  #endif  #endif
317    C--      Implicit Vertical Diffusion for Convection
318             IF (ivdc_kappa.NE.0.) CALL CALC_IVDC(
319         I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
320         U       ConvectCount, KappaRT, KappaRS,
321         I       myTime,myIter,myThid)
322  C--      Recompute density after mixing  C--      Recompute density after mixing
323  #ifdef  INCLUDE_FIND_RHO_CALL  #ifdef  INCLUDE_FIND_RHO_CALL
324           CALL FIND_RHO(           CALL FIND_RHO(
# Line 308  C--       Update fields in layer below a Line 347  C--       Update fields in layer below a
347            CALL CORRECTION_STEP(            CALL CORRECTION_STEP(
348       I         bi,bj,iMin,iMax,jMin,jMax,K+1,       I         bi,bj,iMin,iMax,jMin,jMax,K+1,
349       I         etaSurfX,etaSurfY,myTime,myThid)       I         etaSurfX,etaSurfY,myTime,myThid)
350    #ifdef ALLOW_OBCS
351              IF (openBoundaries) CALL APPLY_OBCS1( bi, bj, K+1, myThid )
352    #endif
353           ENDIF           ENDIF
354  #endif  #endif
355  C--      Density of K level (below W(K)) reference to K level  C--      Density of K level (below W(K)) reference to K level
# Line 317  C--      Density of K level (below W(K)) Line 359  C--      Density of K level (below W(K))
359       O      rhoK,       O      rhoK,
360       I      myThid )       I      myThid )
361  #endif  #endif
362           IF ( .NOT. BOTTOM_LAYER ) THEN           IF (       (.NOT. BOTTOM_LAYER)
363    #ifdef ALLOW_KPP
364         &       .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing
365    #endif
366         &      ) THEN
367  C--       Check static stability with layer below and mix as needed.  C--       Check static stability with layer below and mix as needed.
368  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.
369  #ifdef  INCLUDE_FIND_RHO_CALL  #ifdef  INCLUDE_FIND_RHO_CALL
# Line 329  C--       Density of K+1 level (below W( Line 375  C--       Density of K+1 level (below W(
375  #ifdef  INCLUDE_CONVECT_CALL  #ifdef  INCLUDE_CONVECT_CALL
376            CALL CONVECT(            CALL CONVECT(
377       I        bi,bj,iMin,iMax,jMin,jMax,K+1,rhoK,rhoKp1,       I        bi,bj,iMin,iMax,jMin,jMax,K+1,rhoK,rhoKp1,
378         U        ConvectCount,
379       I        myTime,myIter,myThid)       I        myTime,myIter,myThid)
380  #endif  #endif
381    C--      Implicit Vertical Diffusion for Convection
382             IF (ivdc_kappa.NE.0.) CALL CALC_IVDC(
383         I       bi,bj,iMin,iMax,jMin,jMax,K+1,rhoKm1,rhoKp1,
384         U       ConvectCount, KappaRT, KappaRS,
385         I       myTime,myIter,myThid)
386  C--       Recompute density after mixing  C--       Recompute density after mixing
387  #ifdef  INCLUDE_FIND_RHO_CALL  #ifdef  INCLUDE_FIND_RHO_CALL
388            CALL FIND_RHO(            CALL FIND_RHO(
# Line 374  C--      Calculate iso-neutral slopes fo Line 426  C--      Calculate iso-neutral slopes fo
426           ENDDO           ENDDO
427          ENDDO ! K          ENDDO ! K
428    
429    #ifdef ALLOW_KPP
430    C--     Compute KPP mixing coefficients
431            IF (usingKPPmixing) THEN
432             CALL TIMER_START('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]'
433         I          , myThid)
434             CALL KVMIX(
435         I               bi, bj, myTime, myThid )
436             CALL TIMER_STOP ('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]'
437         I        , myThid)
438            ENDIF
439    #endif
440    
441          DO K = Nr, 1, -1          DO K = Nr, 1, -1
442    
443           kM1  =max(1,k-1)   ! Points to level above k (=k-1)           kM1  =max(1,k-1)   ! Points to level above k (=k-1)
# Line 389  C--      Get temporary terms used by ten Line 453  C--      Get temporary terms used by ten
453       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I        bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
454       O        xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp,       O        xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp,
455       I        myThid)       I        myThid)
456    #ifdef ALLOW_OBCS
457            IF (openBoundaries) THEN
458             CALL APPLY_OBCS3( bi, bj, K, Kup, rTrans, rVel, myThid )
459            ENDIF
460    #endif
461  #ifdef  INCLUDE_CALC_DIFFUSIVITY_CALL  #ifdef  INCLUDE_CALC_DIFFUSIVITY_CALL
462  C--      Calculate the total vertical diffusivity  C--      Calculate the total vertical diffusivity
463           CALL CALC_DIFFUSIVITY(           CALL CALC_DIFFUSIVITY(
464       I        bi,bj,iMin,iMax,jMin,jMax,K,       I        bi,bj,iMin,iMax,jMin,jMax,K,
465       I        maskC,maskUp,KapGM,K33,       I        maskC,maskUp,KapGM,K33,
466       O        KappaRT,KappaRS,       O        KappaRT,KappaRS,KappaRU,KappaRV,
467       I        myThid)       I        myThid)
468  #endif  #endif
469  C--      Calculate accelerations in the momentum equations  C--      Calculate accelerations in the momentum equations
# Line 402  C--      Calculate accelerations in the Line 471  C--      Calculate accelerations in the
471            CALL CALC_MOM_RHS(            CALL CALC_MOM_RHS(
472       I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,       I         bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
473       I         xA,yA,uTrans,vTrans,rTrans,rVel,maskC,       I         xA,yA,uTrans,vTrans,rTrans,rVel,maskC,
474       I         phiHyd,       I         phiHyd,KappaRU,KappaRV,
475       U         aTerm,xTerm,cTerm,mTerm,pTerm,       U         aTerm,xTerm,cTerm,mTerm,pTerm,
476       U         fZon, fMer, fVerU, fVerV,       U         fZon, fMer, fVerU, fVerV,
477       I         myTime, myThid)       I         myTime, myThid)
# Line 424  C--      Calculate active tracer tendenc Line 493  C--      Calculate active tracer tendenc
493       U         aTerm,xTerm,fZon,fMer,fVerS,       U         aTerm,xTerm,fZon,fMer,fVerS,
494       I         myTime, myThid)       I         myTime, myThid)
495           ENDIF           ENDIF
496    #ifdef ALLOW_OBCS
497    C--      Calculate future values on open boundaries
498             IF (openBoundaries) THEN
499    Caja      CALL CYCLE_OBCS( K, bi, bj, myThid )
500              CALL SET_OBCS( K, bi, bj, myTime+deltaTclock, myThid )
501             ENDIF
502    #endif
503  C--      Prediction step (step forward all model variables)  C--      Prediction step (step forward all model variables)
504           CALL TIMESTEP(           CALL TIMESTEP(
505       I       bi,bj,iMin,iMax,jMin,jMax,K,       I       bi,bj,iMin,iMax,jMin,jMax,K,
506       I       myThid)       I       myIter, myThid)
507    #ifdef ALLOW_OBCS
508    C--      Apply open boundary conditions
509             IF (openBoundaries) CALL APPLY_OBCS2( bi, bj, K, myThid )
510    #endif
511    C--      Freeze water
512             IF (allowFreezing)
513         &   CALL FREEZE( bi, bj, iMin, iMax, jMin, jMax, K, myThid )
514  C--      Diagnose barotropic divergence of predicted fields  C--      Diagnose barotropic divergence of predicted fields
515           CALL CALC_DIV_GHAT(           CALL CALC_DIV_GHAT(
516       I       bi,bj,iMin,iMax,jMin,jMax,K,       I       bi,bj,iMin,iMax,jMin,jMax,K,
# Line 439  C--      Cumulative diagnostic calculati Line 522  C--      Cumulative diagnostic calculati
522           IF (taveFreq.GT.0.) THEN           IF (taveFreq.GT.0.) THEN
523            CALL DO_TIME_AVERAGES(            CALL DO_TIME_AVERAGES(
524       I                           myTime, myIter, bi, bj, K, kUp, kDown,       I                           myTime, myIter, bi, bj, K, kUp, kDown,
525       I                           K13, K23, rVel, KapGM,       I                           K13, K23, rVel, KapGM, ConvectCount,
526       I                           myThid )       I                           myThid )
527           ENDIF           ENDIF
528  #endif  #endif
529    
530    
531          ENDDO ! K          ENDDO ! K
532    
533  C--     Implicit diffusion  C--     Implicit diffusion
534          IF (implicitDiffusion) THEN          IF (implicitDiffusion) THEN
535           CALL IMPLDIFF( bi, bj, iMin, iMax, jMin, jMax,           IF (tempStepping) CALL IMPLDIFF(
536       I                  KappaRT,KappaRS,       I         bi, bj, iMin, iMax, jMin, jMax,
537       I                  myThid )       I         deltaTtracer, KappaRT,recip_HFacC,
538          ENDIF       U         gTNm1,
539         I         myThid )
540             IF (saltStepping) CALL IMPLDIFF(
541         I         bi, bj, iMin, iMax, jMin, jMax,
542         I         deltaTtracer, KappaRS,recip_HFacC,
543         U         gSNm1,
544         I         myThid )
545            ENDIF ! implicitDiffusion
546    C--     Implicit viscosity
547            IF (implicitViscosity) THEN
548             IF (momStepping) THEN
549              CALL IMPLDIFF(
550         I         bi, bj, iMin, iMax, jMin, jMax,
551         I         deltaTmom, KappaRU,recip_HFacW,
552         U         gUNm1,
553         I         myThid )
554              CALL IMPLDIFF(
555         I         bi, bj, iMin, iMax, jMin, jMax,
556         I         deltaTmom, KappaRV,recip_HFacS,
557         U         gVNm1,
558         I         myThid )
559    #ifdef INCLUDE_CD_CODE
560              CALL IMPLDIFF(
561         I         bi, bj, iMin, iMax, jMin, jMax,
562         I         deltaTmom, KappaRU,recip_HFacW,
563         U         vVelD,
564         I         myThid )
565              CALL IMPLDIFF(
566         I         bi, bj, iMin, iMax, jMin, jMax,
567         I         deltaTmom, KappaRV,recip_HFacS,
568         U         uVelD,
569         I         myThid )
570    #endif
571             ENDIF ! momStepping
572            ENDIF ! implicitViscosity
573    
574         ENDDO         ENDDO
575        ENDDO        ENDDO

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.22