[Mitgcm-support] impldiff.F
mitgcm-support at dev.mitgcm.org
mitgcm-support at dev.mitgcm.org
Wed Jul 9 15:55:23 EDT 2003
Here's a note to point our a bug fix to mitgcmuv, concerning its implicit
diffusion algorithm. The problem was noted in version c27, but it probably
applies also at least up to c31.
The problem occurs when implicitViscosity or implicitDiffusion is .true. and
topography intersects any of the intermediate lavels. That is, if all the
topography exists within the bottom-most cell, there is no problem, but in the
more common scenario, with bathymetry cutting through several levels, there is a
problem. Note also that it is a _small_ error in many applications with low
mixing levels and deep bathymetry. We noticed it only in an application of
mitgcm to the coastal ocean where diffusivities are large and cell depths are
small.
The routine, as it stands, omits a check at levels above the bottom (i.e.,
with k<Nr) to ensure that zero flux exists at the bottom. A corrected routine,
included below, adds such a check in two locations: at the first level, and at
lower levels still with k<Nr. It checks if recip_hFac = 0 in the level below,
and if it is, sets c=0 (i.e, ensures there is zero flux from the bottom).
Many thanks to Alistair for help in figuring out the problem.
-Chris
#include "CPP_OPTIONS.h"
C /==========================================================\
C | S/R IMPLDIFF |
C | o Solve implicit diffusion equation for vertical |
C | diffusivity. |
C \==========================================================/
SUBROUTINE IMPLDIFF( bi, bj, iMin, iMax, jMin, jMax,
I deltaTX,KappaRX,recip_hFac,
U gXNm1,
I myThid )
IMPLICIT NONE
C == Global data ==
#include "SIZE.h"
#include "DYNVARS.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
C == Routine Arguments ==
INTEGER bi,bj,iMin,iMax,jMin,jMax
_RL deltaTX
_RL KappaRX(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
_RS recip_hFac(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
_RL gXnm1(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
INTEGER myThid
C == Local variables ==
INTEGER i,j,k
_RL a(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
_RL b(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
_RL c(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
_RL ckm1(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
_RL bet(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
_RL gam(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr)
IF (Nr.GT.1) THEN ! Only need do anything if Nr>1
C-- Beginning of forward sweep (top level)
DO j=jMin,jMax
DO i=iMin,iMax
c(i,j)=-deltaTX*recip_hFac(i,j,1,bi,bj)*recip_drF(1)
& *KappaRX(i,j,2)*recip_drC(2)
IF (recip_hFac(i,j,2,bi,bj).EQ.0.) c(i,j)=0.
b(i,j)=1.-c(i,j)
bet(i,j)=0.
IF (b(i,j).NE.0.) bet(i,j)=1. / b(i,j)
gXnm1(i,j,1,bi,bj)=gXnm1(i,j,1,bi,bj)*bet(i,j)
ENDDO
ENDDO
ENDIF
C-- Middle of forward sweep
IF (Nr.GT.2) THEN
DO k=2,Nr-1
DO j=jMin,jMax
DO i=iMin,iMax
ckm1(i,j)=c(i,j)
a(i,j)=-deltaTX*recip_hFac(i,j,k,bi,bj)*recip_drF(k)
& *KappaRX(i,j, k )*recip_drC( k )
IF (recip_hFac(i,j,K,bi,bj).EQ.0.) a(i,j)=0.
c(i,j)=-deltaTX*recip_hFac(i,j,k,bi,bj)*recip_drF(k)
& *KappaRX(i,j,k+1)*recip_drC(k+1)
IF (recip_hFac(i,j,K+1,bi,bj).EQ.0.) c(i,j)=0.
b(i,j)=1.-c(i,j)-a(i,j)
ENDDO
ENDDO
DO j=jMin,jMax
DO i=iMin,iMax
gam(i,j,k)=ckm1(i,j)*bet(i,j)
bet(i,j)=b(i,j)-a(i,j)*gam(i,j,k)
IF (bet(i,j).NE.0.) bet(i,j)=1. / bet(i,j)
gXnm1(i,j,k,bi,bj)=(gXnm1(i,j,k,bi,bj)
& -a(i,j)*gXnm1(i,j,k-1,bi,bj))*bet(i,j)
ENDDO
ENDDO
ENDDO
ENDIF
IF (Nr.GT.1) THEN
C-- End of forward sweep (bottom level)
DO j=jMin,jMax
DO i=iMin,iMax
ckm1(i,j)=c(i,j)
a(i,j)=-deltaTX*recip_hFac(i,j,Nr,bi,bj)*recip_drF(Nr)
& *KappaRX(i,j, Nr )*recip_drC( Nr )
b(i,j)=1.-a(i,j)
ENDDO
ENDDO
DO j=jMin,jMax
DO i=iMin,iMax
gam(i,j,Nr)=ckm1(i,j)*bet(i,j)
bet(i,j)=b(i,j)-a(i,j)*gam(i,j,Nr)
IF (bet(i,j).NE.0.) bet(i,j)=1. / bet(i,j)
gXnm1(i,j,Nr,bi,bj)=(gXnm1(i,j,Nr,bi,bj)
& -a(i,j)*gXnm1(i,j,Nr-1,bi,bj))*bet(i,j)
ENDDO
ENDDO
C-- Backward sweep
DO k=Nr-1,1,-1
DO j=jMin,jMax
DO i=iMin,iMax
gXnm1(i,j,k,bi,bj)=gXnm1(i,j,k,bi,bj)
& -gam(i,j,k+1)*gXnm1(i,j,k+1,bi,bj)
ENDDO
ENDDO
ENDDO
ENDIF
RETURN
END
--
---------------------------------------------------------------------
Christopher Edwards christopher.edwards at uconn.edu
Department of Marine Sciences phone: (860) 405-9173
University of Connecticut fax: (860) 405-9153
1084 Shennecossett Road
Groton, CT 06340
---------------------------------------------------------------------
More information about the MITgcm-support
mailing list