/[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.6 by heimbach, Thu Sep 27 20:12:11 2001 UTC revision 1.23 by jmc, Sat Jun 26 02:38:54 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:  
 C \section{Generica 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    
6    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7  CBOP  CBOP
8  C !ROUTINE: GAD_ADVECTION  C !ROUTINE: GAD_ADVECTION
9    
10  C !INTERFACE: ==========================================================  C !INTERFACE: ==========================================================
11        SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity,        SUBROUTINE GAD_ADVECTION(
12       U                         Tracer,Gtracer,       I     implicitAdvection, advectionScheme, vertAdvecScheme,
13       I                         myTime,myIter,myThid)       I     tracerIdentity,
14         I     uVel, vVel, wVel, tracer,
15         O     gTracer,
16         I     bi,bj, myTime,myIter,myThid)
17    
18  C !DESCRIPTION:  C !DESCRIPTION:
19  C Calculates the tendancy of a tracer due to advection.  C Calculates the tendancy of a tracer due to advection.
# Line 63  C !USES: =============================== Line 39  C !USES: ===============================
39  #include "SIZE.h"  #include "SIZE.h"
40  #include "EEPARAMS.h"  #include "EEPARAMS.h"
41  #include "PARAMS.h"  #include "PARAMS.h"
 #include "DYNVARS.h"  
42  #include "GRID.h"  #include "GRID.h"
43  #include "GAD.h"  #include "GAD.h"
44  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
# Line 72  C !USES: =============================== Line 47  C !USES: ===============================
47  #endif  #endif
48    
49  C !INPUT PARAMETERS: ===================================================  C !INPUT PARAMETERS: ===================================================
50  C  bi,bj                :: tile indices  C  implicitAdvection :: implicit vertical advection (later on)
51  C  advectionScheme      :: advection scheme to use  C  advectionScheme   :: advection scheme to use (Horizontal plane)
52  C  tracerIdentity       :: identifier for the tracer (required only for OBCS)  C  vertAdvecScheme   :: advection scheme to use (vertical direction)
53  C  Tracer               :: tracer field  C  tracerIdentity    :: tracer identifier (required only for OBCS)
54  C  myTime               :: current time  C  uVel              :: velocity, zonal component
55  C  myIter               :: iteration number  C  vVel              :: velocity, meridional component
56  C  myThid               :: thread number  C  wVel              :: velocity, vertical component
57        INTEGER bi,bj  C  tracer            :: tracer field
58        INTEGER advectionScheme  C  bi,bj             :: tile indices
59    C  myTime            :: current time
60    C  myIter            :: iteration number
61    C  myThid            :: thread number
62          LOGICAL implicitAdvection
63          INTEGER advectionScheme, vertAdvecScheme
64        INTEGER tracerIdentity        INTEGER tracerIdentity
65        _RL Gtracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)        _RL uVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
66          _RL vVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
67          _RL wVel  (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
68          _RL tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
69          INTEGER bi,bj
70        _RL myTime        _RL myTime
71        INTEGER myIter        INTEGER myIter
72        INTEGER myThid        INTEGER myThid
73    
74  C !OUTPUT PARAMETERS: ==================================================  C !OUTPUT PARAMETERS: ==================================================
75  C  gTracer              :: tendancy array  C  gTracer           :: tendancy array
76        _RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)        _RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
77    
78  C !LOCAL VARIABLES: ====================================================  C !LOCAL VARIABLES: ====================================================
79  C  maskUp               :: 2-D array for mask at W points  C  maskUp        :: 2-D array for mask at W points
80  C  iMin,iMax,jMin,jMax  :: loop range for called routines  C  iMin,iMax,    :: loop range for called routines
81  C  i,j,k                :: loop indices  C  jMin,jMax     :: loop range for called routines
82  C  kup                  :: index into 2 1/2D array, toggles between 1 and 2  C  i,j,k         :: loop indices
83  C  kdown                :: index into 2 1/2D array, toggles between 2 and 1  C  kup           :: index into 2 1/2D array, toggles between 1 and 2
84  C  kp1                  :: =k+1 for k<Nr, =Nr for k=Nr  C  kdown         :: index into 2 1/2D array, toggles between 2 and 1
85  C  xA,yA                :: areas of X and Y face of tracer cells  C  kp1           :: =k+1 for k<Nr, =Nr for k=Nr
86  C  uTrans,vTrans,rTrans :: 2-D arrays of volume transports at U,V and W points  C  xA,yA         :: areas of X and Y face of tracer cells
87  C  af                   :: 2-D array for horizontal advective flux  C  uTrans,vTrans :: 2-D arrays of volume transports at U,V points
88  C  fVerT                :: 2 1/2D arrays for vertical advective flux  C  rTrans        :: 2-D arrays of volume transports at W points
89  C  localTij             :: 2-D array used as temporary local copy of tracer fld  C  rTransKp1     :: vertical volume transport at interface k+1
90  C  localTijk            :: 3-D array used as temporary local copy of tracer fld  C  af            :: 2-D array for horizontal advective flux
91  C  kp1Msk               :: flag (0,1) to act as over-riding mask for W levels  C  fVerT         :: 2 1/2D arrays for vertical advective flux
92  C  calc_fluxes_X        :: logical to indicate to calculate fluxes in X dir  C  localTij      :: 2-D array, temporary local copy of tracer fld
93  C  calc_fluxes_Y        :: logical to indicate to calculate fluxes in Y dir  C  localTijk     :: 3-D array, temporary local copy of tracer fld
94  C  nipass               :: number of passes to make in multi-dimensional method  C  kp1Msk        :: flag (0,1) for over-riding mask for W levels
95  C  ipass                :: number of the current pass being made  C  calc_fluxes_X :: logical to indicate to calculate fluxes in X dir
96    C  calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir
97    C  nipass        :: number of passes in multi-dimensional method
98    C  ipass         :: number of the current pass being made
99        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS maskUp  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
100        INTEGER iMin,iMax,jMin,jMax        INTEGER iMin,iMax,jMin,jMax
101        INTEGER i,j,k,kup,kDown,kp1        INTEGER i,j,k,kup,kDown
102        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS xA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
103        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS yA      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
104        _RL uTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
105        _RL vTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL vTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
106        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL rTrans  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
107          _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
108        _RL af      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL af      (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
109        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerT   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
110        _RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
# Line 127  C  ipass                :: number of the Line 115  C  ipass                :: number of the
115  CEOP  CEOP
116    
117  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
118              act0 = tracerIdentity - 1
119              max0 = maxpass
120            act1 = bi - myBxLo(myThid)            act1 = bi - myBxLo(myThid)
121            max1 = myBxHi(myThid) - myBxLo(myThid) + 1            max1 = myBxHi(myThid) - myBxLo(myThid) + 1
122            act2 = bj - myByLo(myThid)            act2 = bj - myByLo(myThid)
# Line 134  CEOP Line 124  CEOP
124            act3 = myThid - 1            act3 = myThid - 1
125            max3 = nTx*nTy            max3 = nTx*nTy
126            act4 = ikey_dynamics - 1            act4 = ikey_dynamics - 1
127            ikey = (act1 + 1) + act2*max1            igadkey = (act0 + 1)
128       &                      + act3*max1*max2       &                      + act1*max0
129       &                      + act4*max1*max2*max3       &                      + act2*max0*max1
130         &                      + act3*max0*max1*max2
131         &                      + act4*max0*max1*max2*max3
132              if (tracerIdentity.GT.maxpass) then
133                 print *, 'ph-pass gad_advection ', maxpass, tracerIdentity
134                 STOP 'maxpass seems smaller than tracerIdentity'
135              endif
136  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
137    
138  C--   Set up work arrays with valid (i.e. not NaN) values  C--   Set up work arrays with valid (i.e. not NaN) values
# Line 153  C     uninitialised but inert locations. Line 149  C     uninitialised but inert locations.
149          rTrans(i,j)  = 0. _d 0          rTrans(i,j)  = 0. _d 0
150          fVerT(i,j,1) = 0. _d 0          fVerT(i,j,1) = 0. _d 0
151          fVerT(i,j,2) = 0. _d 0          fVerT(i,j,2) = 0. _d 0
152            rTransKp1(i,j)= 0. _d 0
153         ENDDO         ENDDO
154        ENDDO        ENDDO
155    
# Line 164  C     uninitialised but inert locations. Line 161  C     uninitialised but inert locations.
161  C--   Start of k loop for horizontal fluxes  C--   Start of k loop for horizontal fluxes
162        DO k=1,Nr        DO k=1,Nr
163  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
164           kkey = (ikey-1)*Nr + k           kkey = (igadkey-1)*Nr + k
165  CADJ STORE tracer(:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte  CADJ STORE tracer(:,:,k,bi,bj) =
166    CADJ &     comlev1_bibj_k_gad, key=kkey, byte=isbyte
167  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
168    
169  C--   Get temporary terms used by tendency routines  C--   Get temporary terms used by tendency routines
# Line 174  C--   Get temporary terms used by tenden Line 172  C--   Get temporary terms used by tenden
172       O         xA,yA,uTrans,vTrans,rTrans,maskUp,       O         xA,yA,uTrans,vTrans,rTrans,maskUp,
173       I         myThid)       I         myThid)
174    
175    #ifdef ALLOW_GMREDI
176    C--   Residual transp = Bolus transp + Eulerian transp
177           IF (useGMRedi)
178         &   CALL GMREDI_CALC_UVFLOW(
179         &            uTrans, vTrans, bi, bj, k, myThid)
180    #endif /* ALLOW_GMREDI */
181    
182  C--   Make local copy of tracer array  C--   Make local copy of tracer array
183        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
184         DO i=1-OLx,sNx+OLx         DO i=1-OLx,sNx+OLx
# Line 183  C--   Make local copy of tracer array Line 188  C--   Make local copy of tracer array
188    
189        IF (useCubedSphereExchange) THEN        IF (useCubedSphereExchange) THEN
190         nipass=3         nipass=3
191    #ifdef ALLOW_AUTODIFF_TAMC
192           if ( nipass.GT.maxcube )
193         &      STOP 'maxcube needs to be = 3'
194    #endif
195        ELSE        ELSE
196         nipass=1         nipass=1
197        ENDIF        ENDIF
# Line 191  cph       nipass=1 Line 200  cph       nipass=1
200  C--   Multiple passes for different directions on different tiles  C--   Multiple passes for different directions on different tiles
201        DO ipass=1,nipass        DO ipass=1,nipass
202  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
203           passkey = ipass + (k-1)   *maxpass           passkey = ipass + (k-1)      *maxcube
204       &                   + (ikey-1)*maxpass*Nr       &                   + (igadkey-1)*maxcube*Nr
205           IF (nipass .GT. maxpass) THEN           IF (nipass .GT. maxpass) THEN
206            STOP 'GAD_ADVECTION: nipass > maxpass. check tamc.h'            STOP 'GAD_ADVECTION: nipass > maxcube. check tamc.h'
207           ENDIF           ENDIF
208  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
209    
# Line 242  C-    Advective flux in X Line 251  C-    Advective flux in X
251        ENDDO        ENDDO
252    
253  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
254  #ifdef ALLOW_MULTIDIM_ADVECTION  #ifndef DISABLE_MULTIDIM_ADVECTION
255  CADJ STORE localTij(:,:)  = comlev1_bibj_pass, key=passkey, byte=isbyte  CADJ STORE localTij(:,:)  =
256    CADJ &     comlev1_bibj_k_gad_pass, key=passkey, byte=isbyte
257  #endif  #endif
258  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
259    
# Line 257  CADJ STORE localTij(:,:)  = comlev1_bibj Line 267  CADJ STORE localTij(:,:)  = comlev1_bibj
267         CALL GAD_DST3FL_ADV_X(         CALL GAD_DST3FL_ADV_X(
268       &       bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid)       &       bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid)
269        ELSE        ELSE
270         STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'         STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim'
271        ENDIF        ENDIF
272    
273        DO j=1-Oly,sNy+Oly        DO j=1-Oly,sNy+Oly
# Line 308  C-    Advective flux in Y Line 318  C-    Advective flux in Y
318        ENDDO        ENDDO
319    
320  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
321  #ifdef ALLOW_MULTIDIM_ADVECTION  #ifndef DISABLE_MULTIDIM_ADVECTION
322  CADJ STORE localTij(:,:)  = comlev1_bibj_pass, key=passkey, byte=isbyte  CADJ STORE localTij(:,:)  =
323    CADJ &     comlev1_bibj_k_gad_pass, key=passkey, byte=isbyte
324  #endif  #endif
325  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
326    
# Line 351  C--   Apply open boundary conditions Line 362  C--   Apply open boundary conditions
362  C--   End of Y direction  C--   End of Y direction
363        ENDIF        ENDIF
364    
       DO j=1-Oly,sNy+Oly  
        DO i=1-Olx,sNx+Olx  
         localTijk(i,j,k)=localTij(i,j)  
        ENDDO  
       ENDDO  
   
