1 |
heimbach |
1.13 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_calc_tensor.F,v 1.12 2002/11/14 22:43:49 heimbach Exp $ |
2 |
|
|
C $Name: $ |
3 |
adcroft |
1.1 |
|
4 |
|
|
#include "GMREDI_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
CStartOfInterface |
7 |
|
|
SUBROUTINE GMREDI_CALC_TENSOR( |
8 |
jmc |
1.9 |
I bi, bj, iMin, iMax, jMin, jMax, |
9 |
adcroft |
1.1 |
I sigmaX, sigmaY, sigmaR, |
10 |
|
|
I myThid ) |
11 |
|
|
C /==========================================================\ |
12 |
|
|
C | SUBROUTINE GMREDI_CALC_TENSOR | |
13 |
|
|
C | o Calculate tensor elements for GM/Redi tensor. | |
14 |
|
|
C |==========================================================| |
15 |
|
|
C \==========================================================/ |
16 |
|
|
IMPLICIT NONE |
17 |
|
|
|
18 |
|
|
C == Global variables == |
19 |
|
|
#include "SIZE.h" |
20 |
|
|
#include "GRID.h" |
21 |
|
|
#include "DYNVARS.h" |
22 |
|
|
#include "EEPARAMS.h" |
23 |
|
|
#include "PARAMS.h" |
24 |
|
|
#include "GMREDI.h" |
25 |
|
|
#include "GMREDI_DIAGS.h" |
26 |
|
|
|
27 |
heimbach |
1.10 |
#ifdef ALLOW_AUTODIFF_TAMC |
28 |
|
|
#include "tamc.h" |
29 |
|
|
#include "tamc_keys.h" |
30 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
31 |
|
|
|
32 |
adcroft |
1.1 |
C == Routine arguments == |
33 |
|
|
C |
34 |
|
|
_RL sigmaX(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
35 |
|
|
_RL sigmaY(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
36 |
|
|
_RL sigmaR(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
37 |
jmc |
1.9 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
38 |
adcroft |
1.1 |
INTEGER myThid |
39 |
|
|
CEndOfInterface |
40 |
|
|
|
41 |
|
|
#ifdef ALLOW_GMREDI |
42 |
|
|
|
43 |
|
|
C == Local variables == |
44 |
jmc |
1.9 |
INTEGER i,j,k,km1,kp1 |
45 |
adcroft |
1.1 |
_RL SlopeX(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
46 |
|
|
_RL SlopeY(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
47 |
heimbach |
1.12 |
_RL dSigmaDx(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
48 |
|
|
_RL dSigmaDy(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
49 |
adcroft |
1.1 |
_RL dSigmaDrReal(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
50 |
jmc |
1.8 |
_RL SlopeSqr(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
51 |
|
|
_RL taperFct(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
52 |
heimbach |
1.10 |
_RL maskp1, maskm1, Kgm_tmp |
53 |
adcroft |
1.1 |
|
54 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
55 |
|
|
_RS deltaH,zero_rs |
56 |
|
|
PARAMETER(zero_rs=0.) |
57 |
|
|
_RL N2,SN |
58 |
heimbach |
1.10 |
_RL Ssq(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
59 |
adcroft |
1.1 |
#endif |
60 |
|
|
|
61 |
heimbach |
1.10 |
#ifdef ALLOW_AUTODIFF_TAMC |
62 |
|
|
act1 = bi - myBxLo(myThid) |
63 |
|
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
64 |
|
|
act2 = bj - myByLo(myThid) |
65 |
|
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
66 |
|
|
act3 = myThid - 1 |
67 |
|
|
max3 = nTx*nTy |
68 |
|
|
act4 = ikey_dynamics - 1 |
69 |
heimbach |
1.12 |
igmkey = (act1 + 1) + act2*max1 |
70 |
heimbach |
1.10 |
& + act3*max1*max2 |
71 |
|
|
& + act4*max1*max2*max3 |
72 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
73 |
|
|
|
74 |
heimbach |
1.12 |
#ifdef GM_VISBECK_VARIABLE_K |
75 |
|
|
DO j=1-Oly,sNy+Oly |
76 |
|
|
DO i=1-Olx,sNx+Olx |
77 |
|
|
VisbeckK(i,j,bi,bj) = 0. _d 0 |
78 |
|
|
ENDDO |
79 |
|
|
ENDDO |
80 |
|
|
#endif |
81 |
|
|
|
82 |
jmc |
1.9 |
DO k=2,Nr |
83 |
|
|
C-- 1rst loop on k : compute Tensor Coeff. at W points. |
84 |
heimbach |
1.10 |
km1 = MAX(1,k-1) |
85 |
|
|
maskm1 = 1. _d 0 |
86 |
|
|
IF (k.LE.1) maskm1 = 0. _d 0 |
87 |
adcroft |
1.1 |
|
88 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
89 |
heimbach |
1.12 |
kkey = (igmkey-1)*Nr + k |
90 |
heimbach |
1.10 |
DO j=1-Oly,sNy+Oly |
91 |
|
|
DO i=1-Olx,sNx+Olx |
92 |
|
|
SlopeX(i,j) = 0. _d 0 |
93 |
|
|
SlopeY(i,j) = 0. _d 0 |
94 |
heimbach |
1.12 |
dSigmaDx(i,j) = 0. _d 0 |
95 |
|
|
dSigmaDy(i,j) = 0. _d 0 |
96 |
heimbach |
1.10 |
dSigmaDrReal(i,j) = 0. _d 0 |
97 |
|
|
SlopeSqr(i,j) = 0. _d 0 |
98 |
|
|
taperFct(i,j) = 0. _d 0 |
99 |
|
|
Kwx(i,j,k,bi,bj) = 0. _d 0 |
100 |
|
|
Kwy(i,j,k,bi,bj) = 0. _d 0 |
101 |
|
|
Kwz(i,j,k,bi,bj) = 0. _d 0 |
102 |
heimbach |
1.12 |
# ifdef GM_NON_UNITY_DIAGONAL |
103 |
|
|
Kux(i,j,k,bi,bj) = 0. _d 0 |
104 |
|
|
Kvy(i,j,k,bi,bj) = 0. _d 0 |
105 |
|
|
# endif |
106 |
|
|
# ifdef GM_EXTRA_DIAGONAL |
107 |
|
|
Kuz(i,j,k,bi,bj) = 0. _d 0 |
108 |
|
|
Kvz(i,j,k,bi,bj) = 0. _d 0 |
109 |
|
|
# endif |
110 |
|
|
# ifdef GM_BOLUS_ADVEC |
111 |
|
|
GM_PsiX(i,j,k,bi,bj) = 0. _d 0 |
112 |
|
|
GM_PsiY(i,j,k,bi,bj) = 0. _d 0 |
113 |
|
|
# endif |
114 |
heimbach |
1.10 |
ENDDO |
115 |
|
|
ENDDO |
116 |
adcroft |
1.1 |
#endif |
117 |
heimbach |
1.10 |
|
118 |
adcroft |
1.1 |
DO j=1-Oly+1,sNy+Oly-1 |
119 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
120 |
|
|
C Gradient of Sigma at rVel points |
121 |
heimbach |
1.12 |
dSigmaDx(i,j)=0.25*( sigmaX(i+1, j ,km1) +sigmaX(i,j,km1) |
122 |
adcroft |
1.1 |
& +sigmaX(i+1, j , k ) +sigmaX(i,j, k ) ) |
123 |
heimbach |
1.10 |
& *maskC(i,j,k,bi,bj)*maskm1 |
124 |
heimbach |
1.12 |
dSigmaDy(i,j)=0.25*( sigmaY( i ,j+1,km1) +sigmaY(i,j,km1) |
125 |
adcroft |
1.1 |
& +sigmaY( i ,j+1, k ) +sigmaY(i,j, k ) ) |
126 |
heimbach |
1.10 |
& *maskC(i,j,k,bi,bj)*maskm1 |
127 |
|
|
dSigmaDrReal(i,j)=sigmaR(i,j,k)*maskm1 |
128 |
adcroft |
1.1 |
ENDDO |
129 |
|
|
ENDDO |
130 |
|
|
|
131 |
heimbach |
1.10 |
#ifdef ALLOW_AUTODIFF_TAMC |
132 |
heimbach |
1.12 |
CADJ STORE dSigmaDx(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
133 |
|
|
CADJ STORE dSigmaDy(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
134 |
|
|
CADJ STORE dsigmadrreal(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
135 |
heimbach |
1.10 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
136 |
|
|
|
137 |
adcroft |
1.1 |
C Calculate slopes for use in tensor, taper and/or clip |
138 |
|
|
CALL GMREDI_SLOPE_LIMIT( |
139 |
jmc |
1.9 |
U dSigmadRReal, |
140 |
heimbach |
1.12 |
I rF(K),K, |
141 |
adcroft |
1.1 |
U SlopeX, SlopeY, |
142 |
heimbach |
1.12 |
U dSigmaDx, dSigmaDy, |
143 |
jmc |
1.8 |
O SlopeSqr, taperFct, |
144 |
adcroft |
1.1 |
I bi, bj, myThid ) |
145 |
|
|
|
146 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
147 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
148 |
|
|
|
149 |
|
|
C Mask Iso-neutral slopes |
150 |
heimbach |
1.10 |
SlopeX(i,j)=SlopeX(i,j)*maskC(i,j,k,bi,bj)*maskm1 |
151 |
|
|
SlopeY(i,j)=SlopeY(i,j)*maskC(i,j,k,bi,bj)*maskm1 |
152 |
|
|
SlopeSqr(i,j)=SlopeSqr(i,j)*maskC(i,j,k,bi,bj)*maskm1 |
153 |
|
|
|
154 |
|
|
ENDDO |
155 |
|
|
ENDDO |
156 |
|
|
|
157 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
158 |
heimbach |
1.13 |
CADJ STORE SlopeX(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
159 |
|
|
CADJ STORE SlopeY(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
160 |
|
|
CADJ STORE SlopeSqr(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
161 |
|
|
CADJ STORE taperFct(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
162 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
163 |
|
|
CADJ STORE dSigmaDrReal(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
164 |
|
|
#endif |
165 |
heimbach |
1.10 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
166 |
|
|
|
167 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
168 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
169 |
adcroft |
1.1 |
|
170 |
jmc |
1.9 |
C Components of Redi/GM tensor |
171 |
|
|
Kwx(i,j,k,bi,bj)= SlopeX(i,j)*taperFct(i,j) |
172 |
|
|
Kwy(i,j,k,bi,bj)= SlopeY(i,j)*taperFct(i,j) |
173 |
jmc |
1.8 |
Kwz(i,j,k,bi,bj)= SlopeSqr(i,j)*taperFct(i,j) |
174 |
adcroft |
1.1 |
|
175 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
176 |
jmc |
1.8 |
|
177 |
|
|
C- note (jmc) : moved here since only used in VISBECK_VARIABLE_K |
178 |
|
|
C but don't know if *taperFct (or **2 ?) is necessary |
179 |
heimbach |
1.10 |
Ssq(i,j)=SlopeSqr(i,j)*taperFct(i,j) |
180 |
jmc |
1.8 |
|
181 |
adcroft |
1.1 |
C-- Depth average of M^2/N^2 * N |
182 |
|
|
|
183 |
|
|
C Calculate terms for mean Richardson number |
184 |
|
|
C which is used in the "variable K" parameterisaton. |
185 |
|
|
C Distance between interface above layer and the integration depth |
186 |
|
|
deltaH=abs(GM_Visbeck_depth)-abs(rF(k)) |
187 |
|
|
C If positive we limit this to the layer thickness |
188 |
|
|
deltaH=min(deltaH,drF(k)) |
189 |
|
|
C If negative then we are below the integration level |
190 |
|
|
deltaH=max(deltaH,zero_rs) |
191 |
|
|
C Now we convert deltaH to a non-dimensional fraction |
192 |
|
|
deltaH=deltaH/GM_Visbeck_depth |
193 |
|
|
|
194 |
jmc |
1.8 |
IF (K.eq.2) VisbeckK(i,j,bi,bj)=0. |
195 |
heimbach |
1.13 |
IF ( Ssq(i,j).NE.0. .AND. dSigmaDrReal(i,j).NE.0. ) THEN |
196 |
mlosch |
1.11 |
N2= -Gravity*recip_RhoConst*dSigmaDrReal(i,j) |
197 |
heimbach |
1.10 |
SN=sqrt(Ssq(i,j)*N2) |
198 |
heimbach |
1.3 |
VisbeckK(i,j,bi,bj)=VisbeckK(i,j,bi,bj)+deltaH |
199 |
adcroft |
1.1 |
& *GM_Visbeck_alpha*GM_Visbeck_length*GM_Visbeck_length*SN |
200 |
jmc |
1.8 |
ENDIF |
201 |
adcroft |
1.1 |
|
202 |
jmc |
1.9 |
#endif /* GM_VISBECK_VARIABLE_K */ |
203 |
|
|
|
204 |
|
|
ENDDO |
205 |
|
|
ENDDO |
206 |
|
|
|
207 |
|
|
C-- end 1rst loop on vertical level index k |
208 |
|
|
ENDDO |
209 |
|
|
|
210 |
adcroft |
1.1 |
|
211 |
jmc |
1.9 |
#ifdef GM_VISBECK_VARIABLE_K |
212 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
213 |
|
|
CADJ STORE VisbeckK(:,:,bi,bj) = comlev1_bibj, key=igmkey, byte=isbyte |
214 |
|
|
#endif |
215 |
jmc |
1.9 |
IF ( GM_Visbeck_alpha.NE.0. ) THEN |
216 |
|
|
C- Limit range that KapGM can take |
217 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
218 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
219 |
|
|
VisbeckK(i,j,bi,bj)= |
220 |
|
|
& MIN(VisbeckK(i,j,bi,bj),GM_Visbeck_maxval_K) |
221 |
|
|
#ifdef ALLOW_TIMEAVE |
222 |
|
|
Visbeck_K_T(i,j,bi,bj)=Visbeck_K_T(i,j,bi,bj) |
223 |
|
|
& +VisbeckK(i,j,bi,bj)*deltaTclock |
224 |
|
|
#endif |
225 |
|
|
ENDDO |
226 |
|
|
ENDDO |
227 |
|
|
ENDIF |
228 |
adcroft |
1.1 |
#endif /* GM_VISBECK_VARIABLE_K */ |
229 |
|
|
|
230 |
|
|
|
231 |
jmc |
1.9 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
232 |
heimbach |
1.10 |
|
233 |
jmc |
1.9 |
C-- 2nd loop on k : compute Tensor Coeff. at U,V levels. |
234 |
|
|
DO k=1,Nr |
235 |
|
|
kp1 = MIN(Nr,k+1) |
236 |
|
|
maskp1 = 1. _d 0 |
237 |
|
|
IF (k.GE.Nr) maskp1 = 0. _d 0 |
238 |
|
|
|
239 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
240 |
|
|
kkey = (igmkey-1)*Nr + k |
241 |
heimbach |
1.13 |
#ifdef GM_VISBECK_VARIABLE_K |
242 |
heimbach |
1.12 |
CADJ STORE Kwx(:,:,k,bi,bj) = comlev1_bibj, key=kkey, byte=isbyte |
243 |
|
|
CADJ STORE Kwy(:,:,k,bi,bj) = comlev1_bibj, key=kkey, byte=isbyte |
244 |
|
|
CADJ STORE Kwz(:,:,k,bi,bj) = comlev1_bibj, key=kkey, byte=isbyte |
245 |
|
|
#endif |
246 |
|
|
#endif |
247 |
|
|
|
248 |
jmc |
1.9 |
C- express the Tensor in term of Diffusivity (= m**2 / s ) |
249 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
250 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
251 |
|
|
Kgm_tmp = GM_isopycK + GM_skewflx*GM_background_K |
252 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
253 |
|
|
& + VisbeckK(i,j,bi,bj)*(1.+GM_skewflx) |
254 |
|
|
#endif |
255 |
|
|
Kwx(i,j,k,bi,bj)= Kgm_tmp*Kwx(i,j,k,bi,bj) |
256 |
|
|
Kwy(i,j,k,bi,bj)= Kgm_tmp*Kwy(i,j,k,bi,bj) |
257 |
|
|
Kwz(i,j,k,bi,bj)= ( GM_isopycK |
258 |
adcroft |
1.1 |
#ifdef GM_VISBECK_VARIABLE_K |
259 |
jmc |
1.9 |
& + VisbeckK(i,j,bi,bj) |
260 |
adcroft |
1.1 |
#endif |
261 |
jmc |
1.9 |
& )*Kwz(i,j,k,bi,bj) |
262 |
adcroft |
1.1 |
ENDDO |
263 |
|
|
ENDDO |
264 |
heimbach |
1.13 |
#ifdef ALLOW_AUTODIFF_TAMC |
265 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
266 |
|
|
CADJ STORE VisbeckK(:,:,bi,bj) = |
267 |
|
|
CADJ & comlev1_bibj, key=kkey, byte=isbyte |
268 |
|
|
#endif |
269 |
|
|
#endif |
270 |
adcroft |
1.4 |
|
271 |
jmc |
1.9 |
#if ( defined (GM_NON_UNITY_DIAGONAL) || defined (GM_EXTRA_DIAGONAL) ) |
272 |
adcroft |
1.1 |
|
273 |
|
|
C Gradient of Sigma at U points |
274 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
275 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
276 |
heimbach |
1.12 |
dSigmaDx(i,j)=sigmaX(i,j,k) |
277 |
adcroft |
1.1 |
& *_maskW(i,j,k,bi,bj) |
278 |
heimbach |
1.12 |
dSigmaDy(i,j)=0.25*( sigmaY(i-1,j+1,k) +sigmaY(i,j+1,k) |
279 |
|
|
& +sigmaY(i-1, j ,k) +sigmaY(i, j ,k) ) |
280 |
adcroft |
1.1 |
& *_maskW(i,j,k,bi,bj) |
281 |
|
|
dSigmaDrReal(i,j)=0.25*( sigmaR(i-1,j, k ) +sigmaR(i,j, k ) |
282 |
jmc |
1.9 |
& +maskp1*(sigmaR(i-1,j,kp1) +sigmaR(i,j,kp1)) ) |
283 |
adcroft |
1.1 |
& *_maskW(i,j,k,bi,bj) |
284 |
|
|
ENDDO |
285 |
|
|
ENDDO |
286 |
|
|
|
287 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
288 |
|
|
CADJ STORE dSigmaDx(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
289 |
|
|
CADJ STORE dSigmaDy(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
290 |
|
|
CADJ STORE dsigmadrreal(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
291 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
292 |
|
|
|
293 |
adcroft |
1.1 |
C Calculate slopes for use in tensor, taper and/or clip |
294 |
|
|
CALL GMREDI_SLOPE_LIMIT( |
295 |
jmc |
1.9 |
U dSigmadRReal, |
296 |
heimbach |
1.12 |
I rF(K),K, |
297 |
adcroft |
1.1 |
U SlopeX, SlopeY, |
298 |
heimbach |
1.12 |
U dSigmaDx, dSigmaDy, |
299 |
jmc |
1.8 |
O SlopeSqr, taperFct, |
300 |
adcroft |
1.1 |
I bi, bj, myThid ) |
301 |
|
|
|
302 |
jmc |
1.9 |
#ifdef GM_NON_UNITY_DIAGONAL |
303 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
304 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
305 |
|
|
Kux(i,j,k,bi,bj) = |
306 |
|
|
& ( GM_isopycK |
307 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
308 |
|
|
& +0.5*(VisbeckK(i,j,bi,bj)+VisbeckK(i-1,j,bi,bj)) |
309 |
|
|
#endif |
310 |
heimbach |
1.10 |
& ) |
311 |
|
|
& *taperFct(i,j) |
312 |
|
|
ENDDO |
313 |
|
|
ENDDO |
314 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
315 |
|
|
# ifndef GM_TAPER_ORIG_CLIPPING |
316 |
|
|
CADJ STORE Kux(:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
317 |
|
|
# endif |
318 |
|
|
#endif |
319 |
heimbach |
1.10 |
DO j=1-Oly+1,sNy+Oly-1 |
320 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
321 |
jmc |
1.9 |
Kux(i,j,k,bi,bj) = MAX( Kux(i,j,k,bi,bj), GM_Kmin_horiz ) |
322 |
|
|
ENDDO |
323 |
|
|
ENDDO |
324 |
|
|
#endif /* GM_NON_UNITY_DIAGONAL */ |
325 |
|
|
|
326 |
|
|
#ifdef GM_EXTRA_DIAGONAL |
327 |
heimbach |
1.12 |
|
328 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
329 |
|
|
CADJ STORE SlopeX(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
330 |
|
|
CADJ STORE taperFct(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
331 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
332 |
jmc |
1.9 |
IF (GM_ExtraDiag) THEN |
333 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
334 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
335 |
|
|
Kuz(i,j,k,bi,bj) = |
336 |
|
|
& ( GM_isopycK - GM_skewflx*GM_background_K |
337 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
338 |
|
|
& +0.5*(VisbeckK(i,j,bi,bj)+VisbeckK(i-1,j,bi,bj))*GM_advect |
339 |
|
|
#endif |
340 |
|
|
& )*SlopeX(i,j)*taperFct(i,j) |
341 |
|
|
ENDDO |
342 |
|
|
ENDDO |
343 |
|
|
ENDIF |
344 |
|
|
#endif /* GM_EXTRA_DIAGONAL */ |
345 |
adcroft |
1.1 |
|
346 |
|
|
C Gradient of Sigma at V points |
347 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
348 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
349 |
heimbach |
1.12 |
dSigmaDx(i,j)=0.25*( sigmaX(i, j ,k) +sigmaX(i+1, j ,k) |
350 |
adcroft |
1.1 |
& +sigmaX(i,j-1,k) +sigmaX(i+1,j-1,k) ) |
351 |
|
|
& *_maskS(i,j,k,bi,bj) |
352 |
heimbach |
1.12 |
dSigmaDy(i,j)=sigmaY(i,j,k) |
353 |
adcroft |
1.1 |
& *_maskS(i,j,k,bi,bj) |
354 |
|
|
dSigmaDrReal(i,j)=0.25*( sigmaR(i,j-1, k ) +sigmaR(i,j, k ) |
355 |
jmc |
1.9 |
& +maskp1*(sigmaR(i,j-1,kp1) +sigmaR(i,j,kp1)) ) |
356 |
adcroft |
1.1 |
& *_maskS(i,j,k,bi,bj) |
357 |
|
|
ENDDO |
358 |
|
|
ENDDO |
359 |
|
|
|
360 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
361 |
|
|
CADJ STORE dSigmaDx(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
362 |
|
|
CADJ STORE dSigmaDy(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
363 |
|
|
CADJ STORE dsigmadrreal(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
364 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
365 |
|
|
|
366 |
adcroft |
1.1 |
C Calculate slopes for use in tensor, taper and/or clip |
367 |
|
|
CALL GMREDI_SLOPE_LIMIT( |
368 |
jmc |
1.9 |
U dSigmadRReal, |
369 |
heimbach |
1.12 |
I rF(K),K, |
370 |
adcroft |
1.1 |
U SlopeX, SlopeY, |
371 |
heimbach |
1.12 |
U dSigmaDx, dSigmaDy, |
372 |
jmc |
1.8 |
O SlopeSqr, taperFct, |
373 |
adcroft |
1.1 |
I bi, bj, myThid ) |
374 |
|
|
|
375 |
jmc |
1.9 |
#ifdef GM_NON_UNITY_DIAGONAL |
376 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
377 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
378 |
|
|
Kvy(i,j,k,bi,bj) = |
379 |
|
|
& ( GM_isopycK |
380 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
381 |
|
|
& +0.5*(VisbeckK(i,j,bi,bj)+VisbeckK(i,j-1,bi,bj)) |
382 |
|
|
#endif |
383 |
heimbach |
1.10 |
& ) |
384 |
|
|
& *taperFct(i,j) |
385 |
|
|
ENDDO |
386 |
|
|
ENDDO |
387 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
388 |
|
|
# ifndef GM_TAPER_ORIG_CLIPPING |
389 |
|
|
CADJ STORE Kvy(:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
390 |
|
|
# endif |
391 |
|
|
#endif |
392 |
heimbach |
1.10 |
DO j=1-Oly+1,sNy+Oly-1 |
393 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
394 |
jmc |
1.9 |
Kvy(i,j,k,bi,bj) = MAX( Kvy(i,j,k,bi,bj), GM_Kmin_horiz ) |
395 |
|
|
ENDDO |
396 |
|
|
ENDDO |
397 |
|
|
#endif /* GM_NON_UNITY_DIAGONAL */ |
398 |
|
|
|
399 |
|
|
#ifdef GM_EXTRA_DIAGONAL |
400 |
heimbach |
1.12 |
|
401 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
402 |
|
|
CADJ STORE SlopeY(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
403 |
|
|
CADJ STORE taperFct(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
404 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
405 |
jmc |
1.9 |
IF (GM_ExtraDiag) THEN |
406 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
407 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
408 |
|
|
Kvz(i,j,k,bi,bj) = |
409 |
|
|
& ( GM_isopycK - GM_skewflx*GM_background_K |
410 |
|
|
#ifdef GM_VISBECK_VARIABLE_K |
411 |
|
|
& +0.5*(VisbeckK(i,j,bi,bj)+VisbeckK(i,j-1,bi,bj))*GM_advect |
412 |
|
|
#endif |
413 |
|
|
& )*SlopeY(i,j)*taperFct(i,j) |
414 |
|
|
ENDDO |
415 |
|
|
ENDDO |
416 |
|
|
ENDIF |
417 |
|
|
#endif /* GM_EXTRA_DIAGONAL */ |
418 |
|
|
|
419 |
|
|
#endif /* GM_NON_UNITY_DIAGONAL || GM_EXTRA_DIAGONAL */ |
420 |
|
|
|
421 |
|
|
#ifdef ALLOW_TIMEAVE |
422 |
|
|
C-- Time-average |
423 |
adcroft |
1.1 |
DO j=1-Oly+1,sNy+Oly-1 |
424 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
425 |
jmc |
1.9 |
GM_Kwx_T(i,j,k,bi,bj)=GM_Kwx_T(i,j,k,bi,bj) |
426 |
|
|
& +Kwx(i,j,k,bi,bj)*deltaTclock |
427 |
|
|
GM_Kwy_T(i,j,k,bi,bj)=GM_Kwy_T(i,j,k,bi,bj) |
428 |
|
|
& +Kwy(i,j,k,bi,bj)*deltaTclock |
429 |
|
|
GM_Kwz_T(i,j,k,bi,bj)=GM_Kwz_T(i,j,k,bi,bj) |
430 |
|
|
& +Kwz(i,j,k,bi,bj)*deltaTclock |
431 |
adcroft |
1.1 |
ENDDO |
432 |
|
|
ENDDO |
433 |
jmc |
1.9 |
GM_TimeAve(k,bi,bj)=GM_TimeAve(k,bi,bj)+deltaTclock |
434 |
|
|
#endif /* ALLOW_TIMEAVE */ |
435 |
adcroft |
1.1 |
|
436 |
jmc |
1.9 |
C-- end 2nd loop on vertical level index k |
437 |
|
|
ENDDO |
438 |
adcroft |
1.1 |
|
439 |
|
|
|
440 |
jmc |
1.9 |
#ifdef GM_BOLUS_ADVEC |
441 |
|
|
IF (GM_AdvForm) THEN |
442 |
|
|
CALL GMREDI_CALC_PSI_B( |
443 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
444 |
|
|
I sigmaX, sigmaY, sigmaR, |
445 |
|
|
I myThid ) |
446 |
|
|
ENDIF |
447 |
|
|
#endif |
448 |
adcroft |
1.1 |
|
449 |
|
|
#endif /* ALLOW_GMREDI */ |
450 |
|
|
|
451 |
|
|
RETURN |
452 |
|
|
END |
453 |
heimbach |
1.2 |
|
454 |
|
|
|
455 |
|
|
SUBROUTINE GMREDI_CALC_TENSOR_DUMMY( |
456 |
jmc |
1.9 |
I bi, bj, iMin, iMax, jMin, jMax, |
457 |
heimbach |
1.2 |
I sigmaX, sigmaY, sigmaR, |
458 |
|
|
I myThid ) |
459 |
|
|
C /==========================================================\ |
460 |
|
|
C | SUBROUTINE GMREDI_CALC_TENSOR | |
461 |
|
|
C | o Calculate tensor elements for GM/Redi tensor. | |
462 |
|
|
C |==========================================================| |
463 |
|
|
C \==========================================================/ |
464 |
|
|
IMPLICIT NONE |
465 |
|
|
|
466 |
|
|
C == Global variables == |
467 |
|
|
#include "SIZE.h" |
468 |
|
|
#include "GRID.h" |
469 |
|
|
#include "DYNVARS.h" |
470 |
|
|
#include "EEPARAMS.h" |
471 |
|
|
#include "PARAMS.h" |
472 |
|
|
#include "GMREDI.h" |
473 |
|
|
|
474 |
|
|
C == Routine arguments == |
475 |
|
|
C |
476 |
|
|
_RL sigmaX(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
477 |
|
|
_RL sigmaY(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
478 |
|
|
_RL sigmaR(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
479 |
jmc |
1.9 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
480 |
heimbach |
1.2 |
INTEGER myThid |
481 |
|
|
CEndOfInterface |
482 |
|
|
|
483 |
jmc |
1.9 |
INTEGER i, j, k |
484 |
heimbach |
1.2 |
|
485 |
|
|
#ifdef ALLOW_GMREDI |
486 |
|
|
|
487 |
jmc |
1.9 |
DO k=1,Nr |
488 |
|
|
DO j=1-Oly+1,sNy+Oly-1 |
489 |
|
|
DO i=1-Olx+1,sNx+Olx-1 |
490 |
|
|
Kwx(i,j,k,bi,bj) = 0.0 |
491 |
|
|
Kwy(i,j,k,bi,bj) = 0.0 |
492 |
|
|
Kwz(i,j,k,bi,bj) = 0.0 |
493 |
|
|
ENDDO |
494 |
heimbach |
1.2 |
ENDDO |
495 |
|
|
ENDDO |
496 |
|
|
#endif /* ALLOW_GMREDI */ |
497 |
|
|
|
498 |
jmc |
1.9 |
RETURN |
499 |
|
|
END |