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

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

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


Revision 1.16 - (show annotations) (download)
Fri Apr 4 20:29:08 2014 UTC (10 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65o, checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64w, checkpoint64v, HEAD
Changes since 1.15: +8 -8 lines
- Replace ALLOW_AUTODIFF_TAMC by ALLOW_AUTODIFF (except for tape/storage
  which are specific to TAF/TAMC).

1 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_dst3fl_adv_x.F,v 1.15 2011/10/13 15:10:32 mlosch Exp $
2 C $Name: $
3
4 #include "GAD_OPTIONS.h"
5
6 SUBROUTINE GAD_DST3FL_ADV_X(
7 I bi,bj,k, calcCFL, deltaTloc,
8 I uTrans, uFld,
9 I maskLocW, tracer,
10 O uT,
11 I myThid )
12 C /==========================================================\
13 C | SUBROUTINE GAD_DST3FL_ADV_X |
14 C | o Compute Zonal advective Flux of Tracer using |
15 C | 3rd Order DST Sceheme with flux limiting |
16 C |==========================================================|
17 IMPLICIT NONE
18
19 C == GLobal variables ==
20 #include "SIZE.h"
21 #include "GRID.h"
22 #include "GAD.h"
23
24 C == Routine arguments ==
25 INTEGER bi,bj,k
26 LOGICAL calcCFL
27 _RL deltaTloc
28 _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
29 _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)
32 _RL uT (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
33 INTEGER myThid
34
35 C == Local variables ==
36 INTEGER i,j
37 _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
46 uT(1-OLx,j)=0. _d 0
47 uT(2-OLx,j)=0. _d 0
48 uT(sNx+OLx,j)=0. _d 0
49 ENDDO
50 DO j=1-OLy,sNy+OLy
51 DO i=1-OLx+2,sNx+OLx-1
52 #if (defined ALLOW_AUTODIFF && defined TARGET_NEC_SX)
53 C These lines make TAF create vectorizable code
54 thetaP = 0. _d 0
55 thetaM = 0. _d 0
56 #endif
57 Rjp=(tracer(i+1,j)-tracer( i ,j))*maskLocW(i+1,j)
58 Rj =(tracer( i ,j)-tracer(i-1,j))*maskLocW( i ,j)
59 Rjm=(tracer(i-1,j)-tracer(i-2,j))*maskLocW(i-1,j)
60
61 uCFL = uFld(i,j)
62 IF ( calcCFL ) uCFL = ABS( uFld(i,j)*deltaTloc
63 & *recip_dxC(i,j,bi,bj)*recip_deepFacC(k) )
64 d0=(2. _d 0 -uCFL)*(1. _d 0 -uCFL)*oneSixth
65 d1=(1. _d 0 -uCFL*uCFL)*oneSixth
66
67 C- the old version: can produce overflow, division by zero,
68 c and is wrong for tracer with low concentration:
69 c thetaP=Rjm/(1.D-20+Rj)
70 c thetaM=Rjp/(1.D-20+Rj)
71 C- the right expression, but not bounded:
72 c thetaP=0.D0
73 c thetaM=0.D0
74 c IF (Rj.NE.0.D0) thetaP=Rjm/Rj
75 c IF (Rj.NE.0.D0) thetaM=Rjp/Rj
76 C- prevent |thetaP,M| to reach too big value:
77 IF ( ABS(Rj)*thetaMax .LE. ABS(Rjm) ) THEN
78 thetaP=SIGN(thetaMax,Rjm*Rj)
79 ELSE
80 thetaP=Rjm/Rj
81 ENDIF
82 IF ( ABS(Rj)*thetaMax .LE. ABS(Rjp) ) THEN
83 thetaM=SIGN(thetaMax,Rjp*Rj)
84 ELSE
85 thetaM=Rjp/Rj
86 ENDIF
87
88 psiP=d0+d1*thetaP
89 psiP=MAX(0. _d 0,MIN(MIN(1. _d 0,psiP),
90 & thetaP*(1. _d 0 -uCFL)/(uCFL+1. _d -20) ))
91 psiM=d0+d1*thetaM
92 psiM=MAX(0. _d 0,MIN(MIN(1. _d 0,psiM),
93 & thetaM*(1. _d 0 -uCFL)/(uCFL+1. _d -20) ))
94
95 uT(i,j)=
96 & 0.5*(uTrans(i,j)+ABS(uTrans(i,j)))
97 & *( Tracer(i-1,j) + psiP*Rj )
98 & +0.5*(uTrans(i,j)-ABS(uTrans(i,j)))
99 & *( Tracer( i ,j) - psiM*Rj )
100
101 ENDDO
102 ENDDO
103
104 RETURN
105 END

  ViewVC Help
Powered by ViewVC 1.1.22