@@ -229,15 +229,17 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
229
229
real :: KEm1, KEp1, tauUP, tauDN, tomUP, tomDN
230
230
real :: tauM1, tau, tauP1, tauAV, utemp, vtemp
231
231
real :: B, Cval, diff, wtav, dzmid, Ksps, Sz, Tz, w4k, w4kp1, w2k, w2kp1
232
- real :: lareaFraction, wstar, Q, w3av, tempMoment
232
+ real :: lareaFraction, wstar, Q, w3av, tempMoment, frictionVelocity
233
233
real :: sfcFrictionVelocitySquared, wtSumUp, wtSumDn, wsSumUp, wsSumDn
234
234
235
235
real ,dimension (nVertLevels,nCells) :: Swumd
236
236
real ,dimension (nVertLevels,nCells) :: tauw3, tauTemp, tauSalt, tauVel, tauvVel
237
237
real ,dimension (nVertLevels,nCells) :: areaFractionMid, tumdMid, McMid, wumdMid, sumdMid
238
238
239
- real :: Swk
239
+ real :: Swk, tau_sfc, d_sqrt_wp2_dz, tp2, sp2, min_wp2_sfc_val, wp2_splat_sfc_correction
240
+ real :: min_wps_sfc_val
240
241
242
+ min_wps_sfc_val = 1.0E-10_RKIND
241
243
dt_small = config_adc_timestep
242
244
niter = dt / dt_small
243
245
@@ -246,6 +248,7 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
246
248
247
249
stopflag = .false.
248
250
251
+ do iIter= 1 ,niter
249
252
!on further examination build_diagnostics array can live outside the iter loop
250
253
do iCell= 1 ,nCells
251
254
Q = grav* (alphaT(1 ,iCell)* wtsfc(iCell) - betaS(1 ,iCell)* wssfc(iCell))* &
@@ -263,10 +266,13 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
263
266
w2t(1 ,iCell) = - 0.3_RKIND * wstar * wtsfc(iCell)
264
267
w2s(1 ,iCell) = 0.3_RKIND * wstar * wssfc(iCell)
265
268
266
- sfcFrictionVelocitySquared = sqrt (uwsfc(iCell)** 2 + vwsfc(iCell)** 2 )
269
+ sfcFrictionVelocitySquared = uwsfc(iCell) + vwsfc(iCell)
270
+ frictionVelocity = sqrt (sfcFrictionVelocitySquared + config_adc_bc_wstar * wstar * wstar)
271
+ frictionVelocity = max ( config_adc_frictionVelocityMin, frictionVelocity )
267
272
do k= 1 ,2
268
- u2(k,1 ,iCell) = uwsfc(iCell)! sfcFrictionVelocitySquared !+ 0.3 * wstar** 2.0
269
- v2(k,1 ,iCell) = vwsfc(iCell)! sfcFrictionVelocitySquared !+ 0.3 * wstar** 2.0
273
+ u2(k,1 ,iCell) = config_adc_up2_vp2_factor* config_adc_bc_const* frictionVelocity** 2.0
274
+ v2(k,1 ,iCell) = config_adc_up2_vp2_factor* config_adc_bc_const* frictionVelocity** 2.0
275
+ w2(k,1 ,iCell) = config_adc_bc_const_wp2* frictionVelocity** 2.0
270
276
uw(k,1 ,iCell) = - uwsfc(iCell)
271
277
vw(k,1 ,iCell) = - vwsfc(iCell)
272
278
wt(k,1 ,iCell) = wtsfc(iCell)
@@ -276,45 +282,87 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
276
282
enddo
277
283
enddo
278
284
279
- do iIter= 1 ,niter
280
- do iCell= 1 ,nCells-1000000
281
- do k= 2 ,nVertLevels
282
- w3av = 0.5_RKIND * (w2(i1,k-1 ,iCell) + w2(i1,k,iCell))
283
-
284
- Sw = w3(i1,k-1 ,iCell) / (w3av** 1.5_RKIND + 1.0E-15_RKIND )
285
- lareaFraction = 0.5_RKIND + 0.5_RKIND * Sw / sqrt (4.0_RKIND + Sw** 2 )
285
+ ! compute the splat effect, adds w3tend and w2tend
286
+ if (config_adc_use_splat_parameterization) then
287
+ ! do k= 1 separately for performance reasons, for k= 1 we use one sided derivatives
288
+ ! note that the splat_factor forces the term to be smaller than factor * dt
289
+ k= 1
290
+ do iCell= 1 ,nCells
291
+ d_sqrt_wp2_dz = (sqrt (w2(i1,1 ,iCell)) - sqrt (0.5_RKIND * (w2(i1,1 ,iCell)+ &
292
+ w2(i1,2 ,iCell)))) / (ze(1 ,iCell) - zm(1 ,iCell))
293
+ tau_sfc = length(1 ,iCell) / sqrt (0.5_RKIND * (u2(i1,k,iCell) + v2(i1,k,iCell)))
294
+ w2tend6(1 ,iCell) = min (max (- config_adc_splat_tend_max, - w2(i1,1 ,iCell)* &
295
+ config_adc_splat_wp2_val* tau_sfc* d_sqrt_wp2_dz** 2 ), &
296
+ config_adc_splat_tend_max)
297
+ tau_sfc = 0.5_RKIND * (length(1 ,iCell) + length(2 ,iCell)) / sqrt (0.5_RKIND * ( &
298
+ 0.5_RKIND * (u2(i1,1 ,iCell) + u2(i1,2 ,iCell)) + 0.5_RKIND * ( &
299
+ v2(i1,1 ,iCell) + v2(i1,2 ,iCell)) + 0.5_RKIND * (w2(i1,1 ,iCell) + &
300
+ w2(i1,2 ,iCell))))
301
+ d_sqrt_wp2_dz = (sqrt (w2(i1,1 ,iCell)) - sqrt (w2(i1,2 ,iCell))) / &
302
+ (ze(1 ,iCell) - ze(2 ,iCell))
303
+ w3tend6(1 ,iCell) = min (max (- config_adc_splat_tend_max, - w3(i1,1 ,iCell)* &
304
+ config_adc_splat_wp2_val* tau_sfc* d_sqrt_wp2_dz** 2 ), &
305
+ config_adc_splat_tend_max)
306
+ end do
286
307
287
- !This clips w3 to be consistent with the clipped areaFraction
288
- if (lareaFraction < 0.01_RKIND ) then
289
- w3(i1,k-1 ,iCell) = - 9.85_RKIND * w3av** 1.5
290
- end if
308
+ do iCell= 1 ,nCells
309
+ do k= 2 ,nVertLevels
310
+ d_sqrt_wp2_dz = (sqrt (w2(i1,k-1 ,iCell)) - sqrt (w2(i1,k+1 ,iCell))) / &
311
+ (ze(k-1 ,iCell) - ze(k+1 ,iCell))
312
+ tau_sfc = length(k,iCell) / sqrt (0.5_RKIND * (u2(i1,k,iCell) + v2(i1,k,iCell) + &
313
+ w2(i1,k,iCell)))
314
+ w2tend6(k,iCell) = min (max (- config_adc_splat_tend_max, - w2(i1,k,iCell)* &
315
+ config_adc_splat_wp2_val* tau_sfc* d_sqrt_wp2_dz** 2 ), &
316
+ config_adc_splat_tend_max)
317
+ tau_sfc = 0.5_RKIND * (length(k,iCell) + length(k+1 ,iCell)) / sqrt (0.5_RKIND * ( &
318
+ 0.5_RKIND * (u2(i1,k,iCell) + u2(i1,k+1 ,iCell)) + 0.5_RKIND * ( &
319
+ v2(i1,k,iCell) + v2(i1,k+1 ,iCell)) + 0.5_RKIND * (w2(i1,k,iCell) + &
320
+ w2(i1,k+1 ,iCell))))
321
+ d_sqrt_wp2_dz = (sqrt (w2(i1,k,iCell)) - sqrt (w2(i1,k+1 ,iCell))) / &
322
+ (ze(k,iCell) - ze(k+1 ,iCell))
323
+ w3tend6(1 ,iCell) = min (max (- config_adc_splat_tend_max, - w3(i1,k,iCell)* &
324
+ config_adc_splat_wp2_val* tau_sfc* d_sqrt_wp2_dz** 2 ), &
325
+ config_adc_splat_tend_max)
326
+ end do
327
+ end do
291
328
292
- if (lareaFraction > 0.99_RKIND ) then
293
- w3(i1,k-1 ,iCell) = 9.85_RKIND * w3av** 1.5
329
+ do iCell= 1 ,nCells
330
+ tp2 = 0.4_RKIND * config_adc_bc_const * (wt(i1,1 ,iCell) / frictionVelocity)** 2
331
+ sp2 = 0.4_RKIND * config_adc_bc_const * (ws(i1,1 ,iCell) / frictionVelocity)** 2
332
+ min_wp2_sfc_val = max (1.0E-10_RKIND , wt(i1,1 ,iCell)** 2 / (tp2 * 0.99_RKIND ** 2 + 1.0E-15_RKIND ), &
333
+ ws(i1,1 ,iCell)** 2 / (sp2 * 0.99_RKIND ** 2 + 1.0E-15_RKIND ))
334
+ tau_sfc = length(1 ,iCell) / sqrt (0.5_RKIND * (u2(i1,1 ,iCell) + v2(i1,1 ,iCell)))
335
+
336
+ if (w2(k,1 ,iCell) + tau_sfc * w2tend6(1 ,iCell) < min_wps_sfc_val) then
337
+ wp2_splat_sfc_correction = - w2(i1,1 ,iCell) + min_wp2_sfc_val
338
+ w2(i1,1 ,iCell) = min_wp2_sfc_val
339
+ else
340
+ wp2_splat_sfc_correction = tau_sfc * w2tend6(1 ,iCell)
341
+ w2(i1,1 ,iCell) = w2(i1,1 ,iCell) + wp2_splat_sfc_correction
294
342
end if
295
-
296
- Sw = w3 (i1,k - 1 ,iCell) / (w3av ** 1.5 + 1.0E-15_RKIND )
297
- lareaFraction = 0.5_RKIND + 0.5_RKIND * Sw / sqrt ( 4.0_RKIND + Sw ** 2 )
298
-
299
- areaFractionMid(k -1 ,iCell) = lareaFraction
300
- wumdMid(k -1 , iCell) = sqrt (w3av / (areaFractionMid(k -1 ,iCell) * &
301
- ( 1.0_RKIND - areaFractionMid(k -1 ,iCell))))
302
- McMid(k -1 ,iCell) = areaFractionMid(k -1 ,iCell)* ( 1.0_RKIND - &
303
- areaFractionMid(k -1 ,iCell)) * wumdMid(k -1 ,iCell)
304
- tumdMid(k -1 ,iCell) = ( 0.5 * (wt(i1,k -1 ,iCell) + wt(i1,k,iCell))) / &
305
- ( 1.0E-12_RKIND + McMid(k -1 ,iCell))
306
- sumdMid(k -1 ,iCell) = ( 0.5 * (ws(i1,k -1 ,iCell) + ws(i1,k,iCell))) / &
307
- ( 1.0E-12_RKIND + McMid(k -1 ,iCell))
308
- if (w3av < = epsilon + 1.0e-9 ) then
309
- areaFractionMid(k -1 ,iCell) = 0.5_RKIND
310
- ! wumdMid(k -1 ,iCell) = 0.0_RKIND
311
- tumdMid(k -1 ,iCell) = 0.0_RKIND
312
- sumdMid(k -1 ,iCell) = 0.0_RKIND
313
- ! McMid(k -1 ,iCell) = 0.0_RKIND
314
- endif
315
- enddo
316
- enddo
317
-
343
+ u2(i1, 1 ,iCell) = u2(i1, 1 ,iCell) - 0.5_RKIND * wp2_splat_sfc_correction
344
+ v2(i1, 1 ,iCell) = v2 (i1,1 ,iCell) - 0.5_RKIND * wp2_splat_sfc_correction
345
+ end do
346
+
347
+ !build up splat tend for u2 and v2
348
+ do iCell= 1 ,nCells
349
+ do k = 2 ,nVertLevels
350
+ u2tend6(k ,iCell) = - 0.5_RKIND * w2tend6(k ,iCell)
351
+ v2tend6(k ,iCell) = - 0.5_RKIND * w2tend6(k ,iCell)
352
+ end do
353
+ end do
354
+ else
355
+ do iCell = 1 ,nCells
356
+ do k = 1 ,nVertLevels
357
+ w3tend6(k ,iCell) = 0.0_RKIND
358
+ w2tend6(k ,iCell) = 0.0_RKIND
359
+ u2tend6(k ,iCell) = 0.0_RKIND
360
+ v2tend6(k ,iCell) = 0.0_RKIND
361
+ end do
362
+ end do
363
+ end if ! end use splat correction
364
+
365
+
318
366
!Kernel 1 inlined versions of the base arrays, needed for later to make them collapsible
319
367
do iCell= 1 ,nCells
320
368
do k= 2 ,nVertLevels
@@ -459,7 +507,7 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
459
507
betaS(k,iCell)* w2s(k,iCell))
460
508
461
509
w3tend(i3_f,k,iCell) = w3tend1(k,iCell) + w3tend2(k,iCell) + w3tend3(k,iCell) + &
462
- w3tend4(k,iCell) + w3tend5(k,iCell)
510
+ w3tend4(k,iCell) + w3tend5(k,iCell) + w3tend6(k,iCell)
463
511
464
512
if (k>1 .and. k < nVertLevels .and. kappa_w3 > 0.0 ) then
465
513
w3tend(i3_f,k,iCell) = w3tend(i3_f,k,iCell) + kappa_w3* (w3(i1,k-1 ,iCell) &
@@ -527,7 +575,7 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
527
575
Mc(k,iCell)* (Swumd(k-1 ,iCell) + Swumd(k,iCell))
528
576
529
577
w2tend(i3_f,k,iCell) = w2tend1(k,iCell) + w2tend2(k,iCell) + &
530
- w2tend3(k,iCell) + w2tend4(k,iCell) + w2tend5(k,iCell)
578
+ w2tend3(k,iCell) + w2tend4(k,iCell) + w2tend5(k,iCell) + w2tend6(k,iCell)
531
579
532
580
wttend1(k,iCell) = - 1.0_RKIND * (Entrainment(k,iCell) + Detrainment(k,iCell)) * &
533
581
wumd(k,iCell)* tumd(k,iCell)
@@ -621,7 +669,7 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
621
669
1.0_RKIND - areaFraction(k,iCell))* wumd(k,iCell)** 2 )/ 3.0_RKIND
622
670
623
671
u2tend(i3_f,k,iCell) = u2tend1(k,iCell) + u2tend2(k,iCell) + &
624
- u2tend3(k,iCell) + u2tend4(k,iCell) + u2tend5(k,iCell)
672
+ u2tend3(k,iCell) + u2tend4(k,iCell) + u2tend5(k,iCell) + u2tend6(k,iCell)
625
673
626
674
v2tend1(k,iCell) = - (v2w(k-1 ,iCell) - v2w(k,iCell)) / dzmid
627
675
v2tend2(k,iCell) = (1.0_RKIND / 3.0_RKIND * alpha1 + alpha2 - &
@@ -635,7 +683,7 @@ subroutine compute_ADC_tends(nCells,nVertLevels, nTracers, dt,activeTracers, uve
635
683
1.0_RKIND - areaFraction(k,iCell))* wumd(k,iCell)** 2 )/ 3.0_RKIND
636
684
637
685
v2tend(i3_f,k,iCell) = v2tend1(k,iCell) + v2tend2(k,iCell) + &
638
- v2tend3(k,iCell) + v2tend4(k,iCell) + v2tend5(k,iCell)
686
+ v2tend3(k,iCell) + v2tend4(k,iCell) + v2tend5(k,iCell) + v2tend6(k,iCell)
639
687
640
688
uttend(i3_f,k,iCell) = (- (uwt(k-1 ,iCell) - uwt(k,iCell))/ dz - &
641
689
uw(i1,k,iCell)* Tz - (1.0_RKIND - alpha3)* wt(i1,k,iCell) &
0 commit comments