/[MITgcm]/MITgcm/pkg/generic_advdiff/gad_advection.F
ViewVC logotype

Diff of /MITgcm/pkg/generic_advdiff/gad_advection.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.15 by heimbach, Fri Jun 27 01:57:28 2003 UTC revision 1.34 by jmc, Mon Dec 20 19:10:13 2004 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
 CBOI  
 C !TITLE: pkg/generic\_advdiff  
 C !AUTHORS: adcroft@mit.edu  
 C !INTRODUCTION: Generic Advection Diffusion Package  
 C  
 C Package "generic\_advdiff" provides a common set of routines for calculating  
 C advective/diffusive fluxes for tracers (cell centered quantities on a C-grid).  
 C  
 C Many different advection schemes are available: the standard centered  
 C second order, centered fourth order and upwind biased third order schemes  
 C are known as linear methods and require some stable time-stepping method  
 C such as Adams-Bashforth. Alternatives such as flux-limited schemes are  
 C stable in the forward sense and are best combined with the multi-dimensional  
 C method provided in gad\_advection.  
 C  
 C There are two high-level routines:  
 C  \begin{itemize}  
 C  \item{GAD\_CALC\_RHS} calculates all fluxes at time level "n" and is used  
 C  for the standard linear schemes. This must be used in conjuction with  
 C  Adams-Bashforth time-stepping. Diffusive and parameterized fluxes are  
 C  always calculated here.  
 C  \item{GAD\_ADVECTION} calculates just the advective fluxes using the  
 C  non-linear schemes and can not be used in conjuction with Adams-Bashforth  
 C  time-stepping.  
 C  \end{itemize}  
 CEOI  
   
4  #include "GAD_OPTIONS.h"  #include "GAD_OPTIONS.h"
5    #undef MULTIDIM_OLD_VERSION
6    
7    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
8  CBOP  CBOP
9  C !ROUTINE: GAD_ADVECTION  C !ROUTINE: GAD_ADVECTION
10    
11  C !INTERFACE: ==========================================================  C !INTERFACE: ==========================================================
12        SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity,        SUBROUTINE GAD_ADVECTION(
13       U                         Tracer,Gtracer,       I     implicitAdvection, advectionScheme, vertAdvecScheme,
14       I                         myTime,myIter,myThid)       I     tracerIdentity,
15         I     uVel, vVel, wVel, tracer,
16         O     gTracer,
17         I     bi,bj, myTime,myIter,myThid)
18    
19  C !DESCRIPTION:  C !DESCRIPTION:
20  C Calculates the tendancy of a tracer due to advection.  C Calculates the tendancy of a tracer due to advection.
# Line 62  C !USES: =============================== Line 40  C !USES: ===============================
40  #include "SIZE.h"  #include "SIZE.h"
41  #include "EEPARAMS.h"  #include "EEPARAMS.h"
42  #include "PARAMS.h"  #include "PARAMS.h"
 #include "DYNVARS.h"  
