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

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

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

revision 1.5 by jmc, Wed Mar 6 01:29:36 2002 UTC revision 1.9 by heimbach, Wed Jun 7 01:55:14 2006 UTC
# Line 4  C $Name$ Line 4  C $Name$
4  #include "GAD_OPTIONS.h"  #include "GAD_OPTIONS.h"
5    
6        SUBROUTINE GAD_DST3FL_ADV_X(        SUBROUTINE GAD_DST3FL_ADV_X(
7       I           bi,bj,k,deltaT,       I           bi,bj,k,deltaTloc,
8       I           uTrans, uVel,       I           uTrans, uVel,
9       I           tracer,       I           maskLocW, tracer,
10       O           uT,       O           uT,
11       I           myThid )       I           myThid )
12  C     /==========================================================\  C     /==========================================================\
# Line 23  C     == GLobal variables == Line 23  C     == GLobal variables ==
23    
24  C     == Routine arguments ==  C     == Routine arguments ==
25        INTEGER bi,bj,k        INTEGER bi,bj,k
26        _RL deltaT        _RL deltaTloc
27        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
28        _RL uVel(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)        _RL uVel(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
29          _RS maskLocW(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
30        _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
31        _RL uT    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uT    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
32        INTEGER myThid        INTEGER myThid
# Line 35  C     uFld   :: velocity [m/s], zonal co Line 36  C     uFld   :: velocity [m/s], zonal co
36        INTEGER i,j        INTEGER i,j
37        _RL Rjm,Rj,Rjp,cfl,d0,d1,psiP,psiM,thetaP,thetaM        _RL Rjm,Rj,Rjp,cfl,d0,d1,psiP,psiM,thetaP,thetaM
38        _RL uFld        _RL uFld
39          _RL thetaMax
40          PARAMETER( thetaMax = 1.D+20 )
41    
42    C- jmc: an alternative would be to compute directly psiM*Rj & psiP*Rj
43    C       (if Rj*Rjm < 0 => psiP*Rj = 0 , elsef Rj > 0 ... , else  ... )
44    C       with no need to compute thetaM (might be easier to differentiate)
45    
46        DO j=1-Oly,sNy+Oly        DO j=1-Oly,sNy+Oly
47         uT(1-Olx,j)=0.D0         uT(1-Olx,j)=0. _d 0
48         uT(2-Olx,j)=0.D0         uT(2-Olx,j)=0. _d 0
49         uT(sNx+Olx,j)=0.D0         uT(sNx+Olx,j)=0. _d 0
50         DO i=1-Olx+2,sNx+Olx-1         DO i=1-Olx+2,sNx+Olx-1
51          Rjp=(tracer(i+1,j)-tracer(i,j))*maskW(i+1,j,k,bi,bj)          Rjp=(tracer(i+1,j)-tracer( i ,j))*maskLocW(i+1,j)
52          Rj =(tracer(i,j)-tracer(i-1,j))*maskW(i,j,k,bi,bj)          Rj =(tracer( i ,j)-tracer(i-1,j))*maskLocW( i ,j)
53          Rjm=(tracer(i-1,j)-tracer(i-2,j))*maskW(i-1,j,k,bi,bj)          Rjm=(tracer(i-1,j)-tracer(i-2,j))*maskLocW(i-1,j)
54    
55  c       uFld = uVel(i,j,k,bi,bj)  c       uFld = uVel(i,j,k,bi,bj)
56          uFld = uTrans(i,j)*recip_dyG(i,j,bi,bj)          uFld = uTrans(i,j)*recip_dyG(i,j,bi,bj)
57       &       *recip_drF(k)*recip_hFacW(i,j,k,bi,bj)       &       *recip_drF(k)*_recip_hFacW(i,j,k,bi,bj)
58          cfl=abs(uFld*deltaT*recip_dxC(i,j,bi,bj))          cfl=abs(uFld*deltaTloc*recip_dxC(i,j,bi,bj))
59          d0=(2.D0-cfl)*(1.D0-cfl)*oneSixth          d0=(2. _d 0 -cfl)*(1. _d 0 -cfl)*oneSixth
60          d1=(1.D0-cfl*cfl)*oneSixth          d1=(1. _d 0 -cfl*cfl)*oneSixth
61    
62    C-      the old version: can produce overflow, division by zero,
63    c       and is wrong for tracer with low concentration:
64    c       thetaP=Rjm/(1.D-20+Rj)
65    c       thetaM=Rjp/(1.D-20+Rj)
66    C-      the right expression, but not bounded:
67  c       thetaP=0.D0  c       thetaP=0.D0
 c       IF (Rj.NE.0.D0) thetaP=Rjm/Rj  
         thetaP=Rjm/(1.D-20+Rj)  
         psiP=d0+d1*thetaP  
         psiP=max(0.D0, min(min(1.D0,psiP),  
      &       (1.D0-cfl)/(1.D-20+cfl)*thetaP))  
         thetaM=Rjp/(1.D-20+Rj)  
68  c       thetaM=0.D0  c       thetaM=0.D0
69    c       IF (Rj.NE.0.D0) thetaP=Rjm/Rj
70  c       IF (Rj.NE.0.D0) thetaM=Rjp/Rj  c       IF (Rj.NE.0.D0) thetaM=Rjp/Rj
71    C-      prevent |thetaP,M| to reach too big value:
72            IF ( ABS(Rj)*thetaMax .LE. ABS(Rjm) ) THEN
73              thetaP=SIGN(thetaMax,Rjm*Rj)
74            ELSE
75              thetaP=Rjm/Rj
76            ENDIF
77            IF ( ABS(Rj)*thetaMax .LE. ABS(Rjp) ) THEN
78              thetaM=SIGN(thetaMax,Rjp*Rj)
79            ELSE
80              thetaM=Rjp/Rj
81            ENDIF
82    
83            psiP=d0+d1*thetaP
84            psiP=MAX(0. _d 0, MIN(MIN(1. _d 0,psiP),
85         &                        thetaP*(1. _d 0 -cfl)/(cfl+1. _d -20) ))
86          psiM=d0+d1*thetaM          psiM=d0+d1*thetaM
87          psiM=max(0.D0, min(min(1.D0,psiM),          psiM=MAX(0. _d 0, MIN(MIN(1. _d 0,psiM),
88       &       (1.D0-cfl)/(1.D-20+cfl)*thetaM))       &                        thetaM*(1. _d 0 -cfl)/(cfl+1. _d -20) ))
89    
90          uT(i,j)=          uT(i,j)=
91       &   0.5*(uTrans(i,j)+abs(uTrans(i,j)))       &   0.5*(uTrans(i,j)+abs(uTrans(i,j)))
92       &      *( Tracer(i-1,j) + psiP*Rj )       &      *( Tracer(i-1,j) + psiP*Rj )

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.22