197 type(model_state_type),
target,
intent(inout) :: current_state
200 integer :: jcol, icol, target_x_index, target_y_index
202 real(kind=
default_precision),
dimension(current_state%local_grid%size(Z_INDEX)) :: &
203 s11, s22, s33, s12, s23, s13, s33_on_p
204 real(kind=
default_precision),
dimension(current_state%local_grid%size(Z_INDEX)) :: &
205 tau11,tau22, tau33, tau12, tau23, tau13, tau33_on_p
206 real(kind=
default_precision),
dimension(current_state%local_grid%size(Z_INDEX)) :: u_i_prime_tau_i
207 real(kind=
default_precision) :: vistmp, vis12, vis12a, visonp2, visonp2a, vis13, vis23
208 real(kind=
default_precision),
dimension(current_state%local_grid%size(Z_INDEX)) :: umean, wu_umean, vmean, wv_vmean, &
209 w_pprime_at_w, rke1, w_qvprime_at_w, w_qclprime_at_w, w_thprime_at_w, wq, rho, rec_rho, buoy_cof, &
210 uw_tot, vw_tot,qvprime_at_w,qclprime_at_w,thprime_at_w, sed_eq13, sed_eq23, sed33,uwsg,vwsg,sed_swap
212 real(kind=
default_precision) :: upr_at_w,vpr_at_w, vprime_w_local, uprime_w_local, u_1, u_1_bar
215 logical :: use_Ri_for_buoyant_prod=.true.
217 c_virtual = (ratio_mol_wts-1.0_default_precision)
218 jcol=current_state%column_local_y
219 icol=current_state%column_local_x
220 target_y_index=jcol-current_state%local_grid%halo_size(
y_index)
221 target_x_index=icol-current_state%local_grid%halo_size(
x_index)
223 if (mod(current_state%timestep, diagnostic_generation_frequency) == 0)
then
224 if (current_state%first_timestep_column)
then
225 sed_tot(:) = 0.0_default_precision
226 ssub_tot(:) = 0.0_default_precision
227 buoysg_tot(:) = 0.0_default_precision
228 sed_eq23(:) = 0.0_default_precision
229 sed_eq13(:) = 0.0_default_precision
230 sed_swap(:) = 0.0_default_precision
231 uwsg_tot(:) = 0.0_default_precision
232 vwsg_tot(:) = 0.0_default_precision
233 uusg_tot(:) = 0.0_default_precision
234 vvsg_tot(:) = 0.0_default_precision
235 wwsg_tot(:) = 0.0_default_precision
236 tkesg_tot(:) = 0.0_default_precision
237 vis_coef_tot(:) = 0.0_default_precision
238 diff_coef_tot(:)= 0.0_default_precision
239 dissipation_tot(:) = 0.0_default_precision
240 wkesg_tot(:) = 0.0_default_precision
241 richardson_number_tot(:) = 0.0_default_precision
242 richardson_squared_tot(:) = 0.0_default_precision
243 subke_2d(:,:) = 0.0_default_precision
244 if (current_state%th%active)
then
245 wtsg_tot(:) = 0.0_default_precision
246 th2sg_tot(:) = 0.0_default_precision
247 theta_dis_tot(:)= 0.0_default_precision
249 if (.not. current_state%passive_q .and. &
250 current_state%number_q_fields .gt. 0)
then
251 wqsg_tot(:) = 0.0_default_precision
252 wqv_sg_tot(:)=0.0_default_precision
253 wql_sg_tot(:)=0.0_default_precision
254 if (iqr > 0) wqr_sg_tot(:) = 0.0_default_precision
255 if (iqi > 0) wqi_sg_tot(:) = 0.0_default_precision
256 if (iqs > 0) wqs_sg_tot(:) = 0.0_default_precision
257 if (iqg > 0) wqg_sg_tot(:) = 0.0_default_precision
261 if (.not. current_state%halo_column)
then
263 do k=2,current_state%local_grid%size(
z_index)-1
270 s11(k)=current_state%global_grid%configuration%horizontal%cx*(&
271 (current_state%u%data(k+1, jcol, icol)-&
272 current_state%u%data(k+1, jcol, icol-1))+&
273 (current_state%u%data(k, jcol, icol)-&
274 current_state%u%data(k, jcol, icol-1)))
276 s11(k)=0.0_default_precision
280 s22(k)=current_state%global_grid%configuration%horizontal%cy*(&
281 (current_state%v%data(k+1, jcol, icol)-&
282 current_state%v%data(k+1, jcol-1, icol))+&
283 (current_state%v%data(k, jcol, icol)-&
284 current_state%v%data(k, jcol-1, icol)))
286 s22(k)=0.0_default_precision
290 s33(k)=((current_state%w%data(k, jcol, icol)-&
291 current_state%w%data(k-1, jcol, icol))*&
292 current_state%global_grid%configuration%vertical%rdz(k)) +&
293 ((current_state%w%data(k+1, jcol, icol)-&
294 current_state%w%data(k, jcol, icol))*&
295 current_state%global_grid%configuration%vertical%rdz(k+1))
298 s33_on_p(k) = 2.0_default_precision * &
299 ((current_state%w%data(k, jcol, icol)-&
300 current_state%w%data(k-1, jcol, icol))*&
301 current_state%global_grid%configuration%vertical%rdz(k))
303 s33(k)=0.0_default_precision
304 s33_on_p(k) = 0.0_default_precision
306 #if defined(U_ACTIVE) && defined(W_ACTIVE)
308 s13(k)=(((current_state%u%data(k+1, jcol, icol)-&
309 current_state%u%data(k, jcol, icol))*&
310 current_state%global_grid%configuration%vertical%rdzn(k+1)+&
311 (current_state%w%data(k, jcol, icol+1)-&
312 current_state%w%data(k, jcol, icol))*&
313 current_state%global_grid%configuration%horizontal%cx)+&
314 ((current_state%u%data(k+1, jcol, icol-1)-&
315 current_state%u%data(k, jcol, icol-1))*&
316 current_state%global_grid%configuration%vertical%rdzn(k+1)+&
317 (current_state%w%data(k, jcol, icol)-&
318 current_state%w%data(k, jcol, icol-1))*&
319 current_state%global_grid%configuration%horizontal%cx))*0.5_default_precision
320 #elif defined(U_ACTIVE) && !defined(W_ACTIVE)
321 s13(k)=(((current_state%u%data(k+1, jcol, icol)-&
322 current_state%u%data(k, jcol, icol))*&
323 current_state%global_grid%configuration%vertical%rdzn(k+1))+&
324 ((current_state%u%data(k+1, jcol, icol-1)-&
325 current_state%u%data(k, jcol, icol-1))*&
326 current_state%global_grid%configuration%vertical%rdzn(k+1)))*0.5_default_precision
327 #elif !defined(U_ACTIVE) && defined(W_ACTIVE)
328 s13(k)=(((current_state%w%data(k, jcol, icol+1)-&
329 current_state%w%data(k, jcol, icol))*&
330 current_state%global_grid%configuration%horizontal%cx)+&
331 ((current_state%w%data(k, jcol, icol)-&
332 current_state%w%data(k, jcol, icol-1))*&
333 current_state%global_grid%configuration%horizontal%cx))*0.5_default_precision
335 s13(k)=0.0_default_precision
337 #if defined(W_ACTIVE) && defined(V_ACTIVE)
339 s23(k)=(((current_state%w%data(k, jcol, icol) - &
340 current_state%w%data(k, jcol-1, icol)) * &
341 current_state%global_grid%configuration%horizontal%cy + &
342 (current_state%v%data(k+1, jcol-1, icol) - &
343 current_state%v%data(k, jcol-1, icol)) * &
344 current_state%global_grid%configuration%vertical%rdzn(k+1)) + &
345 ((current_state%w%data(k, jcol+1, icol) - &
346 current_state%w%data(k, jcol, icol)) * &
347 current_state%global_grid%configuration%horizontal%cy + &
348 (current_state%v%data(k+1, jcol, icol)-&
349 current_state%v%data(k, jcol, icol))*&
350 current_state%global_grid%configuration%vertical%rdzn(k+1)))*0.5_default_precision
351 #elif defined(W_ACTIVE) && !defined(V_ACTIVE)
352 s23(k)=(((current_state%w%data(k, jcol, icol)-&
353 current_state%w%data(k, jcol-1, icol))*&
354 current_state%global_grid%configuration%horizontal%cy)+&
355 ((current_state%w%data(k, jcol+1, icol)-&
356 current_state%w%data(k, jcol, icol))*&
357 current_state%global_grid%configuration%horizontal%cy))*0.5_default_precision
358 #elif !defined(W_ACTIVE) && defined(V_ACTIVE)
359 s23(k)=(((current_state%v%data(k+1, jcol-1, icol)-&
360 current_state%v%data(k, jcol-1, icol))*&
361 current_state%global_grid%configuration%vertical%rdzn(k+1))+&
362 ((current_state%v%data(k+1, jcol, icol)-&
363 current_state%v%data(k, jcol, icol))*&
364 current_state%global_grid%configuration%vertical%rdzn(k+1)))*0.5_default_precision
366 s23(k)=0.0_default_precision
368 #if defined(U_ACTIVE) && defined(V_ACTIVE)
370 s12(k)=(((((current_state%u%data(k, jcol, icol-1)-&
371 current_state%u%data(k, jcol-1, icol-1))*&
372 current_state%global_grid%configuration%horizontal%cy+&
373 (current_state%v%data(k, jcol-1, icol)-&
374 current_state%v%data(k, jcol-1, icol-1))*&
375 current_state%global_grid%configuration%horizontal%cx) +&
376 ((current_state%u%data(k, jcol+1, icol-1)-&
377 current_state%u%data(k, jcol, icol-1))*&
378 current_state%global_grid%configuration%horizontal%cy+&
379 (current_state%v%data(k, jcol, icol)-&
380 current_state%v%data(k, jcol, icol-1))*&
381 current_state%global_grid%configuration%horizontal%cx)) +(&
382 ((current_state%u%data(k, jcol, icol)-&
383 current_state%u%data(k, jcol-1, icol))*&
384 current_state%global_grid%configuration%horizontal%cy+&
385 (current_state%v%data(k, jcol-1, icol+1)-&
386 current_state%v%data(k, jcol-1, icol))*&
387 current_state%global_grid%configuration%horizontal%cx) +&
388 ((current_state%u%data(k, jcol+1, icol)-&
389 current_state%u%data(k, jcol, icol))*&
390 current_state%global_grid%configuration%horizontal%cy+&
391 (current_state%v%data(k, jcol, icol+1)-&
392 current_state%v%data(k, jcol, icol))*&
393 current_state%global_grid%configuration%horizontal%cx)))+((&
394 ((current_state%u%data(k+1, jcol, icol-1)-&
395 current_state%u%data(k+1, jcol-1, icol-1))*&
396 current_state%global_grid%configuration%horizontal%cy+&
397 (current_state%v%data(k+1, jcol-1, icol)-&
398 current_state%v%data(k+1, jcol-1, icol-1))*&
399 current_state%global_grid%configuration%horizontal%cx)+&
400 ((current_state%u%data(k+1, jcol+1, icol-1)-&
401 current_state%u%data(k+1, jcol, icol-1))*&
402 current_state%global_grid%configuration%horizontal%cy+&
403 (current_state%v%data(k+1, jcol, icol)-&
404 current_state%v%data(k+1, jcol, icol-1))*&
405 current_state%global_grid%configuration%horizontal%cx))+(&
406 ((current_state%u%data(k+1, jcol, icol)-&
407 current_state%u%data(k+1, jcol-1, icol))*&
408 current_state%global_grid%configuration%horizontal%cy+&
409 (current_state%v%data(k+1, jcol-1, icol+1)-&
410 current_state%v%data(k+1, jcol-1, icol))*&
411 current_state%global_grid%configuration%horizontal%cx)+&
412 ((current_state%u%data(k+1, jcol+1, icol)-&
413 current_state%u%data(k+1, jcol, icol))*&
414 current_state%global_grid%configuration%horizontal%cy+&
415 (current_state%v%data(k+1, jcol, icol+1)-&
416 current_state%v%data(k+1, jcol, icol))*&
417 current_state%global_grid%configuration%horizontal%cx))))*0.125_default_precision
419 #elif defined(U_ACTIVE) && !defined(V_ACTIVE)
421 s12(k)=(((((current_state%u%data(k, jcol, icol-1)-&
422 current_state%u%data(k, jcol-1, icol-1))*&
423 current_state%global_grid%configuration%horizontal%cy) +&
424 ((current_state%u%data(k, jcol+1, icol-1)-&
425 current_state%u%data(k, jcol, icol-1))*&
426 current_state%global_grid%configuration%horizontal%cy)) +(&
427 ((current_state%u%data(k, jcol, icol)-&
428 current_state%u%data(k, jcol-1, icol))*&
429 current_state%global_grid%configuration%horizontal%cy) +&
430 ((current_state%u%data(k, jcol+1, icol)-&
431 current_state%u%data(k, jcol, icol))*&
432 current_state%global_grid%configuration%horizontal%cy)))+((&
433 ((current_state%u%data(k+1, jcol, icol-1)-&
434 current_state%u%data(k+1, jcol-1, icol-1))*&
435 current_state%global_grid%configuration%horizontal%cy)+&
436 ((current_state%u%data(k+1, jcol+1, icol-1)-&
437 current_state%u%data(k+1, jcol, icol-1))*&
438 current_state%global_grid%configuration%horizontal%cy))+(&
439 ((current_state%u%data(k+1, jcol, icol)-&
440 current_state%u%data(k+1, jcol-1, icol))*&
441 current_state%global_grid%configuration%horizontal%cy)+&
442 ((current_state%u%data(k+1, jcol+1, icol)-&
443 current_state%u%data(k+1, jcol, icol))*&
444 current_state%global_grid%configuration%horizontal%cy))))*0.125_default_precision
446 #elif !defined(U_ACTIVE) && defined(V_ACTIVE)
448 s12(k)=(((((current_state%v%data(k, jcol-1, icol)-&
449 current_state%v%data(k, jcol-1, icol-1))*&
450 current_state%global_grid%configuration%horizontal%cx) +&
451 ((current_state%v%data(k, jcol, icol)-&
452 current_state%v%data(k, jcol, icol-1))*&
453 current_state%global_grid%configuration%horizontal%cx)) +&
454 (((current_state%v%data(k, jcol-1, icol+1)-&
455 current_state%v%data(k, jcol-1, icol))*&
456 current_state%global_grid%configuration%horizontal%cx) +&
457 ((current_state%v%data(k, jcol, icol+1)-&
458 current_state%v%data(k, jcol, icol))*&
459 current_state%global_grid%configuration%horizontal%cx)))+((&
460 ((current_state%v%data(k+1, jcol-1, icol)-&
461 current_state%v%data(k+1, jcol-1, icol-1))*&
462 current_state%global_grid%configuration%horizontal%cx)+&
463 ((current_state%v%data(k+1, jcol, icol)-&
464 current_state%v%data(k+1, jcol, icol-1))*&
465 current_state%global_grid%configuration%horizontal%cx))+(&
466 ((current_state%v%data(k+1, jcol-1, icol+1)-&
467 current_state%v%data(k+1, jcol-1, icol))*&
468 current_state%global_grid%configuration%horizontal%cx)+&
469 ((current_state%v%data(k+1, jcol, icol+1)-&
470 current_state%v%data(k+1, jcol, icol))*&
471 current_state%global_grid%configuration%horizontal%cx))))*0.125_default_precision
473 s12(k)=0.0_default_precision
477 #if defined(U_ACTIVE)
479 s13(1)=(current_state%u%data(2, jcol, icol) + &
480 current_state%u%data(2, jcol, icol-1)) * &
481 0.5_default_precision / current_state%global_grid%configuration%vertical%zn(2)
483 s13(1)=0.0_default_precision
485 #if defined(V_ACTIVE)
487 s23(1)=(current_state%v%data(2, jcol, icol) + &
488 current_state%v%data(2, jcol-1, icol)) * &
489 0.5_default_precision / current_state%global_grid%configuration%vertical%zn(2)
491 s23(1)=0.0_default_precision
493 s12(1)=0.0_default_precision
495 do k=1,current_state%local_grid%size(
z_index)-1
496 tau11(k) = current_state%global_grid%configuration%vertical%rho(k) * &
497 current_state%vis_coefficient%data(k,jcol,icol) * &
499 tau22(k) = current_state%global_grid%configuration%vertical%rho(k) * &
500 current_state%vis_coefficient%data(k,jcol,icol) * &
502 tau33(k) = current_state%global_grid%configuration%vertical%rho(k) * &
503 current_state%vis_coefficient%data(k,jcol,icol) * &
505 tau12(k) = current_state%global_grid%configuration%vertical%rho(k) * &
506 current_state%vis_coefficient%data(k,jcol,icol) * &
508 tau13(k) = current_state%global_grid%configuration%vertical%rho(k) * &
509 current_state%vis_coefficient%data(k,jcol,icol) * &
511 tau23(k) = current_state%global_grid%configuration%vertical%rho(k) * &
512 current_state%vis_coefficient%data(k,jcol,icol) * &
516 do k=2,current_state%local_grid%size(
z_index)-1
517 tau33_on_p(k) = current_state%global_grid%configuration%vertical%rhon(k) * 0.5 *&
518 (current_state%vis_coefficient%data(k-1,jcol,icol) + &
519 current_state%vis_coefficient%data(k, jcol,icol)) * &
524 do k=1, current_state%local_grid%size(
z_index)-1
528 uwsg_tot(k) = uwsg_tot(k) - 0.5 * &
529 current_state%vis_coefficient%data(k,jcol,icol-1) * &
530 ( current_state%u%data(k+1,jcol,icol-1) - &
531 current_state%u%data(k,jcol,icol-1) ) * &
532 vertical_grid%rdzn(k+1)
533 uwsg_tot(k) = uwsg_tot(k) - 0.5 * &
534 current_state%vis_coefficient%data(k,jcol,icol) * &
535 ( current_state%u%data(k+1,jcol,icol) - &
536 current_state%u%data(k,jcol,icol) ) * &
537 vertical_grid%rdzn(k+1)
541 vwsg_tot(k) = vwsg_tot(k) - 0.5 * &
542 current_state%vis_coefficient%data(k,jcol-1,icol) * &
543 ( current_state%v%data(k+1,jcol-1,icol) - &
544 current_state%v%data(k,jcol-1,icol) ) * &
545 vertical_grid%rdzn(k+1)
546 vwsg_tot(k) = vwsg_tot(k) - 0.5 * &
547 current_state%vis_coefficient%data(k,jcol,icol) * &
548 ( current_state%v%data(k+1,jcol,icol) - &
549 current_state%v%data(k,jcol,icol) ) * &
550 vertical_grid%rdzn(k+1)
553 vis_coef_tot(k) = vis_coef_tot(k) + &
554 current_state%vis_coefficient%data(k,jcol,icol)
555 diff_coef_tot(k) = diff_coef_tot(k) + &
556 current_state%diff_coefficient%data(k,jcol,icol)
560 if (current_state%th%active)
then
561 do k=1, current_state%local_grid%size(
z_index)-1
562 wtsg_tot(k) = wtsg_tot(k) - &
563 current_state%diff_coefficient%data(k,jcol,icol) * &
564 ( current_state%th%data(k+1,jcol,icol) + &
565 vertical_grid%thref(k+1) - &
566 current_state%th%data(k,jcol,icol) - &
567 vertical_grid%thref(k) ) * &
568 vertical_grid%rdzn(k+1)
573 if (current_state%th%active .and. .not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
575 do k=1, current_state%local_grid%size(
z_index)-1
576 wqv_sg_tot(k) = wqv_sg_tot(k) + &
577 current_state%diff_coefficient%data(k, jcol, icol)* &
578 vertical_grid%rdzn(k+1) * &
579 (current_state%q(iqv)%data(k,jcol,icol) - current_state%q(iqv)%data(k+1,jcol,icol))
580 wql_sg_tot(k) = wql_sg_tot(k) + &
581 current_state%diff_coefficient%data(k, jcol, icol)* &
582 vertical_grid%rdzn(k+1) * &
583 (current_state%q(iql)%data(k,jcol,icol) - current_state%q(iql)%data(k+1,jcol,icol))
586 do k=1, current_state%local_grid%size(
z_index)-1
587 wqr_sg_tot(k) = wqr_sg_tot(k) + &
588 current_state%diff_coefficient%data(k, jcol, icol)* &
589 vertical_grid%rdzn(k+1) * &
590 (current_state%q(iqr)%data(k,jcol,icol) - current_state%q(iqr)%data(k+1,jcol,icol))
594 do k=1, current_state%local_grid%size(
z_index)-1
595 wqi_sg_tot(k) = wqi_sg_tot(k) + &
596 current_state%diff_coefficient%data(k, jcol, icol)* &
597 vertical_grid%rdzn(k+1) * &
598 (current_state%q(iqi)%data(k,jcol,icol) - current_state%q(iqi)%data(k+1,jcol,icol))
602 do k=1, current_state%local_grid%size(
z_index)-1
603 wqs_sg_tot(k) = wqs_sg_tot(k) + &
604 current_state%diff_coefficient%data(k, jcol, icol)* &
605 vertical_grid%rdzn(k+1) * &
606 (current_state%q(iqs)%data(k,jcol,icol) - current_state%q(iqs)%data(k+1,jcol,icol))
610 do k=1, current_state%local_grid%size(
z_index)-1
611 wqg_sg_tot(k) = wqg_sg_tot(k) + &
612 current_state%diff_coefficient%data(k, jcol, icol)* &
613 vertical_grid%rdzn(k+1) * &
614 (current_state%q(iqg)%data(k,jcol,icol) - current_state%q(iqg)%data(k+1,jcol,icol))
621 u_1=sqrt(current_state%u%data(2,jcol,icol) * &
622 current_state%u%data(2,jcol,icol) + &
623 current_state%v%data(2,jcol,icol) * &
624 current_state%v%data(2,jcol,icol))
625 u_1_bar=sqrt(current_state%global_grid%configuration%vertical%olubar(2)*&
626 current_state%global_grid%configuration%vertical%olubar(2)+&
627 current_state%global_grid%configuration%vertical%olvbar(2)*&
628 current_state%global_grid%configuration%vertical%olvbar(2))
631 do k=1, current_state%local_grid%size(
z_index)-1
632 rho(k) = current_state%global_grid%configuration%vertical%rho(k)
637 do k=1, current_state%local_grid%size(
z_index)
638 buoy_cof(k)=g/current_state%global_grid%configuration%vertical%thref(k)
646 ri_crit = 0.25_default_precision
648 ssq=calculate_half_squared_strain_rate(current_state, current_state%u, current_state%v, current_state%w)
649 richardson_number=calculate_richardson_number(current_state, ssq, current_state%th, current_state%q)
651 do k=2, current_state%local_grid%size(
z_index)-1
656 current_state%vis_coefficient%data(k, jcol, icol) &
657 > 0.0) .and. (richardson_number(k) < ri_crit) )
then
659 current_state%vis_coefficient%data(k, jcol, icol) / &
660 sqrt( 1.0 - richardson_number(k) * &
661 current_state%diff_coefficient%data(k, jcol, icol) / &
662 current_state%vis_coefficient%data(k, jcol, icol) )
664 if (l_lem_dissipation_rate)
then
665 dissipation_rate = ssq(k) * ( &
666 current_state%vis_coefficient%data(k, jcol, icol) - &
667 richardson_number(k) * &
668 current_state%diff_coefficient%data(k, jcol, icol) )
670 if (use_ri_for_buoyant_prod)
then
672 buoy_prod = -ssq(k) * richardson_number(k) * &
673 current_state%diff_coefficient%data(k, jcol, icol)
676 if (current_state%th%active .and. &
677 .not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
679 -current_state%diff_coefficient%data(k,jcol,icol) * &
681 current_state%global_grid%configuration%vertical%rdzn(k+1) * &
685 (current_state%th%data(k+1,jcol,icol) + &
686 current_state%global_grid%configuration%vertical%thref(k+1) + &
688 current_state%global_grid%configuration%vertical%thref(k+1) * &
689 (c_virtual * current_state%q(1)%data(k+1,jcol,icol) - &
690 current_state%q(2)%data(k+1,jcol,icol))) - &
693 (current_state%th%data(k,jcol,icol) + &
694 current_state%global_grid%configuration%vertical%thref(k) + &
695 current_state%global_grid%configuration%vertical%thref(k) * &
696 (c_virtual * current_state%q(1)%data(k,jcol,icol) - &
697 current_state%q(2)%data(k,jcol,icol))) )
700 "Subgrid diags - buoy_prod calc needs theta and q active, STOP")
705 dissipation_rate = ssq(k) * &
706 current_state%vis_coefficient%data(k, jcol, icol) + &
709 buoysg_tot(k)=buoysg_tot(k) + buoy_prod
713 dissipation_tot(k) = dissipation_tot(k) + dissipation_rate
720 subgrid_tke(k) = ( dissipation_rate * dissipation_rate * elamr_sq(k) ) ** (1.0/3.0) / a2_n
723 tkesg_tot(k) = tkesg_tot(k) + subgrid_tke(k)
724 uusg_tot(k) = uusg_tot(k) + (2.0/3.0) * subgrid_tke(k)
725 vvsg_tot(k) = vvsg_tot(k) + (2.0/3.0) * subgrid_tke(k)
726 wwsg_tot(k) = wwsg_tot(k) + (2.0/3.0) * subgrid_tke(k)
727 wkesg_tot(k) = wkesg_tot(k) + subgrid_tke(k) * &
728 current_state%w%data(k,jcol,icol)
729 richardson_number_tot(k) = richardson_number_tot(k) + richardson_number(k)
730 richardson_squared_tot(k) = richardson_squared_tot(k) + richardson_number(k)**2.0_default_precision
734 subke_2d(target_y_index, target_x_index) = subke_2d(target_y_index, target_x_index) + &
735 (subgrid_tke(k)*0.5_default_precision* &
736 vertical_grid%dzn(k+1)* &
737 vertical_grid%rho(k))
744 if (.not. l_lem_dissipation_rate)
then
745 if (current_state%th%active .and. &
746 .not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
749 -current_state%diff_coefficient%data(k,jcol,icol) * &
751 current_state%global_grid%configuration%vertical%rdzn(k+1) * &
755 (current_state%th%data(k+1,jcol,icol) + &
756 current_state%global_grid%configuration%vertical%thref(k+1) + &
758 current_state%global_grid%configuration%vertical%thref(k+1) * &
759 (c_virtual * current_state%q(1)%data(k+1,jcol,icol) &
760 - current_state%q(2)%data(k+1,jcol,icol))) - &
763 (current_state%th%data(k,jcol,icol) + &
764 current_state%global_grid%configuration%vertical%thref(k) + &
765 current_state%global_grid%configuration%vertical%thref(k) * &
766 (c_virtual * current_state%q(1)%data(k,jcol,icol) &
767 - current_state%q(2)%data(k,jcol,icol))) )
769 buoysg_tot(k)=buoysg_tot(k) + buoy_prod
772 dissipation_tot(1) = dissipation_tot(1) + &
773 current_state%vis_coefficient%data(1, jcol, icol) &
775 (current_state%global_grid%configuration%vertical%zn(2) * &
776 current_state%global_grid%configuration%vertical%zn(2)) + buoy_prod
779 "Subgrid diags - buoy_prod calc needs theta and q active, STOP")
786 subke_2d(target_y_index, target_x_index) = subke_2d(target_y_index, target_x_index)/ &
787 vertical_grid%z(current_state%local_grid%size(
z_index))
792 if (current_state%th%active)
then
793 epsth=calculate_thermal_dissipation_rate(current_state, current_state%th)
796 do k=2, current_state%local_grid%size(
z_index)-1
798 theta_dis_tot(k) = theta_dis_tot(k) + epsth(k)
799 if (subgrid_tke(k) > 0.0) &
800 th2sg_tot(k) = th2sg_tot(k) + sqrt( a2_n * elamr_sq(k) / subgrid_tke(k) ) * &
801 epsth(k) / ( ath2_n**2 * pr_n)
809 do k=2,current_state%local_grid%size(
z_index)-1
813 umean(k)=(current_state%global_grid%configuration%vertical%olubar(k+1) - &
814 current_state%global_grid%configuration%vertical%olubar(k)) * &
815 current_state%global_grid%configuration%vertical%rdzn(k+1)
816 vmean(k)=(current_state%global_grid%configuration%vertical%olvbar(k+1) - &
817 current_state%global_grid%configuration%vertical%olvbar(k)) * &
818 current_state%global_grid%configuration%vertical%rdzn(k+1)
820 sg_shear_prod = current_state%vis_coefficient%data(k,jcol,icol)* &
821 (s13(k)*umean(k)+s23(k)*vmean(k))
823 ssub_tot(k)=ssub_tot(k) + sg_shear_prod
826 uwsg(k)=0.5*(tau13(k)+tau13(k+1))/rho(k)
827 vwsg(k)=0.5*(tau23(k)+tau23(k+1))/rho(k)
833 sg_shear_prod = current_state%vis_coefficient%data(1, jcol, icol) * &
835 (current_state%u%data(2,jcol,icol-1) + &
836 current_state%u%data(2,jcol,icol) ) * &
837 current_state%global_grid%configuration%vertical%olubar(2) + &
839 (current_state%v%data(2,jcol-1,icol) + &
840 current_state%v%data(2,jcol,icol) ) * &
841 current_state%global_grid%configuration%vertical%olvbar(2) ) / &
842 (current_state%global_grid%configuration%vertical%zn(2) * &
843 current_state%global_grid%configuration%vertical%zn(2))
845 ssub_tot(1)=ssub_tot(1) + sg_shear_prod
851 do k=2, current_state%local_grid%size(
z_index)
853 u_i_prime_tau_i(k) = ( 0.5_default_precision * &
854 (current_state%u%data(k,jcol,icol-1) + &
855 current_state%u%data(k,jcol,icol) ) - &
856 current_state%global_grid%configuration%vertical%olubar(k)) * &
857 0.5_default_precision * ( tau13(k-1)+tau13(k))
859 u_i_prime_tau_i(k) = u_i_prime_tau_i(k) + ( 0.5_default_precision * &
860 (current_state%v%data(k,jcol-1,icol) + &
861 current_state%v%data(k,jcol,icol) ) - &
862 current_state%global_grid%configuration%vertical%olvbar(k)) * &
863 0.5_default_precision * ( tau23(k-1)+tau23(k))
865 u_i_prime_tau_i(k) = u_i_prime_tau_i(k) + ( 0.5_default_precision * &
866 (current_state%w%data(k-1,jcol,icol)+&
867 current_state%w%data(k,jcol,icol))) *&
872 u_i_prime_tau_i(1) = &
873 ( 0.5_default_precision * &
874 (current_state%u%data(2,jcol,icol-1) + &
875 current_state%u%data(2,jcol,icol) ) - &
876 current_state%global_grid%configuration%vertical%olubar(2) ) * &
877 ( 0.5_default_precision * &
878 (current_state%u%data(2,jcol,icol-1) + &
879 current_state%u%data(2,jcol,icol) ) )
881 u_i_prime_tau_i(1) = u_i_prime_tau_i(1) + &
882 ( 0.5_default_precision * &
883 (current_state%v%data(2,jcol-1,icol) + &
884 current_state%v%data(2,jcol,icol) ) - &
885 current_state%global_grid%configuration%vertical%olvbar(2) ) * &
886 ( 0.5_default_precision * &
887 (current_state%v%data(2,jcol-1,icol) + &
888 current_state%v%data(2,jcol,icol) ) )
892 u_i_prime_tau_i(1) = u_i_prime_tau_i(1) * &
893 current_state%vis_coefficient%data(1,jcol,icol) / &
894 current_state%global_grid%configuration%vertical%zn(2)
897 do k=2, current_state%local_grid%size(
z_index)-1
898 sed_tot(k)=sed_tot(k) + (u_i_prime_tau_i(k+1)-u_i_prime_tau_i(k)) * &
899 current_state%global_grid%configuration%vertical%rdzn(k+1) / &
900 current_state%global_grid%configuration%vertical%rho(k)
903 sed_tot(1)=sed_tot(1) + u_i_prime_tau_i(1) / &
904 current_state%global_grid%configuration%vertical%zn(2)