43  #include "GRID.h"  #include "GRID.h"
44  #include "GAD.h"  #include "GAD.h"
45  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
46  # include "tamc.h"  # include "tamc.h"
47  # include "tamc_keys.h"  # include "tamc_keys.h"
48    # ifdef ALLOW_PTRACERS
49    #  include "PTRACERS_SIZE.h"
50    # endif
51  #endif  #endif
52    #ifdef ALLOW_EXCH2
53    #include "W2_EXCH2_TOPOLOGY.h"
54    #include "W2_EXCH2_PARAMS.h"
55    #endif /* ALLOW_EXCH2 */
56    
57  C !INPUT PARAMETERS: ===================================================  C !INPUT PARAMETERS: ===================================================
58  C  bi,bj                :: tile indices  C  implicitAdvection :: implicit vertical advection (later on)
59  C  advectionScheme      :: advection scheme to use  C  advectionScheme   :: advection scheme to use (Horizontal plane)
60  C  tracerIdentity       :: identifier for the tracer (required only for OBCS)  C  vertAdvecScheme   :: advection scheme to use (vertical direction)
61  C  Tracer               :: tracer field  C  tracerIdentity    :: tracer identifier (required only for OBCS)
62  C  myTime               :: current time  C  uVel              :: velocity, zonal component
63  C  myIter               :: iteration number  C  vVel              :: velocity, meridional component
64  C  myThid               :: thread number  C  wVel              :: velocity, vertical component
65        INTEGER bi,bj  C  tracer            :: tracer field
66        INTEGER advectionScheme  C  bi,bj             :: tile indices
67    C  myTime            :: current time
68    C  myIter            :: iteration number
69    C  myThid            :: thread number
70          LOGICAL implicitAdvection
71          INTEGER advectionScheme, vertAdvecScheme
72        INTEGER tracerIdentity        INTEGER tracerIdentity
73        _RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)        _RL uVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
74          _RL vVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
75          _RL wVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
76          _RL tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
77          INTEGER bi,bj
78        _RL myTime        _RL myTime
79        INTEGER myIter        INTEGER myIter
80        INTEGER myThid        INTEGER myThid
81    
82  C !OUTPUT PARAMETERS: ==================================================  C !OUTPUT PARAMETERS: ==================================================
83  C  gTracer              :: tendancy array  C  gTracer           :: tendancy array
84        _RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)        _RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
85    
86  C !LOCAL VARIABLES: ====================================================  C !LOCAL VARIABLES: ====================================================
87  C  maskUp               :: 2-D array for mask at W points  C  maskUp        :: 2-D array for mask at W points
88  C  iMin,iMax,jMin,jMax  :: loop range for called routines  C  maskLocW      :: 2-D array for mask at West points
89  C  i,j,k                :: loop indices  C  maskLocS      :: 2-D array for mask at South points
90  C  kup                  :: index into 2 1/2D array, toggles between 1 and 2  C  iMin,iMax,    :: loop range for called routines
91  C  kdown                :: index into 2 1/2D array, toggles between 2 and 1  C  jMin,jMax     :: loop range for called routines
92  C  kp1                  :: =k+1 for k<Nr, =Nr for k=Nr  C [iMin,iMax]Upd :: loop range to update tracer field
93  C  xA,yA                :: areas of X and Y face of tracer cells  C [jMin,jMax]Upd :: loop range to update tracer field
94  C  uTrans,vTrans,rTrans :: 2-D arrays of volume transports at U,V and W points  C  i,j,k         :: loop indices
95  C  rTransKp1            :: vertical volume transport at interface k+1  C  kup           :: index into 2 1/2D array, toggles between 1 and 2
96  C  af                   :: 2-D array for horizontal advective flux  C  kdown         :: index into 2 1/2D array, toggles between 2 and 1
97  C  fVerT                :: 2 1/2D arrays for vertical advective flux  C  kp1           :: =k+1 for k<Nr, =Nr for k=Nr
98  C  localTij             :: 2-D array used as temporary local copy of tracer fld  C  xA,yA         :: areas of X and Y face of tracer cells
99  C  localTijk            :: 3-D array used as temporary local copy of tracer fld  C  uTrans,vTrans :: 2-D arrays of volume transports at U,V points
100  C  kp1Msk               :: flag (0,1) to act as over-riding mask for W levels  C  rTrans        :: 2-D arrays of volume transports at W points
101  C  calc_fluxes_X        :: logical to indicate to calculate fluxes in X dir  C  rTransKp1     :: vertical volume transport at interface k+1
102  C  calc_fluxes_Y        :: logical to indicate to calculate fluxes in Y dir  C  af            :: 2-D array for horizontal advective flux
103  C  nipass               :: number of passes to make in multi-dimensional method  C  afx           :: 2-D array for horizontal advective flux, x direction
104  C  ipass                :: number of the current pass being made  C  afy           :: 2-D array for horizontal advective flux, y direction
105    C  fVerT         :: 2 1/2D arrays for vertical advective flux
106    C  localTij      :: 2-D array, temporary local copy of tracer fld
107    C  localTijk     :: 3-D array, temporary local copy of tracer fld
108    C  kp1Msk        :: flag (0,1) for over-riding mask for W levels
109    C  calc_fluxes_X :: logical to indicate to calculate fluxes in X dir
110    C  calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir
111    C  interiorOnly  :: only update the interior of myTile, but not the edges
112    C  overlapOnly   :: only update the edges of myTile, but not the interior
113    C  nipass        :: number of passes in multi-dimensional method
114    C  ipass         :: number of the current pass being made
115    C  myTile        :: variables used to determine which cube face
116    C  nCFace        :: owns a tile for cube grid runs using
117    C                :: multi-dim advection.
118    C [N,S,E,W]_edge :: true if N,S,E,W edge of myTile is an Edge of the cube
119        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
120          _RS maskLocW(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
121          _RS maskLocS(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
122        INTEGER iMin,iMax,jMin,jMax        INTEGER iMin,iMax,jMin,jMax
123          INTEGER iMinUpd,iMaxUpd,jMinUpd,jMaxUpd
124        INTEGER i,j,k,kup,kDown        INTEGER i,j,k,kup,kDown
125        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
126        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
# Line 119  C  ipass                :: number of the Line 129  C  ipass                :: number of the
129        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
130        _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
131        _RL af      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL af      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
132          _RL afx     (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
133          _RL afy     (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
134        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
135        _RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
136        _RL localTijk(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL localTijk(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
137        _RL kp1Msk        _RL kp1Msk
138        LOGICAL calc_fluxes_X,calc_fluxes_Y        LOGICAL calc_fluxes_X, calc_fluxes_Y, withSigns
139          LOGICAL interiorOnly, overlapOnly
140        INTEGER nipass,ipass        INTEGER nipass,ipass
141          INTEGER myTile, nCFace
142          LOGICAL N_edge, S_edge, E_edge, W_edge
143    #ifdef ALLOW_DIAGNOSTICS
144          CHARACTER*8 diagName
145          CHARACTER*4 GAD_DIAG_SUFX, diagSufx
146          EXTERNAL    GAD_DIAG_SUFX
147    #endif
148  CEOP  CEOP
149    
150  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
# Line 148  CEOP Line 168  CEOP
168            endif            endif
169  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
170    
171    #ifdef ALLOW_DIAGNOSTICS
172    C--   Set diagnostic suffix for the current tracer
173          IF ( useDiagnostics ) THEN
174            diagSufx = GAD_DIAG_SUFX( tracerIdentity, myThid )
175          ENDIF
176    #endif
177    
178  C--   Set up work arrays with valid (i.e. not NaN) values  C--   Set up work arrays with valid (i.e. not NaN) values
179  C     These inital values do not alter the numerical results. They  C     These inital values do not alter the numerical results. They
180  C     just ensure that all memory references are to valid floating  C     just ensure that all memory references are to valid floating
# Line 166  C     uninitialised but inert locations. Line 193  C     uninitialised but inert locations.
193         ENDDO         ENDDO
194        ENDDO        ENDDO
195    
196    C--   Set tile-specific parameters for horizontal fluxes
197          IF (useCubedSphereExchange) THEN
198           nipass=3
199    #ifdef ALLOW_AUTODIFF_TAMC
200           IF ( nipass.GT.maxcube ) STOP 'maxcube needs to be = 3'
201    #endif
202    #ifdef ALLOW_EXCH2
203           myTile = W2_myTileList(bi)
204           nCFace = exch2_myFace(myTile)
205           N_edge = exch2_isNedge(myTile).EQ.1
206           S_edge = exch2_isSedge(myTile).EQ.1
207           E_edge = exch2_isEedge(myTile).EQ.1
208           W_edge = exch2_isWedge(myTile).EQ.1
209    #else
210           nCFace = bi
211           N_edge = .TRUE.
212           S_edge = .TRUE.
213           E_edge = .TRUE.
214           W_edge = .TRUE.
215    #endif
216          ELSE
217           nipass=2
218           N_edge = .FALSE.
219           S_edge = .FALSE.
220           E_edge = .FALSE.
221           W_edge = .FALSE.
222          ENDIF
223    
224        iMin = 1-OLx        iMin = 1-OLx
225        iMax = sNx+OLx        iMax = sNx+OLx
226        jMin = 1-OLy        jMin = 1-OLy
# Line 187  C--   Get temporary terms used by tenden Line 242  C--   Get temporary terms used by tenden
242    
243  #ifdef ALLOW_GMREDI  #ifdef ALLOW_GMREDI
244  C--   Residual transp = Bolus transp + Eulerian transp  C--   Residual transp = Bolus transp + Eulerian transp
245         IF (useGMRedi)        IF (useGMRedi)
246       &   CALL GMREDI_CALC_UVFLOW(       &   CALL GMREDI_CALC_UVFLOW(
247       &            uTrans, vTrans, bi, bj, k, myThid)       &            uTrans, vTrans, bi, bj, k, myThid)
248  #endif /* ALLOW_GMREDI */  #endif /* ALLOW_GMREDI */
249    
250  C--   Make local copy of tracer array  C--   Make local copy of tracer array and mask West & South
251        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
252         DO i=1-OLx,sNx+OLx         DO i=1-OLx,sNx+OLx
253          localTij(i,j)=tracer(i,j,k,bi,bj)           localTij(i,j)=tracer(i,j,k,bi,bj)
254             maskLocW(i,j)=maskW(i,j,k,bi,bj)
255             maskLocS(i,j)=maskS(i,j,k,bi,bj)
256         ENDDO         ENDDO
257        ENDDO        ENDDO
258    
259    #ifndef ALLOW_AUTODIFF_TAMC
260        IF (useCubedSphereExchange) THEN        IF (useCubedSphereExchange) THEN
261         nipass=3          withSigns = .FALSE.
262  #ifdef ALLOW_AUTODIFF_TAMC          CALL FILL_CS_CORNER_UV_RS(
263         if ( nipass.GT.maxcube )       &            withSigns, maskLocW,maskLocS, bi,bj, myThid )
      &      STOP 'maxcube needs to be = 3'  
 #endif  
       ELSE  
        nipass=1  
264        ENDIF        ENDIF
265  cph       nipass=1  #endif
266    
267  C--   Multiple passes for different directions on different tiles  C--   Multiple passes for different directions on different tiles
268    C--   For cube need one pass for each of red, green and blue axes.
269        DO ipass=1,nipass        DO ipass=1,nipass
270  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
271           passkey = ipass + (k-1)      *maxcube           passkey = ipass + (k-1)      *maxcube
# Line 220  C--   Multiple passes for different dire Line 275  C--   Multiple passes for different dire
275           ENDIF           ENDIF
276  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
277    
278        IF (nipass.EQ.3) THEN        interiorOnly = .FALSE.
279         calc_fluxes_X=.FALSE.        overlapOnly  = .FALSE.
280         calc_fluxes_Y=.FALSE.        IF (useCubedSphereExchange) THEN
281         IF (ipass.EQ.1 .AND. (bi.EQ.1 .OR. bi.EQ.2) ) THEN  #ifdef MULTIDIM_OLD_VERSION
282          calc_fluxes_X=.TRUE.  C-    CubedSphere : pass 3 times, with full update of local tracer field
283         ELSEIF (ipass.EQ.1 .AND. (bi.EQ.4 .OR. bi.EQ.5) ) THEN         IF (ipass.EQ.1) THEN
284          calc_fluxes_Y=.TRUE.          calc_fluxes_X = nCFace.EQ.1 .OR. nCFace.EQ.2
285         ELSEIF (ipass.EQ.2 .AND. (bi.EQ.1 .OR. bi.EQ.6) ) THEN          calc_fluxes_Y = nCFace.EQ.4 .OR. nCFace.EQ.5
286          calc_fluxes_Y=.TRUE.         ELSEIF (ipass.EQ.2) THEN
287         ELSEIF (ipass.EQ.2 .AND. (bi.EQ.3 .OR. bi.EQ.4) ) THEN          calc_fluxes_X = nCFace.EQ.3 .OR. nCFace.EQ.4
288          calc_fluxes_X=.TRUE.          calc_fluxes_Y = nCFace.EQ.6 .OR. nCFace.EQ.1
289         ELSEIF (ipass.EQ.3 .AND. (bi.EQ.2 .OR. bi.EQ.3) ) THEN  #else /* MULTIDIM_OLD_VERSION */
290          calc_fluxes_Y=.TRUE.  C-    CubedSphere : pass 3 times, with partial update of local tracer field
291         ELSEIF (ipass.EQ.3 .AND. (bi.EQ.5 .OR. bi.EQ.6) ) THEN         IF (ipass.EQ.1) THEN
292          calc_fluxes_X=.TRUE.          overlapOnly  = MOD(nCFace,3).EQ.0
293            interiorOnly = MOD(nCFace,3).NE.0
294            calc_fluxes_X = nCFace.EQ.6 .OR. nCFace.EQ.1 .OR. nCFace.EQ.2
295            calc_fluxes_Y = nCFace.EQ.3 .OR. nCFace.EQ.4 .OR. nCFace.EQ.5
296           ELSEIF (ipass.EQ.2) THEN
297            overlapOnly  = MOD(nCFace,3).EQ.2
298            calc_fluxes_X = nCFace.EQ.2 .OR. nCFace.EQ.3 .OR. nCFace.EQ.4
299            calc_fluxes_Y = nCFace.EQ.5 .OR. nCFace.EQ.6 .OR. nCFace.EQ.1
300    #endif /* MULTIDIM_OLD_VERSION */
301           ELSE
302            calc_fluxes_X = nCFace.EQ.5 .OR. nCFace.EQ.6
303            calc_fluxes_Y = nCFace.EQ.2 .OR. nCFace.EQ.3
304         ENDIF         ENDIF
305        ELSE        ELSE
306         calc_fluxes_X=.TRUE.  C-    not CubedSphere
307         calc_fluxes_Y=.TRUE.          calc_fluxes_X = MOD(ipass,2).EQ.1
308            calc_fluxes_Y = .NOT.calc_fluxes_X
309        ENDIF        ENDIF
310    
311    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
312  C--   X direction  C--   X direction
313        IF (calc_fluxes_X) THEN        IF (calc_fluxes_X) THEN
314    
315  C--   Internal exchange for calculations in X  C-     Do not compute fluxes if
316        IF (useCubedSphereExchange) THEN  C       a) needed in overlap only
317         DO j=1,Oly  C   and b) the overlap of myTile are not cube-face Edges
318          DO i=1,Olx         IF ( .NOT.overlapOnly .OR. N_edge .OR. S_edge ) THEN
319           localTij( 1-i , 1-j )=localTij( 1-j ,    i    )  
320           localTij( 1-i ,sNy+j)=localTij( 1-j , sNy+1-i )  #ifndef ALLOW_AUTODIFF_TAMC
321           localTij(sNx+i, 1-j )=localTij(sNx+j,    i    )  C-     Internal exchange for calculations in X
322           localTij(sNx+i,sNy+j)=localTij(sNx+j, sNy+1-i )  #ifdef MULTIDIM_OLD_VERSION
323          ENDDO          IF ( useCubedSphereExchange ) THEN
324         ENDDO  #else
325        ENDIF          IF ( useCubedSphereExchange .AND.
326         &       ( overlapOnly .OR. ipass.EQ.1 ) ) THEN
327    #endif
328             CALL FILL_CS_CORNER_TR_RL( .TRUE., localTij, bi,bj, myThid )
329            ENDIF
330    #endif
331    
332  C-    Advective flux in X  C-     Advective flux in X
333        DO j=1-Oly,sNy+Oly          DO j=1-Oly,sNy+Oly
334         DO i=1-Olx,sNx+Olx           DO i=1-Olx,sNx+Olx
335          af(i,j) = 0.            af(i,j) = 0.
336         ENDDO           ENDDO
337        ENDDO          ENDDO
338    
339  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
340  #ifndef DISABLE_MULTIDIM_ADVECTION  #ifndef DISABLE_MULTIDIM_ADVECTION
# Line 270  CADJ &     comlev1_bibj_k_gad_pass, key= Line 343  CADJ &     comlev1_bibj_k_gad_pass, key=
343  #endif  #endif
344  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
345    
346        IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN          IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN
347         CALL GAD_FLUXLIMIT_ADV_X(            CALL GAD_FLUXLIMIT_ADV_X( bi,bj,k, dTtracerLev(k),
348       &      bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid)       I                              uTrans, uVel, maskLocW, localTij,
349        ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN       O                              af, myThid )
350         CALL GAD_DST3_ADV_X(          ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN
351       &       bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid)            CALL GAD_DST3_ADV_X(      bi,bj,k, dTtracerLev(k),
352        ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN       I                              uTrans, uVel, maskLocW, localTij,
353         CALL GAD_DST3FL_ADV_X(       O                              af, myThid )
354       &       bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid)          ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN
355        ELSE            CALL GAD_DST3FL_ADV_X(    bi,bj,k, dTtracerLev(k),
356         STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim'       I                              uTrans, uVel, maskLocW, localTij,
357        ENDIF       O                              af, myThid )
358            ELSE
359             STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim'
360            ENDIF
361    
362        DO j=1-Oly,sNy+Oly  C-     Advective flux in X : done
363         DO i=1-Olx,sNx+Olx-1         ENDIF
364          localTij(i,j)=localTij(i,j)-deltaTtracer*  
365       &    _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)  #ifndef ALLOW_AUTODIFF_TAMC
366       &    *recip_rA(i,j,bi,bj)  C-     Internal exchange for next calculations in Y
367       &    *( af(i+1,j)-af(i,j)         IF ( overlapOnly .AND. ipass.EQ.1 ) THEN
368       &      -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j))           CALL FILL_CS_CORNER_TR_RL(.FALSE., localTij, bi,bj, myThid )
369       &     )         ENDIF
370         ENDDO  #endif
371        ENDDO  
372    C-     Update the local tracer field where needed:
373    
374    C      update in overlap-Only
375           IF ( overlapOnly ) THEN
376            iMinUpd = 1-Olx+1
377            iMaxUpd = sNx+Olx-1
378    C- notes: these 2 lines below have no real effect (because recip_hFac=0
379    C         in corner region) but safer to keep them.
380            IF ( W_edge ) iMinUpd = 1
381            IF ( E_edge ) iMaxUpd = sNx
382    
383            IF ( S_edge ) THEN
384             DO j=1-Oly,0
385              DO i=iMinUpd,iMaxUpd
386               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
387         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
388         &       *recip_rA(i,j,bi,bj)
389         &       *( af(i+1,j)-af(i,j)
390         &         -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j))
391         &        )
392              ENDDO
393             ENDDO
394            ENDIF
395            IF ( N_edge ) THEN
396             DO j=sNy+1,sNy+Oly
397              DO i=iMinUpd,iMaxUpd
398               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
399         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
400         &       *recip_rA(i,j,bi,bj)
401         &       *( af(i+1,j)-af(i,j)
402         &         -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j))
403         &        )
404              ENDDO
405             ENDDO
406            ENDIF
407    
408           ELSE
409    C      do not only update the overlap
410            jMinUpd = 1-Oly
411            jMaxUpd = sNy+Oly
412            IF ( interiorOnly .AND. S_edge ) jMinUpd = 1
413            IF ( interiorOnly .AND. N_edge ) jMaxUpd = sNy
414            DO j=jMinUpd,jMaxUpd
415             DO i=1-Olx+1,sNx+Olx-1
416               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
417         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
418         &       *recip_rA(i,j,bi,bj)
419         &       *( af(i+1,j)-af(i,j)
420         &         -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j))
421         &        )
422             ENDDO
423            ENDDO
424    C-      keep advective flux (for diagnostics)
425            DO j=1-Oly,sNy+Oly
426             DO i=1-Olx,sNx+Olx
427              afx(i,j) = af(i,j)
428             ENDDO
429            ENDDO
430    
431  #ifdef ALLOW_OBCS  #ifdef ALLOW_OBCS
432  C--   Apply open boundary conditions  C-     Apply open boundary conditions
433        IF (useOBCS) THEN          IF ( useOBCS ) THEN
434         IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN           IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN
435          CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid )            CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid )
436         ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN           ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN
437          CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid )            CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid )
438         END IF           ENDIF
439        END IF          ENDIF
440  #endif /* ALLOW_OBCS */  #endif /* ALLOW_OBCS */
441    
442    C-     end if/else update overlap-Only
443           ENDIF
444            
445  C--   End of X direction  C--   End of X direction
446        ENDIF        ENDIF
447    
448    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
449  C--   Y direction  C--   Y direction
450        IF (calc_fluxes_Y) THEN        IF (calc_fluxes_Y) THEN
451    
452  C--   Internal exchange for calculations in Y  C-     Do not compute fluxes if
453        IF (useCubedSphereExchange) THEN  C       a) needed in overlap only
454         DO j=1,Oly  C   and b) the overlap of myTile are not cube-face edges
455          DO i=1,Olx         IF ( .NOT.overlapOnly .OR. E_edge .OR. W_edge ) THEN
456           localTij( 1-i , 1-j )=localTij(   j   , 1-i )  
457           localTij( 1-i ,sNy+j)=localTij(   j   ,sNy+i)  #ifndef ALLOW_AUTODIFF_TAMC
458           localTij(sNx+i, 1-j )=localTij(sNx+1-j, 1-i )  C-     Internal exchange for calculations in Y
459           localTij(sNx+i,sNy+j)=localTij(sNx+1-j,sNy+i)  #ifdef MULTIDIM_OLD_VERSION
460          ENDDO          IF ( useCubedSphereExchange ) THEN
461         ENDDO  #else
462        ENDIF          IF ( useCubedSphereExchange .AND.
463         &       ( overlapOnly .OR. ipass.EQ.1 ) ) THEN
464    #endif
465             CALL FILL_CS_CORNER_TR_RL(.FALSE., localTij, bi,bj, myThid )
466            ENDIF
467    #endif
468    
469  C-    Advective flux in Y  C-     Advective flux in Y
470        DO j=1-Oly,sNy+Oly          DO j=1-Oly,sNy+Oly
471         DO i=1-Olx,sNx+Olx           DO i=1-Olx,sNx+Olx
472          af(i,j) = 0.            af(i,j) = 0.
473         ENDDO           ENDDO
474        ENDDO          ENDDO
475    
476  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
477  #ifndef DISABLE_MULTIDIM_ADVECTION  #ifndef DISABLE_MULTIDIM_ADVECTION
# Line 337  CADJ &     comlev1_bibj_k_gad_pass, key= Line 480  CADJ &     comlev1_bibj_k_gad_pass, key=
480  #endif  #endif
481  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
482    
483        IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN          IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN
484         CALL GAD_FLUXLIMIT_ADV_Y(            CALL GAD_FLUXLIMIT_ADV_Y( bi,bj,k, dTtracerLev(k),
485       &       bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid)       I                              vTrans, vVel, maskLocS, localTij,
486        ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN       O                              af, myThid )
487         CALL GAD_DST3_ADV_Y(          ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN
488       &       bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid)            CALL GAD_DST3_ADV_Y(      bi,bj,k, dTtracerLev(k),
489        ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN       I                              vTrans, vVel, maskLocS, localTij,
490         CALL GAD_DST3FL_ADV_Y(       O                              af, myThid )
491       &       bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid)          ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN
492        ELSE            CALL GAD_DST3FL_ADV_Y(    bi,bj,k, dTtracerLev(k),
493         STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'       I                              vTrans, vVel, maskLocS, localTij,
494        ENDIF       O                              af, myThid )
495            ELSE
496             STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'
497            ENDIF
498    
499        DO j=1-Oly,sNy+Oly-1  C-     Advective flux in Y : done
500         DO i=1-Olx,sNx+Olx         ENDIF
501          localTij(i,j)=localTij(i,j)-deltaTtracer*  
502       &    _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)  #ifndef ALLOW_AUTODIFF_TAMC
503       &    *recip_rA(i,j,bi,bj)  C-     Internal exchange for next calculations in X
504       &    *( af(i,j+1)-af(i,j)         IF ( overlapOnly .AND. ipass.EQ.1 ) THEN
505       &      -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j))           CALL FILL_CS_CORNER_TR_RL( .TRUE., localTij, bi,bj, myThid )
506       &     )         ENDIF
507         ENDDO  #endif
508        ENDDO  
509    C-     Update the local tracer field where needed:
510    
511    C      update in overlap-Only
512           IF ( overlapOnly ) THEN
513            jMinUpd = 1-Oly+1
514            jMaxUpd = sNy+Oly-1
515    C- notes: these 2 lines below have no real effect (because recip_hFac=0
516    C         in corner region) but safer to keep them.
517            IF ( S_edge ) jMinUpd = 1
518            IF ( N_edge ) jMaxUpd = sNy
519    
520            IF ( W_edge ) THEN
521             DO j=jMinUpd,jMaxUpd
522              DO i=1-Olx,0
523               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
524         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
525         &       *recip_rA(i,j,bi,bj)
526         &       *( af(i,j+1)-af(i,j)
527         &         -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j))
528         &        )
529              ENDDO
530             ENDDO
531            ENDIF
532            IF ( E_edge ) THEN
533             DO j=jMinUpd,jMaxUpd
534              DO i=sNx+1,sNx+Olx
535               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
536         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
537         &       *recip_rA(i,j,bi,bj)
538         &       *( af(i,j+1)-af(i,j)
539         &         -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j))
540         &        )
541              ENDDO
542             ENDDO
543            ENDIF
544    
545           ELSE
546    C      do not only update the overlap
547            iMinUpd = 1-Olx
548            iMaxUpd = sNx+Olx
549            IF ( interiorOnly .AND. W_edge ) iMinUpd = 1
550            IF ( interiorOnly .AND. E_edge ) iMaxUpd = sNx
551            DO j=1-Oly+1,sNy+Oly-1
552             DO i=iMinUpd,iMaxUpd
553               localTij(i,j)=localTij(i,j)-dTtracerLev(k)*
554         &       _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
555         &       *recip_rA(i,j,bi,bj)
556         &       *( af(i,j+1)-af(i,j)
557         &         -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j))
558         &        )
559             ENDDO
560            ENDDO
561    C-      keep advective flux (for diagnostics)
562            DO j=1-Oly,sNy+Oly
563             DO i=1-Olx,sNx+Olx
564              afy(i,j) = af(i,j)
565             ENDDO
566            ENDDO
567    
568  #ifdef ALLOW_OBCS  #ifdef ALLOW_OBCS
569  C--   Apply open boundary conditions  C-     Apply open boundary conditions
570        IF (useOBCS) THEN          IF (useOBCS) THEN
571         IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN           IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN
572          CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid )            CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid )
573         ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN           ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN
574          CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid )            CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid )
575         END IF           ENDIF
576        END IF          ENDIF
577  #endif /* ALLOW_OBCS */  #endif /* ALLOW_OBCS */
578    
579    C      end if/else update overlap-Only
580           ENDIF
581    
582  C--   End of Y direction  C--   End of Y direction
583        ENDIF        ENDIF
584    
       DO j=1-Oly,sNy+Oly  
        DO i=1-Olx,sNx+Olx  
         localTijk(i,j,k)=localTij(i,j)  
        ENDDO  
       ENDDO  
   