365  C--   End of ipass loop  C--   End of ipass loop
366        ENDDO        ENDDO
367    
368          IF ( implicitAdvection ) THEN
369    C-    explicit advection is done ; store tendency in gTracer:
370            DO j=1-Oly,sNy+Oly
371             DO i=1-Olx,sNx+Olx
372              gTracer(i,j,k,bi,bj)=
373         &     (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer
374             ENDDO
375            ENDDO
376          ELSE
377    C-    horizontal advection done; store intermediate result in 3D array:
378           DO j=1-Oly,sNy+Oly
379            DO i=1-Olx,sNx+Olx
380             localTijk(i,j,k)=localTij(i,j)
381            ENDDO
382           ENDDO
383          ENDIF
384    
385  C--   End of K loop for horizontal fluxes  C--   End of K loop for horizontal fluxes
386        ENDDO        ENDDO
387    
388          IF ( .NOT.implicitAdvection ) THEN
389  C--   Start of k loop for vertical flux  C--   Start of k loop for vertical flux
390        DO k=Nr,1,-1         DO k=Nr,1,-1
391  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
392           kkey = (ikey-1)*Nr + k           kkey = (igadkey-1)*Nr + k
393  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
   
394  C--   kup    Cycles through 1,2 to point to w-layer above  C--   kup    Cycles through 1,2 to point to w-layer above
395  C--   kDown  Cycles through 2,1 to point to w-layer below  C--   kDown  Cycles through 2,1 to point to w-layer below
396        kup  = 1+MOD(k+1,2)          kup  = 1+MOD(k+1,2)
397        kDown= 1+MOD(k,2)          kDown= 1+MOD(k,2)
398    c       kp1=min(Nr,k+1)
399            kp1Msk=1.
400            if (k.EQ.Nr) kp1Msk=0.
401    
402    C-- Compute Vertical transport
403    #ifdef ALLOW_AIM
404    C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr
405            IF ( k.EQ.1 .OR.
406         &     (useAIM .AND. tracerIdentity.EQ.GAD_SALINITY .AND. k.EQ.Nr)
407         &              ) THEN
408    #else
409            IF ( k.EQ.1 ) THEN
410    #endif
411    
412  C--   Get temporary terms used by tendency routines  C- Surface interface :
413        CALL CALC_COMMON_FACTORS (           DO j=1-Oly,sNy+Oly
414       I         bi,bj,iMin,iMax,jMin,jMax,k,            DO i=1-Olx,sNx+Olx
415       O         xA,yA,uTrans,vTrans,rTrans,maskUp,             rTransKp1(i,j) = kp1Msk*rTrans(i,j)
416       I         myThid)             rTrans(i,j) = 0.
417               fVerT(i,j,kUp) = 0.
418  C-    Advective flux in R             af(i,j) = 0.
419        DO j=1-Oly,sNy+Oly            ENDDO
420         DO i=1-Olx,sNx+Olx           ENDDO
421          af(i,j) = 0.  
422         ENDDO          ELSE
423        ENDDO  C- Interior interface :
424    
425             DO j=1-Oly,sNy+Oly
426              DO i=1-Olx,sNx+Olx
427               rTransKp1(i,j) = kp1Msk*rTrans(i,j)
428               rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj)
429         &                 *maskC(i,j,k-1,bi,bj)
430               af(i,j) = 0.
431              ENDDO
432             ENDDO
433    
434    #ifdef ALLOW_GMREDI
435    C--   Residual transp = Bolus transp + Eulerian transp
436             IF (useGMRedi)
437         &   CALL GMREDI_CALC_WFLOW(
438         &                    rTrans, bi, bj, k, myThid)
439    #endif /* ALLOW_GMREDI */
440    
441  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
442  CADJ STORE localTijk(:,:,k)    CADJ STORE localTijk(:,:,k)  
443  CADJ &     = comlev1_bibj_k, key=kkey, byte=isbyte  CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
444    CADJ STORE rTrans(:,:)  
445    CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
446  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
447    
 C     Note: wVel needs to be masked  
       IF (K.GE.2) THEN  
