1 |
C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_fluxlimit_impl_r.F,v 1.9 2011/12/01 14:14:44 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "GAD_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: GAD_FLUXLIMIT_IMPL_R |
8 |
C !INTERFACE: |
9 |
SUBROUTINE GAD_FLUXLIMIT_IMPL_R( |
10 |
I bi,bj,k, iMin,iMax,jMin,jMax, |
11 |
I deltaTarg, rTrans, recip_hFac, tFld, |
12 |
O a3d, b3d, c3d, |
13 |
I myThid ) |
14 |
|
15 |
C !DESCRIPTION: |
16 |
C Compute matrix element to solve vertical advection implicitly |
17 |
C using flux--limiter advection scheme. |
18 |
C Method: |
19 |
C contribution of vertical transport at interface k is added |
20 |
C to matrix lines k and k-1. |
21 |
|
22 |
C !USES: |
23 |
IMPLICIT NONE |
24 |
|
25 |
C == Global variables === |
26 |
#include "SIZE.h" |
27 |
#include "GRID.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
|
31 |
C !INPUT/OUTPUT PARAMETERS: |
32 |
C == Routine Arguments == |
33 |
C bi,bj :: tile indices |
34 |
C k :: vertical level |
35 |
C iMin,iMax :: computation domain |
36 |
C jMin,jMax :: computation domain |
37 |
C deltaTarg :: time step |
38 |
C rTrans :: vertical volume transport |
39 |
C recip_hFac :: inverse of cell open-depth factor |
40 |
C tFld :: tracer field |
41 |
C a3d :: lower diagonal of the tridiagonal matrix |
42 |
C b3d :: main diagonal of the tridiagonal matrix |
43 |
C c3d :: upper diagonal of the tridiagonal matrix |
44 |
C myThid :: thread number |
45 |
INTEGER bi,bj,k |
46 |
INTEGER iMin,iMax,jMin,jMax |
47 |
_RL deltaTarg(Nr) |
48 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
49 |
_RS recip_hFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
50 |
_RL tFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
51 |
_RL a3d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
52 |
_RL b3d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
53 |
_RL c3d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
54 |
INTEGER myThid |
55 |
|
56 |
C == Local Variables == |
57 |
C i,j :: loop indices |
58 |
C kp1 :: =min( k+1 , Nr ) |
59 |
C km1 :: =max( k-1 , 1 ) |
60 |
C km2 :: =max( k-2 , 1 ) |
61 |
C Cr :: slope ratio |
62 |
C Rjm,Rj,Rjp :: differences at i-1,i,i+1 |
63 |
C w_CFL :: Courant-Friedrich-Levy number |
64 |
C upwindFac :: upwind factor |
65 |
C rCenter :: centered contribution |
66 |
C rUpwind :: upwind contribution |
67 |
INTEGER i,j,kp1,km1,km2 |
68 |
_RL Cr,Rjm,Rj,Rjp, w_CFL |
69 |
_RL upwindFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
_RL rCenter, rUpwind |
71 |
_RL deltaTcfl |
72 |
|
73 |
C Statement function provides Limiter(Cr) |
74 |
#include "GAD_FLUX_LIMITER.h" |
75 |
CEOP |
76 |
|
77 |
km2=MAX(1,k-2) |
78 |
km1=MAX(1,k-1) |
79 |
kp1=MIN(Nr,k+1) |
80 |
|
81 |
C-- process interior interface only: |
82 |
IF ( k.GT.1 .AND. k.LE.Nr ) THEN |
83 |
|
84 |
C-- Compute the upwind fraction: |
85 |
deltaTcfl = deltaTarg(k) |
86 |
DO j=jMin,jMax |
87 |
DO i=iMin,iMax |
88 |
w_CFL = deltaTcfl*rTrans(i,j)*recip_rA(i,j,bi,bj)*recip_drC(k) |
89 |
& *recip_deepFac2F(k)*recip_rhoFacF(k) |
90 |
Rjp=(tFld(i,j,kp1)-tFld(i,j,k) )*maskC(i,j,kp1,bi,bj) |
91 |
Rj =(tFld(i,j,k) -tFld(i,j,km1)) |
92 |
Rjm=(tFld(i,j,km1)-tFld(i,j,km2))*maskC(i,j,km2,bi,bj) |
93 |
|
94 |
IF ( Rj.NE.0. _d 0) THEN |
95 |
IF (rTrans(i,j).LT.0. _d 0) THEN |
96 |
Cr=Rjm/Rj |
97 |
ELSE |
98 |
Cr=Rjp/Rj |
99 |
ENDIF |
100 |
upwindFac(i,j) = 1. _d 0 |
101 |
& - Limiter(Cr) * ( 1. _d 0 + ABS(w_CFL) ) |
102 |
upwindFac(i,j) = MAX( -1. _d 0, upwindFac(i,j) ) |
103 |
ELSE |
104 |
upwindFac(i,j) = 0. _d 0 |
105 |
ENDIF |
106 |
ENDDO |
107 |
ENDDO |
108 |
|
109 |
C-- Add centered & upwind contributions |
110 |
DO j=jMin,jMax |
111 |
DO i=iMin,iMax |
112 |
rCenter = 0.5 _d 0 *rTrans(i,j)*recip_rA(i,j,bi,bj)*rkSign |
113 |
rUpwind = ABS(rCenter)*upwindFac(i,j) |
114 |
a3d(i,j,k) = a3d(i,j,k) |
115 |
& - (rCenter+rUpwind)*deltaTarg(k) |
116 |
& *recip_hFac(i,j,k)*recip_drF(k) |
117 |
& *recip_deepFac2C(k)*recip_rhoFacC(k) |
118 |
b3d(i,j,k) = b3d(i,j,k) |
119 |
& - (rCenter-rUpwind)*deltaTarg(k) |
120 |
& *recip_hFac(i,j,k)*recip_drF(k) |
121 |
& *recip_deepFac2C(k)*recip_rhoFacC(k) |
122 |
b3d(i,j,k-1) = b3d(i,j,k-1) |
123 |
& + (rCenter+rUpwind)*deltaTarg(k-1) |
124 |
& *recip_hFac(i,j,k-1)*recip_drF(k-1) |
125 |
& *recip_deepFac2C(k-1)*recip_rhoFacC(k-1) |
126 |
c3d(i,j,k-1) = c3d(i,j,k-1) |
127 |
& + (rCenter-rUpwind)*deltaTarg(k-1) |
128 |
& *recip_hFac(i,j,k-1)*recip_drF(k-1) |
129 |
& *recip_deepFac2C(k-1)*recip_rhoFacC(k-1) |
130 |
ENDDO |
131 |
ENDDO |
132 |
|
133 |
C-- process interior interface only: end |
134 |
ENDIF |
135 |
|
136 |
RETURN |
137 |
END |