585  C--   End of ipass loop  C--   End of ipass loop
586        ENDDO        ENDDO
587    
588          IF ( implicitAdvection ) THEN
589    C-    explicit advection is done ; store tendency in gTracer:
590            DO j=1-Oly,sNy+Oly
591             DO i=1-Olx,sNx+Olx
592              gTracer(i,j,k,bi,bj)=
593         &     (localTij(i,j)-tracer(i,j,k,bi,bj))/dTtracerLev(k)
594             ENDDO
595            ENDDO
596          ELSE
597    C-    horizontal advection done; store intermediate result in 3D array:
598           DO j=1-Oly,sNy+Oly
599            DO i=1-Olx,sNx+Olx
600             localTijk(i,j,k)=localTij(i,j)
601            ENDDO
602           ENDDO
603          ENDIF
604    
605    #ifdef ALLOW_DIAGNOSTICS
606            IF ( useDiagnostics ) THEN
607              diagName = 'ADVx'//diagSufx
608              CALL DIAGNOSTICS_FILL(afx,diagName, k,1, 2,bi,bj, myThid)
609              diagName = 'ADVy'//diagSufx
610              CALL DIAGNOSTICS_FILL(afy,diagName, k,1, 2,bi,bj, myThid)
611            ENDIF
612    #endif
613    
614    #ifdef ALLOW_DEBUG
615          IF ( debugLevel .GE. debLevB
616         &   .AND. tracerIdentity.EQ.GAD_TEMPERATURE
617         &   .AND. k.LE.3 .AND. myIter.EQ.1+nIter0
618         &   .AND. nPx.EQ.1 .AND. nPy.EQ.1
619         &   .AND. useCubedSphereExchange ) THEN
620            CALL DEBUG_CS_CORNER_UV( ' afx,afy from GAD_ADVECTION',
621         &             afx,afy, k, standardMessageUnit,bi,bj,myThid )
622          ENDIF
623    #endif /* ALLOW_DEBUG */
624    
625  C--   End of K loop for horizontal fluxes  C--   End of K loop for horizontal fluxes
626        ENDDO        ENDDO
627    
628    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
629    
630          IF ( .NOT.implicitAdvection ) THEN
631  C--   Start of k loop for vertical flux  C--   Start of k loop for vertical flux
632        DO k=Nr,1,-1         DO k=Nr,1,-1
633  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
634           kkey = (ikey-1)*Nr + k           kkey = (igadkey-1)*Nr + k
635  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
   
