/[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.3 by adcroft, Mon Sep 10 00:24:14 2001 UTC revision 1.13 by jmc, Wed Apr 4 01:39:06 2007 UTC
# Line 3  C $Name$ Line 3  C $Name$
3    
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, calcCFL, deltaTloc,
8       I           uTrans, uVel,       I           uTrans, uFld,
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        LOGICAL calcCFL
27          _RL deltaTloc
28        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
29        _RL uVel(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)        _RL uFld  (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
30          _RS maskLocW(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
31        _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
32        _RL uT    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL uT    (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
33        INTEGER myThid        INTEGER myThid
34    
35  C     == Local variables ==  C     == Local variables ==
36        INTEGER i,j        INTEGER i,j
37        _RL Rjm,Rj,Rjp,cfl,d0,d1,psiP,psiM,thetaP,thetaM        _RL Rjm,Rj,Rjp,uCFL,d0,d1,psiP,psiM,thetaP,thetaM
38          _RL thetaMax
39          PARAMETER( thetaMax = 1.D+20 )
40    
41    C- jmc: an alternative would be to compute directly psiM*Rj & psiP*Rj
42    C       (if Rj*Rjm < 0 => psiP*Rj = 0 , elsef Rj > 0 ... , else  ... )
43    C       with no need to compute thetaM (might be easier to differentiate)
44    
45        DO j=1-Oly,sNy+Oly        DO j=1-Oly,sNy+Oly
46         uT(1-Olx,j)=0.         uT(1-Olx,j)=0. _d 0
47         uT(2-Olx,j)=0.         uT(2-Olx,j)=0. _d 0
48         uT(sNx+Olx,j)=0.         uT(sNx+Olx,j)=0. _d 0
49         DO i=1-Olx+2,sNx+Olx-1         DO i=1-Olx+2,sNx+Olx-1
50          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)
51          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)
52          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)
53    
54          cfl=abs(uVel(i,j,k,bi,bj)*deltaT*recip_dxc(i,j,bi,bj))          uCFL = uFld(i,j)
55          d0=(2.-cfl)*(1.-cfl)*oneSixth          IF ( calcCFL ) uCFL = ABS( uFld(i,j)*deltaTloc
56          d1=(1.-cfl*cfl)*oneSixth       &                  *recip_dxC(i,j,bi,bj)*recip_deepFacC(k) )
57  c       thetaP=0.          d0=(2. _d 0 -uCFL)*(1. _d 0 -uCFL)*oneSixth
58  c       IF (Rj.NE.0.) thetaP=Rjm/Rj          d1=(1. _d 0 -uCFL*uCFL)*oneSixth
59          thetaP=Rjm/(1.D-20+Rj)  
60    C-      the old version: can produce overflow, division by zero,
61    c       and is wrong for tracer with low concentration:
62    c       thetaP=Rjm/(1.D-20+Rj)
63    c       thetaM=Rjp/(1.D-20+Rj)
64    C-      the right expression, but not bounded:
65    c       thetaP=0.D0
66    c       thetaM=0.D0
67    c       IF (Rj.NE.0.D0) thetaP=Rjm/Rj
68    c       IF (Rj.NE.0.D0) thetaM=Rjp/Rj
69    C-      prevent |thetaP,M| to reach too big value:
70            IF ( ABS(Rj)*thetaMax .LE. ABS(Rjm) ) THEN
71              thetaP=SIGN(thetaMax,Rjm*Rj)
72            ELSE
73              thetaP=Rjm/Rj
74            ENDIF
75            IF ( ABS(Rj)*thetaMax .LE. ABS(Rjp) ) THEN
76              thetaM=SIGN(thetaMax,Rjp*Rj)
77            ELSE
78              thetaM=Rjp/Rj
79            ENDIF
80    
81          psiP=d0+d1*thetaP          psiP=d0+d1*thetaP
82          psiP=max(0., min(min(1.,psiP),(1.-cfl)/(1.D-20+cfl)*thetaP))          psiP=MAX(0. _d 0,MIN(MIN(1. _d 0,psiP),
83          thetaM=Rjp/(1.D-20+Rj)       &                       thetaP*(1. _d 0 -uCFL)/(uCFL+1. _d -20) ))
 c       thetaM=0.  
 c       IF (Rj.NE.0.) thetaM=Rjp/Rj  
84          psiM=d0+d1*thetaM          psiM=d0+d1*thetaM
85          psiM=max(0., min(min(1.,psiM),(1.-cfl)/(1.D-20+cfl)*thetaM))          psiM=MAX(0. _d 0,MIN(MIN(1. _d 0,psiM),
86         &                       thetaM*(1. _d 0 -uCFL)/(uCFL+1. _d -20) ))
87    
88          uT(i,j)=          uT(i,j)=
89       &   0.5*(uTrans(i,j)+abs(uTrans(i,j)))       &   0.5*(uTrans(i,j)+ABS(uTrans(i,j)))
90       &      *( Tracer(i-1,j) + psiP*Rj )       &      *( Tracer(i-1,j) + psiP*Rj )
91       &  +0.5*(uTrans(i,j)-abs(uTrans(i,j)))       &  +0.5*(uTrans(i,j)-ABS(uTrans(i,j)))
92       &      *( Tracer( i ,j) - psiM*Rj )       &      *( Tracer( i ,j) - psiM*Rj )
93    
94         ENDDO         ENDDO

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22