/[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.92 by jmc, Sat Feb 8 02:09:20 2003 UTC revision 1.101 by heimbach, Fri Oct 10 22:56:08 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    
284  C--     Start computation of dynamics  C--     Start computation of dynamics
285          iMin = 1-OLx+2          iMin = 0
286          iMax = sNx+OLx-1          iMax = sNx+1
287          jMin = 1-OLy+2          jMin = 0
288          jMax = sNy+OLy-1          jMax = sNy+1
289    
290  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
291  CADJ STORE wvel (:,:,:,bi,bj) =  CADJ STORE wvel (:,:,:,bi,bj) =
# Line 319  C--      Calculate the total vertical di Line 321  C--      Calculate the total vertical di
321         ENDDO         ENDDO
322  #endif  #endif
323    
324    #ifdef ALLOW_AUTODIFF_TAMC
325    CADJ STORE KappaRU(:,:,:)
326    CADJ &                 = comlev1_bibj, key=idynkey, byte=isbyte
327    CADJ STORE KappaRV(:,:,:)
328    CADJ &                 = comlev1_bibj, key=idynkey, byte=isbyte
329    #endif /* ALLOW_AUTODIFF_TAMC */
330    
331  C--     Start of dynamics loop  C--     Start of dynamics loop
332          DO k=1,Nr          DO k=1,Nr
333    
# Line 333  C--       kDown  Cycles through 2,1 to p Line 342  C--       kDown  Cycles through 2,1 to p
342    
343  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
344           kkey = (idynkey-1)*Nr + k           kkey = (idynkey-1)*Nr + k
345  CADJ STORE pressure(:,:,k,bi,bj) = comlev1_bibj_k ,  c
346  CADJ &     key=kkey , byte=isbyte  CADJ STORE totphihyd (:,:,k,bi,bj)
347    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
348    CADJ STORE gt (:,:,k,bi,bj)
349    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
350    CADJ STORE gs (:,:,k,bi,bj)
351    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
352    CADJ STORE theta (:,:,k,bi,bj)
353    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
354    CADJ STORE salt  (:,:,k,bi,bj)
355    CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte
356  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
357    
358  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 362  C        distinguishe between Stagger an
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        gT, gS,       I        gT, gS,
365       U        phiHyd,       U        phiHydF,
366       O        dPhiHydX, dPhiHydY,       O        phiHydC, dPhiHydX, dPhiHydY,
367       I        myTime, myIter, myThid )       I        myTime, myIter, myThid )
368           ELSE           ELSE
369             CALL CALC_PHI_HYD(             CALL CALC_PHI_HYD(
370       I        bi,bj,iMin,iMax,jMin,jMax,k,       I        bi,bj,iMin,iMax,jMin,jMax,k,
371       I        theta, salt,       I        theta, salt,
372       U        phiHyd,       U        phiHydF,
373       O        dPhiHydX, dPhiHydY,       O        phiHydC, dPhiHydX, dPhiHydY,
374       I        myTime, myIter, myThid )       I        myTime, myIter, myThid )
375           ENDIF           ENDIF
376    
 C        calculate pressure from phiHyd and store it on common block  
 C        variable pressure  
          CALL STORE_PRESSURE( bi, bj, k, phiHyd, myThid )  
   
377  C--      Calculate accelerations in the momentum equations (gU, gV, ...)  C--      Calculate accelerations in the momentum equations (gU, gV, ...)
378  C        and step forward storing the result in gUnm1, gVnm1, etc...  C        and step forward storing the result in gU, gV, etc...
379           IF ( momStepping ) THEN           IF ( momStepping ) THEN
380  #ifndef DISABLE_MOM_FLUXFORM  #ifndef DISABLE_MOM_FLUXFORM
381             IF (.NOT. vectorInvariantMomentum) CALL MOM_FLUXFORM(             IF (.NOT. vectorInvariantMomentum) CALL MOM_FLUXFORM(
382       I         bi,bj,iMin,iMax,jMin,jMax,k,kup,kDown,       I         bi,bj,iMin,iMax,jMin,jMax,k,kup,kDown,
383       I         phiHyd,dPhiHydX,dPhiHydY,KappaRU,KappaRV,       I         dPhiHydX,dPhiHydY,KappaRU,KappaRV,
384       U         fVerU, fVerV,       U         fVerU, fVerV,
385       I         myTime, myIter, myThid)       I         myTime, myIter, myThid)
386  #endif  #endif
# Line 379  C        and step forward storing the re Line 393  C        and step forward storing the re
393  #endif  #endif
394             CALL TIMESTEP(             CALL TIMESTEP(
395       I         bi,bj,iMin,iMax,jMin,jMax,k,       I         bi,bj,iMin,iMax,jMin,jMax,k,
396       I         phiHyd, dPhiHydX,dPhiHydY, phiSurfX, phiSurfY,       I         dPhiHydX,dPhiHydY, phiSurfX, phiSurfY,
397       I         myIter, myThid)       I         myTime, myIter, myThid)
398    
399  #ifdef   ALLOW_OBCS  #ifdef   ALLOW_OBCS
400  C--      Apply open boundary conditions  C--      Apply open boundary conditions
401           IF (useOBCS) THEN             IF (useOBCS) THEN
402             CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid )               CALL OBCS_APPLY_UV( bi, bj, k, gU, gV, myThid )
403           END IF             ENDIF
404  #endif   /* ALLOW_OBCS */  #endif   /* ALLOW_OBCS */
405    
 #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 */  