448  C-    Compute vertical advective flux in the interior:  C-    Compute vertical advective flux in the interior:
449         IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN           IF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN
450          CALL GAD_FLUXLIMIT_ADV_R(            CALL GAD_FLUXLIMIT_ADV_R(
451       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)       &        bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)
452         ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN           ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN
453          CALL GAD_DST3_ADV_R(            CALL GAD_DST3_ADV_R(
454       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)       &        bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)
455         ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN           ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN
456          CALL GAD_DST3FL_ADV_R(            CALL GAD_DST3FL_ADV_R(
457       &       bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)       &        bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid)
458         ELSE           ELSE
459          STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'            STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim'
460         ENDIF           ENDIF
 C-    Surface "correction" term at k>1 :  
        DO j=1-Oly,sNy+Oly  
         DO i=1-Olx,sNx+Olx  
          af(i,j) = af(i,j)  
      &           + (maskC(i,j,k,bi,bj)-maskC(i,j,k-1,bi,bj))*  
      &             rTrans(i,j)*localTijk(i,j,k)  
         ENDDO  
        ENDDO  
       ELSE  
 C-    Surface "correction" term at k=1 :  
        DO j=1-Oly,sNy+Oly  
         DO i=1-Olx,sNx+Olx  
          af(i,j) = rTrans(i,j)*localTijk(i,j,k)  
         ENDDO  
        ENDDO  
       ENDIF  