636  C--   kup    Cycles through 1,2 to point to w-layer above  C--   kup    Cycles through 1,2 to point to w-layer above
637  C--   kDown  Cycles through 2,1 to point to w-layer below  C--   kDown  Cycles through 2,1 to point to w-layer below
638        kup  = 1+MOD(k+1,2)          kup  = 1+MOD(k+1,2)
639        kDown= 1+MOD(k,2)          kDown= 1+MOD(k,2)
640  c     kp1=min(Nr,k+1)  c       kp1=min(Nr,k+1)
641        kp1Msk=1.          kp1Msk=1.
642        if (k.EQ.Nr) kp1Msk=0.          if (k.EQ.Nr) kp1Msk=0.
   
 #ifdef ALLOW_AUTODIFF_TAMC  
 CADJ STORE localTijk(:,:,k)    
 CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte  
 CADJ STORE rTrans(:,:)    
 CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte  
 #endif /* ALLOW_AUTODIFF_TAMC */  
643    
644  C-- Compute Vertical transport  C-- Compute Vertical transport
645  C     Note: wVel needs to be masked  #ifdef ALLOW_AIM
646    C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr
647            IF ( k.EQ.1 .OR.
648         &     (useAIM .AND. tracerIdentity.EQ.GAD_SALINITY .AND. k.EQ.Nr)
649         &              ) THEN
650    #else
651            IF ( k.EQ.1 ) THEN
652    #endif
653    
       IF (k.EQ.1) THEN  
