1 |
C $Header: /u/gcmpack/models/MITgcmUV/pkg/kpp/kpp_calc.F,v 1.5 2000/11/29 22:29:23 adcroft Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "KPP_OPTIONS.h" |
5 |
|
6 |
subroutine KPP_CALC( |
7 |
I bi, bj, myTime, myThid ) |
8 |
C /==========================================================\ |
9 |
C | SUBROUTINE KPP_CALC | |
10 |
C | o Compute all KPP fields defined in KPP.h | |
11 |
C |==========================================================| |
12 |
C | This subroutine serves as an interface between MITGCMUV | |
13 |
C | code and NCOM 1-D routines in kpp_routines.F | |
14 |
C \==========================================================/ |
15 |
IMPLICIT NONE |
16 |
|
17 |
c======================================================================= |
18 |
c |
19 |
c written by : jan morzel, august 11, 1994 |
20 |
c modified by : jan morzel, january 25, 1995 : "dVsq" and 1d code |
21 |
c detlef stammer, august, 1997 : for MIT GCM Classic |
22 |
c d. menemenlis, july, 1998 : for MIT GCM UV |
23 |
c |
24 |
c compute vertical mixing coefficients based on the k-profile |
25 |
c and oceanic planetary boundary layer scheme by large & mcwilliams. |
26 |
c |
27 |
c summary: |
28 |
c - compute interior mixing everywhere: |
29 |
c interior mixing gets computed at all interfaces due to constant |
30 |
c internal wave background activity ("fkpm" and "fkph"), which |
31 |
c is enhanced in places of static instability (local richardson |
32 |
c number < 0). |
33 |
c Additionally, mixing can be enhanced by adding contribution due |
34 |
c to shear instability which is a function of the local richardson |
35 |
c number |
36 |
c - double diffusivity: |
37 |
c interior mixing can be enhanced by double diffusion due to salt |
38 |
c fingering and diffusive convection (ifdef "kmixdd"). |
39 |
c - kpp scheme in the boundary layer: |
40 |
c |
41 |
c a.boundary layer depth: |
42 |
c at every gridpoint the depth of the oceanic boundary layer |
43 |
c ("hbl") gets computed by evaluating bulk richardson numbers. |
44 |
c b.boundary layer mixing: |
45 |
c within the boundary layer, above hbl, vertical mixing is |
46 |
c determined by turbulent surface fluxes, and interior mixing at |
47 |
c the lower boundary, i.e. at hbl. |
48 |
c |
49 |
c this subroutine provides the interface between the MIT GCM UV and the |
50 |
c subroutine "kppmix", where boundary layer depth, vertical |
51 |
c viscosity, vertical diffusivity, and counter gradient term (ghat) |
52 |
c are computed slabwise. |
53 |
c note: subroutine "kppmix" uses m-k-s units. |
54 |
c |
55 |
c time level: |
56 |
c input tracer and velocity profiles are evaluated at time level |
57 |
c tau, surface fluxes come from tau or tau-1. |
58 |
c |
59 |
c grid option: |
60 |
c in this "1-grid" implementation, diffusivity and viscosity |
61 |
c profiles are computed on the "t-grid" (by using velocity shear |
62 |
c profiles averaged from the "u,v-grid" onto the "t-grid"; note, that |
63 |
c the averaging includes zero values on coastal and seafloor grid |
64 |
c points). viscosity on the "u,v-grid" is computed by averaging the |
65 |
c "t-grid" viscosity values onto the "u,v-grid". |
66 |
c |
67 |
c vertical grid: |
68 |
c mixing coefficients get evaluated at the bottom of the lowest |
69 |
c layer, i.e., at depth zw(Nr). these values are only useful when |
70 |
c the model ocean domain does not include the entire ocean down to |
71 |
c the seafloor ("upperocean" setup) and allows flux through the |
72 |
c bottom of the domain. for full-depth runs, these mixing |
73 |
c coefficients are being zeroed out before leaving this subroutine. |
74 |
c |
75 |
c------------------------------------------------------------------------- |
76 |
|
77 |
c global parameters updated by kpp_calc |
78 |
c KPPviscAz - KPP eddy viscosity coefficient (m^2/s) |
79 |
c KPPdiffKzT - KPP diffusion coefficient for temperature (m^2/s) |
80 |
c KPPdiffKzS - KPP diffusion coefficient for salt and tracers (m^2/s) |
81 |
c KPPghat - Nonlocal transport coefficient (s/m^2) |
82 |
c KPPhbl - Boundary layer depth on "t-grid" (m) |
83 |
c KPPfrac - Fraction of short-wave flux penetrating mixing layer |
84 |
|
85 |
c-- KPP_CALC computes vertical viscosity and diffusivity for region |
86 |
c (-2:sNx+3,-2:sNy+3) as required by CALC_DIFFUSIVITY and requires |
87 |
c values of uVel, vVel, SurfaceTendencyU, SurfaceTendencyV in the |
88 |
c region (-2:sNx+4,-2:sNy+4). |
89 |
c Hence overlap region needs to be set OLx=4, OLy=4. |
90 |
c When option FRUGAL_KPP is used, computation in overlap regions |
91 |
c is replaced with exchange calls hence reducing overlap requirements |
92 |
c to OLx=1, OLy=1. |
93 |
|
94 |
#include "SIZE.h" |
95 |
#include "EEPARAMS.h" |
96 |
#include "PARAMS.h" |
97 |
#include "DYNVARS.h" |
98 |
#include "KPP.h" |
99 |
#include "KPP_PARAMS.h" |
100 |
#include "FFIELDS.h" |
101 |
#include "GRID.h" |
102 |
|
103 |
#ifdef ALLOW_AUTODIFF_TAMC |
104 |
#include "tamc.h" |
105 |
#include "tamc_keys.h" |
106 |
INTEGER isbyte |
107 |
PARAMETER( isbyte = 4 ) |
108 |
#else /* ALLOW_AUTODIFF_TAMC */ |
109 |
integer ikey |
110 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
111 |
|
112 |
EXTERNAL DIFFERENT_MULTIPLE |
113 |
LOGICAL DIFFERENT_MULTIPLE |
114 |
|
115 |
c Routine arguments |
116 |
c bi, bj - array indices on which to apply calculations |
117 |
c myTime - Current time in simulation |
118 |
|
119 |
INTEGER bi, bj |
120 |
INTEGER myThid |
121 |
_RL myTime |
122 |
|
123 |
#ifdef ALLOW_KPP |
124 |
|
125 |
c Local constants |
126 |
c minusone, p0, p5, p25, p125, p0625 |
127 |
c imin, imax, jmin, jmax - array computation indices |
128 |
|
129 |
_RL minusone |
130 |
parameter( minusone=-1.0) |
131 |
_KPP_RL p0 , p5 , p25 , p125 , p0625 |
132 |
parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 ) |
133 |
integer imin , imax , jmin , jmax |
134 |
#ifdef FRUGAL_KPP |
135 |
parameter( imin=1 , imax=sNx , jmin=1 , jmax=sNy ) |
136 |
#else |
137 |
parameter( imin=-2 , imax=sNx+3 , jmin=-2 , jmax=sNy+3 ) |
138 |
#endif |
139 |
|
140 |
c Local arrays and variables |
141 |
c work? (nx,ny) - horizontal working arrays |
142 |
c ustar (nx,ny) - surface friction velocity (m/s) |
143 |
c bo (nx,ny) - surface turbulent buoyancy forcing (m^2/s^3) |
144 |
c bosol (nx,ny) - surface radiative buoyancy forcing (m^2/s^3) |
145 |
c shsq (nx,ny,Nr) - local velocity shear squared |
146 |
c at interfaces for ri_iwmix (m^2/s^2) |
147 |
c dVsq (nx,ny,Nr) - velocity shear re surface squared |
148 |
c at grid levels for bldepth (m^2/s^2) |
149 |
c dbloc (nx,ny,Nr) - local delta buoyancy at interfaces |
150 |
c for ri_iwmix and bldepth (m/s^2) |
151 |
c Ritop (nx,ny,Nr) - numerator of bulk richardson number |
152 |
c at grid levels for bldepth |
153 |
c vddiff (nx,ny,Nrp2,1)- vertical viscosity on "t-grid" (m^2/s) |
154 |
c vddiff (nx,ny,Nrp2,2)- vert. diff. on next row for temperature (m^2/s) |
155 |
c vddiff (nx,ny,Nrp2,3)- vert. diff. on next row for salt&tracers (m^2/s) |
156 |
c ghat (nx,ny,Nr) - nonlocal transport coefficient (s/m^2) |
157 |
c hbl (nx,ny) - mixing layer depth (m) |
158 |
c kmtj (nx,ny) - maximum number of wet levels in each column |
159 |
c z0 (nx,ny) - Roughness length (m) |
160 |
c zRef (nx,ny) - Reference depth: Hmix * epsilon (m) |
161 |
c uRef (nx,ny) - Reference zonal velocity (m/s) |
162 |
c vRef (nx,ny) - Reference meridional velocity (m/s) |
163 |
|
164 |
_RL worka ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy ) |
165 |
integer work1 ( ibot:itop , jbot:jtop ) |
166 |
_KPP_RL work2 ( ibot:itop , jbot:jtop ) |
167 |
_KPP_RL ustar ( ibot:itop , jbot:jtop ) |
168 |
_KPP_RL bo ( ibot:itop , jbot:jtop ) |
169 |
_KPP_RL bosol ( ibot:itop , jbot:jtop ) |
170 |
_KPP_RL shsq ( ibot:itop , jbot:jtop , Nr ) |
171 |
_KPP_RL dVsq ( ibot:itop , jbot:jtop , Nr ) |
172 |
_KPP_RL dbloc ( ibot:itop , jbot:jtop , Nr ) |
173 |
_KPP_RL Ritop ( ibot:itop , jbot:jtop , Nr ) |
174 |
_KPP_RL vddiff( ibot:itop , jbot:jtop , 0:Nrp1, mdiff ) |
175 |
_KPP_RL ghat ( ibot:itop , jbot:jtop , Nr ) |
176 |
_KPP_RL hbl ( ibot:itop , jbot:jtop ) |
177 |
#ifdef KPP_ESTIMATE_UREF |
178 |
_KPP_RL z0 ( ibot:itop , jbot:jtop ) |
179 |
_KPP_RL zRef ( ibot:itop , jbot:jtop ) |
180 |
_KPP_RL uRef ( ibot:itop , jbot:jtop ) |
181 |
_KPP_RL vRef ( ibot:itop , jbot:jtop ) |
182 |
#endif /* KPP_ESTIMATE_UREF */ |
183 |
|
184 |
_KPP_RL tempvar1, tempvar2 |
185 |
integer i, j, k, kp1, im1, ip1, jm1, jp1 |
186 |
|
187 |
#ifdef KPP_ESTIMATE_UREF |
188 |
_KPP_RL dBdz1, dBdz2, ustarX, ustarY |
189 |
#endif |
190 |
|
191 |
c Check to see if new vertical mixing coefficient should be computed now? |
192 |
IF ( DIFFERENT_MULTIPLE(kpp_freq,myTime,myTime-deltaTClock) .OR. |
193 |
1 myTime .EQ. startTime ) THEN |
194 |
|
195 |
c----------------------------------------------------------------------- |
196 |
c prepare input arrays for subroutine "kppmix" to compute |
197 |
c viscosity and diffusivity and ghat. |
198 |
c All input arrays need to be in m-k-s units. |
199 |
c |
200 |
c note: for the computation of the bulk richardson number in the |
201 |
c "bldepth" subroutine, gradients of velocity and buoyancy are |
202 |
c required at every depth. in the case of very fine vertical grids |
203 |
c (thickness of top layer < 2m), the surface reference depth must |
204 |
c be set to zref=epsilon/2*zgrid(k), and the reference value |
205 |
c of velocity and buoyancy must be computed as vertical average |
206 |
c between the surface and 2*zref. in the case of coarse vertical |
207 |
c grids zref is zgrid(1)/2., and the surface reference value is |
208 |
c simply the surface value at zgrid(1). |
209 |
c----------------------------------------------------------------------- |
210 |
|
211 |
c------------------------------------------------------------------------ |
212 |
c density related quantities |
213 |
c -------------------------- |
214 |
c |
215 |
c work2 - density of surface layer (kg/m^3) |
216 |
c dbloc - local buoyancy gradient at Nr interfaces |
217 |
c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2) |
218 |
c dbsfc (stored in Ritop to conserve stack memory) |
219 |
c - buoyancy difference with respect to the surface |
220 |
c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2) |
221 |
c ttalpha (stored in vddiff(:,:,:,1) to conserve stack memory) |
222 |
c - thermal expansion coefficient without 1/rho factor |
223 |
c d(rho{k,k})/d(T(k)) (kg/m^3/C) |
224 |
c ssbeta (stored in vddiff(:,:,:,2) to conserve stack memory) |
225 |
c - salt expansion coefficient without 1/rho factor |
226 |
c d(rho{k,k})/d(S(k)) (kg/m^3/PSU) |
227 |
c------------------------------------------------------------------------ |
228 |
|
229 |
CALL TIMER_START('STATEKPP [KPP_CALC]', myThid) |
230 |
CALL STATEKPP( |
231 |
I bi, bj, myThid |
232 |
O , work2, dbloc, Ritop |
233 |
O , vddiff(ibot,jbot,1,1), vddiff(ibot,jbot,1,2) |
234 |
& ) |
235 |
CALL TIMER_STOP ('STATEKPP [KPP_CALC]', myThid) |
236 |
|
237 |
DO k = 1, Nr |
238 |
DO j = jbot, jtop |
239 |
DO i = ibot, itop |
240 |
ghat(i,j,k) = dbloc(i,j,k) |
241 |
ENDDO |
242 |
ENDDO |
243 |
ENDDO |
244 |
|
245 |
#ifdef KPP_SMOOTH_DBLOC |
246 |
c horizontally smooth dbloc with a 121 filter |
247 |
c smooth dbloc stored in ghat to save space |
248 |
c dbloc(k) is buoyancy gradientnote between k and k+1 |
249 |
c levels therefore k+1 mask must be used |
250 |
|
251 |
DO k = 1, Nr-1 |
252 |
CALL KPP_SMOOTH_HORIZ ( |
253 |
I k+1, bi, bj, |
254 |
U ghat (ibot,jbot,k) ) |
255 |
ENDDO |
256 |
|
257 |
#endif /* KPP_SMOOTH_DBLOC */ |
258 |
|
259 |
#ifdef KPP_SMOOTH_DENS |
260 |
c horizontally smooth density related quantities with 121 filters |
261 |
CALL KPP_SMOOTH_HORIZ ( |
262 |
I 1, bi, bj, |
263 |
U work2 ) |
264 |
DO k = 1, Nr |
265 |
CALL KPP_SMOOTH_HORIZ ( |
266 |
I k+1, bi, bj, |
267 |
U dbloc (ibot,jbot,k) ) |
268 |
CALL KPP_SMOOTH_HORIZ ( |
269 |
I k, bi, bj, |
270 |
U Ritop (ibot,jbot,k) ) |
271 |
CALL KPP_SMOOTH_HORIZ ( |
272 |
I k, bi, bj, |
273 |
U vddiff(ibot,jbot,k,1) ) |
274 |
CALL KPP_SMOOTH_HORIZ ( |
275 |
I k, bi, bj, |
276 |
U vddiff(ibot,jbot,k,2) ) |
277 |
ENDDO |
278 |
#endif /* KPP_SMOOTH_DENS */ |
279 |
|
280 |
DO k = 1, Nr |
281 |
DO j = jbot, jtop |
282 |
DO i = ibot, itop |
283 |
|
284 |
c zero out dbloc over land points (so that the convective |
285 |
c part of the interior mixing can be diagnosed) |
286 |
dbloc(i,j,k) = dbloc(i,j,k) * pMask(i,j,k,bi,bj) |
287 |
ghat(i,j,k) = ghat(i,j,k) * pMask(i,j,k,bi,bj) |
288 |
Ritop(i,j,k) = Ritop(i,j,k) * pMask(i,j,k,bi,bj) |
289 |
if(k.eq.nzmax(i,j,bi,bj)) then |
290 |
dbloc(i,j,k) = p0 |
291 |
ghat(i,j,k) = p0 |
292 |
Ritop(i,j,k) = p0 |
293 |
endif |
294 |
|
295 |
c numerator of bulk richardson number on grid levels |
296 |
c note: land and ocean bottom values need to be set to zero |
297 |
c so that the subroutine "bldepth" works correctly |
298 |
Ritop(i,j,k) = (zgrid(1)-zgrid(k)) * Ritop(i,j,k) |
299 |
|
300 |
END DO |
301 |
END DO |
302 |
END DO |
303 |
|
304 |
c------------------------------------------------------------------------ |
305 |
c friction velocity, turbulent and radiative surface buoyancy forcing |
306 |
c ------------------------------------------------------------------- |
307 |
c taux / rho = SurfaceTendencyU * delZ(1) (N/m^2) |
308 |
c tauy / rho = SurfaceTendencyV * delZ(1) (N/m^2) |
309 |
c ustar = sqrt( sqrt( taux^2 + tauy^2 ) / rho ) (m/s) |
310 |
c bo = - g * ( alpha*SurfaceTendencyT + |
311 |
c beta *SurfaceTendencyS ) * delZ(1) / rho (m^2/s^3) |
312 |
c bosol = - g * alpha * Qsw * delZ(1) / rho (m^2/s^3) |
313 |
c------------------------------------------------------------------------ |
314 |
|
315 |
c initialize arrays to zero |
316 |
DO j = jbot, jtop |
317 |
DO i = ibot, itop |
318 |
ustar(i,j) = p0 |
319 |
bo (I,J) = p0 |
320 |
bosol(I,J) = p0 |
321 |
END DO |
322 |
END DO |
323 |
|
324 |
DO j = jmin, jmax |
325 |
jp1 = j + 1 |
326 |
DO i = imin, imax |
327 |
ip1 = i+1 |
328 |
tempVar1 = |
329 |
& (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) * |
330 |
& (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) + |
331 |
& (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj)) * |
332 |
& (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj)) |
333 |
if ( tempVar1 .lt. (phepsi*phepsi) ) then |
334 |
ustar(i,j) = SQRT( phepsi * p5 * delZ(1) ) |
335 |
else |
336 |
tempVar2 = SQRT( tempVar1 ) * p5 * delZ(1) |
337 |
ustar(i,j) = SQRT( tempVar2 ) |
338 |
endif |
339 |
bo(I,J) = - gravity * |
340 |
& ( vddiff(I,J,1,1) * SurfaceTendencyT(i,j,bi,bj) + |
341 |
& vddiff(I,J,1,2) * SurfaceTendencyS(i,j,bi,bj) |
342 |
& ) * |
343 |
& delZ(1) / work2(I,J) |
344 |
bosol(I,J) = gravity * vddiff(I,J,1,1) * Qsw(i,j,bi,bj) * |
345 |
& recip_Cp*recip_rhoNil*recip_dRf(1) * |
346 |
& delZ(1) / work2(I,J) |
347 |
END DO |
348 |
END DO |
349 |
|
350 |
c------------------------------------------------------------------------ |
351 |
c velocity shear |
352 |
c -------------- |
353 |
c Get velocity shear squared, averaged from "u,v-grid" |
354 |
c onto "t-grid" (in (m/s)**2): |
355 |
c dVsq(k)=(Uref-U(k))**2+(Vref-V(k))**2 at grid levels |
356 |
c shsq(k)=(U(k)-U(k+1))**2+(V(k)-V(k+1))**2 at interfaces |
357 |
c------------------------------------------------------------------------ |
358 |
|
359 |
c initialize arrays to zero |
360 |
DO k = 1, Nr |
361 |
DO j = jbot, jtop |
362 |
DO i = ibot, itop |
363 |
shsq(i,j,k) = p0 |
364 |
dVsq(i,j,k) = p0 |
365 |
END DO |
366 |
END DO |
367 |
END DO |
368 |
|
369 |
c dVsq computation |
370 |
|
371 |
#ifdef KPP_ESTIMATE_UREF |
372 |
|
373 |
c Get rid of vertical resolution dependence of dVsq term by |
374 |
c estimating a surface velocity that is independent of first level |
375 |
c thickness in the model. First determine mixed layer depth hMix. |
376 |
c Second zRef = espilon * hMix. Third determine roughness length |
377 |
c scale z0. Third estimate reference velocity. |
378 |
|
379 |
DO j = jmin, jmax |
380 |
jp1 = j + 1 |
381 |
DO i = imin, imax |
382 |
ip1 = i + 1 |
383 |
|
384 |
c Determine mixed layer depth hMix as the shallowest depth at which |
385 |
c dB/dz exceeds 5.2e-5 s^-2. |
386 |
work1(i,j) = nzmax(i,j,bi,bj) |
387 |
DO k = 1, Nr |
388 |
IF ( k .LT. nzmax(i,j,bi,bj) .AND. |
389 |
& dbloc(i,j,k) / drC(k+1) .GT. dB_dz ) |
390 |
& work1(i,j) = k |
391 |
END DO |
392 |
|
393 |
c Linearly interpolate to find hMix. |
394 |
k = work1(i,j) |
395 |
IF ( k .EQ. 0 .OR. nzmax(i,j,bi,bj) .EQ. 1 ) THEN |
396 |
zRef(i,j) = p0 |
397 |
ELSEIF ( k .EQ. 1) THEN |
398 |
dBdz2 = dbloc(i,j,1) / drC(2) |
399 |
zRef(i,j) = drF(1) * dB_dz / dBdz2 |
400 |
ELSEIF ( k .LT. nzmax(i,j,bi,bj) ) THEN |
401 |
dBdz1 = dbloc(i,j,k-1) / drC(k ) |
402 |
dBdz2 = dbloc(i,j,k ) / drC(k+1) |
403 |
zRef(i,j) = rF(k) + drF(k) * (dB_dz - dBdz1) / |
404 |
& MAX ( phepsi, dBdz2 - dBdz1 ) |
405 |
ELSE |
406 |
zRef(i,j) = rF(k+1) |
407 |
ENDIF |
408 |
|
409 |
c Compute roughness length scale z0 subject to 0 < z0 |
410 |
tempVar1 = p5 * ( |
411 |
& (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) * |
412 |
& (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) + |
413 |
& (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) * |
414 |
& (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) + |
415 |
& (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) * |
416 |
& (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) + |
417 |
& (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) * |
418 |
& (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) ) |
419 |
if ( tempVar1 .lt. (epsln*epsln) ) then |
420 |
tempVar2 = epsln |
421 |
else |
422 |
tempVar2 = SQRT ( tempVar1 ) |
423 |
endif |
424 |
z0(i,j) = rF(2) * |
425 |
& ( rF(3) * LOG ( rF(3) / rF(2) ) / |
426 |
& ( rF(3) - rF(2) ) - |
427 |
& tempVar2 * vonK / |
428 |
& MAX ( ustar(i,j), phepsi ) ) |
429 |
z0(i,j) = MAX ( z0(i,j), phepsi ) |
430 |
|
431 |
c zRef is set to 0.1 * hMix subject to z0 <= zRef <= drF(1) |
432 |
zRef(i,j) = MAX ( epsilon * zRef(i,j), z0(i,j) ) |
433 |
zRef(i,j) = MIN ( zRef(i,j), drF(1) ) |
434 |
|
435 |
c Estimate reference velocity uRef and vRef. |
436 |
uRef(i,j) = p5 * |
437 |
& ( uVel(i,j,1,bi,bj) + uVel(ip1,j,1,bi,bj) ) |
438 |
vRef(i,j) = p5 * |
439 |
& ( vVel(i,j,1,bi,bj) + vVel(i,jp1,1,bi,bj) ) |
440 |
IF ( zRef(i,j) .LT. drF(1) ) THEN |
441 |
ustarX = ( SurfaceTendencyU(i, j,bi,bj) + |
442 |
& SurfaceTendencyU(ip1,j,bi,bj) ) * p5 |
443 |
ustarY = ( SurfaceTendencyV(i,j, bi,bj) + |
444 |
& SurfaceTendencyU(i,jp1,bi,bj) ) * p5 |
445 |
tempVar1 = ustarX * ustarX + ustarY * ustarY |
446 |
if ( tempVar1 .lt. (epsln*epsln) ) then |
447 |
tempVar2 = epsln |
448 |
else |
449 |
tempVar2 = SQRT ( tempVar1 ) |
450 |
endif |
451 |
tempVar2 = ustar(i,j) * |
452 |
& ( LOG ( zRef(i,j) / rF(2) ) + |
453 |
& z0(i,j) / zRef(i,j) - z0(i,j) / rF(2) ) / |
454 |
& vonK / tempVar2 |
455 |
uRef(i,j) = uRef(i,j) + ustarX * tempVar2 |
456 |
vRef(i,j) = vRef(i,j) + ustarY * tempVar2 |
457 |
ENDIF |
458 |
|
459 |
END DO |
460 |
END DO |
461 |
|
462 |
DO k = 1, Nr |
463 |
DO j = jmin, jmax |
464 |
jm1 = j - 1 |
465 |
jp1 = j + 1 |
466 |
DO i = imin, imax |
467 |
im1 = i - 1 |
468 |
ip1 = i + 1 |
469 |
dVsq(i,j,k) = p5 * ( |
470 |
$ (uRef(i,j) - uVel(i, j, k,bi,bj)) * |
471 |
$ (uRef(i,j) - uVel(i, j, k,bi,bj)) + |
472 |
$ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) * |
473 |
$ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) + |
474 |
$ (vRef(i,j) - vVel(i, j, k,bi,bj)) * |
475 |
$ (vRef(i,j) - vVel(i, j, k,bi,bj)) + |
476 |
$ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) * |
477 |
$ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) ) |
478 |
#ifdef KPP_SMOOTH_DVSQ |
479 |
dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * ( |
480 |
$ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) * |
481 |
$ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) + |
482 |
$ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) * |
483 |
$ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) + |
484 |
$ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) * |
485 |
$ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) + |
486 |
$ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) * |
487 |
$ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) + |
488 |
$ (vRef(i,j) - vVel(im1,j, k,bi,bj)) * |
489 |
$ (vRef(i,j) - vVel(im1,j, k,bi,bj)) + |
490 |
$ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) * |
491 |
$ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) + |
492 |
$ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) * |
493 |
$ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) + |
494 |
$ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) * |
495 |
$ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) ) |
496 |
#endif /* KPP_SMOOTH_DVSQ */ |
497 |
END DO |
498 |
END DO |
499 |
END DO |
500 |
|
501 |
#else /* KPP_ESTIMATE_UREF */ |
502 |
|
503 |
DO k = 1, Nr |
504 |
DO j = jmin, jmax |
505 |
jm1 = j - 1 |
506 |
jp1 = j + 1 |
507 |
DO i = imin, imax |
508 |
im1 = i - 1 |
509 |
ip1 = i + 1 |
510 |
dVsq(i,j,k) = p5 * ( |
511 |
$ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) * |
512 |
$ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) + |
513 |
$ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) * |
514 |
$ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) + |
515 |
$ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) * |
516 |
$ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) + |
517 |
$ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) * |
518 |
$ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) ) |
519 |
#ifdef KPP_SMOOTH_DVSQ |
520 |
dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * ( |
521 |
$ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) * |
522 |
$ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) + |
523 |
$ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) * |
524 |
$ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) + |
525 |
$ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) * |
526 |
$ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) + |
527 |
$ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) * |
528 |
$ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) + |
529 |
$ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) * |
530 |
$ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) + |
531 |
$ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) * |
532 |
$ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) + |
533 |
$ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) * |
534 |
$ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) + |
535 |
$ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) * |
536 |
$ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) ) |
537 |
#endif /* KPP_SMOOTH_DVSQ */ |
538 |
END DO |
539 |
END DO |
540 |
END DO |
541 |
|
542 |
#endif /* KPP_ESTIMATE_UREF */ |
543 |
|
544 |
c shsq computation |
545 |
DO k = 1, Nrm1 |
546 |
kp1 = k + 1 |
547 |
DO j = jmin, jmax |
548 |
jm1 = j - 1 |
549 |
jp1 = j + 1 |
550 |
DO i = imin, imax |
551 |
im1 = i - 1 |
552 |
ip1 = i + 1 |
553 |
shsq(i,j,k) = p5 * ( |
554 |
$ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) * |
555 |
$ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) + |
556 |
$ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) * |
557 |
$ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) + |
558 |
$ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) * |
559 |
$ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) + |
560 |
$ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) * |
561 |
$ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) ) |
562 |
#ifdef KPP_SMOOTH_SHSQ |
563 |
shsq(i,j,k) = p5 * shsq(i,j,k) + p125 * ( |
564 |
$ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) * |
565 |
$ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) + |
566 |
$ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) * |
567 |
$ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) + |
568 |
$ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) * |
569 |
$ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) + |
570 |
$ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) * |
571 |
$ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) + |
572 |
$ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) * |
573 |
$ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) + |
574 |
$ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) * |
575 |
$ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) + |
576 |
$ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) * |
577 |
$ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) + |
578 |
$ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) * |
579 |
$ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) ) |
580 |
#endif |
581 |
END DO |
582 |
END DO |
583 |
END DO |
584 |
|
585 |
c----------------------------------------------------------------------- |
586 |
c solve for viscosity, diffusivity, ghat, and hbl on "t-grid" |
587 |
c----------------------------------------------------------------------- |
588 |
|
589 |
DO j = jbot, jtop |
590 |
DO i = ibot, itop |
591 |
work1(i,j) = nzmax(i,j,bi,bj) |
592 |
work2(i,j) = Fcori(i,j,bi,bj) |
593 |
END DO |
594 |
END DO |
595 |
CALL TIMER_START('KPPMIX [KPP_CALC]', myThid) |
596 |
CALL KPPMIX ( |
597 |
I mytime, mythid |
598 |
I , work1, shsq, dVsq, ustar |
599 |
I , bo, bosol, dbloc, Ritop, work2 |
600 |
I , ikey |
601 |
O , vddiff |
602 |
U , ghat |
603 |
O , hbl ) |
604 |
|
605 |
CALL TIMER_STOP ('KPPMIX [KPP_CALC]', myThid) |
606 |
|
607 |
#ifdef ALLOW_AUTODIFF_TAMC |
608 |
cph( storing not necessary |
609 |
cphCADJ STORE vddiff, ghat = comlev1_kpp, key = ikey |
610 |
cph) |
611 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
612 |
|
613 |
c----------------------------------------------------------------------- |
614 |
c zero out land values and transfer to global variables |
615 |
c----------------------------------------------------------------------- |
616 |
|
617 |
DO j = jmin, jmax |
618 |
DO i = imin, imax |
619 |
DO k = 1, Nr |
620 |
KPPviscAz(i,j,k,bi,bj) = vddiff(i,j,k-1,1) * pMask(i,j,k,bi,bj) |
621 |
KPPdiffKzS(i,j,k,bi,bj)= vddiff(i,j,k-1,2) * pMask(i,j,k,bi,bj) |
622 |
KPPdiffKzT(i,j,k,bi,bj)= vddiff(i,j,k-1,3) * pMask(i,j,k,bi,bj) |
623 |
KPPghat(i,j,k,bi,bj) = ghat(i,j,k) * pMask(i,j,k,bi,bj) |
624 |
END DO |
625 |
KPPhbl(i,j,bi,bj) = hbl(i,j) * pMask(i,j,1,bi,bj) |
626 |
END DO |
627 |
END DO |
628 |
#ifdef FRUGAL_KPP |
629 |
_EXCH_XYZ_R8(KPPviscAz , myThid ) |
630 |
_EXCH_XYZ_R8(KPPdiffKzS , myThid ) |
631 |
_EXCH_XYZ_R8(KPPdiffKzT , myThid ) |
632 |
_EXCH_XYZ_R8(KPPghat , myThid ) |
633 |
_EXCH_XY_R8 (KPPhbl , myThid ) |
634 |
#endif |
635 |
|
636 |
#ifdef KPP_SMOOTH_VISC |
637 |
c horizontal smoothing of vertical viscosity |
638 |
DO k = 1, Nr |
639 |
CALL SMOOTH_HORIZ ( |
640 |
I k, bi, bj, |
641 |
U KPPviscAz(1-OLx,1-OLy,k,bi,bj) ) |
642 |
END DO |
643 |
_EXCH_XYZ_R8(KPPviscAz , myThid ) |
644 |
#endif /* KPP_SMOOTH_VISC */ |
645 |
|
646 |
#ifdef KPP_SMOOTH_DIFF |
647 |
c horizontal smoothing of vertical diffusivity |
648 |
DO k = 1, Nr |
649 |
CALL SMOOTH_HORIZ ( |
650 |
I k, bi, bj, |
651 |
U KPPdiffKzS(1-OLx,1-OLy,k,bi,bj) ) |
652 |
CALL SMOOTH_HORIZ ( |
653 |
I k, bi, bj, |
654 |
U KPPdiffKzT(1-OLx,1-OLy,k,bi,bj) ) |
655 |
END DO |
656 |
_EXCH_XYZ_R8(KPPdiffKzS , myThid ) |
657 |
_EXCH_XYZ_R8(KPPdiffKzT , myThid ) |
658 |
#endif /* KPP_SMOOTH_DIFF */ |
659 |
|
660 |
C Compute fraction of solar short-wave flux penetrating to |
661 |
C the bottom of the mixing layer. |
662 |
DO j=1-OLy,sNy+OLy |
663 |
DO i=1-OLx,sNx+OLx |
664 |
worka(i,j) = KPPhbl(i,j,bi,bj) |
665 |
ENDDO |
666 |
ENDDO |
667 |
CALL SWFRAC( |
668 |
I (sNx+2*OLx)*(sNy+2*OLy), minusone, |
669 |
I mytime, mythid, |
670 |
U worka ) |
671 |
DO j=1-OLy,sNy+OLy |
672 |
DO i=1-OLx,sNx+OLx |
673 |
KPPfrac(i,j,bi,bj) = worka(i,j) |
674 |
ENDDO |
675 |
ENDDO |
676 |
|
677 |
ENDIF |
678 |
|
679 |
#endif ALLOW_KPP |
680 |
|
681 |
RETURN |
682 |
END |