C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/pkg/generic_advdiff/gad_advection.F,v 1.5 2001/09/21 13:11:43 adcroft Exp $ C $Name: $ 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 #include "GAD_OPTIONS.h" CBOP C !ROUTINE: GAD_ADVECTION C !INTERFACE: ========================================================== SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity, U Tracer,Gtracer, I myTime,myIter,myThid) C !DESCRIPTION: C Calculates the tendancy of a tracer due to advection. C It uses the multi-dimensional method given in \ref{sect:multiDimAdvection} C and can only be used for the non-linear advection schemes such as the C direct-space-time method and flux-limiters. C C The algorithm is as follows: C \begin{itemize} C \item{$\theta^{(n+1/3)} = \theta^{(n)} C - \Delta t \partial_x (u\theta^{(n)}) + \theta^{(n)} \partial_x u$} C \item{$\theta^{(n+2/3)} = \theta^{(n+1/3)} C - \Delta t \partial_y (v\theta^{(n+1/3)}) + \theta^{(n)} \partial_y v$} C \item{$\theta^{(n+3/3)} = \theta^{(n+2/3)} C - \Delta t \partial_r (w\theta^{(n+2/3)}) + \theta^{(n)} \partial_r w$} C \item{$G_\theta = ( \theta^{(n+3/3)} - \theta^{(n)} )/\Delta t$} C \end{itemize} C C The tendancy (output) is over-written by this routine. C !USES: =============================================================== IMPLICIT NONE #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "DYNVARS.h" #include "GRID.h" #include "GAD.h" C !INPUT PARAMETERS: =================================================== C bi,bj :: tile indices C advectionScheme :: advection scheme to use C tracerIdentity :: identifier for the tracer (required only for OBCS) C Tracer :: tracer field C myTime :: current time C myIter :: iteration number C myThid :: thread number INTEGER bi,bj INTEGER advectionScheme INTEGER tracerIdentity _RL Gtracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) _RL myTime INTEGER myIter INTEGER myThid C !OUTPUT PARAMETERS: ================================================== C gTracer :: tendancy array _RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) C !LOCAL VARIABLES: ==================================================== C maskUp :: 2-D array for mask at W points C iMin,iMax,jMin,jMax :: loop range for called routines C i,j,k :: loop indices C kup :: index into 2 1/2D array, toggles between 1 and 2 C kdown :: index into 2 1/2D array, toggles between 2 and 1 C kp1 :: =k+1 for k1 : 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 C- add the advective flux to fVerT DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx fVerT(i,j,kUp) = af(i,j) ENDDO ENDDO C-- Divergence of fluxes kp1=min(Nr,k+1) kp1Msk=1. if (k.EQ.Nr) kp1Msk=0. DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx localTij(i,j)=localTijk(i,j,k)-deltaTtracer* & _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) & *recip_rA(i,j,bi,bj) & *( fVerT(i,j,kUp)-fVerT(i,j,kDown) & -tracer(i,j,k,bi,bj)*rA(i,j,bi,bj)* & (wVel(i,j,k,bi,bj)-kp1Msk*wVel(i,j,kp1,bi,bj)) & )*rkFac gTracer(i,j,k,bi,bj)= & (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer ENDDO ENDDO C-- End of K loop for vertical flux ENDDO RETURN END