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

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

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


Revision 1.15 - (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.14: +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_y.F,v 1.14 2011/10/13 15:10:32 mlosch Exp $
2 C $Name: $
3
4 #include "GAD_OPTIONS.h"
5
6 SUBROUTINE GAD_DST3FL_ADV_Y(
7 I bi,bj,k, calcCFL, deltaTloc,
8 I vTrans, vFld,
9 I maskLocS, tracer,
10 O vT,
11 I myThid )
12 C /==========================================================\
13 C | SUBROUTINE GAD_DST3FL_ADV_Y |
14 C | o Compute Meridional 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 vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
29 _RL vFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
30 _RS maskLocS(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
31 _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
32 _RL vT (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,vCFL,d0,d1,psiP,psiM,thetaP,thetaM
38 _RL thetaMax
39 PARAMETER( thetaMax = 1.D+20 )
40
41 DO i=1-OLx,sNx+OLx
42 vT(i,1-OLy)=0. _d 0
43 vT(i,2-OLy)=0. _d 0
44 vT(i,sNy+OLy)=0. _d 0
45 ENDDO
46 DO j=1-OLy+2,sNy+OLy-1
47 DO i=1-OLx,sNx+OLx
48 #if (defined ALLOW_AUTODIFF && defined TARGET_NEC_SX)
49 C These lines make TAF create vectorizable code
50 thetaP = 0. _d 0
51 thetaM = 0. _d 0
52 #endif
53 Rjp=(tracer(i,j+1)-tracer(i, j ))*maskLocS(i,j+1)
54 Rj =(tracer(i, j )-tracer(i,j-1))*maskLocS(i, j )
55 Rjm=(tracer(i,j-1)-tracer(i,j-2))*maskLocS(i,j-1)
56
57 vCFL = vFld(i,j)
58 IF ( calcCFL ) vCFL = ABS( vFld(i,j)*deltaTloc
59 & *recip_dyC(i,j,bi,bj)*recip_deepFacC(k) )
60 d0=(2. _d 0 -vCFL)*(1. _d 0 -vCFL)*oneSixth
61 d1=(1. _d 0 -vCFL*vCFL)*oneSixth
62
63 C- the old version: can produce overflow, division by zero,
64 c and is wrong for tracer with low concentration:
65 c thetaP=Rjm/(1.D-20+Rj)
66 c thetaM=Rjp/(1.D-20+Rj)
67 C- the right expression, but not bounded:
68 c thetaP=0.D0
69 c thetaM=0.D0
70 c IF (Rj.NE.0.D0) thetaP=Rjm/Rj
71 c IF (Rj.NE.0.D0) thetaM=Rjp/Rj
72 C- prevent |thetaP,M| to reach too big value:
73 IF ( ABS(Rj)*thetaMax .LE. ABS(Rjm) ) THEN
74 thetaP=SIGN(thetaMax,Rjm*Rj)
75 ELSE
76 thetaP=Rjm/Rj
77 ENDIF
78 IF ( ABS(Rj)*thetaMax .LE. ABS(Rjp) ) THEN
79 thetaM=SIGN(thetaMax,Rjp*Rj)
80 ELSE
81 thetaM=Rjp/Rj
82 ENDIF
83
84 psiP=d0+d1*thetaP
85 psiP=MAX(0. _d 0,MIN(MIN(1. _d 0,psiP),
86 & thetaP*(1. _d 0 -vCFL)/(vCFL+1. _d -20) ))
87 psiM=d0+d1*thetaM
88 psiM=MAX(0. _d 0,MIN(MIN(1. _d 0,psiM),
89 & thetaM*(1. _d 0 -vCFL)/(vCFL+1. _d -20) ))
90
91 vT(i,j)=
92 & 0.5*(vTrans(i,j)+ABS(vTrans(i,j)))
93 & *( Tracer(i,j-1) + psiP*Rj )
94 & +0.5*(vTrans(i,j)-ABS(vTrans(i,j)))
95 & *( Tracer(i, j ) - psiM*Rj )
96
97 ENDDO
98 ENDDO
99
100 RETURN
101 END

  ViewVC Help
Powered by ViewVC 1.1.22