1 |
heimbach |
1.18 |
C $Header: /u/gcmpack/MITgcm/pkg/kpp/kpp_routines.F,v 1.17 2003/09/29 19:24:31 edhill Exp $ |
2 |
heimbach |
1.10 |
C $Name: $ |
3 |
adcroft |
1.1 |
|
4 |
|
|
#include "KPP_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
C-- File kpp_routines.F: subroutines needed to implement |
7 |
|
|
C-- KPP vertical mixing scheme |
8 |
|
|
C-- Contents |
9 |
|
|
C-- o KPPMIX - Main driver and interface routine. |
10 |
|
|
C-- o BLDEPTH - Determine oceanic planetary boundary layer depth. |
11 |
|
|
C-- o WSCALE - Compute turbulent velocity scales. |
12 |
|
|
C-- o RI_IWMIX - Compute interior viscosity diffusivity coefficients. |
13 |
|
|
C-- o Z121 - Apply 121 vertical smoothing. |
14 |
heimbach |
1.4 |
C-- o KPP_SMOOTH_HORIZ - Apply horizontal smoothing to KPP array. |
15 |
|
|
C-- o SMOOTH_HORIZ - Apply horizontal smoothing to global array. |
16 |
adcroft |
1.1 |
C-- o BLMIX - Boundary layer mixing coefficients. |
17 |
|
|
C-- o ENHANCE - Enhance diffusivity at boundary layer interface. |
18 |
|
|
C-- o STATEKPP - Compute buoyancy-related input arrays. |
19 |
|
|
|
20 |
heimbach |
1.4 |
c*********************************************************************** |
21 |
adcroft |
1.1 |
|
22 |
|
|
SUBROUTINE KPPMIX ( |
23 |
heimbach |
1.4 |
I mytime, mythid |
24 |
|
|
I , kmtj, shsq, dvsq, ustar |
25 |
|
|
I , bo, bosol, dbloc, Ritop, coriol |
26 |
heimbach |
1.16 |
I , ikppkey |
27 |
adcroft |
1.1 |
O , diffus |
28 |
|
|
U , ghat |
29 |
|
|
O , hbl ) |
30 |
|
|
|
31 |
heimbach |
1.4 |
c----------------------------------------------------------------------- |
32 |
adcroft |
1.1 |
c |
33 |
|
|
c Main driver subroutine for kpp vertical mixing scheme and |
34 |
|
|
c interface to greater ocean model |
35 |
|
|
c |
36 |
|
|
c written by: bill large, june 6, 1994 |
37 |
|
|
c modified by: jan morzel, june 30, 1994 |
38 |
|
|
c bill large, august 11, 1994 |
39 |
|
|
c bill large, january 25, 1995 : "dVsq" and 1d code |
40 |
|
|
c detlef stammer, august 1997 : for use with MIT GCM Classic |
41 |
|
|
c d. menemenlis, june 1998 : for use with MIT GCM UV |
42 |
|
|
c |
43 |
|
|
c----------------------------------------------------------------------- |
44 |
|
|
|
45 |
|
|
IMPLICIT NONE |
46 |
|
|
|
47 |
|
|
#include "SIZE.h" |
48 |
|
|
#include "EEPARAMS.h" |
49 |
|
|
#include "PARAMS.h" |
50 |
|
|
#include "DYNVARS.h" |
51 |
|
|
#include "FFIELDS.h" |
52 |
|
|
#include "KPP_PARAMS.h" |
53 |
|
|
|
54 |
|
|
c input |
55 |
heimbach |
1.4 |
c myTime - current time in simulation |
56 |
|
|
c myThid - thread number for this instance of the routine |
57 |
adcroft |
1.1 |
c kmtj (imt) - number of vertical layers on this row |
58 |
|
|
c shsq (imt,Nr) - (local velocity shear)^2 ((m/s)^2) |
59 |
|
|
c dvsq (imt,Nr) - (velocity shear re sfc)^2 ((m/s)^2) |
60 |
|
|
c ustar (imt) - surface friction velocity (m/s) |
61 |
|
|
c bo (imt) - surface turbulent buoy. forcing (m^2/s^3) |
62 |
|
|
c bosol (imt) - radiative buoyancy forcing (m^2/s^3) |
63 |
|
|
c dbloc (imt,Nr) - local delta buoyancy across interfaces (m/s^2) |
64 |
|
|
c dblocSm(imt,Nr) - horizontally smoothed dbloc (m/s^2) |
65 |
|
|
c stored in ghat to save space |
66 |
|
|
c Ritop (imt,Nr) - numerator of bulk Richardson Number |
67 |
|
|
c (zref-z) * delta buoyancy w.r.t. surface ((m/s)^2) |
68 |
|
|
c coriol (imt) - Coriolis parameter (1/s) |
69 |
|
|
c note: there is a conversion from 2-D to 1-D for input output variables, |
70 |
|
|
c e.g., hbl(sNx,sNy) -> hbl(imt), |
71 |
|
|
c where hbl(i,j) -> hbl((j-1)*sNx+i) |
72 |
|
|
|
73 |
heimbach |
1.4 |
_RL mytime |
74 |
|
|
integer mythid |
75 |
adcroft |
1.1 |
integer kmtj (imt ) |
76 |
heimbach |
1.4 |
_KPP_RL shsq (imt,Nr) |
77 |
|
|
_KPP_RL dvsq (imt,Nr) |
78 |
|
|
_KPP_RL ustar (imt ) |
79 |
|
|
_KPP_RL bo (imt ) |
80 |
|
|
_KPP_RL bosol (imt ) |
81 |
|
|
_KPP_RL dbloc (imt,Nr) |
82 |
|
|
_KPP_RL Ritop (imt,Nr) |
83 |
|
|
_KPP_RL coriol(imt ) |
84 |
adcroft |
1.1 |
|
85 |
heimbach |
1.16 |
integer ikppkey |
86 |
adcroft |
1.1 |
|
87 |
|
|
c output |
88 |
|
|
c diffus (imt,1) - vertical viscosity coefficient (m^2/s) |
89 |
|
|
c diffus (imt,2) - vertical scalar diffusivity (m^2/s) |
90 |
|
|
c diffus (imt,3) - vertical temperature diffusivity (m^2/s) |
91 |
|
|
c ghat (imt) - nonlocal transport coefficient (s/m^2) |
92 |
|
|
c hbl (imt) - mixing layer depth (m) |
93 |
|
|
|
94 |
heimbach |
1.4 |
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
95 |
|
|
_KPP_RL ghat (imt,Nr) |
96 |
|
|
_KPP_RL hbl (imt) |
97 |
adcroft |
1.1 |
|
98 |
|
|
#ifdef ALLOW_KPP |
99 |
|
|
|
100 |
|
|
c local |
101 |
|
|
c kbl (imt ) - index of first grid level below hbl |
102 |
|
|
c bfsfc (imt ) - surface buoyancy forcing (m^2/s^3) |
103 |
|
|
c casea (imt ) - 1 in case A; 0 in case B |
104 |
|
|
c stable (imt ) - 1 in stable forcing; 0 if unstable |
105 |
|
|
c dkm1 (imt, mdiff) - boundary layer diffusivity at kbl-1 level |
106 |
|
|
c blmc (imt,Nr,mdiff) - boundary layer mixing coefficients |
107 |
|
|
c sigma (imt ) - normalized depth (d / hbl) |
108 |
|
|
c Rib (imt,Nr ) - bulk Richardson number |
109 |
|
|
|
110 |
heimbach |
1.4 |
integer kbl (imt ) |
111 |
|
|
_KPP_RL bfsfc (imt ) |
112 |
|
|
_KPP_RL casea (imt ) |
113 |
|
|
_KPP_RL stable(imt ) |
114 |
|
|
_KPP_RL dkm1 (imt, mdiff) |
115 |
|
|
_KPP_RL blmc (imt,Nr,mdiff) |
116 |
|
|
_KPP_RL sigma (imt ) |
117 |
|
|
_KPP_RL Rib (imt,Nr ) |
118 |
adcroft |
1.1 |
|
119 |
|
|
integer i, k, md |
120 |
|
|
|
121 |
|
|
c----------------------------------------------------------------------- |
122 |
|
|
c compute interior mixing coefficients everywhere, due to constant |
123 |
|
|
c internal wave activity, static instability, and local shear |
124 |
|
|
c instability. |
125 |
|
|
c (ghat is temporary storage for horizontally smoothed dbloc) |
126 |
|
|
c----------------------------------------------------------------------- |
127 |
|
|
|
128 |
heimbach |
1.15 |
cph( |
129 |
|
|
cph these storings avoid recomp. of Ri_iwmix |
130 |
heimbach |
1.16 |
CADJ STORE ghat = comlev1_kpp, key = ikppkey |
131 |
|
|
CADJ STORE dbloc = comlev1_kpp, key = ikppkey |
132 |
heimbach |
1.15 |
cph) |
133 |
adcroft |
1.1 |
call Ri_iwmix ( |
134 |
|
|
I kmtj, shsq, dbloc, ghat |
135 |
heimbach |
1.16 |
I , ikppkey |
136 |
adcroft |
1.1 |
O , diffus ) |
137 |
|
|
|
138 |
heimbach |
1.15 |
cph( |
139 |
|
|
cph these storings avoid recomp. of Ri_iwmix |
140 |
|
|
cph DESPITE TAFs 'not necessary' warning! |
141 |
heimbach |
1.16 |
CADJ STORE dbloc = comlev1_kpp, key = ikppkey |
142 |
|
|
CADJ STORE shsq = comlev1_kpp, key = ikppkey |
143 |
|
|
CADJ STORE ghat = comlev1_kpp, key = ikppkey |
144 |
|
|
CADJ STORE diffus = comlev1_kpp, key = ikppkey |
145 |
heimbach |
1.15 |
cph) |
146 |
|
|
|
147 |
adcroft |
1.1 |
c----------------------------------------------------------------------- |
148 |
|
|
c set seafloor values to zero and fill extra "Nrp1" coefficients |
149 |
|
|
c for blmix |
150 |
|
|
c----------------------------------------------------------------------- |
151 |
|
|
|
152 |
|
|
do md = 1, mdiff |
153 |
|
|
do i = 1,imt |
154 |
|
|
do k=kmtj(i),Nrp1 |
155 |
|
|
diffus(i,k,md) = 0.0 |
156 |
|
|
end do |
157 |
|
|
end do |
158 |
|
|
end do |
159 |
|
|
|
160 |
|
|
c----------------------------------------------------------------------- |
161 |
|
|
c compute boundary layer mixing coefficients: |
162 |
|
|
c |
163 |
|
|
c diagnose the new boundary layer depth |
164 |
|
|
c----------------------------------------------------------------------- |
165 |
|
|
|
166 |
|
|
call bldepth ( |
167 |
heimbach |
1.4 |
I mytime, mythid |
168 |
|
|
I , kmtj |
169 |
adcroft |
1.1 |
I , dvsq, dbloc, Ritop, ustar, bo, bosol, coriol |
170 |
heimbach |
1.16 |
I , ikppkey |
171 |
adcroft |
1.1 |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
172 |
|
|
& ) |
173 |
|
|
|
174 |
heimbach |
1.16 |
CADJ STORE hbl,bfsfc,stable,casea,kbl = comlev1_kpp, key = ikppkey |
175 |
adcroft |
1.1 |
|
176 |
|
|
c----------------------------------------------------------------------- |
177 |
|
|
c compute boundary layer diffusivities |
178 |
|
|
c----------------------------------------------------------------------- |
179 |
|
|
|
180 |
|
|
call blmix ( |
181 |
|
|
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
182 |
heimbach |
1.16 |
O , dkm1, blmc, ghat, sigma, ikppkey |
183 |
adcroft |
1.1 |
& ) |
184 |
heimbach |
1.15 |
cph( |
185 |
heimbach |
1.16 |
CADJ STORE dkm1,blmc,ghat = comlev1_kpp, key = ikppkey |
186 |
|
|
CADJ STORE hbl, kbl, diffus, casea = comlev1_kpp, key = ikppkey |
187 |
heimbach |
1.15 |
cph) |
188 |
adcroft |
1.1 |
|
189 |
|
|
c----------------------------------------------------------------------- |
190 |
|
|
c enhance diffusivity at interface kbl - 1 |
191 |
|
|
c----------------------------------------------------------------------- |
192 |
|
|
|
193 |
|
|
call enhance ( |
194 |
|
|
I dkm1, hbl, kbl, diffus, casea |
195 |
|
|
U , ghat |
196 |
|
|
O , blmc ) |
197 |
heimbach |
1.15 |
|
198 |
|
|
cph( |
199 |
|
|
cph avoids recomp. of enhance |
200 |
heimbach |
1.16 |
CADJ STORE blmc = comlev1_kpp, key = ikppkey |
201 |
heimbach |
1.15 |
cph) |
202 |
adcroft |
1.1 |
|
203 |
|
|
c----------------------------------------------------------------------- |
204 |
|
|
c combine interior and boundary layer coefficients and nonlocal term |
205 |
dimitri |
1.14 |
c !!!NOTE!!! In shallow (2-level) regions and for shallow mixed layers |
206 |
edhill |
1.17 |
c (< 1 level), diffusivity blmc can become negative. The max-s below |
207 |
dimitri |
1.14 |
c are a hack until this problem is properly diagnosed and fixed. |
208 |
adcroft |
1.1 |
c----------------------------------------------------------------------- |
209 |
|
|
do k = 1, Nr |
210 |
|
|
do i = 1, imt |
211 |
|
|
if (k .lt. kbl(i)) then |
212 |
dimitri |
1.14 |
diffus(i,k,1) = max ( blmc(i,k,1), viscAr ) |
213 |
|
|
diffus(i,k,2) = max ( blmc(i,k,2), diffKrS ) |
214 |
|
|
diffus(i,k,3) = max ( blmc(i,k,3), diffKrT ) |
215 |
adcroft |
1.1 |
else |
216 |
|
|
ghat(i,k) = 0. |
217 |
|
|
endif |
218 |
|
|
end do |
219 |
|
|
end do |
220 |
|
|
|
221 |
|
|
#endif /* ALLOW_KPP */ |
222 |
|
|
|
223 |
|
|
return |
224 |
|
|
end |
225 |
|
|
|
226 |
|
|
c************************************************************************* |
227 |
|
|
|
228 |
|
|
subroutine bldepth ( |
229 |
heimbach |
1.4 |
I mytime, mythid |
230 |
|
|
I , kmtj |
231 |
adcroft |
1.1 |
I , dvsq, dbloc, Ritop, ustar, bo, bosol, coriol |
232 |
heimbach |
1.16 |
I , ikppkey |
233 |
adcroft |
1.1 |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
234 |
|
|
& ) |
235 |
|
|
|
236 |
|
|
c the oceanic planetary boundary layer depth, hbl, is determined as |
237 |
|
|
c the shallowest depth where the bulk Richardson number is |
238 |
|
|
c equal to the critical value, Ricr. |
239 |
|
|
c |
240 |
|
|
c bulk Richardson numbers are evaluated by computing velocity and |
241 |
|
|
c buoyancy differences between values at zgrid(kl) < 0 and surface |
242 |
|
|
c reference values. |
243 |
|
|
c in this configuration, the reference values are equal to the |
244 |
|
|
c values in the surface layer. |
245 |
|
|
c when using a very fine vertical grid, these values should be |
246 |
|
|
c computed as the vertical average of velocity and buoyancy from |
247 |
|
|
c the surface down to epsilon*zgrid(kl). |
248 |
|
|
c |
249 |
|
|
c when the bulk Richardson number at k exceeds Ricr, hbl is |
250 |
|
|
c linearly interpolated between grid levels zgrid(k) and zgrid(k-1). |
251 |
|
|
c |
252 |
|
|
c The water column and the surface forcing are diagnosed for |
253 |
|
|
c stable/ustable forcing conditions, and where hbl is relative |
254 |
|
|
c to grid points (caseA), so that conditional branches can be |
255 |
|
|
c avoided in later subroutines. |
256 |
|
|
c |
257 |
|
|
IMPLICIT NONE |
258 |
|
|
|
259 |
|
|
#include "SIZE.h" |
260 |
|
|
#include "EEPARAMS.h" |
261 |
|
|
#include "PARAMS.h" |
262 |
|
|
#include "KPP_PARAMS.h" |
263 |
|
|
#include "FFIELDS.h" |
264 |
|
|
|
265 |
|
|
c input |
266 |
|
|
c------ |
267 |
heimbach |
1.4 |
c myTime : current time in simulation |
268 |
|
|
c myThid : thread number for this instance of the routine |
269 |
adcroft |
1.1 |
c kmtj : number of vertical layers |
270 |
|
|
c dvsq : (velocity shear re sfc)^2 ((m/s)^2) |
271 |
|
|
c dbloc : local delta buoyancy across interfaces (m/s^2) |
272 |
|
|
c Ritop : numerator of bulk Richardson Number |
273 |
|
|
c =(z-zref)*dbsfc, where dbsfc=delta |
274 |
|
|
c buoyancy with respect to surface ((m/s)^2) |
275 |
|
|
c ustar : surface friction velocity (m/s) |
276 |
|
|
c bo : surface turbulent buoyancy forcing (m^2/s^3) |
277 |
|
|
c bosol : radiative buoyancy forcing (m^2/s^3) |
278 |
|
|
c coriol : Coriolis parameter (1/s) |
279 |
heimbach |
1.4 |
_RL mytime |
280 |
|
|
integer mythid |
281 |
adcroft |
1.1 |
integer kmtj(imt) |
282 |
heimbach |
1.4 |
_KPP_RL dvsq (imt,Nr) |
283 |
|
|
_KPP_RL dbloc (imt,Nr) |
284 |
|
|
_KPP_RL Ritop (imt,Nr) |
285 |
|
|
_KPP_RL ustar (imt) |
286 |
|
|
_KPP_RL bo (imt) |
287 |
|
|
_KPP_RL bosol (imt) |
288 |
|
|
_KPP_RL coriol(imt) |
289 |
heimbach |
1.16 |
integer ikppkey |
290 |
adcroft |
1.1 |
|
291 |
|
|
c output |
292 |
|
|
c-------- |
293 |
|
|
c hbl : boundary layer depth (m) |
294 |
|
|
c bfsfc : Bo+radiation absorbed to d=hbf*hbl (m^2/s^3) |
295 |
|
|
c stable : =1 in stable forcing; =0 unstable |
296 |
|
|
c casea : =1 in case A, =0 in case B |
297 |
|
|
c kbl : -1 of first grid level below hbl |
298 |
|
|
c Rib : Bulk Richardson number |
299 |
|
|
c sigma : normalized depth (d/hbl) |
300 |
heimbach |
1.4 |
_KPP_RL hbl (imt) |
301 |
|
|
_KPP_RL bfsfc (imt) |
302 |
|
|
_KPP_RL stable(imt) |
303 |
|
|
_KPP_RL casea (imt) |
304 |
|
|
integer kbl (imt) |
305 |
|
|
_KPP_RL Rib (imt,Nr) |
306 |
|
|
_KPP_RL sigma (imt) |
307 |
adcroft |
1.1 |
|
308 |
|
|
#ifdef ALLOW_KPP |
309 |
|
|
|
310 |
|
|
c local |
311 |
|
|
c------- |
312 |
|
|
c wm, ws : turbulent velocity scales (m/s) |
313 |
heimbach |
1.4 |
_KPP_RL wm(imt), ws(imt) |
314 |
|
|
_RL worka(imt) |
315 |
adcroft |
1.1 |
|
316 |
heimbach |
1.4 |
_KPP_RL bvsq, vtsq, hekman, hmonob, hlimit, tempVar1, tempVar2 |
317 |
adcroft |
1.1 |
integer i, kl |
318 |
|
|
|
319 |
heimbach |
1.4 |
_KPP_RL p5 , eins |
320 |
|
|
parameter ( p5=0.5, eins=1.0 ) |
321 |
|
|
_RL minusone |
322 |
|
|
parameter ( minusone=-1.0 ) |
323 |
adcroft |
1.1 |
|
324 |
|
|
c find bulk Richardson number at every grid level until > Ricr |
325 |
|
|
c |
326 |
|
|
c note: the reference depth is -epsilon/2.*zgrid(k), but the reference |
327 |
|
|
c u,v,t,s values are simply the surface layer values, |
328 |
|
|
c and not the averaged values from 0 to 2*ref.depth, |
329 |
|
|
c which is necessary for very fine grids(top layer < 2m thickness) |
330 |
|
|
c note: max values when Ricr never satisfied are |
331 |
|
|
c kbl(i)=kmtj(i) and hbl(i)=-zgrid(kmtj(i)) |
332 |
|
|
|
333 |
|
|
c initialize hbl and kbl to bottomed out values |
334 |
|
|
|
335 |
|
|
do i = 1, imt |
336 |
|
|
Rib(i,1) = 0.0 |
337 |
|
|
kbl(i) = max(kmtj(i),1) |
338 |
|
|
hbl(i) = -zgrid(kbl(i)) |
339 |
|
|
end do |
340 |
|
|
|
341 |
|
|
do kl = 2, Nr |
342 |
|
|
|
343 |
|
|
c compute bfsfc = sw fraction at hbf * zgrid |
344 |
|
|
|
345 |
|
|
do i = 1, imt |
346 |
heimbach |
1.4 |
worka(i) = zgrid(kl) |
347 |
adcroft |
1.1 |
end do |
348 |
|
|
call SWFRAC( |
349 |
heimbach |
1.4 |
I imt, hbf, |
350 |
|
|
I mytime, mythid, |
351 |
|
|
U worka ) |
352 |
adcroft |
1.1 |
|
353 |
|
|
do i = 1, imt |
354 |
|
|
|
355 |
|
|
c use caseA as temporary array |
356 |
|
|
|
357 |
|
|
casea(i) = -zgrid(kl) |
358 |
|
|
|
359 |
|
|
c compute bfsfc= Bo + radiative contribution down to hbf * hbl |
360 |
|
|
|
361 |
heimbach |
1.4 |
bfsfc(i) = bo(i) + bosol(i)*(1. - worka(i)) |
362 |
adcroft |
1.1 |
stable(i) = p5 + sign(p5,bfsfc(i)) |
363 |
|
|
sigma(i) = stable(i) + (1. - stable(i)) * epsilon |
364 |
|
|
|
365 |
|
|
end do |
366 |
|
|
|
367 |
|
|
c----------------------------------------------------------------------- |
368 |
|
|
c compute velocity scales at sigma, for hbl= caseA = -zgrid(kl) |
369 |
|
|
c----------------------------------------------------------------------- |
370 |
|
|
|
371 |
|
|
call wscale ( |
372 |
|
|
I sigma, casea, ustar, bfsfc, |
373 |
|
|
O wm, ws ) |
374 |
|
|
|
375 |
|
|
do i = 1, imt |
376 |
|
|
|
377 |
|
|
c----------------------------------------------------------------------- |
378 |
|
|
c compute the turbulent shear contribution to Rib |
379 |
|
|
c----------------------------------------------------------------------- |
380 |
|
|
|
381 |
|
|
bvsq = p5 * |
382 |
|
|
1 ( dbloc(i,kl-1) / (zgrid(kl-1)-zgrid(kl ))+ |
383 |
|
|
2 dbloc(i,kl ) / (zgrid(kl )-zgrid(kl+1))) |
384 |
|
|
|
385 |
|
|
if (bvsq .eq. 0.) then |
386 |
|
|
vtsq = 0.0 |
387 |
|
|
else |
388 |
|
|
vtsq = -zgrid(kl) * ws(i) * sqrt(abs(bvsq)) * Vtc |
389 |
|
|
endif |
390 |
|
|
|
391 |
|
|
c compute bulk Richardson number at new level |
392 |
|
|
c note: Ritop needs to be zero on land and ocean bottom |
393 |
|
|
c points so that the following if statement gets triggered |
394 |
|
|
c correctly; otherwise, hbl might get set to (big) negative |
395 |
|
|
c values, that might exceed the limit for the "exp" function |
396 |
|
|
c in "SWFRAC" |
397 |
|
|
|
398 |
|
|
c |
399 |
|
|
c rg: assignment to double precision variable to avoid overflow |
400 |
|
|
c ph: test for zero nominator |
401 |
|
|
c |
402 |
heimbach |
1.4 |
|
403 |
|
|
tempVar1 = dvsq(i,kl) + vtsq |
404 |
|
|
tempVar2 = max(tempVar1, phepsi) |
405 |
|
|
Rib(i,kl) = Ritop(i,kl) / tempVar2 |
406 |
|
|
|
407 |
adcroft |
1.1 |
end do |
408 |
|
|
end do |
409 |
heimbach |
1.10 |
|
410 |
|
|
cph( |
411 |
edhill |
1.17 |
cph without this store, there is a recomputation error for |
412 |
heimbach |
1.10 |
cph rib in adbldepth (probably partial recomputation problem) |
413 |
|
|
CADJ store Rib = comlev1_kpp |
414 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy),Nr /) |
415 |
heimbach |
1.10 |
cph) |
416 |
|
|
|
417 |
adcroft |
1.1 |
do kl = 2, Nr |
418 |
|
|
do i = 1, imt |
419 |
|
|
if (kbl(i).eq.kmtj(i) .and. Rib(i,kl).gt.Ricr) kbl(i) = kl |
420 |
|
|
end do |
421 |
|
|
end do |
422 |
|
|
|
423 |
heimbach |
1.2 |
CADJ store kbl = comlev1_kpp |
424 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
425 |
adcroft |
1.1 |
|
426 |
|
|
do i = 1, imt |
427 |
|
|
kl = kbl(i) |
428 |
|
|
c linearly interpolate to find hbl where Rib = Ricr |
429 |
|
|
if (kl.gt.1 .and. kl.lt.kmtj(i)) then |
430 |
heimbach |
1.4 |
tempVar1 = (Rib(i,kl)-Rib(i,kl-1)) |
431 |
adcroft |
1.1 |
hbl(i) = -zgrid(kl-1) + (zgrid(kl-1)-zgrid(kl)) * |
432 |
heimbach |
1.4 |
1 (Ricr - Rib(i,kl-1)) / tempVar1 |
433 |
adcroft |
1.1 |
endif |
434 |
|
|
end do |
435 |
|
|
|
436 |
heimbach |
1.2 |
CADJ store hbl = comlev1_kpp |
437 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
438 |
adcroft |
1.1 |
|
439 |
|
|
c----------------------------------------------------------------------- |
440 |
|
|
c find stability and buoyancy forcing for boundary layer |
441 |
|
|
c----------------------------------------------------------------------- |
442 |
|
|
|
443 |
heimbach |
1.4 |
do i = 1, imt |
444 |
|
|
worka(i) = hbl(i) |
445 |
|
|
end do |
446 |
adcroft |
1.1 |
call SWFRAC( |
447 |
heimbach |
1.4 |
I imt, minusone, |
448 |
|
|
I mytime, mythid, |
449 |
|
|
U worka ) |
450 |
adcroft |
1.1 |
|
451 |
heimbach |
1.4 |
do i = 1, imt |
452 |
|
|
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
453 |
|
|
end do |
454 |
heimbach |
1.2 |
CADJ store bfsfc = comlev1_kpp |
455 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
456 |
heimbach |
1.2 |
|
457 |
heimbach |
1.4 |
c-- ensure bfsfc is never 0 |
458 |
adcroft |
1.1 |
do i = 1, imt |
459 |
|
|
stable(i) = p5 + sign( p5, bfsfc(i) ) |
460 |
heimbach |
1.4 |
bfsfc(i) = sign(eins,bfsfc(i))*max(phepsi,abs(bfsfc(i))) |
461 |
|
|
end do |
462 |
adcroft |
1.1 |
|
463 |
heimbach |
1.10 |
cph( |
464 |
|
|
cph added stable to store list to avoid extensive recomp. |
465 |
|
|
CADJ store bfsfc, stable = comlev1_kpp |
466 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
467 |
heimbach |
1.10 |
cph) |
468 |
adcroft |
1.1 |
|
469 |
|
|
c----------------------------------------------------------------------- |
470 |
|
|
c check hbl limits for hekman or hmonob |
471 |
|
|
c ph: test for zero nominator |
472 |
|
|
c----------------------------------------------------------------------- |
473 |
|
|
|
474 |
|
|
do i = 1, imt |
475 |
|
|
if (bfsfc(i) .gt. 0.0) then |
476 |
|
|
hekman = cekman * ustar(i) / max(abs(Coriol(i)),phepsi) |
477 |
|
|
hmonob = cmonob * ustar(i)*ustar(i)*ustar(i) |
478 |
|
|
& / vonk / bfsfc(i) |
479 |
|
|
hlimit = stable(i) * min(hekman,hmonob) |
480 |
|
|
& + (stable(i)-1.) * zgrid(Nr) |
481 |
|
|
hbl(i) = min(hbl(i),hlimit) |
482 |
heimbach |
1.4 |
end if |
483 |
|
|
end do |
484 |
|
|
CADJ store hbl = comlev1_kpp |
485 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
486 |
heimbach |
1.4 |
|
487 |
|
|
do i = 1, imt |
488 |
|
|
hbl(i) = max(hbl(i),minKPPhbl) |
489 |
adcroft |
1.1 |
kbl(i) = kmtj(i) |
490 |
|
|
end do |
491 |
|
|
|
492 |
heimbach |
1.2 |
CADJ store hbl = comlev1_kpp |
493 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
494 |
adcroft |
1.1 |
|
495 |
|
|
c----------------------------------------------------------------------- |
496 |
|
|
c find new kbl |
497 |
|
|
c----------------------------------------------------------------------- |
498 |
|
|
|
499 |
|
|
do kl = 2, Nr |
500 |
|
|
do i = 1, imt |
501 |
|
|
if ( kbl(i).eq.kmtj(i) .and. (-zgrid(kl)).gt.hbl(i) ) then |
502 |
|
|
kbl(i) = kl |
503 |
|
|
endif |
504 |
|
|
end do |
505 |
|
|
end do |
506 |
|
|
|
507 |
|
|
c----------------------------------------------------------------------- |
508 |
|
|
c find stability and buoyancy forcing for final hbl values |
509 |
|
|
c----------------------------------------------------------------------- |
510 |
|
|
|
511 |
heimbach |
1.4 |
do i = 1, imt |
512 |
|
|
worka(i) = hbl(i) |
513 |
|
|
end do |
514 |
adcroft |
1.1 |
call SWFRAC( |
515 |
heimbach |
1.4 |
I imt, minusone, |
516 |
|
|
I mytime, mythid, |
517 |
|
|
U worka ) |
518 |
adcroft |
1.1 |
|
519 |
heimbach |
1.4 |
do i = 1, imt |
520 |
|
|
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
521 |
|
|
end do |
522 |
heimbach |
1.2 |
CADJ store bfsfc = comlev1_kpp |
523 |
heimbach |
1.16 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
524 |
heimbach |
1.2 |
|
525 |
heimbach |
1.4 |
c-- ensures bfsfc is never 0 |
526 |
adcroft |
1.1 |
do i = 1, imt |
527 |
|
|
stable(i) = p5 + sign( p5, bfsfc(i) ) |
528 |
heimbach |
1.4 |
bfsfc(i) = sign(eins,bfsfc(i))*max(phepsi,abs(bfsfc(i))) |
529 |
adcroft |
1.1 |
end do |
530 |
|
|
|
531 |
|
|
c----------------------------------------------------------------------- |
532 |
|
|
c determine caseA and caseB |
533 |
|
|
c----------------------------------------------------------------------- |
534 |
|
|
|
535 |
|
|
do i = 1, imt |
536 |
|
|
casea(i) = p5 + |
537 |
|
|
1 sign(p5, -zgrid(kbl(i)) - p5*hwide(kbl(i)) - hbl(i)) |
538 |
|
|
end do |
539 |
|
|
|
540 |
|
|
#endif /* ALLOW_KPP */ |
541 |
|
|
|
542 |
|
|
return |
543 |
|
|
end |
544 |
|
|
|
545 |
|
|
c************************************************************************* |
546 |
|
|
|
547 |
|
|
subroutine wscale ( |
548 |
|
|
I sigma, hbl, ustar, bfsfc, |
549 |
|
|
O wm, ws ) |
550 |
|
|
|
551 |
|
|
c compute turbulent velocity scales. |
552 |
|
|
c use a 2D-lookup table for wm and ws as functions of ustar and |
553 |
|
|
c zetahat (=vonk*sigma*hbl*bfsfc). |
554 |
|
|
c |
555 |
|
|
c note: the lookup table is only used for unstable conditions |
556 |
|
|
c (zehat.le.0), in the stable domain wm (=ws) gets computed |
557 |
|
|
c directly. |
558 |
|
|
c |
559 |
|
|
IMPLICIT NONE |
560 |
|
|
|
561 |
|
|
#include "SIZE.h" |
562 |
|
|
#include "KPP_PARAMS.h" |
563 |
|
|
|
564 |
|
|
c input |
565 |
|
|
c------ |
566 |
|
|
c sigma : normalized depth (d/hbl) |
567 |
|
|
c hbl : boundary layer depth (m) |
568 |
|
|
c ustar : surface friction velocity (m/s) |
569 |
|
|
c bfsfc : total surface buoyancy flux (m^2/s^3) |
570 |
heimbach |
1.4 |
_KPP_RL sigma(imt) |
571 |
|
|
_KPP_RL hbl (imt) |
572 |
|
|
_KPP_RL ustar(imt) |
573 |
|
|
_KPP_RL bfsfc(imt) |
574 |
adcroft |
1.1 |
|
575 |
|
|
c output |
576 |
|
|
c-------- |
577 |
|
|
c wm, ws : turbulent velocity scales at sigma |
578 |
heimbach |
1.4 |
_KPP_RL wm(imt), ws(imt) |
579 |
adcroft |
1.1 |
|
580 |
|
|
#ifdef ALLOW_KPP |
581 |
|
|
|
582 |
|
|
c local |
583 |
|
|
c------ |
584 |
|
|
c zehat : = zeta * ustar**3 |
585 |
heimbach |
1.4 |
_KPP_RL zehat |
586 |
adcroft |
1.1 |
|
587 |
|
|
integer iz, izp1, ju, i, jup1 |
588 |
heimbach |
1.4 |
_KPP_RL udiff, zdiff, zfrac, ufrac, fzfrac, wam |
589 |
|
|
_KPP_RL wbm, was, wbs, u3, tempVar |
590 |
adcroft |
1.1 |
|
591 |
|
|
c----------------------------------------------------------------------- |
592 |
|
|
c use lookup table for zehat < zmax only; otherwise use |
593 |
|
|
c stable formulae |
594 |
|
|
c----------------------------------------------------------------------- |
595 |
|
|
|
596 |
|
|
do i = 1, imt |
597 |
|
|
zehat = vonk*sigma(i)*hbl(i)*bfsfc(i) |
598 |
|
|
|
599 |
|
|
if (zehat .le. zmax) then |
600 |
|
|
|
601 |
|
|
zdiff = zehat - zmin |
602 |
|
|
iz = int( zdiff / deltaz ) |
603 |
|
|
iz = min( iz, nni ) |
604 |
|
|
iz = max( iz, 0 ) |
605 |
|
|
izp1 = iz + 1 |
606 |
heimbach |
1.4 |
|
607 |
adcroft |
1.1 |
udiff = ustar(i) - umin |
608 |
|
|
ju = int( udiff / deltau ) |
609 |
|
|
ju = min( ju, nnj ) |
610 |
|
|
ju = max( ju, 0 ) |
611 |
|
|
jup1 = ju + 1 |
612 |
heimbach |
1.4 |
|
613 |
adcroft |
1.1 |
zfrac = zdiff / deltaz - float(iz) |
614 |
|
|
ufrac = udiff / deltau - float(ju) |
615 |
heimbach |
1.4 |
|
616 |
adcroft |
1.1 |
fzfrac= 1. - zfrac |
617 |
|
|
wam = fzfrac * wmt(iz,jup1) + zfrac * wmt(izp1,jup1) |
618 |
|
|
wbm = fzfrac * wmt(iz,ju ) + zfrac * wmt(izp1,ju ) |
619 |
|
|
wm(i) = (1.-ufrac) * wbm + ufrac * wam |
620 |
heimbach |
1.4 |
|
621 |
adcroft |
1.1 |
was = fzfrac * wst(iz,jup1) + zfrac * wst(izp1,jup1) |
622 |
|
|
wbs = fzfrac * wst(iz,ju ) + zfrac * wst(izp1,ju ) |
623 |
|
|
ws(i) = (1.-ufrac) * wbs + ufrac * was |
624 |
heimbach |
1.4 |
|
625 |
adcroft |
1.1 |
else |
626 |
heimbach |
1.4 |
|
627 |
|
|
u3 = ustar(i) * ustar(i) * ustar(i) |
628 |
|
|
tempVar = u3 + conc1 * zehat |
629 |
|
|
wm(i) = vonk * ustar(i) * u3 / tempVar |
630 |
adcroft |
1.1 |
ws(i) = wm(i) |
631 |
heimbach |
1.4 |
|
632 |
adcroft |
1.1 |
endif |
633 |
|
|
|
634 |
|
|
end do |
635 |
|
|
|
636 |
|
|
#endif /* ALLOW_KPP */ |
637 |
|
|
|
638 |
|
|
return |
639 |
|
|
end |
640 |
|
|
|
641 |
|
|
c************************************************************************* |
642 |
|
|
|
643 |
|
|
subroutine Ri_iwmix ( |
644 |
|
|
I kmtj, shsq, dbloc, dblocSm |
645 |
heimbach |
1.16 |
I , ikppkey |
646 |
adcroft |
1.1 |
O , diffus ) |
647 |
|
|
|
648 |
|
|
c compute interior viscosity diffusivity coefficients due |
649 |
|
|
c to shear instability (dependent on a local Richardson number), |
650 |
|
|
c to background internal wave activity, and |
651 |
|
|
c to static instability (local Richardson number < 0). |
652 |
|
|
|
653 |
|
|
IMPLICIT NONE |
654 |
|
|
|
655 |
|
|
#include "SIZE.h" |
656 |
|
|
#include "EEPARAMS.h" |
657 |
|
|
#include "PARAMS.h" |
658 |
|
|
#include "KPP_PARAMS.h" |
659 |
|
|
|
660 |
|
|
c input |
661 |
|
|
c kmtj (imt) number of vertical layers on this row |
662 |
|
|
c shsq (imt,Nr) (local velocity shear)^2 ((m/s)^2) |
663 |
|
|
c dbloc (imt,Nr) local delta buoyancy (m/s^2) |
664 |
|
|
c dblocSm(imt,Nr) horizontally smoothed dbloc (m/s^2) |
665 |
|
|
integer kmtj (imt) |
666 |
heimbach |
1.4 |
_KPP_RL shsq (imt,Nr) |
667 |
|
|
_KPP_RL dbloc (imt,Nr) |
668 |
|
|
_KPP_RL dblocSm(imt,Nr) |
669 |
heimbach |
1.16 |
integer ikppkey |
670 |
adcroft |
1.1 |
|
671 |
|
|
c output |
672 |
|
|
c diffus(imt,0:Nrp1,1) vertical viscosivity coefficient (m^2/s) |
673 |
|
|
c diffus(imt,0:Nrp1,2) vertical scalar diffusivity (m^2/s) |
674 |
|
|
c diffus(imt,0:Nrp1,3) vertical temperature diffusivity (m^2/s) |
675 |
heimbach |
1.4 |
_KPP_RL diffus(imt,0:Nrp1,3) |
676 |
adcroft |
1.1 |
|
677 |
|
|
#ifdef ALLOW_KPP |
678 |
|
|
|
679 |
|
|
c local variables |
680 |
|
|
c Rig local Richardson number |
681 |
|
|
c fRi, fcon function of Rig |
682 |
heimbach |
1.4 |
_KPP_RL Rig |
683 |
|
|
_KPP_RL fRi, fcon |
684 |
|
|
_KPP_RL ratio |
685 |
dimitri |
1.13 |
integer i, ki |
686 |
heimbach |
1.4 |
_KPP_RL c1, c0 |
687 |
adcroft |
1.1 |
|
688 |
heimbach |
1.5 |
#ifdef ALLOW_KPP_VERTICALLY_SMOOTH |
689 |
dimitri |
1.13 |
integer mr |
690 |
heimbach |
1.5 |
CADJ INIT kpp_ri_tape_mr = common, 1 |
691 |
|
|
#endif |
692 |
|
|
|
693 |
adcroft |
1.1 |
c constants |
694 |
|
|
c1 = 1.0 |
695 |
|
|
c0 = 0.0 |
696 |
|
|
|
697 |
|
|
c----------------------------------------------------------------------- |
698 |
|
|
c compute interior gradient Ri at all interfaces ki=1,Nr, (not surface) |
699 |
|
|
c use diffus(*,*,1) as temporary storage of Ri to be smoothed |
700 |
|
|
c use diffus(*,*,2) as temporary storage for Brunt-Vaisala squared |
701 |
|
|
c set values at bottom and below to nearest value above bottom |
702 |
heimbach |
1.5 |
#ifdef ALLOW_AUTODIFF_TAMC |
703 |
|
|
C break data flow dependence on diffus |
704 |
|
|
diffus(1,1,1) = 0.0 |
705 |
|
|
#endif |
706 |
adcroft |
1.1 |
|
707 |
|
|
do ki = 1, Nr |
708 |
|
|
do i = 1, imt |
709 |
heimbach |
1.9 |
if (kmtj(i) .LE. 1 ) then |
710 |
adcroft |
1.1 |
diffus(i,ki,1) = 0. |
711 |
|
|
diffus(i,ki,2) = 0. |
712 |
|
|
elseif (ki .GE. kmtj(i)) then |
713 |
|
|
diffus(i,ki,1) = diffus(i,ki-1,1) |
714 |
|
|
diffus(i,ki,2) = diffus(i,ki-1,2) |
715 |
|
|
else |
716 |
|
|
diffus(i,ki,1) = dblocSm(i,ki) * (zgrid(ki)-zgrid(ki+1)) |
717 |
|
|
& / max( Shsq(i,ki), phepsi ) |
718 |
|
|
diffus(i,ki,2) = dbloc(i,ki) / (zgrid(ki)-zgrid(ki+1)) |
719 |
|
|
endif |
720 |
|
|
end do |
721 |
|
|
end do |
722 |
|
|
|
723 |
|
|
c----------------------------------------------------------------------- |
724 |
|
|
c vertically smooth Ri |
725 |
heimbach |
1.5 |
#ifdef ALLOW_KPP_VERTICALLY_SMOOTH |
726 |
adcroft |
1.1 |
do mr = 1, num_v_smooth_Ri |
727 |
heimbach |
1.2 |
|
728 |
heimbach |
1.5 |
CADJ store diffus(:,:,1) = kpp_ri_tape_mr |
729 |
|
|
CADJ & , key=mr, shape=(/ (sNx+2*OLx)*(sNy+2*OLy),Nr+2 /) |
730 |
heimbach |
1.2 |
|
731 |
adcroft |
1.1 |
call z121 ( |
732 |
|
|
U diffus(1,0,1)) |
733 |
|
|
end do |
734 |
heimbach |
1.5 |
#endif |
735 |
adcroft |
1.1 |
|
736 |
|
|
c----------------------------------------------------------------------- |
737 |
|
|
c after smoothing loop |
738 |
|
|
|
739 |
|
|
do ki = 1, Nr |
740 |
|
|
do i = 1, imt |
741 |
|
|
|
742 |
|
|
c evaluate f of Brunt-Vaisala squared for convection, store in fcon |
743 |
|
|
|
744 |
|
|
Rig = max ( diffus(i,ki,2) , BVSQcon ) |
745 |
|
|
ratio = min ( (BVSQcon - Rig) / BVSQcon, c1 ) |
746 |
|
|
fcon = c1 - ratio * ratio |
747 |
|
|
fcon = fcon * fcon * fcon |
748 |
|
|
|
749 |
|
|
c evaluate f of smooth Ri for shear instability, store in fRi |
750 |
|
|
|
751 |
|
|
Rig = max ( diffus(i,ki,1), c0 ) |
752 |
|
|
ratio = min ( Rig / Riinfty , c1 ) |
753 |
|
|
fRi = c1 - ratio * ratio |
754 |
|
|
fRi = fRi * fRi * fRi |
755 |
|
|
|
756 |
|
|
c ---------------------------------------------------------------------- |
757 |
|
|
c evaluate diffusivities and viscosity |
758 |
|
|
c mixing due to internal waves, and shear and static instability |
759 |
heimbach |
1.18 |
|
760 |
|
|
#ifndef EXCLUDE_KPP_SHEAR_MIX |
761 |
adcroft |
1.1 |
diffus(i,ki,1) = viscAr + fcon * difmcon + fRi * difm0 |
762 |
|
|
diffus(i,ki,2) = diffKrS + fcon * difscon + fRi * difs0 |
763 |
heimbach |
1.2 |
diffus(i,ki,3) = diffKrT + fcon * difscon + fRi * difs0 |
764 |
heimbach |
1.18 |
#else |
765 |
|
|
diffus(i,ki,1) = viscAr |
766 |
|
|
diffus(i,ki,2) = diffKrS |
767 |
|
|
diffus(i,ki,3) = diffKrT |
768 |
|
|
#endif |
769 |
adcroft |
1.1 |
|
770 |
|
|
end do |
771 |
|
|
end do |
772 |
|
|
|
773 |
|
|
c ------------------------------------------------------------------------ |
774 |
|
|
c set surface values to 0.0 |
775 |
|
|
|
776 |
|
|
do i = 1, imt |
777 |
|
|
diffus(i,0,1) = c0 |
778 |
|
|
diffus(i,0,2) = c0 |
779 |
|
|
diffus(i,0,3) = c0 |
780 |
|
|
end do |
781 |
|
|
|
782 |
|
|
#endif /* ALLOW_KPP */ |
783 |
|
|
|
784 |
|
|
return |
785 |
|
|
end |
786 |
|
|
|
787 |
|
|
c************************************************************************* |
788 |
|
|
|
789 |
|
|
subroutine z121 ( |
790 |
|
|
U v ) |
791 |
|
|
|
792 |
|
|
c Apply 121 smoothing in k to 2-d array V(i,k=1,Nr) |
793 |
|
|
c top (0) value is used as a dummy |
794 |
|
|
c bottom (Nrp1) value is set to input value from above. |
795 |
|
|
|
796 |
heimbach |
1.2 |
c Note that it is important to exclude from the smoothing any points |
797 |
adcroft |
1.1 |
c that are outside the range of the K(Ri) scheme, ie. >0.8, or <0.0. |
798 |
heimbach |
1.2 |
c Otherwise, there is interference with other physics, especially |
799 |
adcroft |
1.1 |
c penetrative convection. |
800 |
|
|
|
801 |
|
|
IMPLICIT NONE |
802 |
|
|
#include "SIZE.h" |
803 |
|
|
#include "KPP_PARAMS.h" |
804 |
|
|
|
805 |
|
|
c input/output |
806 |
|
|
c------------- |
807 |
|
|
c v : 2-D array to be smoothed in Nrp1 direction |
808 |
heimbach |
1.4 |
_KPP_RL v(imt,0:Nrp1) |
809 |
adcroft |
1.1 |
|
810 |
|
|
#ifdef ALLOW_KPP |
811 |
|
|
|
812 |
|
|
c local |
813 |
heimbach |
1.4 |
_KPP_RL zwork, zflag |
814 |
|
|
_KPP_RL KRi_range(1:Nrp1) |
815 |
adcroft |
1.1 |
integer i, k, km1, kp1 |
816 |
|
|
|
817 |
heimbach |
1.4 |
_KPP_RL p0 , p25 , p5 , p2 |
818 |
heimbach |
1.2 |
parameter ( p0 = 0.0, p25 = 0.25, p5 = 0.5, p2 = 2.0 ) |
819 |
|
|
|
820 |
|
|
KRi_range(Nrp1) = p0 |
821 |
adcroft |
1.1 |
|
822 |
heimbach |
1.2 |
#ifdef ALLOW_AUTODIFF_TAMC |
823 |
|
|
C-- dummy assignment to end declaration part for TAMC |
824 |
|
|
i = 0 |
825 |
|
|
|
826 |
|
|
C-- HPF directive to help TAMC |
827 |
|
|
CHPF$ INDEPENDENT |
828 |
heimbach |
1.4 |
CADJ INIT z121tape = common, Nr |
829 |
heimbach |
1.2 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
830 |
heimbach |
1.4 |
|
831 |
adcroft |
1.1 |
do i = 1, imt |
832 |
|
|
|
833 |
heimbach |
1.4 |
k = 1 |
834 |
|
|
CADJ STORE v(i,k) = z121tape |
835 |
adcroft |
1.1 |
v(i,Nrp1) = v(i,Nr) |
836 |
|
|
|
837 |
|
|
do k = 1, Nr |
838 |
|
|
KRi_range(k) = p5 + SIGN(p5,v(i,k)) |
839 |
|
|
KRi_range(k) = KRi_range(k) * |
840 |
|
|
& ( p5 + SIGN(p5,(Riinfty-v(i,k))) ) |
841 |
|
|
end do |
842 |
|
|
|
843 |
|
|
zwork = KRi_range(1) * v(i,1) |
844 |
|
|
v(i,1) = p2 * v(i,1) + |
845 |
|
|
& KRi_range(1) * KRi_range(2) * v(i,2) |
846 |
|
|
zflag = p2 + KRi_range(1) * KRi_range(2) |
847 |
|
|
v(i,1) = v(i,1) / zflag |
848 |
|
|
|
849 |
|
|
do k = 2, Nr |
850 |
heimbach |
1.2 |
CADJ STORE v(i,k), zwork = z121tape |
851 |
adcroft |
1.1 |
km1 = k - 1 |
852 |
|
|
kp1 = k + 1 |
853 |
|
|
zflag = v(i,k) |
854 |
|
|
v(i,k) = p2 * v(i,k) + |
855 |
|
|
& KRi_range(k) * KRi_range(kp1) * v(i,kp1) + |
856 |
|
|
& KRi_range(k) * zwork |
857 |
|
|
zwork = KRi_range(k) * zflag |
858 |
|
|
zflag = p2 + KRi_range(k)*(KRi_range(kp1)+KRi_range(km1)) |
859 |
|
|
v(i,k) = v(i,k) / zflag |
860 |
|
|
end do |
861 |
|
|
|
862 |
|
|
end do |
863 |
|
|
|
864 |
|
|
#endif /* ALLOW_KPP */ |
865 |
|
|
|
866 |
|
|
return |
867 |
|
|
end |
868 |
|
|
|
869 |
|
|
c************************************************************************* |
870 |
|
|
|
871 |
heimbach |
1.4 |
subroutine kpp_smooth_horiz ( |
872 |
adcroft |
1.1 |
I k, bi, bj, |
873 |
heimbach |
1.4 |
U fld ) |
874 |
adcroft |
1.1 |
|
875 |
heimbach |
1.4 |
c Apply horizontal smoothing to KPP array |
876 |
adcroft |
1.1 |
|
877 |
|
|
IMPLICIT NONE |
878 |
|
|
#include "SIZE.h" |
879 |
|
|
#include "KPP_PARAMS.h" |
880 |
|
|
|
881 |
|
|
c input |
882 |
heimbach |
1.4 |
c bi, bj : array indices |
883 |
|
|
c k : vertical index used for masking |
884 |
adcroft |
1.1 |
integer k, bi, bj |
885 |
|
|
|
886 |
heimbach |
1.4 |
c input/output |
887 |
|
|
c fld : 2-D array to be smoothed |
888 |
|
|
_KPP_RL fld( ibot:itop, jbot:jtop ) |
889 |
adcroft |
1.1 |
|
890 |
|
|
#ifdef ALLOW_KPP |
891 |
|
|
|
892 |
|
|
c local |
893 |
|
|
integer i, j, im1, ip1, jm1, jp1 |
894 |
heimbach |
1.4 |
_KPP_RL tempVar |
895 |
|
|
_KPP_RL fld_tmp( ibot:itop, jbot:jtop ) |
896 |
adcroft |
1.1 |
|
897 |
heimbach |
1.4 |
integer imin , imax , jmin , jmax |
898 |
|
|
parameter( imin=ibot+1, imax=itop-1, jmin=jbot+1, jmax=jtop-1 ) |
899 |
adcroft |
1.1 |
|
900 |
heimbach |
1.4 |
_KPP_RL p0 , p5 , p25 , p125 , p0625 |
901 |
adcroft |
1.1 |
parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 ) |
902 |
|
|
|
903 |
|
|
DO j = jmin, jmax |
904 |
|
|
jm1 = j-1 |
905 |
|
|
jp1 = j+1 |
906 |
|
|
DO i = imin, imax |
907 |
|
|
im1 = i-1 |
908 |
|
|
ip1 = i+1 |
909 |
|
|
tempVar = |
910 |
|
|
& p25 * pMask(i ,j ,k,bi,bj) + |
911 |
|
|
& p125 * ( pMask(im1,j ,k,bi,bj) + |
912 |
|
|
& pMask(ip1,j ,k,bi,bj) + |
913 |
|
|
& pMask(i ,jm1,k,bi,bj) + |
914 |
|
|
& pMask(i ,jp1,k,bi,bj) ) + |
915 |
|
|
& p0625 * ( pMask(im1,jm1,k,bi,bj) + |
916 |
|
|
& pMask(im1,jp1,k,bi,bj) + |
917 |
|
|
& pMask(ip1,jm1,k,bi,bj) + |
918 |
|
|
& pMask(ip1,jp1,k,bi,bj) ) |
919 |
|
|
IF ( tempVar .GE. p25 ) THEN |
920 |
|
|
fld_tmp(i,j) = ( |
921 |
heimbach |
1.4 |
& p25 * fld(i ,j )*pMask(i ,j ,k,bi,bj) + |
922 |
|
|
& p125 *(fld(im1,j )*pMask(im1,j ,k,bi,bj) + |
923 |
|
|
& fld(ip1,j )*pMask(ip1,j ,k,bi,bj) + |
924 |
|
|
& fld(i ,jm1)*pMask(i ,jm1,k,bi,bj) + |
925 |
|
|
& fld(i ,jp1)*pMask(i ,jp1,k,bi,bj))+ |
926 |
|
|
& p0625*(fld(im1,jm1)*pMask(im1,jm1,k,bi,bj) + |
927 |
|
|
& fld(im1,jp1)*pMask(im1,jp1,k,bi,bj) + |
928 |
|
|
& fld(ip1,jm1)*pMask(ip1,jm1,k,bi,bj) + |
929 |
|
|
& fld(ip1,jp1)*pMask(ip1,jp1,k,bi,bj))) |
930 |
adcroft |
1.1 |
& / tempVar |
931 |
|
|
ELSE |
932 |
heimbach |
1.4 |
fld_tmp(i,j) = fld(i,j) |
933 |
adcroft |
1.1 |
ENDIF |
934 |
|
|
ENDDO |
935 |
|
|
ENDDO |
936 |
|
|
|
937 |
|
|
c transfer smoothed field to output array |
938 |
|
|
DO j = jmin, jmax |
939 |
|
|
DO i = imin, imax |
940 |
heimbach |
1.4 |
fld(i,j) = fld_tmp(i,j) |
941 |
adcroft |
1.1 |
ENDDO |
942 |
|
|
ENDDO |
943 |
|
|
|
944 |
|
|
#endif /* ALLOW_KPP */ |
945 |
|
|
|
946 |
|
|
return |
947 |
|
|
end |
948 |
|
|
|
949 |
|
|
c************************************************************************* |
950 |
|
|
|
951 |
heimbach |
1.4 |
subroutine smooth_horiz ( |
952 |
adcroft |
1.1 |
I k, bi, bj, |
953 |
heimbach |
1.4 |
U fld ) |
954 |
adcroft |
1.1 |
|
955 |
heimbach |
1.4 |
c Apply horizontal smoothing to global _RL 2-D array |
956 |
adcroft |
1.1 |
|
957 |
|
|
IMPLICIT NONE |
958 |
|
|
#include "SIZE.h" |
959 |
|
|
#include "KPP_PARAMS.h" |
960 |
|
|
|
961 |
|
|
c input |
962 |
heimbach |
1.4 |
c bi, bj : array indices |
963 |
|
|
c k : vertical index used for masking |
964 |
adcroft |
1.1 |
integer k, bi, bj |
965 |
|
|
|
966 |
heimbach |
1.4 |
c input/output |
967 |
|
|
c fld : 2-D array to be smoothed |
968 |
|
|
_RL fld( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy ) |
969 |
adcroft |
1.1 |
|
970 |
|
|
#ifdef ALLOW_KPP |
971 |
|
|
|
972 |
|
|
c local |
973 |
|
|
integer i, j, im1, ip1, jm1, jp1 |
974 |
|
|
_RL tempVar |
975 |
heimbach |
1.4 |
_RL fld_tmp( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy ) |
976 |
adcroft |
1.1 |
|
977 |
heimbach |
1.4 |
integer imin , imax , jmin , jmax |
978 |
|
|
parameter(imin=2-OLx, imax=sNx+OLx-1, jmin=2-OLy, jmax=sNy+OLy-1) |
979 |
adcroft |
1.1 |
|
980 |
heimbach |
1.4 |
_RL p0 , p5 , p25 , p125 , p0625 |
981 |
adcroft |
1.1 |
parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 ) |
982 |
|
|
|
983 |
|
|
DO j = jmin, jmax |
984 |
|
|
jm1 = j-1 |
985 |
|
|
jp1 = j+1 |
986 |
|
|
DO i = imin, imax |
987 |
|
|
im1 = i-1 |
988 |
|
|
ip1 = i+1 |
989 |
|
|
tempVar = |
990 |
|
|
& p25 * pMask(i ,j ,k,bi,bj) + |
991 |
|
|
& p125 * ( pMask(im1,j ,k,bi,bj) + |
992 |
|
|
& pMask(ip1,j ,k,bi,bj) + |
993 |
|
|
& pMask(i ,jm1,k,bi,bj) + |
994 |
|
|
& pMask(i ,jp1,k,bi,bj) ) + |
995 |
|
|
& p0625 * ( pMask(im1,jm1,k,bi,bj) + |
996 |
|
|
& pMask(im1,jp1,k,bi,bj) + |
997 |
|
|
& pMask(ip1,jm1,k,bi,bj) + |
998 |
|
|
& pMask(ip1,jp1,k,bi,bj) ) |
999 |
|
|
IF ( tempVar .GE. p25 ) THEN |
1000 |
|
|
fld_tmp(i,j) = ( |
1001 |
heimbach |
1.4 |
& p25 * fld(i ,j )*pMask(i ,j ,k,bi,bj) + |
1002 |
|
|
& p125 *(fld(im1,j )*pMask(im1,j ,k,bi,bj) + |
1003 |
|
|
& fld(ip1,j )*pMask(ip1,j ,k,bi,bj) + |
1004 |
|
|
& fld(i ,jm1)*pMask(i ,jm1,k,bi,bj) + |
1005 |
|
|
& fld(i ,jp1)*pMask(i ,jp1,k,bi,bj))+ |
1006 |
|
|
& p0625*(fld(im1,jm1)*pMask(im1,jm1,k,bi,bj) + |
1007 |
|
|
& fld(im1,jp1)*pMask(im1,jp1,k,bi,bj) + |
1008 |
|
|
& fld(ip1,jm1)*pMask(ip1,jm1,k,bi,bj) + |
1009 |
|
|
& fld(ip1,jp1)*pMask(ip1,jp1,k,bi,bj))) |
1010 |
adcroft |
1.1 |
& / tempVar |
1011 |
|
|
ELSE |
1012 |
heimbach |
1.4 |
fld_tmp(i,j) = fld(i,j) |
1013 |
adcroft |
1.1 |
ENDIF |
1014 |
|
|
ENDDO |
1015 |
|
|
ENDDO |
1016 |
|
|
|
1017 |
|
|
c transfer smoothed field to output array |
1018 |
|
|
DO j = jmin, jmax |
1019 |
|
|
DO i = imin, imax |
1020 |
heimbach |
1.4 |
fld(i,j) = fld_tmp(i,j) |
1021 |
adcroft |
1.1 |
ENDDO |
1022 |
|
|
ENDDO |
1023 |
|
|
|
1024 |
|
|
#endif /* ALLOW_KPP */ |
1025 |
|
|
|
1026 |
|
|
return |
1027 |
|
|
end |
1028 |
|
|
|
1029 |
|
|
c************************************************************************* |
1030 |
|
|
|
1031 |
|
|
subroutine blmix ( |
1032 |
|
|
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
1033 |
heimbach |
1.16 |
O , dkm1, blmc, ghat, sigma, ikppkey |
1034 |
adcroft |
1.1 |
& ) |
1035 |
|
|
|
1036 |
|
|
c mixing coefficients within boundary layer depend on surface |
1037 |
|
|
c forcing and the magnitude and gradient of interior mixing below |
1038 |
|
|
c the boundary layer ("matching"). |
1039 |
|
|
c |
1040 |
|
|
c caution: if mixing bottoms out at hbl = -zgrid(Nr) then |
1041 |
|
|
c fictitious layer at Nrp1 is needed with small but finite width |
1042 |
|
|
c hwide(Nrp1) (eg. epsln = 1.e-20). |
1043 |
|
|
c |
1044 |
|
|
IMPLICIT NONE |
1045 |
|
|
|
1046 |
|
|
#include "SIZE.h" |
1047 |
|
|
#include "KPP_PARAMS.h" |
1048 |
|
|
|
1049 |
|
|
c input |
1050 |
|
|
c ustar (imt) surface friction velocity (m/s) |
1051 |
|
|
c bfsfc (imt) surface buoyancy forcing (m^2/s^3) |
1052 |
|
|
c hbl (imt) boundary layer depth (m) |
1053 |
|
|
c stable(imt) = 1 in stable forcing |
1054 |
|
|
c casea (imt) = 1 in case A |
1055 |
|
|
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
1056 |
|
|
c kbl(imt) -1 of first grid level below hbl |
1057 |
heimbach |
1.4 |
_KPP_RL ustar (imt) |
1058 |
|
|
_KPP_RL bfsfc (imt) |
1059 |
|
|
_KPP_RL hbl (imt) |
1060 |
|
|
_KPP_RL stable(imt) |
1061 |
|
|
_KPP_RL casea (imt) |
1062 |
|
|
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
1063 |
adcroft |
1.1 |
integer kbl(imt) |
1064 |
|
|
|
1065 |
|
|
c output |
1066 |
|
|
c dkm1 (imt,mdiff) boundary layer difs at kbl-1 level |
1067 |
|
|
c blmc (imt,Nr,mdiff) boundary layer mixing coefficients (m^2/s) |
1068 |
|
|
c ghat (imt,Nr) nonlocal scalar transport |
1069 |
|
|
c sigma(imt) normalized depth (d / hbl) |
1070 |
heimbach |
1.4 |
_KPP_RL dkm1 (imt,mdiff) |
1071 |
|
|
_KPP_RL blmc (imt,Nr,mdiff) |
1072 |
|
|
_KPP_RL ghat (imt,Nr) |
1073 |
|
|
_KPP_RL sigma(imt) |
1074 |
heimbach |
1.16 |
integer ikppkey |
1075 |
adcroft |
1.1 |
|
1076 |
|
|
#ifdef ALLOW_KPP |
1077 |
|
|
|
1078 |
|
|
c local |
1079 |
heimbach |
1.2 |
c gat1*(imt) shape function at sigma = 1 |
1080 |
|
|
c dat1*(imt) derivative of shape function at sigma = 1 |
1081 |
adcroft |
1.1 |
c ws(imt), wm(imt) turbulent velocity scales (m/s) |
1082 |
heimbach |
1.4 |
_KPP_RL gat1m(imt), gat1s(imt), gat1t(imt) |
1083 |
|
|
_KPP_RL dat1m(imt), dat1s(imt), dat1t(imt) |
1084 |
|
|
_KPP_RL ws(imt), wm(imt) |
1085 |
adcroft |
1.1 |
integer i, kn, ki |
1086 |
heimbach |
1.4 |
_KPP_RL R, dvdzup, dvdzdn, viscp |
1087 |
|
|
_KPP_RL difsp, diftp, visch, difsh, difth |
1088 |
|
|
_KPP_RL f1, sig, a1, a2, a3, delhat |
1089 |
|
|
_KPP_RL Gm, Gs, Gt |
1090 |
|
|
_KPP_RL tempVar |
1091 |
adcroft |
1.1 |
|
1092 |
heimbach |
1.4 |
_KPP_RL p0 , eins |
1093 |
heimbach |
1.2 |
parameter (p0=0.0, eins=1.0) |
1094 |
adcroft |
1.1 |
|
1095 |
|
|
c----------------------------------------------------------------------- |
1096 |
|
|
c compute velocity scales at hbl |
1097 |
|
|
c----------------------------------------------------------------------- |
1098 |
|
|
|
1099 |
|
|
do i = 1, imt |
1100 |
|
|
sigma(i) = stable(i) * 1.0 + (1. - stable(i)) * epsilon |
1101 |
|
|
end do |
1102 |
|
|
|
1103 |
|
|
call wscale ( |
1104 |
|
|
I sigma, hbl, ustar, bfsfc, |
1105 |
|
|
O wm, ws ) |
1106 |
|
|
|
1107 |
|
|
do i = 1, imt |
1108 |
heimbach |
1.4 |
wm(i) = sign(eins,wm(i))*max(phepsi,abs(wm(i))) |
1109 |
|
|
ws(i) = sign(eins,ws(i))*max(phepsi,abs(ws(i))) |
1110 |
|
|
end do |
1111 |
heimbach |
1.16 |
CADJ STORE wm = comlev1_kpp, key = ikppkey |
1112 |
|
|
CADJ STORE ws = comlev1_kpp, key = ikppkey |
1113 |
heimbach |
1.4 |
|
1114 |
|
|
do i = 1, imt |
1115 |
adcroft |
1.1 |
|
1116 |
|
|
kn = int(caseA(i)+phepsi) *(kbl(i) -1) + |
1117 |
|
|
$ (1 - int(caseA(i)+phepsi)) * kbl(i) |
1118 |
|
|
|
1119 |
|
|
c----------------------------------------------------------------------- |
1120 |
|
|
c find the interior viscosities and derivatives at hbl(i) |
1121 |
|
|
c----------------------------------------------------------------------- |
1122 |
|
|
|
1123 |
|
|
delhat = 0.5*hwide(kn) - zgrid(kn) - hbl(i) |
1124 |
|
|
R = 1.0 - delhat / hwide(kn) |
1125 |
|
|
dvdzup = (diffus(i,kn-1,1) - diffus(i,kn ,1)) / hwide(kn) |
1126 |
|
|
dvdzdn = (diffus(i,kn ,1) - diffus(i,kn+1,1)) / hwide(kn+1) |
1127 |
|
|
viscp = 0.5 * ( (1.-R) * (dvdzup + abs(dvdzup)) + |
1128 |
|
|
1 R * (dvdzdn + abs(dvdzdn)) ) |
1129 |
|
|
|
1130 |
|
|
dvdzup = (diffus(i,kn-1,2) - diffus(i,kn ,2)) / hwide(kn) |
1131 |
|
|
dvdzdn = (diffus(i,kn ,2) - diffus(i,kn+1,2)) / hwide(kn+1) |
1132 |
|
|
difsp = 0.5 * ( (1.-R) * (dvdzup + abs(dvdzup)) + |
1133 |
|
|
1 R * (dvdzdn + abs(dvdzdn)) ) |
1134 |
|
|
|
1135 |
|
|
dvdzup = (diffus(i,kn-1,3) - diffus(i,kn ,3)) / hwide(kn) |
1136 |
|
|
dvdzdn = (diffus(i,kn ,3) - diffus(i,kn+1,3)) / hwide(kn+1) |
1137 |
|
|
diftp = 0.5 * ( (1.-R) * (dvdzup + abs(dvdzup)) + |
1138 |
|
|
1 R * (dvdzdn + abs(dvdzdn)) ) |
1139 |
|
|
|
1140 |
|
|
visch = diffus(i,kn,1) + viscp * delhat |
1141 |
|
|
difsh = diffus(i,kn,2) + difsp * delhat |
1142 |
|
|
difth = diffus(i,kn,3) + diftp * delhat |
1143 |
|
|
|
1144 |
|
|
f1 = stable(i) * conc1 * bfsfc(i) / |
1145 |
|
|
& max(ustar(i)**4,phepsi) |
1146 |
heimbach |
1.2 |
gat1m(i) = visch / hbl(i) / wm(i) |
1147 |
|
|
dat1m(i) = -viscp / wm(i) + f1 * visch |
1148 |
|
|
dat1m(i) = min(dat1m(i),p0) |
1149 |
adcroft |
1.1 |
|
1150 |
heimbach |
1.2 |
gat1s(i) = difsh / hbl(i) / ws(i) |
1151 |
|
|
dat1s(i) = -difsp / ws(i) + f1 * difsh |
1152 |
|
|
dat1s(i) = min(dat1s(i),p0) |
1153 |
adcroft |
1.1 |
|
1154 |
heimbach |
1.2 |
gat1t(i) = difth / hbl(i) / ws(i) |
1155 |
|
|
dat1t(i) = -diftp / ws(i) + f1 * difth |
1156 |
|
|
dat1t(i) = min(dat1t(i),p0) |
1157 |
adcroft |
1.1 |
|
1158 |
|
|
end do |
1159 |
|
|
|
1160 |
|
|
do ki = 1, Nr |
1161 |
|
|
|
1162 |
|
|
c----------------------------------------------------------------------- |
1163 |
|
|
c compute turbulent velocity scales on the interfaces |
1164 |
|
|
c----------------------------------------------------------------------- |
1165 |
|
|
|
1166 |
|
|
do i = 1, imt |
1167 |
|
|
sig = (-zgrid(ki) + 0.5 * hwide(ki)) / hbl(i) |
1168 |
|
|
sigma(i) = stable(i)*sig + (1.-stable(i))*min(sig,epsilon) |
1169 |
|
|
end do |
1170 |
|
|
call wscale ( |
1171 |
|
|
I sigma, hbl, ustar, bfsfc, |
1172 |
|
|
O wm, ws ) |
1173 |
|
|
|
1174 |
|
|
c----------------------------------------------------------------------- |
1175 |
|
|
c compute the dimensionless shape functions at the interfaces |
1176 |
|
|
c----------------------------------------------------------------------- |
1177 |
|
|
|
1178 |
|
|
do i = 1, imt |
1179 |
|
|
sig = (-zgrid(ki) + 0.5 * hwide(ki)) / hbl(i) |
1180 |
|
|
a1 = sig - 2. |
1181 |
|
|
a2 = 3. - 2. * sig |
1182 |
|
|
a3 = sig - 1. |
1183 |
|
|
|
1184 |
heimbach |
1.2 |
Gm = a1 + a2 * gat1m(i) + a3 * dat1m(i) |
1185 |
|
|
Gs = a1 + a2 * gat1s(i) + a3 * dat1s(i) |
1186 |
|
|
Gt = a1 + a2 * gat1t(i) + a3 * dat1t(i) |
1187 |
adcroft |
1.1 |
|
1188 |
|
|
c----------------------------------------------------------------------- |
1189 |
|
|
c compute boundary layer diffusivities at the interfaces |
1190 |
|
|
c----------------------------------------------------------------------- |
1191 |
|
|
|
1192 |
heimbach |
1.2 |
blmc(i,ki,1) = hbl(i) * wm(i) * sig * (1. + sig * Gm) |
1193 |
adcroft |
1.1 |
blmc(i,ki,2) = hbl(i) * ws(i) * sig * (1. + sig * Gs) |
1194 |
|
|
blmc(i,ki,3) = hbl(i) * ws(i) * sig * (1. + sig * Gt) |
1195 |
|
|
|
1196 |
|
|
c----------------------------------------------------------------------- |
1197 |
|
|
c nonlocal transport term = ghat * <ws>o |
1198 |
|
|
c----------------------------------------------------------------------- |
1199 |
heimbach |
1.4 |
|
1200 |
|
|
tempVar = ws(i) * hbl(i) |
1201 |
|
|
ghat(i,ki) = (1.-stable(i)) * cg / max(phepsi,tempVar) |
1202 |
adcroft |
1.1 |
|
1203 |
|
|
end do |
1204 |
|
|
end do |
1205 |
|
|
|
1206 |
|
|
c----------------------------------------------------------------------- |
1207 |
|
|
c find diffusivities at kbl-1 grid level |
1208 |
|
|
c----------------------------------------------------------------------- |
1209 |
|
|
|
1210 |
|
|
do i = 1, imt |
1211 |
|
|
sig = -zgrid(kbl(i)-1) / hbl(i) |
1212 |
|
|
sigma(i) = stable(i) * sig |
1213 |
|
|
& + (1. - stable(i)) * min(sig,epsilon) |
1214 |
|
|
end do |
1215 |
|
|
|
1216 |
|
|
call wscale ( |
1217 |
|
|
I sigma, hbl, ustar, bfsfc, |
1218 |
|
|
O wm, ws ) |
1219 |
|
|
|
1220 |
|
|
do i = 1, imt |
1221 |
|
|
sig = -zgrid(kbl(i)-1) / hbl(i) |
1222 |
|
|
a1 = sig - 2. |
1223 |
|
|
a2 = 3. - 2. * sig |
1224 |
|
|
a3 = sig - 1. |
1225 |
heimbach |
1.2 |
Gm = a1 + a2 * gat1m(i) + a3 * dat1m(i) |
1226 |
|
|
Gs = a1 + a2 * gat1s(i) + a3 * dat1s(i) |
1227 |
|
|
Gt = a1 + a2 * gat1t(i) + a3 * dat1t(i) |
1228 |
|
|
dkm1(i,1) = hbl(i) * wm(i) * sig * (1. + sig * Gm) |
1229 |
adcroft |
1.1 |
dkm1(i,2) = hbl(i) * ws(i) * sig * (1. + sig * Gs) |
1230 |
|
|
dkm1(i,3) = hbl(i) * ws(i) * sig * (1. + sig * Gt) |
1231 |
|
|
end do |
1232 |
|
|
|
1233 |
|
|
#endif /* ALLOW_KPP */ |
1234 |
|
|
|
1235 |
|
|
return |
1236 |
|
|
end |
1237 |
|
|
|
1238 |
|
|
c************************************************************************* |
1239 |
|
|
|
1240 |
|
|
subroutine enhance ( |
1241 |
|
|
I dkm1, hbl, kbl, diffus, casea |
1242 |
|
|
U , ghat |
1243 |
|
|
O , blmc |
1244 |
|
|
& ) |
1245 |
|
|
|
1246 |
|
|
c enhance the diffusivity at the kbl-.5 interface |
1247 |
|
|
|
1248 |
|
|
IMPLICIT NONE |
1249 |
|
|
|
1250 |
|
|
#include "SIZE.h" |
1251 |
|
|
#include "KPP_PARAMS.h" |
1252 |
|
|
|
1253 |
|
|
c input |
1254 |
|
|
c dkm1(imt,mdiff) bl diffusivity at kbl-1 grid level |
1255 |
|
|
c hbl(imt) boundary layer depth (m) |
1256 |
|
|
c kbl(imt) grid above hbl |
1257 |
|
|
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
1258 |
|
|
c casea(imt) = 1 in caseA, = 0 in case B |
1259 |
heimbach |
1.4 |
_KPP_RL dkm1 (imt,mdiff) |
1260 |
|
|
_KPP_RL hbl (imt) |
1261 |
adcroft |
1.1 |
integer kbl (imt) |
1262 |
heimbach |
1.4 |
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
1263 |
|
|
_KPP_RL casea (imt) |
1264 |
adcroft |
1.1 |
|
1265 |
|
|
c input/output |
1266 |
|
|
c nonlocal transport, modified ghat at kbl(i)-1 interface (s/m**2) |
1267 |
heimbach |
1.4 |
_KPP_RL ghat (imt,Nr) |
1268 |
adcroft |
1.1 |
|
1269 |
|
|
c output |
1270 |
|
|
c enhanced bound. layer mixing coeff. |
1271 |
heimbach |
1.4 |
_KPP_RL blmc (imt,Nr,mdiff) |
1272 |
adcroft |
1.1 |
|
1273 |
|
|
#ifdef ALLOW_KPP |
1274 |
|
|
|
1275 |
|
|
c local |
1276 |
|
|
c fraction hbl lies beteen zgrid neighbors |
1277 |
heimbach |
1.4 |
_KPP_RL delta |
1278 |
adcroft |
1.1 |
integer ki, i, md |
1279 |
heimbach |
1.4 |
_KPP_RL dkmp5, dstar |
1280 |
adcroft |
1.1 |
|
1281 |
|
|
do i = 1, imt |
1282 |
|
|
ki = kbl(i)-1 |
1283 |
|
|
if ((ki .ge. 1) .and. (ki .lt. Nr)) then |
1284 |
|
|
delta = (hbl(i) + zgrid(ki)) / (zgrid(ki) - zgrid(ki+1)) |
1285 |
|
|
do md = 1, mdiff |
1286 |
|
|
dkmp5 = casea(i) * diffus(i,ki,md) + |
1287 |
|
|
1 (1.- casea(i)) * blmc (i,ki,md) |
1288 |
|
|
dstar = (1.- delta)**2 * dkm1(i,md) |
1289 |
|
|
& + delta**2 * dkmp5 |
1290 |
|
|
blmc(i,ki,md) = (1.- delta)*diffus(i,ki,md) |
1291 |
|
|
& + delta*dstar |
1292 |
|
|
end do |
1293 |
|
|
ghat(i,ki) = (1.- casea(i)) * ghat(i,ki) |
1294 |
|
|
endif |
1295 |
|
|
end do |
1296 |
|
|
|
1297 |
|
|
#endif /* ALLOW_KPP */ |
1298 |
|
|
|
1299 |
|
|
return |
1300 |
|
|
end |
1301 |
|
|
|
1302 |
|
|
c************************************************************************* |
1303 |
|
|
|
1304 |
|
|
SUBROUTINE STATEKPP ( |
1305 |
|
|
I bi, bj, myThid, |
1306 |
|
|
O RHO1, DBLOC, DBSFC, TTALPHA, SSBETA) |
1307 |
|
|
c |
1308 |
|
|
c----------------------------------------------------------------------- |
1309 |
|
|
c "statekpp" computes all necessary input arrays |
1310 |
|
|
c for the kpp mixing scheme |
1311 |
|
|
c |
1312 |
|
|
c input: |
1313 |
|
|
c bi, bj = array indices on which to apply calculations |
1314 |
|
|
c |
1315 |
|
|
c output: |
1316 |
|
|
c rho1 = potential density of surface layer (kg/m^3) |
1317 |
|
|
c dbloc = local buoyancy gradient at Nr interfaces |
1318 |
|
|
c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2) |
1319 |
|
|
c dbsfc = buoyancy difference with respect to the surface |
1320 |
|
|
c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2) |
1321 |
|
|
c ttalpha= thermal expansion coefficient without 1/rho factor |
1322 |
|
|
c d(rho) / d(potential temperature) (kg/m^3/C) |
1323 |
|
|
c ssbeta = salt expansion coefficient without 1/rho factor |
1324 |
|
|
c d(rho) / d(salinity) (kg/m^3/PSU) |
1325 |
|
|
c |
1326 |
|
|
c see also subroutines find_rho.F find_alpha.F find_beta.F |
1327 |
|
|
c |
1328 |
|
|
c written by: jan morzel, feb. 10, 1995 (converted from "sigma" version) |
1329 |
|
|
c modified by: d. menemenlis, june 1998 : for use with MIT GCM UV |
1330 |
|
|
c |
1331 |
|
|
c----------------------------------------------------------------------- |
1332 |
|
|
|
1333 |
|
|
IMPLICIT NONE |
1334 |
|
|
|
1335 |
|
|
#include "SIZE.h" |
1336 |
|
|
#include "EEPARAMS.h" |
1337 |
|
|
#include "PARAMS.h" |
1338 |
|
|
#include "KPP_PARAMS.h" |
1339 |
adcroft |
1.6 |
#include "DYNVARS.h" |
1340 |
adcroft |
1.1 |
|
1341 |
|
|
c-------------- Routine arguments ----------------------------------------- |
1342 |
|
|
INTEGER bi, bj, myThid |
1343 |
heimbach |
1.4 |
_KPP_RL RHO1 ( ibot:itop, jbot:jtop ) |
1344 |
|
|
_KPP_RL DBLOC ( ibot:itop, jbot:jtop, Nr ) |
1345 |
|
|
_KPP_RL DBSFC ( ibot:itop, jbot:jtop, Nr ) |
1346 |
|
|
_KPP_RL TTALPHA( ibot:itop, jbot:jtop, Nrp1 ) |
1347 |
|
|
_KPP_RL SSBETA ( ibot:itop, jbot:jtop, Nrp1 ) |
1348 |
adcroft |
1.1 |
|
1349 |
|
|
#ifdef ALLOW_KPP |
1350 |
|
|
|
1351 |
|
|
c-------------------------------------------------------------------------- |
1352 |
|
|
c |
1353 |
|
|
c local arrays: |
1354 |
|
|
c |
1355 |
|
|
c rhok - density of t(k ) & s(k ) at depth k |
1356 |
|
|
c rhokm1 - density of t(k-1) & s(k-1) at depth k |
1357 |
|
|
c rho1k - density of t(1 ) & s(1 ) at depth k |
1358 |
|
|
c work1, work2 - work arrays for holding horizontal slabs |
1359 |
|
|
|
1360 |
|
|
_RL RHOK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1361 |
|
|
_RL RHOKM1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1362 |
|
|
_RL RHO1K (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1363 |
|
|
_RL WORK1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1364 |
|
|
_RL WORK2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1365 |
|
|
_RL WORK3 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1366 |
|
|
INTEGER I, J, K |
1367 |
|
|
|
1368 |
|
|
c calculate density, alpha, beta in surface layer, and set dbsfc to zero |
1369 |
|
|
|
1370 |
|
|
call FIND_RHO( |
1371 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
1372 |
adcroft |
1.6 |
I theta, salt, |
1373 |
adcroft |
1.1 |
O WORK1, |
1374 |
|
|
I myThid ) |
1375 |
|
|
|
1376 |
|
|
call FIND_ALPHA( |
1377 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
1378 |
adcroft |
1.1 |
O WORK2 ) |
1379 |
|
|
|
1380 |
|
|
call FIND_BETA( |
1381 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
1382 |
adcroft |
1.1 |
O WORK3 ) |
1383 |
|
|
|
1384 |
heimbach |
1.4 |
DO J = jbot, jtop |
1385 |
|
|
DO I = ibot, itop |
1386 |
mlosch |
1.12 |
RHO1(I,J) = WORK1(I,J) + rhoConst |
1387 |
adcroft |
1.1 |
TTALPHA(I,J,1) = WORK2(I,J) |
1388 |
|
|
SSBETA(I,J,1) = WORK3(I,J) |
1389 |
|
|
DBSFC(I,J,1) = 0. |
1390 |
|
|
END DO |
1391 |
|
|
END DO |
1392 |
|
|
|
1393 |
|
|
c calculate alpha, beta, and gradients in interior layers |
1394 |
|
|
|
1395 |
heimbach |
1.2 |
CHPF$ INDEPENDENT, NEW (RHOK,RHOKM1,RHO1K,WORK1,WORK2) |
1396 |
adcroft |
1.1 |
DO K = 2, Nr |
1397 |
|
|
|
1398 |
|
|
call FIND_RHO( |
1399 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
1400 |
adcroft |
1.6 |
I theta, salt, |
1401 |
adcroft |
1.1 |
O RHOK, |
1402 |
|
|
I myThid ) |
1403 |
|
|
|
1404 |
|
|
call FIND_RHO( |
1405 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, K-1, K, |
1406 |
adcroft |
1.6 |
I theta, salt, |
1407 |
adcroft |
1.1 |
O RHOKM1, |
1408 |
|
|
I myThid ) |
1409 |
|
|
|
1410 |
|
|
call FIND_RHO( |
1411 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, 1, K, |
1412 |
adcroft |
1.6 |
I theta, salt, |
1413 |
adcroft |
1.1 |
O RHO1K, |
1414 |
|
|
I myThid ) |
1415 |
|
|
|
1416 |
|
|
call FIND_ALPHA( |
1417 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
1418 |
adcroft |
1.1 |
O WORK1 ) |
1419 |
|
|
|
1420 |
|
|
call FIND_BETA( |
1421 |
mlosch |
1.11 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
1422 |
adcroft |
1.1 |
O WORK2 ) |
1423 |
|
|
|
1424 |
heimbach |
1.4 |
DO J = jbot, jtop |
1425 |
|
|
DO I = ibot, itop |
1426 |
adcroft |
1.1 |
TTALPHA(I,J,K) = WORK1 (I,J) |
1427 |
|
|
SSBETA(I,J,K) = WORK2 (I,J) |
1428 |
|
|
DBLOC(I,J,K-1) = gravity * (RHOK(I,J) - RHOKM1(I,J)) / |
1429 |
mlosch |
1.12 |
& (RHOK(I,J) + rhoConst) |
1430 |
adcroft |
1.1 |
DBSFC(I,J,K) = gravity * (RHOK(I,J) - RHO1K (I,J)) / |
1431 |
mlosch |
1.12 |
& (RHOK(I,J) + rhoConst) |
1432 |
adcroft |
1.1 |
END DO |
1433 |
|
|
END DO |
1434 |
|
|
|
1435 |
|
|
END DO |
1436 |
|
|
|
1437 |
|
|
c compute arrays for K = Nrp1 |
1438 |
heimbach |
1.4 |
DO J = jbot, jtop |
1439 |
|
|
DO I = ibot, itop |
1440 |
adcroft |
1.1 |
TTALPHA(I,J,Nrp1) = TTALPHA(I,J,Nr) |
1441 |
|
|
SSBETA(I,J,Nrp1) = SSBETA(I,J,Nr) |
1442 |
|
|
DBLOC(I,J,Nr) = 0. |
1443 |
|
|
END DO |
1444 |
|
|
END DO |
1445 |
|
|
|
1446 |
|
|
#endif /* ALLOW_KPP */ |
1447 |
|
|
|
1448 |
|
|
RETURN |
1449 |
|
|
END |