654  C- Surface interface :  C- Surface interface :
655             DO j=1-Oly,sNy+Oly
656              DO i=1-Olx,sNx+Olx
657               rTransKp1(i,j) = kp1Msk*rTrans(i,j)
658               rTrans(i,j) = 0.
659               fVerT(i,j,kUp) = 0.
660              ENDDO
661             ENDDO
662    
663         DO j=1-Oly,sNy+Oly          ELSE
         DO i=1-Olx,sNx+Olx  
          rTransKp1(i,j) = rTrans(i,j)  
          rTrans(i,j) = 0.  
          fVerT(i,j,kUp) = 0.  
         ENDDO  
        ENDDO  
   
       ELSE  
664  C- Interior interface :  C- Interior interface :
665         DO j=1-Oly,sNy+Oly  
666          DO i=1-Olx,sNx+Olx           DO j=1-Oly,sNy+Oly
667           rTransKp1(i,j) = kp1Msk*rTrans(i,j)            DO i=1-Olx,sNx+Olx
668           rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj)             rTransKp1(i,j) = kp1Msk*rTrans(i,j)
669       &               *maskC(i,j,k-1,bi,bj)             rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj)
670           af(i,j) = 0.       &                 *maskC(i,j,k-1,bi,bj)
671          ENDDO             fVerT(i,j,kUp) = 0.
672         ENDDO            ENDDO
673             ENDDO
674    
675  #ifdef ALLOW_GMREDI  #ifdef ALLOW_GMREDI
676  C--   Residual transp = Bolus transp + Eulerian transp  C--   Residual transp = Bolus transp + Eulerian transp
677         IF (useGMRedi)           IF (useGMRedi)
678       &   CALL GMREDI_CALC_WFLOW(       &   CALL GMREDI_CALC_WFLOW(
679       &                    rTrans, bi, bj, k, myThid)       &                    rTrans, bi, bj, k, myThid)
680  #endif /* ALLOW_GMREDI */  #endif /* ALLOW_GMREDI */
681    
682    #ifdef ALLOW_AUTODIFF_TAMC
683    CADJ STORE localTijk(:,:,k)  
684    CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
685    CADJ STORE rTrans(:,:)  
686    CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
687    #endif /* ALLOW_AUTODIFF_TAMC */
688    
689  C-    Compute vertical advective flux in the interior:  C-    Compute vertical advective flux in the interior:
690         IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN           IF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN
691          CALL GAD_FLUXLIMIT_ADV_R(  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
692       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)             CALL GAD_FLUXLIMIT_ADV_R( bi,bj,k, dTtracerLev(k),
693         ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN       I                               rTrans, wVel, localTijk,
694          CALL GAD_DST3_ADV_R(       O                               fVerT(1-Olx,1-Oly,kUp), myThid )
695       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)           ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN
696         ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN             CALL GAD_DST3_ADV_R(      bi,bj,k, dTtracerLev(k),
697          CALL GAD_DST3FL_ADV_R(       I                               rTrans, wVel, localTijk,
698       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)       O                               fVerT(1-Olx,1-Oly,kUp), myThid )
699         ELSE           ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN
700          STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'             CALL GAD_DST3FL_ADV_R(    bi,bj,k, dTtracerLev(k),
701         ENDIF       I                               rTrans, wVel, localTijk,
702  C-    add the advective flux to fVerT       O                               fVerT(1-Olx,1-Oly,kUp), myThid )
703         DO j=1-Oly,sNy+Oly           ELSE
704          DO i=1-Olx,sNx+Olx            STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'
705           fVerT(i,j,kUp) = af(i,j)           ENDIF
         ENDDO  
        ENDDO  
