/[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.93 by jmc, Tue Feb 11 04:05:32 2003 UTC revision 1.100 by edhill, Thu Oct 9 04:19:18 2003 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4    #include "PACKAGES_CONFIG.h"
5  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
6    
7  CBOP  CBOP
# Line 85  C     == Global variables === Line 86  C     == Global variables ===
86  #  include "KPP.h"  #  include "KPP.h"
87  # endif  # endif
88  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
 #ifdef ALLOW_TIMEAVE  
 #include "TIMEAVE_STATV.h"  
 #endif  
89    
90  C     !CALLING SEQUENCE:  C     !CALLING SEQUENCE:
91  C     DYNAMICS()  C     DYNAMICS()
# Line 98  C      |-- CALC_VISCOSITY Line 96  C      |-- CALC_VISCOSITY
96  C      |  C      |
97  C      |-- CALC_PHI_HYD    C      |-- CALC_PHI_HYD  
98  C      |  C      |
 C      |-- STORE_PRESSURE  
 C      |  
99  C      |-- MOM_FLUXFORM    C      |-- MOM_FLUXFORM  
100  C      |  C      |
101  C      |-- MOM_VECINV      C      |-- MOM_VECINV    
# Line 130  C     fVer[STUV]               o fVer: V Line 126  C     fVer[STUV]               o fVer: V
126  C                                      is "pipelined" in the vertical  C                                      is "pipelined" in the vertical
127  C                                      so we need an fVer for each  C                                      so we need an fVer for each
128  C                                      variable.  C                                      variable.
129  C     rhoK, rhoKM1   - Density at current level, and level above  C     phiHydC    :: hydrostatic potential anomaly at cell center
130  C     phiHyd         - Hydrostatic part of the potential.  C                   In z coords phiHyd is the hydrostatic potential
131  C                      In z coords phiHyd is the hydrostatic  C                      (=pressure/rho0) anomaly
132  C                      Potential (=pressure/rho0) anomaly  C                   In p coords phiHyd is the geopotential height anomaly.
133  C                      In p coords phiHyd is the geopotential  C     phiHydF    :: hydrostatic potential anomaly at middle between 2 centers
134  C                      surface height anomaly.  C     dPhiHydX,Y :: Gradient (X & Y directions) of hydrostatic potential anom.
135  C     dPhiHydX,Y :: Gradient (X & Y directions) of Hydrostatic Potential  C     phiSurfX,  ::  gradient of Surface potential (Pressure/rho, ocean)
 C     phiSurfX, - gradient of Surface potential (Pressure/rho, ocean)  
136  C     phiSurfY             or geopotential (atmos) in X and Y direction  C     phiSurfY             or geopotential (atmos) in X and Y direction
137  C     iMin, iMax     - Ranges and sub-block indices on which calculations  C     iMin, iMax     - Ranges and sub-block indices on which calculations
138  C     jMin, jMax       are applied.  C     jMin, jMax       are applied.
# Line 147  C     kDown, km1       are switched with Line 142  C     kDown, km1       are switched with
142  C                      index into fVerTerm.  C                      index into fVerTerm.
143        _RL fVerU   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerU   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
144        _RL fVerV   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerV   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
145        _RL phiHyd  (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL phiHydF (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
146          _RL phiHydC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
147        _RL dPhiHydX(1-Olx:sNx+Olx,1-Oly:sNy+Oly)        _RL dPhiHydX(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
148        _RL dPhiHydY(1-Olx:sNx+Olx,1-Oly:sNy+Oly)        _RL dPhiHydY(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
       _RL rhokm1  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)  
       _RL rhok    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)  
149        _RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
150        _RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
151        _RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)        _RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
# Line 211  C         (1 + dt * K * d_zz) salt[n] = Line 205  C         (1 + dt * K * d_zz) salt[n] =
205  C---  C---
206  CEOP  CEOP
207    
 C--   Set up work arrays with valid (i.e. not NaN) values  
 C     These inital values do not alter the numerical results. They  
 C     just ensure that all memory references are to valid floating  
 C     point numbers. This prevents spurious hardware signals due to  
 C     uninitialised but inert locations.  
       DO j=1-OLy,sNy+OLy  
        DO i=1-OLx,sNx+OLx  
         rhoKM1 (i,j) = 0. _d 0  
         rhok   (i,j) = 0. _d 0  
         phiSurfX(i,j) = 0. _d 0  
         phiSurfY(i,j) = 0. _d 0  
        ENDDO  
       ENDDO  
   
208  C-- Call to routine for calculation of  C-- Call to routine for calculation of
209  C   Eliassen-Palm-flux-forced U-tendency,  C   Eliassen-Palm-flux-forced U-tendency,
210  C   if desired:  C   if desired:
# Line 242  CHPF$ INDEPENDENT Line 222  CHPF$ INDEPENDENT
222  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
223  C--    HPF directive to help TAMC  C--    HPF directive to help TAMC
224  CHPF$  INDEPENDENT, NEW (fVerU,fVerV  CHPF$  INDEPENDENT, NEW (fVerU,fVerV
225  CHPF$&                  ,phiHyd  CHPF$&                  ,phiHydF
226  CHPF$&                  ,KappaRU,KappaRV  CHPF$&                  ,KappaRU,KappaRV
227  CHPF$&                  )  CHPF$&                  )
228  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
# Line 262  CHPF$&                  ) Line 242  CHPF$&                  )
242       &                      + act4*max1*max2*max3       &                      + act4*max1*max2*max3
243  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
244    
245  C--     Set up work arrays that need valid initial values  C--   Set up work arrays with valid (i.e. not NaN) values
246          DO j=1-OLy,sNy+OLy  C     These inital values do not alter the numerical results. They
247           DO i=1-OLx,sNx+OLx  C     just ensure that all memory references are to valid floating
248            DO k=1,Nr  C     point numbers. This prevents spurious hardware signals due to
249             phiHyd(i,j,k)  = 0. _d 0  C     uninitialised but inert locations.
250    
251            DO k=1,Nr
252             DO j=1-OLy,sNy+OLy
253              DO i=1-OLx,sNx+OLx
254             KappaRU(i,j,k) = 0. _d 0             KappaRU(i,j,k) = 0. _d 0
255             KappaRV(i,j,k) = 0. _d 0             KappaRV(i,j,k) = 0. _d 0
256    #ifdef ALLOW_AUTODIFF_TAMC
257    cph(
258    c--   need some re-initialisation here to break dependencies
259    c--   totphihyd is assumed zero from ini_pressure, i.e.
260    c--   avoiding iterate pressure p = integral of (g*rho(p)*dz)
261    cph)
262               totPhiHyd(i,j,k,bi,bj) = 0. _d 0
263               gu(i,j,k,bi,bj) = 0. _d 0
264               gv(i,j,k,bi,bj) = 0. _d 0
265    #endif
266            ENDDO            ENDDO
267             ENDDO
268            ENDDO
269            DO j=1-OLy,sNy+OLy
270             DO i=1-OLx,sNx+OLx
271            fVerU  (i,j,1) = 0. _d 0            fVerU  (i,j,1) = 0. _d 0
272            fVerU  (i,j,2) = 0. _d 0            fVerU  (i,j,2) = 0. _d 0
273            fVerV  (i,j,1) = 0. _d 0            fVerV  (i,j,1) = 0. _d 0
274            fVerV  (i,j,2) = 0. _d 0            fVerV  (i,j,2) = 0. _d 0
275              phiHydF (i,j)  = 0. _d 0
276              phiHydC (i,j)  = 0. _d 0
277            dPhiHydX(i,j)  = 0. _d 0            dPhiHydX(i,j)  = 0. _d 0
278            dPhiHydY(i,j)  = 0. _d 0            dPhiHydY(i,j)  = 0. _d 0
279              phiSurfX(i,j)  = 0. _d 0
280              phiSurfY(i,j)  = 0. _d 0
281           ENDDO           ENDDO
282          ENDDO          ENDDO
283    
# Line 333  C--       kDown  Cycles through 2,1 to p Line 335  C--       kDown  Cycles through 2,1 to p
335    
336  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
337           kkey = (idynkey-1)*Nr + k           kkey = (idynkey-1)*Nr + k
338  CADJ STORE pressure(:,:,k,bi,bj) = comlev1_bibj_k ,  c
339  CADJ &     key=kkey , byte=isbyte  CADJ STORE totphihyd (:,:,k,bi,bj)
340    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
341    CADJ STORE gt (:,:,k,bi,bj)
342    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
343    CADJ STORE gs (:,:,k,bi,bj)
344    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
345    CADJ STORE theta (:,:,k,bi,bj)
346    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
347    CADJ STORE salt  (:,:,k,bi,bj)
348    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
349  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
350    
351  C--      Integrate hydrostatic balance for phiHyd with BC of  C--      Integrate hydrostatic balance for phiHyd with BC of
# Line 344  C        distinguishe between Stagger an Line 355  C        distinguishe between Stagger an
355             CALL CALC_PHI_HYD(             CALL CALC_PHI_HYD(
356       I        bi,bj,iMin,iMax,jMin,jMax,k,       I        bi,bj,iMin,iMax,jMin,jMax,k,
357       I        gT, gS,       I        gT, gS,
358       U        phiHyd,       U        phiHydF,
359       O        dPhiHydX, dPhiHydY,       O        phiHydC, dPhiHydX, dPhiHydY,
360       I        myTime, myIter, myThid )       I        myTime, myIter, myThid )
361           ELSE           ELSE
362             CALL CALC_PHI_HYD(             CALL CALC_PHI_HYD(
363       I        bi,bj,iMin,iMax,jMin,jMax,k,       I        bi,bj,iMin,iMax,jMin,jMax,k,
364       I        theta, salt,       I        theta, salt,
365       U        phiHyd,       U        phiHydF,
366       O        dPhiHydX, dPhiHydY,       O        phiHydC, dPhiHydX, dPhiHydY,
367       I        myTime, myIter, myThid )       I        myTime, myIter, myThid )
368           ENDIF           ENDIF
369    
 C        calculate pressure from phiHyd and store it on common block  
 C        variable pressure  
          CALL STORE_PRESSURE( bi, bj, k, phiHyd, myThid )  
   
370  C--      Calculate accelerations in the momentum equations (gU, gV, ...)  C--      Calculate accelerations in the momentum equations (gU, gV, ...)
371  C        and step forward storing the result in gUnm1, gVnm1, etc...  C        and step forward storing the result in gU, gV, etc...
372           IF ( momStepping ) THEN           IF ( momStepping ) THEN
373  #ifndef DISABLE_MOM_FLUXFORM  #ifndef DISABLE_MOM_FLUXFORM
374             IF (.NOT. vectorInvariantMomentum) CALL MOM_FLUXFORM(             IF (.NOT. vectorInvariantMomentum) CALL MOM_FLUXFORM(
375       I         bi,bj,iMin,iMax,jMin,jMax,k,kup,kDown,       I         bi,bj,iMin,iMax,jMin,jMax,k,kup,kDown,
376       I         phiHyd,dPhiHydX,dPhiHydY,KappaRU,KappaRV,       I         dPhiHydX,dPhiHydY,KappaRU,KappaRV,
377       U         fVerU, fVerV,       U         fVerU, fVerV,
378       I         myTime, myIter, myThid)       I         myTime, myIter, myThid)
379  #endif  #endif
# Line 379  C        and step forward storing the re Line 386  C        and step forward storing the re
386  #endif  #endif
387             CALL TIMESTEP(             CALL TIMESTEP(
388       I         bi,bj,iMin,iMax,jMin,jMax,k,       I         bi,bj,iMin,iMax,jMin,jMax,k,
389       I         phiHyd, dPhiHydX,dPhiHydY, phiSurfX, phiSurfY,       I         dPhiHydX,dPhiHydY, phiSurfX, phiSurfY,
390       I         myIter, myThid)       I         myTime, myIter, myThid)
391    
392  #ifdef   ALLOW_OBCS  #ifdef   ALLOW_OBCS
393  C--      Apply open boundary conditions  C--      Apply open boundary conditions
394           IF (useOBCS) THEN             IF (useOBCS) THEN
395             CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid )               CALL OBCS_APPLY_UV( bi, bj, k, gU, gV, myThid )
396           END IF             ENDIF
397  #endif   /* ALLOW_OBCS */  #endif   /* ALLOW_OBCS */
398    
 #ifdef   ALLOW_AUTODIFF_TAMC  
 #ifdef   INCLUDE_CD_CODE  
          ELSE  
            DO j=1-OLy,sNy+OLy  
              DO i=1-OLx,sNx+OLx  
                guCD(i,j,k,bi,bj) = 0.0  
                gvCD(i,j,k,bi,bj) = 0.0  
              END DO  
            END DO  
 #endif   /* INCLUDE_CD_CODE */  
 #endif   /* ALLOW_AUTODIFF_TAMC */  
399           ENDIF           ENDIF
400    
401    
# Line 409  C--     end of dynamics k loop (1:Nr) Line 405  C--     end of dynamics k loop (1:Nr)
405  C--     Implicit viscosity  C--     Implicit viscosity
406          IF (implicitViscosity.AND.momStepping) THEN          IF (implicitViscosity.AND.momStepping) THEN
407  #ifdef    ALLOW_AUTODIFF_TAMC  #ifdef    ALLOW_AUTODIFF_TAMC
408  CADJ STORE gUNm1(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte  CADJ STORE gU(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
409  #endif    /* ALLOW_AUTODIFF_TAMC */  #endif    /* ALLOW_AUTODIFF_TAMC */
410            CALL IMPLDIFF(            CALL IMPLDIFF(
411       I         bi, bj, iMin, iMax, jMin, jMax,       I         bi, bj, iMin, iMax, jMin, jMax,
412       I         deltaTmom, KappaRU,recip_HFacW,       I         deltaTmom, KappaRU,recip_HFacW,
413       U         gUNm1,       U         gU,
414       I         myThid )       I         myThid )
415  #ifdef    ALLOW_AUTODIFF_TAMC  #ifdef    ALLOW_AUTODIFF_TAMC
416  CADJ STORE gVNm1(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte  CADJ STORE gV(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
417  #endif    /* ALLOW_AUTODIFF_TAMC */  #endif    /* ALLOW_AUTODIFF_TAMC */
418            CALL IMPLDIFF(            CALL IMPLDIFF(
419       I         bi, bj, iMin, iMax, jMin, jMax,       I         bi, bj, iMin, iMax, jMin, jMax,
420       I         deltaTmom, KappaRV,recip_HFacS,       I         deltaTmom, KappaRV,recip_HFacS,
421       U         gVNm1,       U         gV,
422       I         myThid )       I         myThid )
423    
424  #ifdef   ALLOW_OBCS  #ifdef   ALLOW_OBCS
425  C--      Apply open boundary conditions  C--      Apply open boundary conditions
426           IF (useOBCS) THEN           IF (useOBCS) THEN
427             DO K=1,Nr             DO K=1,Nr
428               CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid )               CALL OBCS_APPLY_UV( bi, bj, k, gU, gV, myThid )
429             ENDDO             ENDDO
430           END IF           END IF
431  #endif   /* ALLOW_OBCS */  #endif   /* ALLOW_OBCS */
# Line 455  CADJ STORE uVelD(:,:,:,bi,bj) = comlev1_ Line 451  CADJ STORE uVelD(:,:,:,bi,bj) = comlev1_
451  C--     End If implicitViscosity.AND.momStepping  C--     End If implicitViscosity.AND.momStepping
452          ENDIF          ENDIF
453    
 C- jmc: add for diagnostic of phiHyd  
         IF ( DIFFERENT_MULTIPLE(diagFreq,myTime+deltaTClock,myTime)  
      &       .AND. buoyancyRelation .NE. 'OCEANIC' ) THEN  
           CALL WRITE_LOCAL_RL('Ph','I10',Nr,phiHyd,  
      &                         bi,bj,1,myIter+1,myThid)  
         ENDIF  
   
 #ifdef ALLOW_TIMEAVE  
         IF (taveFreq.GT.0.) THEN  
           CALL TIMEAVE_CUMUL_1T(phiHydtave, phiHyd, Nr,  
      I                              deltaTclock, bi, bj, myThid)  
         ENDIF  
 #endif /* ALLOW_TIMEAVE */  
   
454         ENDDO         ENDDO
455        ENDDO        ENDDO
456    
# Line 481  C     &                'phiHydLow', myTh Line 463  C     &                'phiHydLow', myTh
463  Cml)  Cml)
464    
465  #ifndef DISABLE_DEBUGMODE  #ifndef DISABLE_DEBUGMODE
466        If (debugMode) THEN        If ( debugLevel .GE. debLevB ) THEN
467         CALL DEBUG_STATS_RL(1,EtaN,'EtaN (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(1,EtaN,'EtaN (DYNAMICS)',myThid)
468         CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (DYNAMICS)',myThid)
469         CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (DYNAMICS)',myThid)

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.100

  ViewVC Help
Powered by ViewVC 1.1.22