1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
|
#include "PACKAGES_CONFIG.h" |
5 |
#include "KPP_OPTIONS.h" |
#include "KPP_OPTIONS.h" |
6 |
|
|
7 |
C-- File kpp_routines.F: subroutines needed to implement |
C-- File kpp_routines.F: subroutines needed to implement |
12 |
C-- o WSCALE - Compute turbulent velocity scales. |
C-- o WSCALE - Compute turbulent velocity scales. |
13 |
C-- o RI_IWMIX - Compute interior viscosity diffusivity coefficients. |
C-- o RI_IWMIX - Compute interior viscosity diffusivity coefficients. |
14 |
C-- o Z121 - Apply 121 vertical smoothing. |
C-- o Z121 - Apply 121 vertical smoothing. |
15 |
C-- o KPP_SMOOTH_HORIZ - Apply horizontal smoothing to KPP array. |
C-- o SMOOTH_HORIZ- Apply horizontal smoothing to global array. |
|
C-- o SMOOTH_HORIZ - Apply horizontal smoothing to global array. |
|
16 |
C-- o BLMIX - Boundary layer mixing coefficients. |
C-- o BLMIX - Boundary layer mixing coefficients. |
17 |
C-- o ENHANCE - Enhance diffusivity at boundary layer interface. |
C-- o ENHANCE - Enhance diffusivity at boundary layer interface. |
18 |
C-- o STATEKPP - Compute buoyancy-related input arrays. |
C-- o STATEKPP - Compute buoyancy-related input arrays. |
20 |
c*********************************************************************** |
c*********************************************************************** |
21 |
|
|
22 |
SUBROUTINE KPPMIX ( |
SUBROUTINE KPPMIX ( |
23 |
I mytime, mythid |
I kmtj, shsq, dvsq, ustar, msk |
24 |
I , kmtj, shsq, dvsq, ustar |
I , bo, bosol |
25 |
I , bo, bosol, dbloc, Ritop, coriol |
#ifdef ALLOW_SALT_PLUME |
26 |
|
I , boplume,SPDepth |
27 |
|
#endif /* ALLOW_SALT_PLUME */ |
28 |
|
I , dbloc, Ritop, coriol |
29 |
|
I , diffusKzS, diffusKzT |
30 |
I , ikppkey |
I , ikppkey |
31 |
O , diffus |
O , diffus |
32 |
U , ghat |
U , ghat |
33 |
O , hbl ) |
O , hbl |
34 |
|
I , myTime, myIter, myThid ) |
35 |
|
|
36 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
37 |
c |
c |
52 |
#include "SIZE.h" |
#include "SIZE.h" |
53 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
54 |
#include "PARAMS.h" |
#include "PARAMS.h" |
|
#include "DYNVARS.h" |
|
|
#include "FFIELDS.h" |
|
55 |
#include "KPP_PARAMS.h" |
#include "KPP_PARAMS.h" |
56 |
|
#ifdef ALLOW_AUTODIFF |
57 |
|
# include "tamc.h" |
58 |
|
#endif |
59 |
|
|
60 |
c input |
c input |
61 |
c myTime - current time in simulation |
c myTime :: Current time in simulation |
62 |
c myThid - thread number for this instance of the routine |
c myIter :: Current iteration number in simulation |
63 |
c kmtj (imt) - number of vertical layers on this row |
c myThid :: My Thread Id. number |
64 |
c shsq (imt,Nr) - (local velocity shear)^2 ((m/s)^2) |
c kmtj (imt) - number of vertical layers on this row |
65 |
c dvsq (imt,Nr) - (velocity shear re sfc)^2 ((m/s)^2) |
c msk (imt) - surface mask (=1 if water, =0 otherwise) |
66 |
c ustar (imt) - surface friction velocity (m/s) |
c shsq (imt,Nr) - (local velocity shear)^2 ((m/s)^2) |
67 |
c bo (imt) - surface turbulent buoy. forcing (m^2/s^3) |
c dvsq (imt,Nr) - (velocity shear re sfc)^2 ((m/s)^2) |
68 |
c bosol (imt) - radiative buoyancy forcing (m^2/s^3) |
c ustar (imt) - surface friction velocity (m/s) |
69 |
c dbloc (imt,Nr) - local delta buoyancy across interfaces (m/s^2) |
c bo (imt) - surface turbulent buoy. forcing (m^2/s^3) |
70 |
c dblocSm(imt,Nr) - horizontally smoothed dbloc (m/s^2) |
c bosol (imt) - radiative buoyancy forcing (m^2/s^3) |
71 |
c stored in ghat to save space |
c boplume(imt) - haline buoyancy forcing (m^2/s^3) |
72 |
c Ritop (imt,Nr) - numerator of bulk Richardson Number |
c dbloc (imt,Nr) - local delta buoyancy across interfaces (m/s^2) |
73 |
c (zref-z) * delta buoyancy w.r.t. surface ((m/s)^2) |
c dblocSm(imt,Nr) - horizontally smoothed dbloc (m/s^2) |
74 |
c coriol (imt) - Coriolis parameter (1/s) |
c stored in ghat to save space |
75 |
|
c Ritop (imt,Nr) - numerator of bulk Richardson Number |
76 |
|
c (zref-z) * delta buoyancy w.r.t. surface ((m/s)^2) |
77 |
|
c coriol (imt) - Coriolis parameter (1/s) |
78 |
|
c diffusKzS(imt,Nr)- background vertical diffusivity for scalars (m^2/s) |
79 |
|
c diffusKzT(imt,Nr)- background vertical diffusivity for theta (m^2/s) |
80 |
c note: there is a conversion from 2-D to 1-D for input output variables, |
c note: there is a conversion from 2-D to 1-D for input output variables, |
81 |
c e.g., hbl(sNx,sNy) -> hbl(imt), |
c e.g., hbl(sNx,sNy) -> hbl(imt), |
82 |
c where hbl(i,j) -> hbl((j-1)*sNx+i) |
c where hbl(i,j) -> hbl((j-1)*sNx+i) |
83 |
|
|
84 |
_RL mytime |
_RL myTime |
85 |
integer mythid |
integer myIter |
86 |
integer kmtj (imt ) |
integer myThid |
87 |
_KPP_RL shsq (imt,Nr) |
integer kmtj (imt ) |
88 |
_KPP_RL dvsq (imt,Nr) |
_RL shsq (imt,Nr) |
89 |
_KPP_RL ustar (imt ) |
_RL dvsq (imt,Nr) |
90 |
_KPP_RL bo (imt ) |
_RL ustar (imt ) |
91 |
_KPP_RL bosol (imt ) |
_RL bo (imt ) |
92 |
_KPP_RL dbloc (imt,Nr) |
_RL bosol (imt ) |
93 |
_KPP_RL Ritop (imt,Nr) |
#ifdef ALLOW_SALT_PLUME |
94 |
_KPP_RL coriol(imt ) |
_RL boplume (imt ) |
95 |
|
_RL SPDepth (imt ) |
96 |
|
#endif /* ALLOW_SALT_PLUME */ |
97 |
|
_RL dbloc (imt,Nr) |
98 |
|
_RL Ritop (imt,Nr) |
99 |
|
_RL coriol (imt ) |
100 |
|
_RS msk (imt ) |
101 |
|
_RL diffusKzS(imt,Nr) |
102 |
|
_RL diffusKzT(imt,Nr) |
103 |
|
|
104 |
integer ikppkey |
integer ikppkey |
105 |
|
|
110 |
c ghat (imt) - nonlocal transport coefficient (s/m^2) |
c ghat (imt) - nonlocal transport coefficient (s/m^2) |
111 |
c hbl (imt) - mixing layer depth (m) |
c hbl (imt) - mixing layer depth (m) |
112 |
|
|
113 |
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
_RL diffus(imt,0:Nrp1,mdiff) |
114 |
_KPP_RL ghat (imt,Nr) |
_RL ghat (imt,Nr) |
115 |
_KPP_RL hbl (imt) |
_RL hbl (imt) |
116 |
|
|
117 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
118 |
|
|
126 |
c sigma (imt ) - normalized depth (d / hbl) |
c sigma (imt ) - normalized depth (d / hbl) |
127 |
c Rib (imt,Nr ) - bulk Richardson number |
c Rib (imt,Nr ) - bulk Richardson number |
128 |
|
|
129 |
integer kbl (imt ) |
integer kbl(imt ) |
130 |
_KPP_RL bfsfc (imt ) |
_RL bfsfc (imt ) |
131 |
_KPP_RL casea (imt ) |
_RL casea (imt ) |
132 |
_KPP_RL stable(imt ) |
_RL stable (imt ) |
133 |
_KPP_RL dkm1 (imt, mdiff) |
_RL dkm1 (imt, mdiff) |
134 |
_KPP_RL blmc (imt,Nr,mdiff) |
_RL blmc (imt,Nr,mdiff) |
135 |
_KPP_RL sigma (imt ) |
_RL sigma (imt ) |
136 |
_KPP_RL Rib (imt,Nr ) |
_RL Rib (imt,Nr ) |
137 |
|
|
138 |
integer i, k, md |
integer i, k, md |
139 |
|
|
146 |
|
|
147 |
cph( |
cph( |
148 |
cph these storings avoid recomp. of Ri_iwmix |
cph these storings avoid recomp. of Ri_iwmix |
149 |
CADJ STORE ghat = comlev1_kpp, key = ikppkey |
CADJ STORE ghat = comlev1_kpp, key=ikppkey, kind=isbyte |
150 |
CADJ STORE dbloc = comlev1_kpp, key = ikppkey |
CADJ STORE dbloc = comlev1_kpp, key=ikppkey, kind=isbyte |
151 |
cph) |
cph) |
152 |
call Ri_iwmix ( |
call Ri_iwmix ( |
153 |
I kmtj, shsq, dbloc, ghat |
I kmtj, shsq, dbloc, ghat |
154 |
|
I , diffusKzS, diffusKzT |
155 |
I , ikppkey |
I , ikppkey |
156 |
O , diffus ) |
O , diffus, myThid ) |
157 |
|
|
158 |
cph( |
cph( |
159 |
cph these storings avoid recomp. of Ri_iwmix |
cph these storings avoid recomp. of Ri_iwmix |
160 |
cph DESPITE TAFs 'not necessary' warning! |
cph DESPITE TAFs 'not necessary' warning! |
161 |
CADJ STORE dbloc = comlev1_kpp, key = ikppkey |
CADJ STORE dbloc = comlev1_kpp, key=ikppkey, kind=isbyte |
162 |
CADJ STORE shsq = comlev1_kpp, key = ikppkey |
CADJ STORE shsq = comlev1_kpp, key=ikppkey, kind=isbyte |
163 |
CADJ STORE ghat = comlev1_kpp, key = ikppkey |
CADJ STORE ghat = comlev1_kpp, key=ikppkey, kind=isbyte |
164 |
CADJ STORE diffus = comlev1_kpp, key = ikppkey |
CADJ STORE diffus = comlev1_kpp, key=ikppkey, kind=isbyte |
165 |
cph) |
cph) |
166 |
|
|
167 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
170 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
171 |
|
|
172 |
do md = 1, mdiff |
do md = 1, mdiff |
173 |
|
do k=1,Nrp1 |
174 |
do i = 1,imt |
do i = 1,imt |
175 |
do k=kmtj(i),Nrp1 |
if(k.ge.kmtj(i)) diffus(i,k,md) = 0.0 |
|
diffus(i,k,md) = 0.0 |
|
176 |
end do |
end do |
177 |
end do |
end do |
178 |
end do |
end do |
184 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
185 |
|
|
186 |
call bldepth ( |
call bldepth ( |
187 |
I mytime, mythid |
I kmtj |
188 |
I , kmtj |
I , dvsq, dbloc, Ritop, ustar, bo, bosol |
189 |
I , dvsq, dbloc, Ritop, ustar, bo, bosol, coriol |
#ifdef ALLOW_SALT_PLUME |
190 |
|
I , boplume,SPDepth |
191 |
|
#endif /* ALLOW_SALT_PLUME */ |
192 |
|
I , coriol |
193 |
I , ikppkey |
I , ikppkey |
194 |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
195 |
& ) |
I , myTime, myIter, myThid ) |
196 |
|
|
197 |
CADJ STORE hbl,bfsfc,stable,casea,kbl = comlev1_kpp, key = ikppkey |
CADJ STORE hbl,bfsfc,stable,casea,kbl = comlev1_kpp, |
198 |
|
CADJ & key=ikppkey, kind=isbyte |
199 |
|
|
200 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
201 |
c compute boundary layer diffusivities |
c compute boundary layer diffusivities |
204 |
call blmix ( |
call blmix ( |
205 |
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
206 |
O , dkm1, blmc, ghat, sigma, ikppkey |
O , dkm1, blmc, ghat, sigma, ikppkey |
207 |
& ) |
I , myThid ) |
208 |
cph( |
cph( |
209 |
CADJ STORE dkm1,blmc,ghat = comlev1_kpp, key = ikppkey |
CADJ STORE dkm1,blmc,ghat = comlev1_kpp, |
210 |
CADJ STORE hbl, kbl, diffus, casea = comlev1_kpp, key = ikppkey |
CADJ & key=ikppkey, kind=isbyte |
211 |
|
CADJ STORE hbl, kbl, diffus, casea = comlev1_kpp, |
212 |
|
CADJ & key=ikppkey, kind=isbyte |
213 |
cph) |
cph) |
214 |
|
|
215 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
219 |
call enhance ( |
call enhance ( |
220 |
I dkm1, hbl, kbl, diffus, casea |
I dkm1, hbl, kbl, diffus, casea |
221 |
U , ghat |
U , ghat |
222 |
O , blmc ) |
O , blmc |
223 |
|
I , myThid ) |
224 |
|
|
225 |
cph( |
cph( |
226 |
cph avoids recomp. of enhance |
cph avoids recomp. of enhance |
227 |
CADJ STORE blmc = comlev1_kpp, key = ikppkey |
CADJ STORE blmc = comlev1_kpp, key=ikppkey, kind=isbyte |
228 |
cph) |
cph) |
229 |
|
|
230 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
236 |
do k = 1, Nr |
do k = 1, Nr |
237 |
do i = 1, imt |
do i = 1, imt |
238 |
if (k .lt. kbl(i)) then |
if (k .lt. kbl(i)) then |
239 |
|
#ifdef ALLOW_SHELFICE |
240 |
|
C when there is shelfice on top (msk(i)=0), reset the boundary layer |
241 |
|
C mixing coefficients blmc to pure Ri-number based mixing |
242 |
|
blmc(i,k,1) = max ( blmc(i,k,1)*msk(i), |
243 |
|
& diffus(i,k,1) ) |
244 |
|
blmc(i,k,2) = max ( blmc(i,k,2)*msk(i), |
245 |
|
& diffus(i,k,2) ) |
246 |
|
blmc(i,k,3) = max ( blmc(i,k,3)*msk(i), |
247 |
|
& diffus(i,k,3) ) |
248 |
|
#endif /* not ALLOW_SHELFICE */ |
249 |
diffus(i,k,1) = max ( blmc(i,k,1), viscAr ) |
diffus(i,k,1) = max ( blmc(i,k,1), viscAr ) |
250 |
diffus(i,k,2) = max ( blmc(i,k,2), diffKrNrS(k) ) |
diffus(i,k,2) = max ( blmc(i,k,2), diffusKzS(i,Nr) ) |
251 |
diffus(i,k,3) = max ( blmc(i,k,3), diffKrNrT(k) ) |
diffus(i,k,3) = max ( blmc(i,k,3), diffusKzT(i,Nr) ) |
252 |
else |
else |
253 |
ghat(i,k) = 0. |
ghat(i,k) = 0. _d 0 |
254 |
endif |
endif |
255 |
end do |
end do |
256 |
end do |
end do |
263 |
c************************************************************************* |
c************************************************************************* |
264 |
|
|
265 |
subroutine bldepth ( |
subroutine bldepth ( |
266 |
I mytime, mythid |
I kmtj |
267 |
I , kmtj |
I , dvsq, dbloc, Ritop, ustar, bo, bosol |
268 |
I , dvsq, dbloc, Ritop, ustar, bo, bosol, coriol |
#ifdef ALLOW_SALT_PLUME |
269 |
|
I , boplume,SPDepth |
270 |
|
#endif /* ALLOW_SALT_PLUME */ |
271 |
|
I , coriol |
272 |
I , ikppkey |
I , ikppkey |
273 |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
O , hbl, bfsfc, stable, casea, kbl, Rib, sigma |
274 |
& ) |
I , myTime, myIter, myThid ) |
275 |
|
|
276 |
c the oceanic planetary boundary layer depth, hbl, is determined as |
c the oceanic planetary boundary layer depth, hbl, is determined as |
277 |
c the shallowest depth where the bulk Richardson number is |
c the shallowest depth where the bulk Richardson number is |
300 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
301 |
#include "PARAMS.h" |
#include "PARAMS.h" |
302 |
#include "KPP_PARAMS.h" |
#include "KPP_PARAMS.h" |
303 |
#include "FFIELDS.h" |
#ifdef ALLOW_AUTODIFF |
304 |
|
# include "tamc.h" |
305 |
|
#endif |
306 |
|
|
307 |
c input |
c input |
308 |
c------ |
c------ |
309 |
c myTime : current time in simulation |
c myTime :: Current time in simulation |
310 |
c myThid : thread number for this instance of the routine |
c myIter :: Current iteration number in simulation |
311 |
|
c myThid :: My Thread Id. number |
312 |
c kmtj : number of vertical layers |
c kmtj : number of vertical layers |
313 |
c dvsq : (velocity shear re sfc)^2 ((m/s)^2) |
c dvsq : (velocity shear re sfc)^2 ((m/s)^2) |
314 |
c dbloc : local delta buoyancy across interfaces (m/s^2) |
c dbloc : local delta buoyancy across interfaces (m/s^2) |
318 |
c ustar : surface friction velocity (m/s) |
c ustar : surface friction velocity (m/s) |
319 |
c bo : surface turbulent buoyancy forcing (m^2/s^3) |
c bo : surface turbulent buoyancy forcing (m^2/s^3) |
320 |
c bosol : radiative buoyancy forcing (m^2/s^3) |
c bosol : radiative buoyancy forcing (m^2/s^3) |
321 |
|
c boplume : haline buoyancy forcing (m^2/s^3) |
322 |
c coriol : Coriolis parameter (1/s) |
c coriol : Coriolis parameter (1/s) |
323 |
_RL mytime |
_RL myTime |
324 |
integer mythid |
integer myIter |
325 |
|
integer myThid |
326 |
integer kmtj(imt) |
integer kmtj(imt) |
327 |
_KPP_RL dvsq (imt,Nr) |
_RL dvsq (imt,Nr) |
328 |
_KPP_RL dbloc (imt,Nr) |
_RL dbloc (imt,Nr) |
329 |
_KPP_RL Ritop (imt,Nr) |
_RL Ritop (imt,Nr) |
330 |
_KPP_RL ustar (imt) |
_RL ustar (imt) |
331 |
_KPP_RL bo (imt) |
_RL bo (imt) |
332 |
_KPP_RL bosol (imt) |
_RL bosol (imt) |
333 |
_KPP_RL coriol(imt) |
_RL coriol (imt) |
334 |
integer ikppkey, kkppkey |
integer ikppkey, kkppkey |
335 |
|
#ifdef ALLOW_SALT_PLUME |
336 |
|
_RL boplume (imt) |
337 |
|
_RL SPDepth (imt) |
338 |
|
#endif /* ALLOW_SALT_PLUME */ |
339 |
|
|
340 |
c output |
c output |
341 |
c-------- |
c-------- |
346 |
c kbl : -1 of first grid level below hbl |
c kbl : -1 of first grid level below hbl |
347 |
c Rib : Bulk Richardson number |
c Rib : Bulk Richardson number |
348 |
c sigma : normalized depth (d/hbl) |
c sigma : normalized depth (d/hbl) |
349 |
_KPP_RL hbl (imt) |
_RL hbl (imt) |
350 |
_KPP_RL bfsfc (imt) |
_RL bfsfc (imt) |
351 |
_KPP_RL stable(imt) |
_RL stable (imt) |
352 |
_KPP_RL casea (imt) |
_RL casea (imt) |
353 |
integer kbl (imt) |
integer kbl(imt) |
354 |
_KPP_RL Rib (imt,Nr) |
_RL Rib (imt,Nr) |
355 |
_KPP_RL sigma (imt) |
_RL sigma (imt) |
356 |
|
|
357 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
358 |
|
|
359 |
c local |
c local |
360 |
c------- |
c------- |
361 |
c wm, ws : turbulent velocity scales (m/s) |
c wm, ws : turbulent velocity scales (m/s) |
362 |
_KPP_RL wm(imt), ws(imt) |
_RL wm(imt), ws(imt) |
363 |
_RL worka(imt) |
_RL worka(imt) |
364 |
|
_RL bvsq, vtsq, hekman, hmonob, hlimit, tempVar1, tempVar2 |
|
_KPP_RL bvsq, vtsq, hekman, hmonob, hlimit, tempVar1, tempVar2 |
|
365 |
integer i, kl |
integer i, kl |
366 |
|
|
367 |
_KPP_RL p5 , eins |
_RL p5 , eins |
368 |
parameter ( p5=0.5, eins=1.0 ) |
parameter ( p5=0.5, eins=1.0 ) |
369 |
_RL minusone |
_RL minusone |
370 |
parameter ( minusone=-1.0 ) |
parameter ( minusone=-1.0 ) |
371 |
|
|
372 |
|
#ifdef ALLOW_DIAGNOSTICS |
373 |
|
c KPPBFSFC - Bo+radiation absorbed to d=hbf*hbl + plume (m^2/s^3) |
374 |
|
_RL KPPBFSFC(imt,Nr) |
375 |
|
_RL KPPRi(imt,Nr) |
376 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
377 |
|
|
378 |
c find bulk Richardson number at every grid level until > Ricr |
c find bulk Richardson number at every grid level until > Ricr |
379 |
c |
c |
380 |
c note: the reference depth is -epsilon/2.*zgrid(k), but the reference |
c note: the reference depth is -epsilon/2.*zgrid(k), but the reference |
387 |
c initialize hbl and kbl to bottomed out values |
c initialize hbl and kbl to bottomed out values |
388 |
|
|
389 |
do i = 1, imt |
do i = 1, imt |
390 |
Rib(i,1) = 0.0 |
Rib(i,1) = 0. _d 0 |
391 |
kbl(i) = max(kmtj(i),1) |
kbl(i) = max(kmtj(i),1) |
392 |
hbl(i) = -zgrid(kbl(i)) |
hbl(i) = -zgrid(kbl(i)) |
393 |
end do |
end do |
394 |
|
|
395 |
|
#ifdef ALLOW_DIAGNOSTICS |
396 |
|
do kl = 1, Nr |
397 |
|
do i = 1, imt |
398 |
|
KPPBFSFC(i,kl) = 0. _d 0 |
399 |
|
KPPRi(i,kl) = 0. _d 0 |
400 |
|
enddo |
401 |
|
enddo |
402 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
403 |
|
|
404 |
do kl = 2, Nr |
do kl = 2, Nr |
405 |
|
|
406 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
412 |
do i = 1, imt |
do i = 1, imt |
413 |
worka(i) = zgrid(kl) |
worka(i) = zgrid(kl) |
414 |
end do |
end do |
415 |
CADJ store worka = comlev1_kpp_k, key = kkppkey |
CADJ store worka = comlev1_kpp_k, key = kkppkey, kind=isbyte |
416 |
call SWFRAC( |
call SWFRAC( |
417 |
I imt, hbf, |
I imt, hbf, |
418 |
I mytime, mythid, |
U worka, |
419 |
U worka ) |
I myTime, myIter, myThid ) |
420 |
CADJ store worka = comlev1_kpp_k, key = kkppkey |
CADJ store worka = comlev1_kpp_k, key = kkppkey, kind=isbyte |
|
|
|
421 |
|
|
422 |
do i = 1, imt |
do i = 1, imt |
423 |
|
|
428 |
c compute bfsfc= Bo + radiative contribution down to hbf * hbl |
c compute bfsfc= Bo + radiative contribution down to hbf * hbl |
429 |
|
|
430 |
bfsfc(i) = bo(i) + bosol(i)*(1. - worka(i)) |
bfsfc(i) = bo(i) + bosol(i)*(1. - worka(i)) |
|
stable(i) = p5 + sign(p5,bfsfc(i)) |
|
|
sigma(i) = stable(i) + (1. - stable(i)) * epsilon |
|
431 |
|
|
432 |
end do |
end do |
433 |
|
#ifdef ALLOW_SALT_PLUME |
434 |
|
c compute bfsfc = plume fraction at hbf * zgrid |
435 |
|
IF ( useSALT_PLUME ) THEN |
436 |
|
do i = 1, imt |
437 |
|
worka(i) = zgrid(kl) |
438 |
|
enddo |
439 |
|
call SALT_PLUME_FRAC( |
440 |
|
I imt, hbf,SPDepth, |
441 |
|
U worka, |
442 |
|
I myTime, myIter, myThid) |
443 |
|
do i = 1, imt |
444 |
|
bfsfc(i) = bfsfc(i) + boplume(i)*(1. - worka(i)) |
445 |
|
enddo |
446 |
|
ENDIF |
447 |
|
#endif /* ALLOW_SALT_PLUME */ |
448 |
|
|
449 |
|
#ifdef ALLOW_DIAGNOSTICS |
450 |
|
do i = 1, imt |
451 |
|
KPPBFSFC(i,kl) = bfsfc(i) |
452 |
|
enddo |
453 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
454 |
|
|
455 |
|
do i = 1, imt |
456 |
|
stable(i) = p5 + sign(p5,bfsfc(i)) |
457 |
|
sigma(i) = stable(i) + (1. - stable(i)) * epsilon |
458 |
|
enddo |
459 |
|
|
460 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
461 |
c compute velocity scales at sigma, for hbl= caseA = -zgrid(kl) |
c compute velocity scales at sigma, for hbl= caseA = -zgrid(kl) |
463 |
|
|
464 |
call wscale ( |
call wscale ( |
465 |
I sigma, casea, ustar, bfsfc, |
I sigma, casea, ustar, bfsfc, |
466 |
O wm, ws ) |
O wm, ws, myThid ) |
467 |
CADJ store ws = comlev1_kpp_k, key = kkppkey |
CADJ store ws = comlev1_kpp_k, key = kkppkey, kind=isbyte |
468 |
|
|
469 |
do i = 1, imt |
do i = 1, imt |
470 |
|
|
476 |
1 ( dbloc(i,kl-1) / (zgrid(kl-1)-zgrid(kl ))+ |
1 ( dbloc(i,kl-1) / (zgrid(kl-1)-zgrid(kl ))+ |
477 |
2 dbloc(i,kl ) / (zgrid(kl )-zgrid(kl+1))) |
2 dbloc(i,kl ) / (zgrid(kl )-zgrid(kl+1))) |
478 |
|
|
479 |
if (bvsq .eq. 0.) then |
if (bvsq .eq. 0. _d 0) then |
480 |
vtsq = 0.0 |
vtsq = 0. _d 0 |
481 |
else |
else |
482 |
vtsq = -zgrid(kl) * ws(i) * sqrt(abs(bvsq)) * Vtc |
vtsq = -zgrid(kl) * ws(i) * sqrt(abs(bvsq)) * Vtc |
483 |
endif |
endif |
497 |
tempVar1 = dvsq(i,kl) + vtsq |
tempVar1 = dvsq(i,kl) + vtsq |
498 |
tempVar2 = max(tempVar1, phepsi) |
tempVar2 = max(tempVar1, phepsi) |
499 |
Rib(i,kl) = Ritop(i,kl) / tempVar2 |
Rib(i,kl) = Ritop(i,kl) / tempVar2 |
500 |
|
#ifdef ALLOW_DIAGNOSTICS |
501 |
|
KPPRi(i,kl) = Rib(i,kl) |
502 |
|
#endif |
503 |
|
|
504 |
end do |
end do |
505 |
end do |
end do |
506 |
|
|
507 |
|
#ifdef ALLOW_DIAGNOSTICS |
508 |
|
CALL DIAGNOSTICS_FILL(KPPBFSFC,'KPPbfsfc',0,Nr,0,1,1,myThid) |
509 |
|
CALL DIAGNOSTICS_FILL(KPPRi ,'KPPRi ',0,Nr,0,1,1,myThid) |
510 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
511 |
|
|
512 |
cph( |
cph( |
513 |
cph without this store, there is a recomputation error for |
cph without this store, there is a recomputation error for |
514 |
cph rib in adbldepth (probably partial recomputation problem) |
cph rib in adbldepth (probably partial recomputation problem) |
515 |
CADJ store Rib = comlev1_kpp |
CADJ store Rib = comlev1_kpp |
516 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy),Nr /) |
CADJ & , key=ikppkey, kind=isbyte, |
517 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy),Nr /) |
518 |
cph) |
cph) |
519 |
|
|
520 |
do kl = 2, Nr |
do kl = 2, Nr |
524 |
end do |
end do |
525 |
|
|
526 |
CADJ store kbl = comlev1_kpp |
CADJ store kbl = comlev1_kpp |
527 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
528 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
529 |
|
|
530 |
do i = 1, imt |
do i = 1, imt |
531 |
kl = kbl(i) |
kl = kbl(i) |
538 |
end do |
end do |
539 |
|
|
540 |
CADJ store hbl = comlev1_kpp |
CADJ store hbl = comlev1_kpp |
541 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
542 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
543 |
|
|
544 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
545 |
c find stability and buoyancy forcing for boundary layer |
c find stability and buoyancy forcing for boundary layer |
549 |
worka(i) = hbl(i) |
worka(i) = hbl(i) |
550 |
end do |
end do |
551 |
CADJ store worka = comlev1_kpp |
CADJ store worka = comlev1_kpp |
552 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
553 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
554 |
call SWFRAC( |
call SWFRAC( |
555 |
I imt, minusone, |
I imt, minusone, |
556 |
I mytime, mythid, |
U worka, |
557 |
U worka ) |
I myTime, myIter, myThid ) |
558 |
CADJ store worka = comlev1_kpp |
CADJ store worka = comlev1_kpp |
559 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
560 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
561 |
|
|
562 |
do i = 1, imt |
do i = 1, imt |
563 |
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
564 |
end do |
end do |
565 |
|
|
566 |
|
#ifdef ALLOW_SALT_PLUME |
567 |
|
IF ( useSALT_PLUME ) THEN |
568 |
|
do i = 1, imt |
569 |
|
worka(i) = hbl(i) |
570 |
|
enddo |
571 |
|
call SALT_PLUME_FRAC( |
572 |
|
I imt,minusone,SPDepth, |
573 |
|
U worka, |
574 |
|
I myTime, myIter, myThid ) |
575 |
|
do i = 1, imt |
576 |
|
bfsfc(i) = bfsfc(i) + boplume(i) * (1. - worka(i)) |
577 |
|
enddo |
578 |
|
ENDIF |
579 |
|
#endif /* ALLOW_SALT_PLUME */ |
580 |
CADJ store bfsfc = comlev1_kpp |
CADJ store bfsfc = comlev1_kpp |
581 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
582 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
583 |
|
|
584 |
c-- ensure bfsfc is never 0 |
c-- ensure bfsfc is never 0 |
585 |
do i = 1, imt |
do i = 1, imt |
590 |
cph( |
cph( |
591 |
cph added stable to store list to avoid extensive recomp. |
cph added stable to store list to avoid extensive recomp. |
592 |
CADJ store bfsfc, stable = comlev1_kpp |
CADJ store bfsfc, stable = comlev1_kpp |
593 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
594 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
595 |
cph) |
cph) |
596 |
|
|
597 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
599 |
c ph: test for zero nominator |
c ph: test for zero nominator |
600 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
601 |
|
|
602 |
|
IF ( LimitHblStable ) THEN |
603 |
do i = 1, imt |
do i = 1, imt |
604 |
if (bfsfc(i) .gt. 0.0) then |
if (bfsfc(i) .gt. 0.0) then |
605 |
hekman = cekman * ustar(i) / max(abs(Coriol(i)),phepsi) |
hekman = cekman * ustar(i) / max(abs(Coriol(i)),phepsi) |
610 |
hbl(i) = min(hbl(i),hlimit) |
hbl(i) = min(hbl(i),hlimit) |
611 |
end if |
end if |
612 |
end do |
end do |
613 |
|
ENDIF |
614 |
|
|
615 |
CADJ store hbl = comlev1_kpp |
CADJ store hbl = comlev1_kpp |
616 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
617 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
618 |
|
|
619 |
do i = 1, imt |
do i = 1, imt |
620 |
hbl(i) = max(hbl(i),minKPPhbl) |
hbl(i) = max(hbl(i),minKPPhbl) |
622 |
end do |
end do |
623 |
|
|
624 |
CADJ store hbl = comlev1_kpp |
CADJ store hbl = comlev1_kpp |
625 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
626 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
627 |
|
|
628 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
629 |
c find new kbl |
c find new kbl |
645 |
worka(i) = hbl(i) |
worka(i) = hbl(i) |
646 |
end do |
end do |
647 |
CADJ store worka = comlev1_kpp |
CADJ store worka = comlev1_kpp |
648 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
649 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
650 |
call SWFRAC( |
call SWFRAC( |
651 |
I imt, minusone, |
I imt, minusone, |
652 |
I mytime, mythid, |
U worka, |
653 |
U worka ) |
I myTime, myIter, myThid ) |
654 |
CADJ store worka = comlev1_kpp |
CADJ store worka = comlev1_kpp |
655 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
656 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
657 |
|
|
658 |
do i = 1, imt |
do i = 1, imt |
659 |
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
bfsfc(i) = bo(i) + bosol(i) * (1. - worka(i)) |
660 |
end do |
end do |
661 |
|
|
662 |
|
#ifdef ALLOW_SALT_PLUME |
663 |
|
IF ( useSALT_PLUME ) THEN |
664 |
|
do i = 1, imt |
665 |
|
worka(i) = hbl(i) |
666 |
|
enddo |
667 |
|
call SALT_PLUME_FRAC( |
668 |
|
I imt,minusone,SPDepth, |
669 |
|
U worka, |
670 |
|
I myTime, myIter, myThid ) |
671 |
|
do i = 1, imt |
672 |
|
bfsfc(i) = bfsfc(i) + boplume(i) * (1. - worka(i)) |
673 |
|
enddo |
674 |
|
ENDIF |
675 |
|
#endif /* ALLOW_SALT_PLUME */ |
676 |
CADJ store bfsfc = comlev1_kpp |
CADJ store bfsfc = comlev1_kpp |
677 |
CADJ & , key = ikppkey, shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
CADJ & , key=ikppkey, kind=isbyte, |
678 |
|
CADJ & shape = (/ (sNx+2*OLx)*(sNy+2*OLy) /) |
679 |
|
|
680 |
c-- ensures bfsfc is never 0 |
c-- ensures bfsfc is never 0 |
681 |
do i = 1, imt |
do i = 1, imt |
701 |
|
|
702 |
subroutine wscale ( |
subroutine wscale ( |
703 |
I sigma, hbl, ustar, bfsfc, |
I sigma, hbl, ustar, bfsfc, |
704 |
O wm, ws ) |
O wm, ws, |
705 |
|
I myThid ) |
706 |
|
|
707 |
c compute turbulent velocity scales. |
c compute turbulent velocity scales. |
708 |
c use a 2D-lookup table for wm and ws as functions of ustar and |
c use a 2D-lookup table for wm and ws as functions of ustar and |
723 |
c hbl : boundary layer depth (m) |
c hbl : boundary layer depth (m) |
724 |
c ustar : surface friction velocity (m/s) |
c ustar : surface friction velocity (m/s) |
725 |
c bfsfc : total surface buoyancy flux (m^2/s^3) |
c bfsfc : total surface buoyancy flux (m^2/s^3) |
726 |
_KPP_RL sigma(imt) |
c myThid : thread number for this instance of the routine |
727 |
_KPP_RL hbl (imt) |
integer myThid |
728 |
_KPP_RL ustar(imt) |
_RL sigma(imt) |
729 |
_KPP_RL bfsfc(imt) |
_RL hbl (imt) |
730 |
|
_RL ustar(imt) |
731 |
|
_RL bfsfc(imt) |
732 |
|
|
733 |
c output |
c output |
734 |
c-------- |
c-------- |
735 |
c wm, ws : turbulent velocity scales at sigma |
c wm, ws : turbulent velocity scales at sigma |
736 |
_KPP_RL wm(imt), ws(imt) |
_RL wm(imt), ws(imt) |
737 |
|
|
738 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
739 |
|
|
740 |
c local |
c local |
741 |
c------ |
c------ |
742 |
c zehat : = zeta * ustar**3 |
c zehat : = zeta * ustar**3 |
743 |
_KPP_RL zehat |
_RL zehat |
744 |
|
|
745 |
integer iz, izp1, ju, i, jup1 |
integer iz, izp1, ju, i, jup1 |
746 |
_KPP_RL udiff, zdiff, zfrac, ufrac, fzfrac, wam |
_RL udiff, zdiff, zfrac, ufrac, fzfrac, wam |
747 |
_KPP_RL wbm, was, wbs, u3, tempVar |
_RL wbm, was, wbs, u3, tempVar |
748 |
|
|
749 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
750 |
c use lookup table for zehat < zmax only; otherwise use |
c use lookup table for zehat < zmax only; otherwise use |
799 |
c************************************************************************* |
c************************************************************************* |
800 |
|
|
801 |
subroutine Ri_iwmix ( |
subroutine Ri_iwmix ( |
802 |
I kmtj, shsq, dbloc, dblocSm |
I kmtj, shsq, dbloc, dblocSm, |
803 |
I , ikppkey |
I diffusKzS, diffusKzT, |
804 |
O , diffus ) |
I ikppkey, |
805 |
|
O diffus, |
806 |
|
I myThid ) |
807 |
|
|
808 |
c compute interior viscosity diffusivity coefficients due |
c compute interior viscosity diffusivity coefficients due |
809 |
c to shear instability (dependent on a local Richardson number), |
c to shear instability (dependent on a local Richardson number), |
816 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
817 |
#include "PARAMS.h" |
#include "PARAMS.h" |
818 |
#include "KPP_PARAMS.h" |
#include "KPP_PARAMS.h" |
819 |
|
#ifdef ALLOW_AUTODIFF |
820 |
|
# include "tamc.h" |
821 |
|
#endif |
822 |
|
|
823 |
c input |
c input |
824 |
c kmtj (imt) number of vertical layers on this row |
c kmtj (imt) number of vertical layers on this row |
825 |
c shsq (imt,Nr) (local velocity shear)^2 ((m/s)^2) |
c shsq (imt,Nr) (local velocity shear)^2 ((m/s)^2) |
826 |
c dbloc (imt,Nr) local delta buoyancy (m/s^2) |
c dbloc (imt,Nr) local delta buoyancy (m/s^2) |
827 |
c dblocSm(imt,Nr) horizontally smoothed dbloc (m/s^2) |
c dblocSm(imt,Nr) horizontally smoothed dbloc (m/s^2) |
828 |
integer kmtj (imt) |
c diffusKzS(imt,Nr)- background vertical diffusivity for scalars (m^2/s) |
829 |
_KPP_RL shsq (imt,Nr) |
c diffusKzT(imt,Nr)- background vertical diffusivity for theta (m^2/s) |
830 |
_KPP_RL dbloc (imt,Nr) |
c myThid :: My Thread Id. number |
831 |
_KPP_RL dblocSm(imt,Nr) |
integer kmtj (imt) |
832 |
|
_RL shsq (imt,Nr) |
833 |
|
_RL dbloc (imt,Nr) |
834 |
|
_RL dblocSm (imt,Nr) |
835 |
|
_RL diffusKzS(imt,Nr) |
836 |
|
_RL diffusKzT(imt,Nr) |
837 |
integer ikppkey |
integer ikppkey |
838 |
|
integer myThid |
839 |
|
|
840 |
c output |
c output |
841 |
c diffus(imt,0:Nrp1,1) vertical viscosivity coefficient (m^2/s) |
c diffus(imt,0:Nrp1,1) vertical viscosivity coefficient (m^2/s) |
842 |
c diffus(imt,0:Nrp1,2) vertical scalar diffusivity (m^2/s) |
c diffus(imt,0:Nrp1,2) vertical scalar diffusivity (m^2/s) |
843 |
c diffus(imt,0:Nrp1,3) vertical temperature diffusivity (m^2/s) |
c diffus(imt,0:Nrp1,3) vertical temperature diffusivity (m^2/s) |
844 |
_KPP_RL diffus(imt,0:Nrp1,3) |
_RL diffus(imt,0:Nrp1,3) |
845 |
|
|
846 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
847 |
|
|
848 |
c local variables |
c local variables |
849 |
c Rig local Richardson number |
c Rig local Richardson number |
850 |
c fRi, fcon function of Rig |
c fRi, fcon function of Rig |
851 |
_KPP_RL Rig |
_RL Rig |
852 |
_KPP_RL fRi, fcon |
_RL fRi, fcon |
853 |
_KPP_RL ratio |
_RL ratio |
854 |
integer i, ki |
integer i, ki, kp1 |
855 |
_KPP_RL c1, c0 |
_RL c1, c0 |
856 |
|
|
857 |
#ifdef ALLOW_KPP_VERTICALLY_SMOOTH |
#ifdef ALLOW_KPP_VERTICALLY_SMOOTH |
858 |
integer mr |
integer mr |
860 |
#endif |
#endif |
861 |
|
|
862 |
c constants |
c constants |
863 |
c1 = 1.0 |
c1 = 1. _d 0 |
864 |
c0 = 0.0 |
c0 = 0. _d 0 |
865 |
|
|
866 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
867 |
c compute interior gradient Ri at all interfaces ki=1,Nr, (not surface) |
c compute interior gradient Ri at all interfaces ki=1,Nr, (not surface) |
897 |
endif |
endif |
898 |
end do |
end do |
899 |
end do |
end do |
900 |
CADJ store diffus = comlev1_kpp, key = ikppkey |
CADJ store diffus = comlev1_kpp, key=ikppkey, kind=isbyte |
901 |
|
|
902 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
903 |
c vertically smooth Ri |
c vertically smooth Ri |
908 |
CADJ & , key=mr, shape=(/ (sNx+2*OLx)*(sNy+2*OLy),Nr+2 /) |
CADJ & , key=mr, shape=(/ (sNx+2*OLx)*(sNy+2*OLy),Nr+2 /) |
909 |
|
|
910 |
call z121 ( |
call z121 ( |
911 |
U diffus(1,0,1)) |
U diffus(1,0,1), |
912 |
|
I myThid ) |
913 |
end do |
end do |
914 |
#endif |
#endif |
915 |
|
|
937 |
c evaluate diffusivities and viscosity |
c evaluate diffusivities and viscosity |
938 |
c mixing due to internal waves, and shear and static instability |
c mixing due to internal waves, and shear and static instability |
939 |
|
|
940 |
|
kp1 = MIN(ki+1,Nr) |
941 |
#ifndef EXCLUDE_KPP_SHEAR_MIX |
#ifndef EXCLUDE_KPP_SHEAR_MIX |
942 |
if ( .NOT. inAdMode ) then |
if ( .NOT. inAdMode ) then |
943 |
diffus(i,ki,1) = viscAr + fcon * difmcon + fRi * difm0 |
diffus(i,ki,1) = viscAr + fcon * difmcon + fRi * difm0 |
944 |
diffus(i,ki,2) = diffKrNrS(ki)+ fcon*difscon + fRi*difs0 |
diffus(i,ki,2) = diffusKzS(i,kp1)+fcon*difscon+fRi*difs0 |
945 |
diffus(i,ki,3) = diffKrNrT(ki)+ fcon*difscon + fRi*difs0 |
diffus(i,ki,3) = diffusKzT(i,kp1)+fcon*diftcon+fRi*dift0 |
946 |
else |
else |
947 |
diffus(i,ki,1) = viscAr |
diffus(i,ki,1) = viscAr |
948 |
diffus(i,ki,2) = diffKrNrS(ki) |
diffus(i,ki,2) = diffusKzS(i,kp1) |
949 |
diffus(i,ki,3) = diffKrNrT(ki) |
diffus(i,ki,3) = diffusKzT(i,kp1) |
950 |
endif |
endif |
951 |
#else |
#else |
952 |
diffus(i,ki,1) = viscAr |
diffus(i,ki,1) = viscAr |
953 |
diffus(i,ki,2) = diffKrNrS(ki) |
diffus(i,ki,2) = diffusKzS(i,kp1) |
954 |
diffus(i,ki,3) = diffKrNrT(ki) |
diffus(i,ki,3) = diffusKzT(i,kp1) |
955 |
#endif |
#endif |
956 |
|
|
957 |
end do |
end do |
974 |
c************************************************************************* |
c************************************************************************* |
975 |
|
|
976 |
subroutine z121 ( |
subroutine z121 ( |
977 |
U v ) |
U v, |
978 |
|
I myThid ) |
979 |
|
|
980 |
c Apply 121 smoothing in k to 2-d array V(i,k=1,Nr) |
c Apply 121 smoothing in k to 2-d array V(i,k=1,Nr) |
981 |
c top (0) value is used as a dummy |
c top (0) value is used as a dummy |
993 |
c input/output |
c input/output |
994 |
c------------- |
c------------- |
995 |
c v : 2-D array to be smoothed in Nrp1 direction |
c v : 2-D array to be smoothed in Nrp1 direction |
996 |
_KPP_RL v(imt,0:Nrp1) |
c myThid: thread number for this instance of the routine |
997 |
|
integer myThid |
998 |
|
_RL v(imt,0:Nrp1) |
999 |
|
|
1000 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
1001 |
|
|
1002 |
c local |
c local |
1003 |
_KPP_RL zwork, zflag |
_RL zwork, zflag |
1004 |
_KPP_RL KRi_range(1:Nrp1) |
_RL KRi_range(1:Nrp1) |
1005 |
integer i, k, km1, kp1 |
integer i, k, km1, kp1 |
1006 |
|
|
1007 |
_KPP_RL p0 , p25 , p5 , p2 |
_RL p0 , p25 , p5 , p2 |
1008 |
parameter ( p0 = 0.0, p25 = 0.25, p5 = 0.5, p2 = 2.0 ) |
parameter ( p0 = 0.0, p25 = 0.25, p5 = 0.5, p2 = 2.0 ) |
1009 |
|
|
1010 |
KRi_range(Nrp1) = p0 |
KRi_range(Nrp1) = p0 |
1058 |
|
|
1059 |
c************************************************************************* |
c************************************************************************* |
1060 |
|
|
|
subroutine kpp_smooth_horiz ( |
|
|
I k, bi, bj, |
|
|
U fld ) |
|
|
|
|
|
c Apply horizontal smoothing to KPP array |
|
|
|
|
|
IMPLICIT NONE |
|
|
#include "SIZE.h" |
|
|
#include "GRID.h" |
|
|
#include "KPP_PARAMS.h" |
|
|
|
|
|
c input |
|
|
c bi, bj : array indices |
|
|
c k : vertical index used for masking |
|
|
integer k, bi, bj |
|
|
|
|
|
c input/output |
|
|
c fld : 2-D array to be smoothed |
|
|
_KPP_RL fld( ibot:itop, jbot:jtop ) |
|
|
|
|
|
#ifdef ALLOW_KPP |
|
|
|
|
|
c local |
|
|
integer i, j, im1, ip1, jm1, jp1 |
|
|
_KPP_RL tempVar |
|
|
_KPP_RL fld_tmp( ibot:itop, jbot:jtop ) |
|
|
|
|
|
integer imin , imax , jmin , jmax |
|
|
parameter( imin=ibot+1, imax=itop-1, jmin=jbot+1, jmax=jtop-1 ) |
|
|
|
|
|
_KPP_RL p0 , p5 , p25 , p125 , p0625 |
|
|
parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 ) |
|
|
|
|
|
DO j = jmin, jmax |
|
|
jm1 = j-1 |
|
|
jp1 = j+1 |
|
|
DO i = imin, imax |
|
|
im1 = i-1 |
|
|
ip1 = i+1 |
|
|
tempVar = |
|
|
& p25 * maskC(i ,j ,k,bi,bj) + |
|
|
& p125 * ( maskC(im1,j ,k,bi,bj) + |
|
|
& maskC(ip1,j ,k,bi,bj) + |
|
|
& maskC(i ,jm1,k,bi,bj) + |
|
|
& maskC(i ,jp1,k,bi,bj) ) + |
|
|
& p0625 * ( maskC(im1,jm1,k,bi,bj) + |
|
|
& maskC(im1,jp1,k,bi,bj) + |
|
|
& maskC(ip1,jm1,k,bi,bj) + |
|
|
& maskC(ip1,jp1,k,bi,bj) ) |
|
|
IF ( tempVar .GE. p25 ) THEN |
|
|
fld_tmp(i,j) = ( |
|
|
& p25 * fld(i ,j )*maskC(i ,j ,k,bi,bj) + |
|
|
& p125 *(fld(im1,j )*maskC(im1,j ,k,bi,bj) + |
|
|
& fld(ip1,j )*maskC(ip1,j ,k,bi,bj) + |
|
|
& fld(i ,jm1)*maskC(i ,jm1,k,bi,bj) + |
|
|
& fld(i ,jp1)*maskC(i ,jp1,k,bi,bj))+ |
|
|
& p0625*(fld(im1,jm1)*maskC(im1,jm1,k,bi,bj) + |
|
|
& fld(im1,jp1)*maskC(im1,jp1,k,bi,bj) + |
|
|
& fld(ip1,jm1)*maskC(ip1,jm1,k,bi,bj) + |
|
|
& fld(ip1,jp1)*maskC(ip1,jp1,k,bi,bj))) |
|
|
& / tempVar |
|
|
ELSE |
|
|
fld_tmp(i,j) = fld(i,j) |
|
|
ENDIF |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
|
c transfer smoothed field to output array |
|
|
DO j = jmin, jmax |
|
|
DO i = imin, imax |
|
|
fld(i,j) = fld_tmp(i,j) |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
|
#endif /* ALLOW_KPP */ |
|
|
|
|
|
return |
|
|
end |
|
|
|
|
|
c************************************************************************* |
|
|
|
|
1061 |
subroutine smooth_horiz ( |
subroutine smooth_horiz ( |
1062 |
I k, bi, bj, |
I k, bi, bj, |
1063 |
U fld ) |
U fld, |
1064 |
|
I myThid ) |
1065 |
|
|
1066 |
c Apply horizontal smoothing to global _RL 2-D array |
c Apply horizontal smoothing to global _RL 2-D array |
1067 |
|
|
1073 |
c input |
c input |
1074 |
c bi, bj : array indices |
c bi, bj : array indices |
1075 |
c k : vertical index used for masking |
c k : vertical index used for masking |
1076 |
|
c myThid : thread number for this instance of the routine |
1077 |
|
INTEGER myThid |
1078 |
integer k, bi, bj |
integer k, bi, bj |
1079 |
|
|
1080 |
c input/output |
c input/output |
1145 |
subroutine blmix ( |
subroutine blmix ( |
1146 |
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
I ustar, bfsfc, hbl, stable, casea, diffus, kbl |
1147 |
O , dkm1, blmc, ghat, sigma, ikppkey |
O , dkm1, blmc, ghat, sigma, ikppkey |
1148 |
& ) |
I , myThid ) |
1149 |
|
|
1150 |
c mixing coefficients within boundary layer depend on surface |
c mixing coefficients within boundary layer depend on surface |
1151 |
c forcing and the magnitude and gradient of interior mixing below |
c forcing and the magnitude and gradient of interior mixing below |
1159 |
|
|
1160 |
#include "SIZE.h" |
#include "SIZE.h" |
1161 |
#include "KPP_PARAMS.h" |
#include "KPP_PARAMS.h" |
1162 |
|
#ifdef ALLOW_AUTODIFF |
1163 |
|
# include "tamc.h" |
1164 |
|
#endif |
1165 |
|
|
1166 |
c input |
c input |
1167 |
c ustar (imt) surface friction velocity (m/s) |
c ustar (imt) surface friction velocity (m/s) |
1170 |
c stable(imt) = 1 in stable forcing |
c stable(imt) = 1 in stable forcing |
1171 |
c casea (imt) = 1 in case A |
c casea (imt) = 1 in case A |
1172 |
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
1173 |
c kbl(imt) -1 of first grid level below hbl |
c kbl (imt) -1 of first grid level below hbl |
1174 |
_KPP_RL ustar (imt) |
c myThid thread number for this instance of the routine |
1175 |
_KPP_RL bfsfc (imt) |
integer myThid |
1176 |
_KPP_RL hbl (imt) |
_RL ustar (imt) |
1177 |
_KPP_RL stable(imt) |
_RL bfsfc (imt) |
1178 |
_KPP_RL casea (imt) |
_RL hbl (imt) |
1179 |
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
_RL stable(imt) |
1180 |
|
_RL casea (imt) |
1181 |
|
_RL diffus(imt,0:Nrp1,mdiff) |
1182 |
integer kbl(imt) |
integer kbl(imt) |
1183 |
|
|
1184 |
c output |
c output |
1186 |
c blmc (imt,Nr,mdiff) boundary layer mixing coefficients (m^2/s) |
c blmc (imt,Nr,mdiff) boundary layer mixing coefficients (m^2/s) |
1187 |
c ghat (imt,Nr) nonlocal scalar transport |
c ghat (imt,Nr) nonlocal scalar transport |
1188 |
c sigma(imt) normalized depth (d / hbl) |
c sigma(imt) normalized depth (d / hbl) |
1189 |
_KPP_RL dkm1 (imt,mdiff) |
_RL dkm1 (imt,mdiff) |
1190 |
_KPP_RL blmc (imt,Nr,mdiff) |
_RL blmc (imt,Nr,mdiff) |
1191 |
_KPP_RL ghat (imt,Nr) |
_RL ghat (imt,Nr) |
1192 |
_KPP_RL sigma(imt) |
_RL sigma(imt) |
1193 |
integer ikppkey, kkppkey |
integer ikppkey, kkppkey |
1194 |
|
|
1195 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
1198 |
c gat1*(imt) shape function at sigma = 1 |
c gat1*(imt) shape function at sigma = 1 |
1199 |
c dat1*(imt) derivative of shape function at sigma = 1 |
c dat1*(imt) derivative of shape function at sigma = 1 |
1200 |
c ws(imt), wm(imt) turbulent velocity scales (m/s) |
c ws(imt), wm(imt) turbulent velocity scales (m/s) |
1201 |
_KPP_RL gat1m(imt), gat1s(imt), gat1t(imt) |
_RL gat1m(imt), gat1s(imt), gat1t(imt) |
1202 |
_KPP_RL dat1m(imt), dat1s(imt), dat1t(imt) |
_RL dat1m(imt), dat1s(imt), dat1t(imt) |
1203 |
_KPP_RL ws(imt), wm(imt) |
_RL ws(imt), wm(imt) |
1204 |
integer i, kn, ki |
integer i, kn, ki |
1205 |
_KPP_RL R, dvdzup, dvdzdn, viscp |
_RL R, dvdzup, dvdzdn, viscp |
1206 |
_KPP_RL difsp, diftp, visch, difsh, difth |
_RL difsp, diftp, visch, difsh, difth |
1207 |
_KPP_RL f1, sig, a1, a2, a3, delhat |
_RL f1, sig, a1, a2, a3, delhat |
1208 |
_KPP_RL Gm, Gs, Gt |
_RL Gm, Gs, Gt |
1209 |
_KPP_RL tempVar |
_RL tempVar |
1210 |
|
|
1211 |
_KPP_RL p0 , eins |
_RL p0 , eins |
1212 |
parameter (p0=0.0, eins=1.0) |
parameter (p0=0.0, eins=1.0) |
1213 |
|
|
1214 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
1219 |
sigma(i) = stable(i) * 1.0 + (1. - stable(i)) * epsilon |
sigma(i) = stable(i) * 1.0 + (1. - stable(i)) * epsilon |
1220 |
end do |
end do |
1221 |
|
|
1222 |
CADJ STORE sigma = comlev1_kpp, key = ikppkey |
CADJ STORE sigma = comlev1_kpp, key=ikppkey, kind=isbyte |
1223 |
call wscale ( |
call wscale ( |
1224 |
I sigma, hbl, ustar, bfsfc, |
I sigma, hbl, ustar, bfsfc, |
1225 |
O wm, ws ) |
O wm, ws, myThid ) |
1226 |
CADJ STORE wm = comlev1_kpp, key = ikppkey |
CADJ STORE wm = comlev1_kpp, key=ikppkey, kind=isbyte |
1227 |
CADJ STORE ws = comlev1_kpp, key = ikppkey |
CADJ STORE ws = comlev1_kpp, key=ikppkey, kind=isbyte |
1228 |
|
|
1229 |
do i = 1, imt |
do i = 1, imt |
1230 |
wm(i) = sign(eins,wm(i))*max(phepsi,abs(wm(i))) |
wm(i) = sign(eins,wm(i))*max(phepsi,abs(wm(i))) |
1231 |
ws(i) = sign(eins,ws(i))*max(phepsi,abs(ws(i))) |
ws(i) = sign(eins,ws(i))*max(phepsi,abs(ws(i))) |
1232 |
end do |
end do |
1233 |
CADJ STORE wm = comlev1_kpp, key = ikppkey |
CADJ STORE wm = comlev1_kpp, key=ikppkey, kind=isbyte |
1234 |
CADJ STORE ws = comlev1_kpp, key = ikppkey |
CADJ STORE ws = comlev1_kpp, key=ikppkey, kind=isbyte |
1235 |
|
|
1236 |
do i = 1, imt |
do i = 1, imt |
1237 |
|
|
1276 |
|
|
1277 |
end do |
end do |
1278 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1279 |
CADJ STORE gat1m = comlev1_kpp, key = ikppkey |
CADJ STORE gat1m = comlev1_kpp, key=ikppkey, kind=isbyte |
1280 |
CADJ STORE gat1s = comlev1_kpp, key = ikppkey |
CADJ STORE gat1s = comlev1_kpp, key=ikppkey, kind=isbyte |
1281 |
CADJ STORE gat1t = comlev1_kpp, key = ikppkey |
CADJ STORE gat1t = comlev1_kpp, key=ikppkey, kind=isbyte |
1282 |
CADJ STORE dat1m = comlev1_kpp, key = ikppkey |
CADJ STORE dat1m = comlev1_kpp, key=ikppkey, kind=isbyte |
1283 |
CADJ STORE dat1s = comlev1_kpp, key = ikppkey |
CADJ STORE dat1s = comlev1_kpp, key=ikppkey, kind=isbyte |
1284 |
CADJ STORE dat1t = comlev1_kpp, key = ikppkey |
CADJ STORE dat1t = comlev1_kpp, key=ikppkey, kind=isbyte |
1285 |
#endif |
#endif |
1286 |
do i = 1, imt |
do i = 1, imt |
1287 |
dat1m(i) = min(dat1m(i),p0) |
dat1m(i) = min(dat1m(i),p0) |
1289 |
dat1t(i) = min(dat1t(i),p0) |
dat1t(i) = min(dat1t(i),p0) |
1290 |
end do |
end do |
1291 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1292 |
CADJ STORE dat1m = comlev1_kpp, key = ikppkey |
CADJ STORE dat1m = comlev1_kpp, key=ikppkey, kind=isbyte |
1293 |
CADJ STORE dat1s = comlev1_kpp, key = ikppkey |
CADJ STORE dat1s = comlev1_kpp, key=ikppkey, kind=isbyte |
1294 |
CADJ STORE dat1t = comlev1_kpp, key = ikppkey |
CADJ STORE dat1t = comlev1_kpp, key=ikppkey, kind=isbyte |
1295 |
#endif |
#endif |
1296 |
|
|
1297 |
do ki = 1, Nr |
do ki = 1, Nr |
1315 |
CADJ STORE sigma = comlev1_kpp_k, key = kkppkey |
CADJ STORE sigma = comlev1_kpp_k, key = kkppkey |
1316 |
call wscale ( |
call wscale ( |
1317 |
I sigma, hbl, ustar, bfsfc, |
I sigma, hbl, ustar, bfsfc, |
1318 |
O wm, ws ) |
O wm, ws, myThid ) |
1319 |
CADJ STORE wm = comlev1_kpp_k, key = kkppkey |
CADJ STORE wm = comlev1_kpp_k, key = kkppkey |
1320 |
CADJ STORE ws = comlev1_kpp_k, key = kkppkey |
CADJ STORE ws = comlev1_kpp_k, key = kkppkey |
1321 |
|
|
1362 |
end do |
end do |
1363 |
|
|
1364 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1365 |
CADJ STORE wm = comlev1_kpp, key = ikppkey |
CADJ STORE wm = comlev1_kpp, key=ikppkey, kind=isbyte |
1366 |
CADJ STORE ws = comlev1_kpp, key = ikppkey |
CADJ STORE ws = comlev1_kpp, key=ikppkey, kind=isbyte |
1367 |
#endif |
#endif |
1368 |
CADJ STORE sigma = comlev1_kpp, key = ikppkey |
CADJ STORE sigma = comlev1_kpp, key=ikppkey, kind=isbyte |
1369 |
call wscale ( |
call wscale ( |
1370 |
I sigma, hbl, ustar, bfsfc, |
I sigma, hbl, ustar, bfsfc, |
1371 |
O wm, ws ) |
O wm, ws, myThid ) |
1372 |
CADJ STORE wm = comlev1_kpp, key = ikppkey |
CADJ STORE wm = comlev1_kpp, key=ikppkey, kind=isbyte |
1373 |
CADJ STORE ws = comlev1_kpp, key = ikppkey |
CADJ STORE ws = comlev1_kpp, key=ikppkey, kind=isbyte |
1374 |
|
|
1375 |
do i = 1, imt |
do i = 1, imt |
1376 |
sig = -zgrid(kbl(i)-1) / hbl(i) |
sig = -zgrid(kbl(i)-1) / hbl(i) |
1396 |
I dkm1, hbl, kbl, diffus, casea |
I dkm1, hbl, kbl, diffus, casea |
1397 |
U , ghat |
U , ghat |
1398 |
O , blmc |
O , blmc |
1399 |
& ) |
& , myThid ) |
1400 |
|
|
1401 |
c enhance the diffusivity at the kbl-.5 interface |
c enhance the diffusivity at the kbl-.5 interface |
1402 |
|
|
1411 |
c kbl(imt) grid above hbl |
c kbl(imt) grid above hbl |
1412 |
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
c diffus(imt,0:Nrp1,mdiff) vertical diffusivities (m^2/s) |
1413 |
c casea(imt) = 1 in caseA, = 0 in case B |
c casea(imt) = 1 in caseA, = 0 in case B |
1414 |
_KPP_RL dkm1 (imt,mdiff) |
c myThid thread number for this instance of the routine |
1415 |
_KPP_RL hbl (imt) |
integer myThid |
1416 |
|
_RL dkm1 (imt,mdiff) |
1417 |
|
_RL hbl (imt) |
1418 |
integer kbl (imt) |
integer kbl (imt) |
1419 |
_KPP_RL diffus(imt,0:Nrp1,mdiff) |
_RL diffus(imt,0:Nrp1,mdiff) |
1420 |
_KPP_RL casea (imt) |
_RL casea (imt) |
1421 |
|
|
1422 |
c input/output |
c input/output |
1423 |
c nonlocal transport, modified ghat at kbl(i)-1 interface (s/m**2) |
c nonlocal transport, modified ghat at kbl(i)-1 interface (s/m**2) |
1424 |
_KPP_RL ghat (imt,Nr) |
_RL ghat (imt,Nr) |
1425 |
|
|
1426 |
c output |
c output |
1427 |
c enhanced bound. layer mixing coeff. |
c enhanced bound. layer mixing coeff. |
1428 |
_KPP_RL blmc (imt,Nr,mdiff) |
_RL blmc (imt,Nr,mdiff) |
1429 |
|
|
1430 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
1431 |
|
|
1432 |
c local |
c local |
1433 |
c fraction hbl lies beteen zgrid neighbors |
c fraction hbl lies beteen zgrid neighbors |
1434 |
_KPP_RL delta |
_RL delta |
1435 |
integer ki, i, md |
integer ki, i, md |
1436 |
_KPP_RL dkmp5, dstar |
_RL dkmp5, dstar |
1437 |
|
|
1438 |
do i = 1, imt |
do i = 1, imt |
1439 |
ki = kbl(i)-1 |
ki = kbl(i)-1 |
1459 |
c************************************************************************* |
c************************************************************************* |
1460 |
|
|
1461 |
SUBROUTINE STATEKPP ( |
SUBROUTINE STATEKPP ( |
1462 |
I ikppkey, bi, bj, myThid, |
O RHO1, DBLOC, DBSFC, TTALPHA, SSBETA, |
1463 |
O RHO1, DBLOC, DBSFC, TTALPHA, SSBETA) |
I ikppkey, bi, bj, myThid ) |
1464 |
c |
c |
1465 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
1466 |
c "statekpp" computes all necessary input arrays |
c "statekpp" computes all necessary input arrays |
1485 |
c written by: jan morzel, feb. 10, 1995 (converted from "sigma" version) |
c written by: jan morzel, feb. 10, 1995 (converted from "sigma" version) |
1486 |
c modified by: d. menemenlis, june 1998 : for use with MIT GCM UV |
c modified by: d. menemenlis, june 1998 : for use with MIT GCM UV |
1487 |
c |
c |
1488 |
|
|
1489 |
c----------------------------------------------------------------------- |
c----------------------------------------------------------------------- |
1490 |
|
|
1491 |
IMPLICIT NONE |
IMPLICIT NONE |
1495 |
#include "PARAMS.h" |
#include "PARAMS.h" |
1496 |
#include "KPP_PARAMS.h" |
#include "KPP_PARAMS.h" |
1497 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
1498 |
|
#include "GRID.h" |
1499 |
|
#ifdef ALLOW_AUTODIFF |
1500 |
|
# include "tamc.h" |
1501 |
|
#endif |
1502 |
|
|
1503 |
c-------------- Routine arguments ----------------------------------------- |
c-------------- Routine arguments ----------------------------------------- |
1504 |
INTEGER bi, bj, myThid |
INTEGER bi, bj, myThid |
1505 |
_KPP_RL RHO1 ( ibot:itop, jbot:jtop ) |
_RL RHO1 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy ) |
1506 |
_KPP_RL DBLOC ( ibot:itop, jbot:jtop, Nr ) |
_RL DBLOC ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr ) |
1507 |
_KPP_RL DBSFC ( ibot:itop, jbot:jtop, Nr ) |
_RL DBSFC ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr ) |
1508 |
_KPP_RL TTALPHA( ibot:itop, jbot:jtop, Nrp1 ) |
_RL TTALPHA( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 ) |
1509 |
_KPP_RL SSBETA ( ibot:itop, jbot:jtop, Nrp1 ) |
_RL SSBETA ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 ) |
1510 |
|
|
1511 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
1512 |
|
|
1517 |
c rhok - density of t(k ) & s(k ) at depth k |
c rhok - density of t(k ) & s(k ) at depth k |
1518 |
c rhokm1 - density of t(k-1) & s(k-1) at depth k |
c rhokm1 - density of t(k-1) & s(k-1) at depth k |
1519 |
c rho1k - density of t(1 ) & s(1 ) at depth k |
c rho1k - density of t(1 ) & s(1 ) at depth k |
1520 |
c work1, work2 - work arrays for holding horizontal slabs |
c work1,2,3 - work arrays for holding horizontal slabs |
1521 |
|
|
1522 |
_RL RHOK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL RHOK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1523 |
_RL RHOKM1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL RHOKM1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1525 |
_RL WORK1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL WORK1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1526 |
_RL WORK2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL WORK2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1527 |
_RL WORK3 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL WORK3 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
1528 |
|
|
1529 |
INTEGER I, J, K |
INTEGER I, J, K |
1530 |
INTEGER ikppkey, kkppkey |
INTEGER ikppkey, kkppkey |
1531 |
|
|
1534 |
kkppkey = (ikppkey-1)*Nr + 1 |
kkppkey = (ikppkey-1)*Nr + 1 |
1535 |
|
|
1536 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1537 |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, |
1538 |
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1539 |
|
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, |
1540 |
|
CADJ & key=kkppkey, kind=isbyte |
1541 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1542 |
call FIND_RHO( |
CALL FIND_RHO_2D( |
1543 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, 1, |
1544 |
I theta, salt, |
I theta(1-OLx,1-OLy,1,bi,bj), salt(1-OLx,1-OLy,1,bi,bj), |
1545 |
O WORK1, |
O WORK1, |
1546 |
I myThid ) |
I 1, bi, bj, myThid ) |
1547 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1548 |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, |
1549 |
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1550 |
|
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, |
1551 |
|
CADJ & key=kkppkey, kind=isbyte |
1552 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1553 |
|
|
1554 |
call FIND_ALPHA( |
call FIND_ALPHA( |
1555 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
I bi, bj, 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, 1, 1, |
1556 |
O WORK2 ) |
O WORK2, myThid ) |
1557 |
|
|
1558 |
call FIND_BETA( |
call FIND_BETA( |
1559 |
I bi, bj, ibot, itop, jbot, jtop, 1, 1, |
I bi, bj, 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, 1, 1, |
1560 |
O WORK3 ) |
O WORK3, myThid ) |
1561 |
|
|
1562 |
DO J = jbot, jtop |
DO J = 1-OLy, sNy+OLy |
1563 |
DO I = ibot, itop |
DO I = 1-OLx, sNx+OLx |
1564 |
RHO1(I,J) = WORK1(I,J) + rhoConst |
RHO1(I,J) = WORK1(I,J) + rhoConst |
1565 |
TTALPHA(I,J,1) = WORK2(I,J) |
TTALPHA(I,J,1) = WORK2(I,J) |
1566 |
SSBETA(I,J,1) = WORK3(I,J) |
SSBETA(I,J,1) = WORK3(I,J) |
1576 |
kkppkey = (ikppkey-1)*Nr + k |
kkppkey = (ikppkey-1)*Nr + k |
1577 |
|
|
1578 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1579 |
CADJ STORE theta(:,:,k,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ STORE theta(:,:,k,bi,bj) = comlev1_kpp_k, |
1580 |
CADJ STORE salt (:,:,k,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1581 |
|
CADJ STORE salt (:,:,k,bi,bj) = comlev1_kpp_k, |
1582 |
|
CADJ & key=kkppkey, kind=isbyte |
1583 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1584 |
call FIND_RHO( |
CALL FIND_RHO_2D( |
1585 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, k, |
1586 |
I theta, salt, |
I theta(1-OLx,1-OLy,k,bi,bj), salt(1-OLx,1-OLy,k,bi,bj), |
1587 |
O RHOK, |
O RHOK, |
1588 |
I myThid ) |
I k, bi, bj, myThid ) |
1589 |
|
|
1590 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1591 |
CADJ STORE theta(:,:,k-1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ STORE theta(:,:,k-1,bi,bj) = comlev1_kpp_k, |
1592 |
CADJ STORE salt (:,:,k-1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1593 |
|
CADJ STORE salt (:,:,k-1,bi,bj) = comlev1_kpp_k, |
1594 |
|
CADJ & key=kkppkey, kind=isbyte |
1595 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1596 |
call FIND_RHO( |
CALL FIND_RHO_2D( |
1597 |
I bi, bj, ibot, itop, jbot, jtop, K-1, K, |
I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, k, |
1598 |
I theta, salt, |
I theta(1-OLx,1-OLy,k-1,bi,bj),salt(1-OLx,1-OLy,k-1,bi,bj), |
1599 |
O RHOKM1, |
O RHOKM1, |
1600 |
I myThid ) |
I k-1, bi, bj, myThid ) |
1601 |
|
|
1602 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1603 |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ STORE theta(:,:,1,bi,bj) = comlev1_kpp_k, |
1604 |
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1605 |
|
CADJ STORE salt (:,:,1,bi,bj) = comlev1_kpp_k, |
1606 |
|
CADJ & key=kkppkey, kind=isbyte |
1607 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1608 |
call FIND_RHO( |
CALL FIND_RHO_2D( |
1609 |
I bi, bj, ibot, itop, jbot, jtop, 1, K, |
I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, k, |
1610 |
I theta, salt, |
I theta(1-OLx,1-OLy,1,bi,bj), salt(1-OLx,1-OLy,1,bi,bj), |
1611 |
O RHO1K, |
O RHO1K, |
1612 |
I myThid ) |
I 1, bi, bj, myThid ) |
1613 |
|
|
1614 |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
#ifdef KPP_AUTODIFF_EXCESSIVE_STORE |
1615 |
CADJ STORE rhok (:,:) = comlev1_kpp_k, key=kkppkey |
CADJ STORE rhok (:,:) = comlev1_kpp_k, |
1616 |
CADJ STORE rhokm1(:,:) = comlev1_kpp_k, key=kkppkey |
CADJ & key=kkppkey, kind=isbyte |
1617 |
CADJ STORE rho1k (:,:) = comlev1_kpp_k, key=kkppkey |
CADJ STORE rhokm1(:,:) = comlev1_kpp_k, |
1618 |
|
CADJ & key=kkppkey, kind=isbyte |
1619 |
|
CADJ STORE rho1k (:,:) = comlev1_kpp_k, |
1620 |
|
CADJ & key=kkppkey, kind=isbyte |
1621 |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
#endif /* KPP_AUTODIFF_EXCESSIVE_STORE */ |
1622 |
|
|
1623 |
call FIND_ALPHA( |
call FIND_ALPHA( |
1624 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
I bi, bj, 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, K, K, |
1625 |
O WORK1 ) |
O WORK1, myThid ) |
1626 |
|
|
1627 |
call FIND_BETA( |
call FIND_BETA( |
1628 |
I bi, bj, ibot, itop, jbot, jtop, K, K, |
I bi, bj, 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, K, K, |
1629 |
O WORK2 ) |
O WORK2, myThid ) |
1630 |
|
|
1631 |
DO J = jbot, jtop |
DO J = 1-OLy, sNy+OLy |
1632 |
DO I = ibot, itop |
DO I = 1-OLx, sNx+OLx |
1633 |
TTALPHA(I,J,K) = WORK1 (I,J) |
TTALPHA(I,J,K) = WORK1 (I,J) |
1634 |
SSBETA(I,J,K) = WORK2 (I,J) |
SSBETA(I,J,K) = WORK2 (I,J) |
1635 |
DBLOC(I,J,K-1) = gravity * (RHOK(I,J) - RHOKM1(I,J)) / |
DBLOC(I,J,K-1) = gravity * (RHOK(I,J) - RHOKM1(I,J)) / |
1642 |
END DO |
END DO |
1643 |
|
|
1644 |
c compute arrays for K = Nrp1 |
c compute arrays for K = Nrp1 |
1645 |
DO J = jbot, jtop |
DO J = 1-OLy, sNy+OLy |
1646 |
DO I = ibot, itop |
DO I = 1-OLx, sNx+OLx |
1647 |
TTALPHA(I,J,Nrp1) = TTALPHA(I,J,Nr) |
TTALPHA(I,J,Nrp1) = TTALPHA(I,J,Nr) |
1648 |
SSBETA(I,J,Nrp1) = SSBETA(I,J,Nr) |
SSBETA(I,J,Nrp1) = SSBETA(I,J,Nr) |
1649 |
DBLOC(I,J,Nr) = 0. |
DBLOC(I,J,Nr) = 0. |
1650 |
END DO |
END DO |
1651 |
END DO |
END DO |
1652 |
|
|
1653 |
|
#ifdef ALLOW_DIAGNOSTICS |
1654 |
|
IF ( useDiagnostics ) THEN |
1655 |
|
CALL DIAGNOSTICS_FILL(DBSFC ,'KPPdbsfc',0,Nr,0,1,1,myThid) |
1656 |
|
CALL DIAGNOSTICS_FILL(DBLOC ,'KPPdbloc',0,Nr,0,1,1,myThid) |
1657 |
|
ENDIF |
1658 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
1659 |
|
|
1660 |
#endif /* ALLOW_KPP */ |
#endif /* ALLOW_KPP */ |
1661 |
|
|
1662 |
RETURN |
RETURN |