1 |
C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_dst3fl_adv_y.F,v 1.13 2007/04/04 01:39:06 jmc 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_TAMC && 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 |