706    
707  C- end Surface/Interior if bloc  C- end Surface/Interior if bloc
708        ENDIF          ENDIF
709    
710  C--   Divergence of fluxes  #ifdef ALLOW_AUTODIFF_TAMC
711        DO j=1-Oly,sNy+Oly  CADJ STORE rTrans(:,:)  
712         DO i=1-Olx,sNx+Olx  CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
713          localTij(i,j)=localTijk(i,j,k)-deltaTtracer*  CADJ STORE rTranskp1(:,:)  
714       &    _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)  CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
715       &    *recip_rA(i,j,bi,bj)  #endif /* ALLOW_AUTODIFF_TAMC */
716       &    *( fVerT(i,j,kUp)-fVerT(i,j,kDown)  
717       &      -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j))  C--   Divergence of vertical fluxes
718       &     )*rkFac          DO j=1-Oly,sNy+Oly
719          gTracer(i,j,k,bi,bj)=           DO i=1-Olx,sNx+Olx
720       &   (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer            localTij(i,j)=localTijk(i,j,k)-dTtracerLev(k)*
721         ENDDO       &     _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
722        ENDDO       &     *recip_rA(i,j,bi,bj)
723         &     *( fVerT(i,j,kUp)-fVerT(i,j,kDown)
724         &       -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j))
725         &      )*rkFac
726              gTracer(i,j,k,bi,bj)=
727         &     (localTij(i,j)-tracer(i,j,k,bi,bj))/dTtracerLev(k)
728             ENDDO
729            ENDDO
730    
731    #ifdef ALLOW_DIAGNOSTICS
732            IF ( useDiagnostics ) THEN
733              diagName = 'ADVr'//diagSufx
734              CALL DIAGNOSTICS_FILL( fVerT(1-Olx,1-Oly,kUp),
735         &                           diagName, k,1, 2,bi,bj, myThid)
736            ENDIF
737    #endif
738    
739  C--   End of K loop for vertical flux  C--   End of K loop for vertical flux
740        ENDDO         ENDDO
741    C--   end of if not.implicitAdvection block
742          ENDIF
743    
744        RETURN        RETURN
745        END        END

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.22