461  C-    add the advective flux to fVerT  C-    add the advective flux to fVerT
462        DO j=1-Oly,sNy+Oly           DO j=1-Oly,sNy+Oly
463         DO i=1-Olx,sNx+Olx            DO i=1-Olx,sNx+Olx
464          fVerT(i,j,kUp) = af(i,j)             fVerT(i,j,kUp) = af(i,j)
465         ENDDO            ENDDO
466        ENDDO           ENDDO
467    
468  C--   Divergence of fluxes  C- end Surface/Interior if bloc
469        kp1=min(Nr,k+1)          ENDIF
470        kp1Msk=1.  
471        if (k.EQ.Nr) kp1Msk=0.  #ifdef ALLOW_AUTODIFF_TAMC
472        DO j=1-Oly,sNy+Oly  CADJ STORE rTrans(:,:)  
473         DO i=1-Olx,sNx+Olx  CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
474          localTij(i,j)=localTijk(i,j,k)-deltaTtracer*  CADJ STORE rTranskp1(:,:)  
475       &    _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)  CADJ &     = comlev1_bibj_k_gad, key=kkey, byte=isbyte
476       &    *recip_rA(i,j,bi,bj)  #endif /* ALLOW_AUTODIFF_TAMC */
477       &    *( fVerT(i,j,kUp)-fVerT(i,j,kDown)  
478       &      -tracer(i,j,k,bi,bj)*rA(i,j,bi,bj)*  C--   Divergence of vertical fluxes
479       &        (wVel(i,j,k,bi,bj)-kp1Msk*wVel(i,j,kp1,bi,bj))          DO j=1-Oly,sNy+Oly
480       &     )*rkFac           DO i=1-Olx,sNx+Olx
481          gTracer(i,j,k,bi,bj)=            localTij(i,j)=localTijk(i,j,k)-deltaTtracer*
482       &   (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer       &     _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)
483         ENDDO       &     *recip_rA(i,j,bi,bj)
484        ENDDO       &     *( fVerT(i,j,kUp)-fVerT(i,j,kDown)
485         &       -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j))
486         &      )*rkFac
487              gTracer(i,j,k,bi,bj)=
488         &     (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer
489             ENDDO
490            ENDDO
491    
492  C--   End of K loop for vertical flux  C--   End of K loop for vertical flux
493        ENDDO         ENDDO
494    C--   end of if not.implicitAdvection block
495          ENDIF
496    
497        RETURN        RETURN
498        END        END

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.22