C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/global_with_CFC11/code1x1/Attic/gad_calc_rhs.F,v 1.1.2.1 2005/08/25 16:22:17 dimitri Exp $ C $Name: $ #include "GAD_OPTIONS.h" CBOP C !ROUTINE: GAD_CALC_RHS C !INTERFACE: ========================================================== SUBROUTINE GAD_CALC_RHS( I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, I xA,yA,uTrans,vTrans,rTrans,maskUp, I diffKh, diffK4, KappaRT, Tracer, I tracerIdentity, advectionScheme, U fVerT, gTracer, I myThid ) C !DESCRIPTION: C Calculates the tendancy of a tracer due to advection and diffusion. C It calculates the fluxes in each direction indepentently and then C sets the tendancy to the divergence of these fluxes. The advective C fluxes are only calculated here when using the linear advection schemes C otherwise only the diffusive and parameterized fluxes are calculated. C C Contributions to the flux are calculated and added: C \begin{equation*} C {\bf F} = {\bf F}_{adv} + {\bf F}_{diff} +{\bf F}_{GM} + {\bf F}_{KPP} C \end{equation*} C C The tendancy is the divergence of the fluxes: C \begin{equation*} C G_\theta = G_\theta + \nabla \cdot {\bf F} C \end{equation*} C C The tendancy is assumed to contain data on entry. C !USES: =============================================================== IMPLICIT NONE #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "GRID.h" #include "DYNVARS.h" #include "GAD.h" #ifdef ALLOW_AUTODIFF_TAMC #include "tamc.h" #include "tamc_keys.h" #endif /* ALLOW_AUTODIFF_TAMC */ C !INPUT PARAMETERS: =================================================== C bi,bj :: tile indices C iMin,iMax,jMin,jMax :: loop range for called routines 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)*Tracer(i,j,k,bi,bj) 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)*Tracer(i,j,k,bi,bj) 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) = fVerT(i,j,kUp) + af(i,j) ENDDO ENDDO ENDIF C- Diffusive flux in R C Note: For K=1 then KM1=1 and this gives a dT/dr = 0 upper C boundary condition. IF (implicitDiffusion) THEN DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx df(i,j) = 0. _d 0 ENDDO ENDDO ELSE CALL GAD_DIFF_R(bi,bj,k,KappaRT,tracer,df,myThid) ENDIF c DO j=1-Oly,sNy+Oly c DO i=1-Olx,sNx+Olx c fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) c ENDDO c ENDDO #ifdef ALLOW_GMREDI C- GM/Redi flux in R IF (useGMRedi) THEN C *note* should update GMREDI_RTRANSPORT to set df *aja* CALL GMREDI_RTRANSPORT( I iMin,iMax,jMin,jMax,bi,bj,K, I Tracer,tracerIdentity, U df, I myThid) c DO j=1-Oly,sNy+Oly c DO i=1-Olx,sNx+Olx c fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) c ENDDO c ENDDO ENDIF #endif DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) ENDDO ENDDO #ifdef ALLOW_KPP C- Add non local KPP transport term (ghat) to diffusive T flux. IF (useKPP) THEN DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx df(i,j) = 0. _d 0 ENDDO ENDDO IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN C *note* should update KPP_TRANSPORT_T to set df *aja* CALL KPP_TRANSPORT_T( I iMin,iMax,jMin,jMax,bi,bj,k,km1, I KappaRT, U df ) ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN CALL KPP_TRANSPORT_S( I iMin,iMax,jMin,jMax,bi,bj,k,km1, I KappaRT, U df ) ELSEIF (tracerIdentity.EQ.GAD_TR1) THEN CALL KPP_TRANSPORT_TR1( I iMin,iMax,jMin,jMax,bi,bj,k,km1, I KappaRT, U df ) ELSE STOP 'GAD_CALC_RHS: Ooops' ENDIF DO j=1-Oly,sNy+Oly DO i=1-Olx,sNx+Olx fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) ENDDO ENDDO ENDIF #endif C-- Divergence of fluxes DO j=1-Oly,sNy+Oly-1 DO i=1-Olx,sNx+Olx-1 gTracer(i,j,k,bi,bj)=gTracer(i,j,k,bi,bj) & -_recip_hFacC(i,j,k,bi,bj)*recip_drF(k) & *recip_rA(i,j,bi,bj) & *( & +( fZon(i+1,j)-fZon(i,j) ) & +( fMer(i,j+1)-fMer(i,j) ) & +( fVerT(i,j,kUp)-fVerT(i,j,kDown) )*rkFac & ) ENDDO ENDDO RETURN END