406           ENDIF           ENDIF
407    
408    
# Line 409  C--     end of dynamics k loop (1:Nr) Line 412  C--     end of dynamics k loop (1:Nr)
412  C--     Implicit viscosity  C--     Implicit viscosity
413          IF (implicitViscosity.AND.momStepping) THEN          IF (implicitViscosity.AND.momStepping) THEN
414  #ifdef    ALLOW_AUTODIFF_TAMC  #ifdef    ALLOW_AUTODIFF_TAMC
415  CADJ STORE gUNm1(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte  CADJ STORE KappaRU(:,:,:) = comlev1_bibj , key=idynkey, byte=isbyte
416    CADJ STORE gU(:,:,:,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, KappaRU,recip_HFacW,       I         deltaTmom, KappaRU,recip_HFacW,
421       U         gUNm1,       U         gU,
422       I         myThid )       I         myThid )
423  #ifdef    ALLOW_AUTODIFF_TAMC  #ifdef    ALLOW_AUTODIFF_TAMC
424  CADJ STORE gVNm1(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte  CADJ STORE KappaRV(:,:,:) = comlev1_bibj , key=idynkey, byte=isbyte
425    CADJ STORE gV(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
426  #endif    /* ALLOW_AUTODIFF_TAMC */  #endif    /* ALLOW_AUTODIFF_TAMC */
427            CALL IMPLDIFF(            CALL IMPLDIFF(
428       I         bi, bj, iMin, iMax, jMin, jMax,       I         bi, bj, iMin, iMax, jMin, jMax,
429       I         deltaTmom, KappaRV,recip_HFacS,       I         deltaTmom, KappaRV,recip_HFacS,
430       U         gVNm1,       U         gV,
431       I         myThid )       I         myThid )
432    
433  #ifdef   ALLOW_OBCS  #ifdef   ALLOW_OBCS
434  C--      Apply open boundary conditions  C--      Apply open boundary conditions
435           IF (useOBCS) THEN           IF (useOBCS) THEN
436             DO K=1,Nr             DO K=1,Nr
437               CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid )               CALL OBCS_APPLY_UV( bi, bj, k, gU, gV, myThid )
438             ENDDO             ENDDO
439           END IF           END IF
440  #endif   /* ALLOW_OBCS */  #endif   /* ALLOW_OBCS */
# Line 455  CADJ STORE uVelD(:,:,:,bi,bj) = comlev1_ Line 460  CADJ STORE uVelD(:,:,:,bi,bj) = comlev1_
460  C--     End If implicitViscosity.AND.momStepping  C--     End If implicitViscosity.AND.momStepping
461          ENDIF          ENDIF
462    
 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 */  
   
463         ENDDO         ENDDO
464        ENDDO        ENDDO
465    
# Line 481  C     &                'phiHydLow', myTh Line 472  C     &                'phiHydLow', myTh
472  Cml)  Cml)
473    
474  #ifndef DISABLE_DEBUGMODE  #ifndef DISABLE_DEBUGMODE
475        If (debugMode) THEN        If ( debugLevel .GE. debLevB ) THEN
476         CALL DEBUG_STATS_RL(1,EtaN,'EtaN (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(1,EtaN,'EtaN (DYNAMICS)',myThid)
477         CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (DYNAMICS)',myThid)
478         CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (DYNAMICS)',myThid)         CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (DYNAMICS)',myThid)

Legend:
Removed from v.1.92  
changed lines
  Added in v.1.101

  ViewVC Help
Powered by ViewVC 1.1.22