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

Annotation of /MITgcm/pkg/generic_advdiff/gad_dst3fl_adv_r.F

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


Revision 1.11 - (hide annotations) (download)
Fri Apr 4 20:29:08 2014 UTC (10 years, 1 month 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.10: +4 -4 lines
- Replace ALLOW_AUTODIFF_TAMC by ALLOW_AUTODIFF (except for tape/storage
  which are specific to TAF/TAMC).

1 jmc 1.11 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_dst3fl_adv_r.F,v 1.10 2011/10/13 15:10:32 mlosch Exp $
2 adcroft 1.3 C $Name: $
3 adcroft 1.1
4     #include "GAD_OPTIONS.h"
5    
6 jmc 1.6 CBOP
7     C !ROUTINE: GAD_DST3FL_ADV_R
8    
9     C !INTERFACE: ==========================================================
10 jmc 1.7 SUBROUTINE GAD_DST3FL_ADV_R(
11 jmc 1.6 I bi,bj,k,dTarg,
12 jmc 1.7 I rTrans, wFld,
13 adcroft 1.1 I tracer,
14     O wT,
15     I myThid )
16 jmc 1.6
17     C !DESCRIPTION:
18     C Calculates the area integrated vertical flux due to advection of a tracer
19     C using 3rd Order DST Scheme with flux limiting
20    
21     C !USES: ===============================================================
22 adcroft 1.1 IMPLICIT NONE
23    
24     C == GLobal variables ==
25     #include "SIZE.h"
26     #include "GRID.h"
27     #include "GAD.h"
28    
29     C == Routine arguments ==
30 jmc 1.6 C !INPUT PARAMETERS: ===================================================
31     C bi,bj :: tile indices
32     C k :: vertical level
33     C deltaTloc :: local time-step (s)
34     C rTrans :: vertical volume transport
35 jmc 1.7 C wFld :: vertical flow
36 jmc 1.6 C tracer :: tracer field
37     C myThid :: thread number
38     INTEGER bi,bj,k
39 adcroft 1.1 _RL dTarg
40     _RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
41 jmc 1.7 _RL wFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
42 jmc 1.6 _RL tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
43     INTEGER myThid
44    
45     C !OUTPUT PARAMETERS: ==================================================
46     C wT :: vertical advective flux
47 adcroft 1.1 _RL wT (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
48    
49     C == Local variables ==
50 jmc 1.6 C !LOCAL VARIABLES: ====================================================
51     C i,j :: loop indices
52     C km1 :: =max( k-1 , 1 )
53 jmc 1.7 C wLoc :: velocity, vertical component
54 jmc 1.6 C wCFL :: Courant-Friedrich-Levy number
55     INTEGER i,j,kp1,km1,km2
56 jmc 1.9 _RL Rjm,Rj,Rjp,wCFL,d0,d1
57 adcroft 1.1 _RL psiP,psiM,thetaP,thetaM
58 jmc 1.7 _RL wLoc
59 jmc 1.5 _RL thetaMax
60     PARAMETER( thetaMax = 1.D+20 )
61 adcroft 1.1
62     km2=MAX(1,k-2)
63     km1=MAX(1,k-1)
64     kp1=MIN(Nr,k+1)
65    
66 jmc 1.11 DO j=1-OLy,sNy+OLy
67     DO i=1-OLx,sNx+OLx
68     #if (defined ALLOW_AUTODIFF && defined TARGET_NEC_SX)
69 mlosch 1.10 C These lines make TAF create vectorizable code
70     thetaP = 0. _d 0
71     thetaM = 0. _d 0
72     #endif
73 jmc 1.6 Rjp=(tracer(i,j,k)-tracer(i,j,kp1))
74     & *maskC(i,j,kp1,bi,bj)
75     Rj =(tracer(i,j,km1)-tracer(i,j,k))
76     & *maskC(i,j,k,bi,bj)*maskC(i,j,km1,bi,bj)
77     Rjm=(tracer(i,j,km2)-tracer(i,j,km1))
78     & *maskC(i,j,km1,bi,bj)
79 adcroft 1.1
80 jmc 1.8 wLoc = wFld(i,j)
81 jmc 1.9 wCFL = ABS(wLoc*dTarg*recip_drC(k))
82     d0=(2. _d 0 -wCFL)*(1. _d 0 -wCFL)*oneSixth
83     d1=(1. _d 0 -wCFL*wCFL)*oneSixth
84 jmc 1.5
85     C- the old version: can produce overflow, division by zero,
86     C and is wrong for tracer with low concentration:
87     c thetaP=Rjm/(1.D-20+Rj)
88     c thetaM=Rjp/(1.D-20+Rj)
89     C- the right expression, but not bounded:
90 heimbach 1.2 c thetaP=0.D0
91 jmc 1.5 c thetaM=0.D0
92 heimbach 1.2 c IF (Rj.NE.0.D0) thetaP=Rjm/Rj
93 jmc 1.5 c IF (Rj.NE.0.D0) thetaM=Rjp/Rj
94     C- prevent |thetaP,M| to reach too big value:
95     IF ( ABS(Rj)*thetaMax .LE. ABS(Rjm) ) THEN
96     thetaP=SIGN(thetaMax,Rjm*Rj)
97     ELSE
98     thetaP=Rjm/Rj
99     ENDIF
100     IF ( ABS(Rj)*thetaMax .LE. ABS(Rjp) ) THEN
101     thetaM=SIGN(thetaMax,Rjp*Rj)
102     ELSE
103     thetaM=Rjp/Rj
104     ENDIF
105    
106 adcroft 1.1 psiP=d0+d1*thetaP
107 jmc 1.5 psiP=MAX(0. _d 0,MIN(MIN(1. _d 0,psiP),
108 jmc 1.9 & thetaP*(1. _d 0 -wCFL)/(wCFL+1. _d -20) ))
109 adcroft 1.1 psiM=d0+d1*thetaM
110 jmc 1.5 psiM=MAX(0. _d 0,MIN(MIN(1. _d 0,psiM),
111 jmc 1.9 & thetaM*(1. _d 0 -wCFL)/(wCFL+1. _d -20) ))
112 jmc 1.5
113 adcroft 1.1 wT(i,j)=
114 jmc 1.9 & 0.5*(rTrans(i,j)+ABS(rTrans(i,j)))
115 jmc 1.6 & *( tracer(i,j, k ) + psiM*Rj )
116 jmc 1.9 & +0.5*(rTrans(i,j)-ABS(rTrans(i,j)))
117 jmc 1.6 & *( tracer(i,j,km1) - psiP*Rj )
118 adcroft 1.1
119     ENDDO
120     ENDDO
121    
122     RETURN
123     END

  ViewVC Help
Powered by ViewVC 1.1.22