288 matrix_solver_tridiagonal
292 real(RP),
intent(out) :: qflx_sgs_momz(KA,IA,JA,3)
293 real(RP),
intent(out) :: qflx_sgs_momx(KA,IA,JA,3)
294 real(RP),
intent(out) :: qflx_sgs_momy(KA,IA,JA,3)
295 real(RP),
intent(out) :: qflx_sgs_rhot(KA,IA,JA,3)
296 real(RP),
intent(out) :: qflx_sgs_rhoq(KA,IA,JA,3,QA)
298 real(RP),
intent(out) :: MOMZ_t (KA,IA,JA)
299 real(RP),
intent(out) :: MOMX_t (KA,IA,JA)
300 real(RP),
intent(out) :: MOMY_t (KA,IA,JA)
301 real(RP),
intent(out) :: RHOT_t (KA,IA,JA)
302 real(RP),
intent(out) :: RHOQ_t (KA,IA,JA,QA)
304 real(RP),
intent(out) :: nu (KA,IA,JA)
305 real(RP),
intent(out) :: Ri (KA,IA,JA)
306 real(RP),
intent(out) :: Pr (KA,IA,JA)
308 real(RP),
intent(in) :: MOMZ (KA,IA,JA)
309 real(RP),
intent(in) :: MOMX (KA,IA,JA)
310 real(RP),
intent(in) :: MOMY (KA,IA,JA)
311 real(RP),
intent(in) :: POTT (KA,IA,JA)
312 real(RP),
intent(in) :: DENS (KA,IA,JA)
313 real(RP),
intent(in) :: QTRC (KA,IA,JA,QA)
314 real(RP),
intent(in) :: N2 (KA,IA,JA)
316 real(RP),
intent(in) :: FZ (0:KA,IA,JA)
317 real(RP),
intent(in) :: FDZ (KA-1)
318 real(RP),
intent(in) :: RCDZ (KA)
319 real(RP),
intent(in) :: RFDZ (KA-1)
320 real(RP),
intent(in) :: CDX (IA)
321 real(RP),
intent(in) :: FDX (IA-1)
322 real(RP),
intent(in) :: CDY (JA)
323 real(RP),
intent(in) :: FDY (JA-1)
325 real(RP),
intent(in) :: GSQRT (KA,IA,JA,7)
326 real(RP),
intent(in) :: J13G (KA,IA,JA,7)
327 real(RP),
intent(in) :: J23G (KA,IA,JA,7)
328 real(RP),
intent(in) :: J33G
329 real(RP),
intent(in) :: MAPF(IA,JA,2,4)
330 real(DP),
intent(in) :: dt
333 real(RP) :: TKE(KA,IA,JA)
336 real(RP) :: S33_C(KA,IA,JA)
337 real(RP) :: S11_C(KA,IA,JA)
338 real(RP) :: S22_C(KA,IA,JA)
339 real(RP) :: S31_C(KA,IA,JA)
340 real(RP) :: S12_C(KA,IA,JA)
341 real(RP) :: S23_C(KA,IA,JA)
342 real(RP) :: S12_Z(KA,IA,JA)
343 real(RP) :: S23_X(KA,IA,JA)
344 real(RP) :: S31_Y(KA,IA,JA)
345 real(RP) :: S2 (KA,IA,JA)
347 real(RP) :: Kh(KA,IA,JA)
351 real(RP) :: lambda_r(KA)
358 real(RP) :: TEND(KA,IA,JA)
359 real(RP) :: TEND2(KA,IA,JA)
360 real(RP) :: a (KA,IA,JA)
361 real(RP) :: b (KA,IA,JA)
362 real(RP) :: c (KA,IA,JA)
366 real(RP) :: random (KA,IA,JA)
367 real(RP) :: random_mz(KA,IA,JA)
368 real(RP) :: random_mx(KA,IA,JA)
369 real(RP) :: random_my(KA,IA,JA)
370 real(RP) :: random_qz(KA,IA,JA)
371 real(RP) :: random_qx(KA,IA,JA)
372 real(RP) :: random_qy(KA,IA,JA)
373 real(RP) :: dd (KA,IA,JA)
375 real(RP) :: dz, dx, dy
382 integer :: k, i, j, iq
396 log_progress(*)
'atmosphere / physics / turbulence / Smagorinsky'
400 qflx_sgs_momz(:,:,:,:) = undef
401 qflx_sgs_momx(:,:,:,:) = undef
402 qflx_sgs_momy(:,:,:,:) = undef
403 qflx_sgs_rhot(:,:,:,:) = undef
404 qflx_sgs_rhoq(:,:,:,:,:) = undef
416 qflx_sgs_momz(ks:ke, 1:is-1, : ,:) = undef
417 qflx_sgs_momz(ks:ke,ie+1:ia , : ,:) = undef
418 qflx_sgs_momz(ks:ke, : , 1:js-1,:) = undef
419 qflx_sgs_momz(ks:ke, : ,je+1:ja ,:) = undef
420 qflx_sgs_momx(ks:ke, 1:is-1, : ,:) = undef
421 qflx_sgs_momx(ks:ke,ie+1:ia , : ,:) = undef
422 qflx_sgs_momx(ks:ke, : , 1:js-1,:) = undef
423 qflx_sgs_momx(ks:ke, : ,je+1:ja ,:) = undef
424 qflx_sgs_momy(ks:ke, 1:is-1, : ,:) = undef
425 qflx_sgs_momy(ks:ke,ie+1:ia , : ,:) = undef
426 qflx_sgs_momy(ks:ke, : , 1:js-1,:) = undef
427 qflx_sgs_momy(ks:ke, : ,je+1:ja ,:) = undef
434 call calc_strain_tensor( &
435 s33_c, s11_c, s22_c, &
436 s31_c, s12_c, s23_c, &
437 s12_z, s23_x, s31_y, &
439 dens, momz, momx, momy, &
440 gsqrt, j13g, j23g, j33g, mapf )
442 if ( atmos_phy_tb_smg_backscatter )
then
443 call random_normal( random(:,:,:) )
450 random_mz(k,i,j) = ( random(k,i,j) * 2.0_rp &
451 + random(k+1,i,j) + random(k-1,i,j) &
452 + random(k,i+1,j) + random(k,i-1,j) &
453 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
455 random_mz(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
457 + random(ks,i+1,j) + random(ks,i-1,j) &
458 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
459 random_mz(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
461 + random(ke,i+1,j) + random(ke,i-1,j) &
462 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
467 call random_normal( random(:,:,:) )
474 random_mx(k,i,j) = ( random(k,i,j) * 2.0_rp &
475 + random(k+1,i,j) + random(k-1,i,j) &
476 + random(k,i+1,j) + random(k,i-1,j) &
477 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
479 random_mx(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
481 + random(ks,i+1,j) + random(ks,i-1,j) &
482 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
483 random_mx(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
485 + random(ke,i+1,j) + random(ke,i-1,j) &
486 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
491 call random_normal( random(:,:,:) )
498 random_my(k,i,j) = ( random(k,i,j) * 2.0_rp &
499 + random(k+1,i,j) + random(k-1,i,j) &
500 + random(k,i+1,j) + random(k,i-1,j) &
501 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
503 random_my(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
505 + random(ks,i+1,j) + random(ks,i-1,j) &
506 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
507 random_my(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
509 + random(ke,i+1,j) + random(ke,i-1,j) &
510 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
515 call random_normal( random(:,:,:) )
522 random_qz(k,i,j) = ( random(k,i,j) * 2.0_rp &
523 + random(k+1,i,j) + random(k-1,i,j) &
524 + random(k,i+1,j) + random(k,i-1,j) &
525 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
527 random_qz(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
529 + random(ks,i+1,j) + random(ks,i-1,j) &
530 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
531 random_qz(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
533 + random(ke,i+1,j) + random(ke,i-1,j) &
534 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
539 call random_normal( random(:,:,:) )
546 random_qx(k,i,j) = ( random(k,i,j) * 2.0_rp &
547 + random(k+1,i,j) + random(k-1,i,j) &
548 + random(k,i+1,j) + random(k,i-1,j) &
549 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
551 random_qx(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
553 + random(ks,i+1,j) + random(ks,i-1,j) &
554 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
555 random_qx(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
557 + random(ke,i+1,j) + random(ke,i-1,j) &
558 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
563 call random_normal( random(:,:,:) )
570 random_qy(k,i,j) = ( random(k,i,j) * 2.0_rp &
571 + random(k+1,i,j) + random(k-1,i,j) &
572 + random(k,i+1,j) + random(k,i-1,j) &
573 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
575 random_qy(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
577 + random(ks,i+1,j) + random(ks,i-1,j) &
578 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
579 random_qy(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
581 + random(ke,i+1,j) + random(ke,i-1,j) &
582 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
598 ri(k,i,j) = n2(k,i,j) / max(s2(k,i,j), eps)
604 if ( ri(k,i,j) < 0.0_rp )
then
605 fm(k) = sqrt( 1.0_rp - fmc * ri(k,i,j) )
606 nu(k,i,j) = lambda(k,i,j)**2 * sqrt( s2(k,i,j) ) * fm(k)
607 pr(k,i,j) = fm(k) / sqrt( 1.0_rp - fhb*ri(k,i,j) ) * prn
608 else if ( ri(k,i,j) < ric )
then
609 fm(k) = ( 1.0_rp - ri(k,i,j)*rric )**4
610 nu(k,i,j) = lambda(k,i,j)**2 * sqrt( s2(k,i,j) ) * fm(k)
611 pr(k,i,j) = prn / ( 1.0_rp - prnovric * ri(k,i,j) )
619 if ( ri(k,i,j) < ric )
then
620 kh(k,i,j) = max( min( nu(k,i,j) / pr(k,i,j), atmos_phy_tb_smg_nu_max ), eps )
621 nu(k,i,j) = max( min( nu(k,i,j), atmos_phy_tb_smg_nu_max ), eps )
622 pr(k,i,j) = nu(k,i,j) / kh(k,i,j)
623 rf = ri(k,i,j) / pr(k,i,j)
624 lambda_r(k) = lambda(k,i,j) * sqrt( fm(k) / sqrt( 1.0_rp - rf ) )
632 if ( atmos_phy_tb_smg_backscatter )
then
634 lambda_r(k) = min( 1.8_rp * lambda0(k,i,j), lambda_r(k) )
635 leovleo5 = ( lambda_r(k) / lambda0(k,i,j) )**5
636 c2 = cb * leovleo5 / ( 1.0_rp + cb * leovleo5 )
637 d2 = cbt * leovleo5 / ( 1.0_rp + cbt * leovleo5 )
638 c1(k) = c1o / sqrt( 1.0_rp - c2 )
640 e(k) = nu(k,i,j)**3 * ( 1.0_rp - c2 ) / ( lambda_r(k)**4 + eps )
641 et = kh(k,i,j) * ( 1.0_rp - d2 )
643 dz = fz(k,i,j) - fz(k-1,i,j)
644 dx = cdx(i) / mapf(i,j,1,
i_xy)
645 dy = cdy(j) / mapf(i,j,2,
i_xy)
647 fact = sqrt( cb * leovleo5 * e(k) / ( 3.0_rp * dt ) ) * dens(k,i,j)
648 random_mz(k,i,j) = random_mz(k,i,j) * fact * dx * dy / sqrt( dx**2 + dy**2 )
649 random_mx(k,i,j) = random_mx(k,i,j) * fact * dy * dz / sqrt( dy**2 + dz**2 )
650 random_my(k,i,j) = random_my(k,i,j) * fact * dz * dx / sqrt( dz**2 + dx**2 )
652 fact = sqrt( cbt * leovleo5 * et / ( 3.0_rp * dt ) ) * dens(k,i,j)
653 random_qz(k,i,j) = random_qz(k,i,j) * fact * dz
654 random_qx(k,i,j) = random_qx(k,i,j) * fact * dx
655 random_qy(k,i,j) = random_qy(k,i,j) * fact * dy
661 e(k) = nu(k,i,j)**3 / ( lambda_r(k)**4 + eps )
669 tke(k,i,j) = ( e(k) * lambda_r(k) / c1(k) )**twooverthree
676 i = iundef; j = iundef; k = iundef
688 if ( atmos_phy_tb_smg_horizontal )
then
691 qflx_sgs_momz(:,:,:,
zdir) = 0.0_rp
701 call check( __line__, dens(k,i,j) )
702 call check( __line__, nu(k,i,j) )
703 call check( __line__, s33_c(k,i,j) )
704 call check( __line__, s11_c(k,i,j) )
705 call check( __line__, s22_c(k,i,j) )
706 call check( __line__, tke(k,i,j) )
708 qflx_sgs_momz(k,i,j,
zdir) = dens(k,i,j) * ( &
709 - 2.0_rp * nu(k,i,j) &
710 * ( s33_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
711 + twooverthree * tke(k,i,j) * tke_fact )
717 i = iundef; j = iundef; k = iundef
724 qflx_sgs_momz(ks,i,j,
zdir) = dens(ks,i,j) * twooverthree * tke(ks,i,j) * tke_fact
725 qflx_sgs_momz(ke,i,j,
zdir) = dens(ke,i,j) * twooverthree * tke(ke,i,j) * tke_fact
732 i = iundef; j = iundef; k = iundef
742 call check( __line__, dens(k,i,j) )
743 call check( __line__, dens(k,i+1,j) )
744 call check( __line__, dens(k+1,i,j) )
745 call check( __line__, dens(k+1,i+1,j) )
746 call check( __line__, nu(k,i,j) )
747 call check( __line__, nu(k,i+1,j) )
748 call check( __line__, nu(k+1,i,j) )
749 call check( __line__, nu(k+1,i+1,j) )
750 call check( __line__, s31_y(k,i,j) )
752 qflx_sgs_momz(k,i,j,
xdir) = - 0.125_rp &
753 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i+1,j)+dens(k+1,i+1,j) ) &
754 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i+1,j)+nu(k+1,i+1,j)) &
762 i = iundef; j = iundef; k = iundef
771 call check( __line__, dens(k,i,j) )
772 call check( __line__, dens(k,i,j+1) )
773 call check( __line__, dens(k+1,i,j) )
774 call check( __line__, dens(k+1,i,j+1) )
775 call check( __line__, nu(k,i,j) )
776 call check( __line__, nu(k,i,j+1) )
777 call check( __line__, nu(k+1,i,j) )
778 call check( __line__, nu(k+1,i,j+1) )
779 call check( __line__, s23_x(k,i,j) )
781 qflx_sgs_momz(k,i,j,
ydir) = - 0.125_rp &
782 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i,j+1)+dens(k+1,i,j+1) ) &
783 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i,j+1)+nu(k+1,i,j+1) ) &
791 i = iundef; j = iundef; k = iundef
796 if ( atmos_phy_tb_smg_implicit )
then
798 call calc_tend_momz( tend, &
800 gsqrt, j13g, j23g, j33g, mapf, &
808 ap = - fouroverthree * dt &
809 * dens(ks+1,i,j)*nu(ks+1,i,j) &
810 * rcdz(ks+1) / gsqrt(ks+1,i,j,
i_xyz)
811 a(ks,i,j) = ap * rfdz(ks) / gsqrt(ks,i,j,
i_xyw)
813 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks+1,i,j) )
816 ap = - fouroverthree * dt &
817 * dens(k,i,j)*nu(k,i,j) &
818 * rcdz(k) / gsqrt(k,i,j,
i_xyz)
820 c(k,i,j) = ap * rfdz(k+1) / gsqrt(k+1,i,j,
i_xyw)
821 ap = - fouroverthree * dt &
822 * dens(k+1,i,j)*nu(k+1,i,j) &
823 * rcdz(k+1) / gsqrt(k+1,i,j,
i_xyz)
824 a(k,i,j) = ap * rfdz(k) / gsqrt(k,i,j,
i_xyw)
825 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k+1,i,j) )
828 ap = - fouroverthree * dt &
829 * dens(ke-1,i,j)*nu(ke-1,i,j) &
830 * rcdz(ke-1) / gsqrt(ke-1,i,j,
i_xyz)
833 c(ke-1,i,j) = ap * rfdz(ke) / gsqrt(ke,i,j,
i_xyw)
834 b(ke-1,i,j) = - c(ke-1,i,j) + 0.5_rp * ( dens(ke-1,i,j)+dens(ke,i,j) )
839 call matrix_solver_tridiagonal( ka, ks, ke-1, ia, iis, iie, ja, jjs, jje, &
840 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
848 qflx_sgs_momz(k,i,j,
zdir) = qflx_sgs_momz(k,i,j,
zdir) &
849 - fouroverthree * dens(k,i,j) * nu(k,i,j) * dt &
850 * ( tend2(k,i,j) - tend2(k-1,i,j) ) * rcdz(k) / gsqrt(k,i,j,
i_xyz)
863 if ( atmos_phy_tb_smg_horizontal )
then
866 qflx_sgs_momx(:,:,:,
zdir) = 0.0_rp
876 call check( __line__, dens(k,i,j) )
877 call check( __line__, dens(k,i+1,j) )
878 call check( __line__, dens(k+1,i,j) )
879 call check( __line__, dens(k+1,i+1,j) )
880 call check( __line__, nu(k,i,j) )
881 call check( __line__, nu(k,i+1,j) )
882 call check( __line__, nu(k+1,i,j) )
883 call check( __line__, nu(k+1,i+1,j) )
884 call check( __line__, s31_y(k,i,j) )
886 qflx_sgs_momx(k,i,j,
zdir) = - 0.125_rp &
887 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i+1,j)+dens(k+1,i+1,j) ) &
888 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i+1,j)+nu(k+1,i+1,j) ) &
896 i = iundef; j = iundef; k = iundef
902 qflx_sgs_momx(ks-1,i,j,
zdir) = 0.0_rp
903 qflx_sgs_momx(ke ,i,j,
zdir) = 0.0_rp
909 i = iundef; j = iundef; k = iundef
920 call check( __line__, dens(k,i,j) )
921 call check( __line__, nu(k,i,j) )
922 call check( __line__, s11_c(k,i,j) )
923 call check( __line__, s22_c(k,i,j) )
924 call check( __line__, s33_c(k,i,j) )
925 call check( __line__, tke(k,i,j) )
927 qflx_sgs_momx(k,i,j,
xdir) = dens(k,i,j) * ( &
928 - 2.0_rp * nu(k,i,j) &
929 * ( s11_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
930 + twooverthree * tke(k,i,j) * tke_fact )
937 i = iundef; j = iundef; k = iundef
947 call check( __line__, dens(k,i,j) )
948 call check( __line__, dens(k,i+1,j) )
949 call check( __line__, dens(k,i,j+1) )
950 call check( __line__, dens(k,i+1,j+1) )
951 call check( __line__, nu(k,i,j) )
952 call check( __line__, nu(k,i+1,j) )
953 call check( __line__, nu(k,i,j+1) )
954 call check( __line__, nu(k,i+1,j+1) )
955 call check( __line__, s12_z(k,i,j) )
957 qflx_sgs_momx(k,i,j,
ydir) = - 0.125_rp &
958 * ( dens(k,i,j)+dens(k,i+1,j)+dens(k,i,j+1)+dens(k,i+1,j+1) ) &
959 * ( nu(k,i,j)+nu(k,i+1,j)+nu(k,i,j+1)+nu(k,i+1,j+1) ) &
967 i = iundef; j = iundef; k = iundef
972 if ( atmos_phy_tb_smg_implicit )
then
973 call calc_tend_momx( tend, &
975 gsqrt, j13g, j23g, j33g, mapf, &
984 ap = - dt * 0.25_rp * ( dens(ks ,i ,j)*nu(ks ,i ,j) &
985 + dens(ks+1,i ,j)*nu(ks+1,i ,j) &
986 + dens(ks ,i+1,j)*nu(ks ,i+1,j) &
987 + dens(ks+1,i+1,j)*nu(ks+1,i+1,j) ) &
988 * rfdz(ks) / gsqrt(ks,i,j,
i_uyw)
989 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_uyz)
991 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks,i+1,j) )
994 ap = - dt * 0.25_rp * ( dens(k-1,i ,j)*nu(k-1,i ,j) &
995 + dens(k ,i ,j)*nu(k ,i ,j) &
996 + dens(k-1,i+1,j)*nu(k-1,i+1,j) &
997 + dens(k ,i+1,j)*nu(k ,i+1,j) ) &
998 * rfdz(k-1) / gsqrt(k-1,i,j,
i_uyw)
1000 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_uyz)
1001 ap = - dt * 0.25_rp * ( dens(k ,i ,j)*nu(k ,i ,j) &
1002 + dens(k+1,i ,j)*nu(k+1,i ,j) &
1003 + dens(k ,i+1,j)*nu(k ,i+1,j) &
1004 + dens(k+1,i+1,j)*nu(k+1,i+1,j) ) &
1005 * rfdz(k) / gsqrt(k,i,j,
i_uyw)
1006 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_uyz)
1007 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k,i+1,j) )
1010 ap = - dt * 0.25_rp * ( dens(ke-1,i ,j)*nu(ke-1,i ,j) &
1011 + dens(ke ,i ,j)*nu(ke ,i ,j) &
1012 + dens(ke-1,i+1,j)*nu(ke-1,i+1,j) &
1013 + dens(ke ,i+1,j)*nu(ke ,i+1,j) ) &
1014 * rfdz(ke-1) / gsqrt(ke-1,i,j,
i_uyw)
1017 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_uyz)
1018 b(ke,i,j) = - c(ke,i,j) + 0.5_rp * ( dens(ke,i,j)+dens(ke,i+1,j) )
1023 call matrix_solver_tridiagonal( ka, ks, ke, ia, iis, iie, ja, jjs, jje, &
1024 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
1032 qflx_sgs_momx(k,i,j,
zdir) = qflx_sgs_momx(k,i,j,
zdir) &
1033 - 0.25_rp * ( dens(k ,i ,j)*nu(k ,i ,j) &
1034 + dens(k+1,i ,j)*nu(k+1,i ,j) &
1035 + dens(k ,i+1,j)*nu(k ,i+1,j) &
1036 + dens(k+1,i+1,j)*nu(k+1,i+1,j) ) &
1037 * dt * ( tend2(k+1,i,j) - tend2(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_uyw)
1050 if ( atmos_phy_tb_smg_horizontal )
then
1053 qflx_sgs_momy(:,:,:,
zdir) = 0.0_rp
1063 call check( __line__, dens(k,i,j) )
1064 call check( __line__, dens(k,i,j+1) )
1065 call check( __line__, dens(k+1,i,j) )
1066 call check( __line__, dens(k+1,i,j+1) )
1067 call check( __line__, nu(k,i,j) )
1068 call check( __line__, nu(k,i,j+1) )
1069 call check( __line__, nu(k+1,i,j) )
1070 call check( __line__, nu(k+1,i,j+1) )
1071 call check( __line__, s23_x(k,i,j) )
1073 qflx_sgs_momy(k,i,j,
zdir) = - 0.125_rp &
1074 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i,j+1)+dens(k+1,i,j+1) ) &
1075 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i,j+1)+nu(k+1,i,j+1) ) &
1083 i = iundef; j = iundef; k = iundef
1089 qflx_sgs_momy(ks-1,i,j,
zdir) = 0.0_rp
1090 qflx_sgs_momy(ke ,i,j,
zdir) = 0.0_rp
1096 i = iundef; j = iundef; k = iundef
1107 call check( __line__, dens(k,i,j) )
1108 call check( __line__, dens(k,i+1,j) )
1109 call check( __line__, dens(k,i,j+1) )
1110 call check( __line__, dens(k,i+1,j+1) )
1111 call check( __line__, nu(k,i,j) )
1112 call check( __line__, nu(k,i+1,j) )
1113 call check( __line__, nu(k,i,j+1) )
1114 call check( __line__, nu(k,i+1,j+1) )
1115 call check( __line__, s12_z(k,i,j) )
1117 qflx_sgs_momy(k,i,j,
xdir) = - 0.125_rp &
1118 * ( dens(k,i,j)+dens(k,i+1,j)+dens(k,i,j+1)+dens(k,i+1,j+1) ) &
1119 * ( nu(k,i,j)+nu(k,i+1,j)+nu(k,i,j+1)+nu(k,i+1,j+1) ) &
1127 i = iundef; j = iundef; k = iundef
1137 call check( __line__, dens(k,i,j) )
1138 call check( __line__, nu(k,i,j) )
1139 call check( __line__, s11_c(k,i,j) )
1140 call check( __line__, s22_c(k,i,j) )
1141 call check( __line__, s33_c(k,i,j) )
1142 call check( __line__, tke(k,i,j) )
1144 qflx_sgs_momy(k,i,j,
ydir) = dens(k,i,j) * ( &
1145 - 2.0_rp * nu(k,i,j) &
1146 * ( s22_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
1147 + twooverthree * tke(k,i,j) * tke_fact)
1154 i = iundef; j = iundef; k = iundef
1159 if ( atmos_phy_tb_smg_implicit )
then
1160 call calc_tend_momy( tend, &
1162 gsqrt, j13g, j23g, j33g, mapf, &
1163 iis, iie, jjs, jje )
1171 ap = - dt * 0.25_rp * ( dens(ks ,i,j )*nu(ks ,i,j ) &
1172 + dens(ks+1,i,j )*nu(ks+1,i,j ) &
1173 + dens(ks ,i,j+1)*nu(ks ,i,j+1) &
1174 + dens(ks+1,i,j+1)*nu(ks+1,i,j+1) ) &
1175 * rfdz(ks) / gsqrt(ks,i,j,
i_xvw)
1176 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_xvz)
1178 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks,i,j+1) )
1181 ap = - dt * 0.25_rp * ( dens(k-1,i,j )*nu(k-1,i,j ) &
1182 + dens(k ,i,j )*nu(k ,i,j ) &
1183 + dens(k-1,i,j+1)*nu(k-1,i,j+1) &
1184 + dens(k ,i,j+1)*nu(k ,i,j+1) ) &
1185 * rfdz(k-1) / gsqrt(k-1,i,j,
i_xvw)
1187 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xvz)
1188 ap = - dt * 0.25_rp * ( dens(k ,i,j )*nu(k ,i,j ) &
1189 + dens(k+1,i,j )*nu(k+1,i,j ) &
1190 + dens(k ,i,j+1)*nu(k ,i,j+1) &
1191 + dens(k+1,i,j+1)*nu(k+1,i,j+1) ) &
1192 * rfdz(k) / gsqrt(k,i,j,
i_xvw)
1193 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xvz)
1194 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k,i,j+1) )
1197 ap = - dt * 0.25_rp * ( dens(ke-1,i,j )*nu(ke-1,i,j ) &
1198 + dens(ke ,i,j )*nu(ke ,i,j ) &
1199 + dens(ke-1,i,j+1)*nu(ke-1,i,j+1) &
1200 + dens(ke ,i,j+1)*nu(ke ,i,j+1) ) &
1201 * rfdz(ke-1) / gsqrt(ke-1,i,j,
i_xvw)
1204 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_xvz)
1205 b(ke,i,j) = - c(ke,i,j) + 0.5_rp * ( dens(ke,i,j)+dens(ke,i,j+1) )
1210 call matrix_solver_tridiagonal( ka, ks, ke, ia, iis, iie, ja, jjs, jje, &
1211 a(:,:,:), b(:,:,:), c(:,:,:), tend(:,:,:), &
1219 qflx_sgs_momy(k,i,j,
zdir) = qflx_sgs_momy(k,i,j,
zdir) &
1220 - 0.25_rp * ( dens(k ,i,j )*nu(k ,i,j ) &
1221 + dens(k+1,i,j )*nu(k+1,i,j ) &
1222 + dens(k ,i,j+1)*nu(k ,i,j+1) &
1223 + dens(k+1,i,j+1)*nu(k+1,i,j+1) ) &
1224 * dt * ( tend2(k+1,i,j) - tend2(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_xvw)
1233 if ( atmos_phy_tb_smg_backscatter )
then
1235 #define f2h(k,i,j,p) ( ( FZ(k+p-1,i,j) - FZ(k+p-2,i,j) ) / ( FZ(k+1,i,j) - FZ(k-1,i,j) ) )
1246 flxz(k) = j13g(k,i,j,
i_xyz) * random_my(k,i,j) &
1247 - j23g(k,i,j,
i_xyz) * random_mx(k,i,j)
1252 momz_t(k,i,j) = ( ( gsqrt(k,i+1,j,
i_xyw) * ( f2h(k,i+1,j,1) * random_my(k+1,i+1,j) &
1253 + f2h(k,i+1,j,2) * random_my(k,i+1,j) ) &
1254 - gsqrt(k,i-1,j,
i_xyw) * ( f2h(k,i-1,j,1) * random_my(k+1,i-1,j) &
1255 + f2h(k,i-1,j,2) * random_my(k,i-1,j) ) &
1256 ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1257 - ( gsqrt(k,i,j+1,
i_xyw) * ( f2h(k,i,j+1,1) * random_mx(k+1,i,j+1) &
1258 + f2h(k,i,j+1,2) * random_mx(k,i,j+1) ) &
1259 - gsqrt(k,i,j-1,
i_xyw) * ( f2h(k,i,j-1,1) * random_mx(k+1,i,j-1) &
1260 + f2h(k,i,j+1,2) * random_mx(k,i,j-1) ) &
1261 ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1262 + ( flxz(k+1) - flxz(k) ) * rfdz(k) &
1263 ) / gsqrt(k,i,j,
i_xyw)
1265 momz_t(ke,i,j) = 0.0_rp
1278 flxz(k) = j23g(k,i,j,
i_uyw) * ( f2h(k,i+1,j,1) * random_mz(k+1,i+1,j) + f2h(k,i,j+1,2) * random_mz(k,i+1,j) &
1279 + f2h(k,i ,j,1) * random_mz(k+1,i ,j) + f2h(k,i ,j,2) * random_mz(k,i ,j) ) * 0.5_rp &
1280 - j33g * ( f2h(k,i+1,j,1) * random_my(k+1,i+1,j) + f2h(k,i+1,j,2) * random_my(k,i+1,j) &
1281 + f2h(k,i ,j,1) * random_my(k+1,i ,j) + f2h(k,i ,j,2) * random_my(k,i ,j) ) * 0.5_rp
1286 momx_t(k,i,j) = ( ( gsqrt(k,i,j+1,
i_uyz) * ( random_mz(k,i+1,j+1) + random_mz(k,i,j+1) ) * 0.5_rp &
1287 - gsqrt(k,i,j-1,
i_uyz) * ( random_mz(k,i+1,j-1) + random_mz(k,i,j-1) ) * 0.5_rp ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_uy) &
1288 + ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1289 ) / gsqrt(k,i,j,
i_uyz)
1303 flxz(k) = j33g * ( f2h(k,i,j+1,1) * random_mx(k+1,i,j+1) + f2h(k,i,j+1,2) * random_mx(k,i,j+1) &
1304 + f2h(k,i,j ,1) * random_mx(k+1,i,j ) + f2h(k,i,j ,2) * random_mx(k,i,j ) ) * 0.5_rp &
1305 - j13g(k,i,j,
i_xvw) * ( f2h(k,i,j+1,1) * random_mz(k+1,i,j+1) + f2h(k,i,j+1,2) * random_mz(k,i,j+1) &
1306 + f2h(k,i,j ,1) * random_mz(k+1,i,j ) + f2h(k,i,j ,2) * random_mz(k,i,j ) ) * 0.5_rp
1311 momy_t(k,i,j) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1312 - ( gsqrt(k,i+1,j,
i_xvz) * ( random_mz(k,i+1,j+1) + random_mz(k,i+1,j) ) * 0.5_rp &
1313 - gsqrt(k,i-1,j,
i_xyz) * ( random_mz(k,i-1,j+1) + random_mz(k,i-1,j) ) * 0.5_rp ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xv) &
1314 ) / gsqrt(k,i,j,
i_xvz)
1333 momz_t(k,i,j) = 0.0_rp
1346 momx_t(k,i,j) = 0.0_rp
1359 momy_t(k,i,j) = 0.0_rp
1372 if ( atmos_phy_tb_smg_implicit )
then
1379 ap = - dt * 0.25_rp * ( dens(ks,i,j)+dens(ks+1,i,j) ) &
1380 * ( kh(ks,i,j)+kh(ks+1,i,j) ) &
1381 * rfdz(ks) / gsqrt(ks,i,j,
i_xyw)
1382 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_xyz)
1384 b(ks,i,j) = - a(ks,i,j) + dens(ks,i,j)
1387 ap = - dt * 0.25_rp * ( dens(k-1,i,j)+dens(k,i,j) ) &
1388 * ( kh(k-1,i,j)+kh(k,i,j) ) &
1389 * rfdz(k-1) / gsqrt(k-1,i,j,
i_xyw)
1391 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xyz)
1392 ap = - dt * 0.25_rp * ( dens(k,i,j)+dens(k+1,i,j) ) &
1393 * ( kh(k,i,j)+kh(k+1,i,j) ) &
1394 * rfdz(k) / gsqrt(k,i,j,
i_xyw)
1395 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xyz)
1396 b(k,i,j) = - a(k,i,j) - c(k,i,j) + dens(k,i,j)
1399 ap = - dt * 0.25_rp * ( dens(ke-1,i,j)+dens(ke,i,j) ) &
1400 * ( kh(ke-1,i,j)+kh(ke,i,j) ) &
1401 * rfdz(ke-1) / gsqrt(ke-1,i,j,
i_xyw)
1404 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_xyz)
1405 b(ke,i,j) = - c(ke,i,j) + dens(ke,i,j)
1413 call calc_flux_phi( &
1415 dens, pott, kh, 1.0_rp, &
1416 gsqrt, j13g, j23g, j33g, mapf, &
1417 atmos_phy_tb_smg_horizontal, &
1418 atmos_phy_tb_smg_implicit, &
1420 iis, iie, jjs, jje )
1422 if ( atmos_phy_tb_smg_backscatter )
then
1429 dd(k,i,j) = sqrt( ( ( pott(k+1,i,j) - pott(k-1,i,j) ) * j33g / ( fdz(k) + fdz(k-1) ) )**2 &
1430 + ( ( ( gsqrt(k,i+1,j,
i_xyz)*pott(k,i+1,j) - gsqrt(k,i-1,j,
i_xyz)*pott(k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1431 + ( j13g(k+1,i,j,
i_xyz)*pott(k+1,i,j) - j13g(k-1,i,j,
i_xyz)*pott(k-1,i,j) ) / ( fdz(k) + fdz(k-1) ) ) * mapf(i,j,1,
i_xy) )**2 &
1432 + ( ( ( gsqrt(k,i,j+1,
i_xyz)*pott(k,i,j+1) - gsqrt(k,i,j-1,
i_xyz)*pott(k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1433 + ( j23g(k+1,i,j,
i_xyz)*pott(k+1,i,j) - j23g(k-1,i,j,
i_xyz)*pott(k-1,i,j) ) / ( fdz(k) + fdz(k-1) ) ) * mapf(i,j,2,
i_xy) )**2 &
1434 ) / gsqrt(k,i,j,
i_xyz)
1436 dd(ks,i,j) = sqrt( ( ( pott(ks+1,i,j) - pott(ks,i,j) ) * j33g * rfdz(ks) )**2 &
1437 + ( ( ( gsqrt(ks,i+1,j,
i_xyz)*pott(ks,i+1,j) - gsqrt(ks,i-1,j,
i_xyz)*pott(ks,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1438 + ( j13g(ks+1,i,j,
i_xyz)*pott(ks+1,i,j) - j13g(ks,i,j,
i_xyz)*pott(ks,i,j) ) * rfdz(ks) ) * mapf(i,j,1,
i_xy) )**2 &
1439 + ( ( ( gsqrt(ks,i,j+1,
i_xyz)*pott(ks,i,j+1) - gsqrt(ks,i,j-1,
i_xyz)*pott(ks,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1440 + ( j23g(ks+1,i,j,
i_xyz)*pott(ks+1,i,j) - j23g(ks,i,j,
i_xyz)*pott(ks,i,j) ) * rfdz(ks) ) * mapf(i,j,2,
i_xy) )**2 &
1441 ) / gsqrt(ks,i,j,
i_xyz)
1442 dd(ke,i,j) = sqrt( ( ( pott(ke,i,j) - pott(ke-1,i,j) ) * j33g * rfdz(ke-1) )**2 &
1443 + ( ( ( gsqrt(ke,i+1,j,
i_xyz)*pott(ke,i+1,j) - gsqrt(ke,i-1,j,
i_xyz)*pott(ke,i-1,j) ) / ( fdx(i) + fdx(i-1) ) &
1444 + ( j13g(ke,i,j,
i_xyz)*pott(ke,i,j) - j13g(ke-1,i,j,
i_xyz)*pott(ke-1,i,j) ) * rfdz(ke-1) ) * mapf(i,j,1,
i_xy) )**2 &
1445 + ( ( ( gsqrt(ke,i,j+1,
i_xyz)*pott(ke,i,j+1) - gsqrt(ke,i,j-1,
i_xyz)*pott(ke,i,j-1) ) / ( fdy(j) + fdy(j-1) ) &
1446 + ( j23g(ke,i,j,
i_xyz)*pott(ke,i,j) - j23g(ke-1,i,j,
i_xyz)*pott(ke-1,i,j) ) * rfdz(ke-1) ) * mapf(i,j,2,
i_xy) )**2 &
1447 ) / gsqrt(ke,i,j,
i_xyz)
1460 flxz(k) = j33g * ( f2h(k,i,j,1) * random_qz(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qz(k,i,j) * dd(k,i,j) ) &
1461 + j13g(k,i,j,
i_xyw) * ( f2h(k,i,j,1) * random_qx(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qx(k,i,j) * dd(k,i,j) ) &
1462 + j23g(k,i,j,
i_xyw) * ( f2h(k,i,j,1) * random_qy(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qy(k,i,j) * dd(k,i,j) )
1467 rhot_t(k,i,j) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1468 + ( gsqrt(k,i+1,j,
i_xyz) * random_qx(k,i+1,j) * dd(k,i+1,j) - gsqrt(k,i-1,j,
i_xyz) * random_qx(k,i-1,j) * dd(k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1469 + ( gsqrt(k,i,j+1,
i_xyz) * random_qy(k,i,j+1) * dd(k,i,j+1) - gsqrt(k,i,j-1,
i_xyz) * random_qy(k,i,j-1) * dd(k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1470 ) / gsqrt(k,i,j,
i_xyz)
1484 rhot_t(k,i,j) = 0.0_rp
1506 call calc_flux_phi( &
1507 qflx_sgs_rhoq(:,:,:,:,iq), &
1508 dens, qtrc(:,:,:,iq), kh, 1.0_rp, &
1509 gsqrt, j13g, j23g, j33g, mapf, &
1510 atmos_phy_tb_smg_horizontal, &
1511 atmos_phy_tb_smg_implicit, &
1513 iis, iie, jjs, jje )
1516 if ( atmos_phy_tb_smg_backscatter .and. iq == i_qv )
then
1523 dd(k,i,j) = sqrt( ( ( qtrc(k+1,i,j,iq) - qtrc(k-1,i,j,iq) ) * j33g / ( fdz(k) + fdz(k-1) ) )**2 &
1524 + ( ( ( gsqrt(k,i+1,j,
i_xyz)*qtrc(k,i+1,j,iq) - gsqrt(k,i-1,j,
i_xyz)*qtrc(k,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1525 + ( j13g(k+1,i,j,
i_xyz)*qtrc(k+1,i,j,iq) - j13g(k-1,i,j,
i_xyz)*qtrc(k-1,i,j,iq) ) / ( fdz(k) + fdz(k-1) ) ) * mapf(i,j,1,
i_xy) )**2 &
1526 + ( ( ( gsqrt(k,i,j+1,
i_xyz)*qtrc(k,i,j+1,iq) - gsqrt(k,i,j-1,
i_xyz)*qtrc(k,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1527 + ( j23g(k+1,i,j,
i_xyz)*qtrc(k+1,i,j,iq) - j23g(k-1,i,j,
i_xyz)*qtrc(k-1,i,j,iq) ) / ( fdz(k) + fdz(k-1) ) ) * mapf(i,j,2,
i_xy) )**2 &
1528 ) / gsqrt(k,i,j,
i_xyz)
1530 dd(ks,i,j) = sqrt( ( ( qtrc(ks+1,i,j,iq) - qtrc(ks,i,j,iq) ) * j33g * rfdz(ks) )**2 &
1531 + ( ( ( gsqrt(ks,i+1,j,
i_xyz)*qtrc(ks,i+1,j,iq) - gsqrt(ks,i-1,j,
i_xyz)*qtrc(ks,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1532 + ( j13g(ks+1,i,j,
i_xyz)*qtrc(ks+1,i,j,iq) - j13g(ks,i,j,
i_xyz)*qtrc(ks,i,j,iq) ) * rfdz(ks) ) * mapf(i,j,1,
i_xy) )**2 &
1533 + ( ( ( gsqrt(ks,i,j+1,
i_xyz)*qtrc(ks,i,j+1,iq) - gsqrt(ks,i,j-1,
i_xyz)*qtrc(ks,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1534 + ( j23g(ks+1,i,j,
i_xyz)*qtrc(ks+1,i,j,iq) - j23g(ks,i,j,
i_xyz)*qtrc(ks,i,j,iq) ) * rfdz(ks) ) * mapf(i,j,2,
i_xy) )**2 &
1535 ) / gsqrt(ks,i,j,
i_xyz)
1536 dd(ke,i,j) = sqrt( ( ( qtrc(ke,i,j,iq) - qtrc(ke-1,i,j,iq) ) * j33g * rfdz(ke-1) )**2 &
1537 + ( ( ( gsqrt(ke,i+1,j,
i_xyz)*qtrc(ke,i+1,j,iq) - gsqrt(ke,i-1,j,
i_xyz)*qtrc(ke,i-1,j,iq) ) / ( fdx(i) + fdx(i-1) ) &
1538 + ( j13g(ke,i,j,
i_xyz)*qtrc(ke,i,j,iq) - j13g(ke-1,i,j,
i_xyz)*qtrc(ke-1,i,j,iq) ) * rfdz(ke-1) ) * mapf(i,j,1,
i_xy) )**2 &
1539 + ( ( ( gsqrt(ke,i,j+1,
i_xyz)*qtrc(ke,i,j+1,iq) - gsqrt(ke,i,j-1,
i_xyz)*qtrc(ke,i,j-1,iq) ) / ( fdy(j) + fdy(j-1) ) &
1540 + ( j23g(ke,i,j,
i_xyz)*qtrc(ke,i,j,iq) - j23g(ke-1,i,j,
i_xyz)*qtrc(ke-1,i,j,iq) ) * rfdz(ke-1) ) * mapf(i,j,2,
i_xy) )**2 &
1541 ) / gsqrt(ke,i,j,
i_xyz)
1554 flxz(k) = j33g * ( f2h(k,i,j,1) * random_qz(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qz(k,i,j) * dd(k,i,j) ) &
1555 + j13g(k,i,j,
i_xyw) * ( f2h(k,i,j,1) * random_qx(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qx(k,i,j) * dd(k,i,j) ) &
1556 + j23g(k,i,j,
i_xyw) * ( f2h(k,i,j,1) * random_qy(k+1,i,j) * dd(k+1,i,j) + f2h(k,i,j,2) * random_qy(k,i,j) * dd(k,i,j) )
1561 rhoq_t(k,i,j,iq) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1562 + ( gsqrt(k,i+1,j,
i_xyz) * random_qx(k,i+1,j) * dd(k,i+1,j) - gsqrt(k,i-1,j,
i_xyz) * random_qx(k,i-1,j) * dd(k,i-1,j) ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1563 + ( gsqrt(k,i,j+1,
i_xyz) * random_qy(k,i,j+1) * dd(k,i,j+1) - gsqrt(k,i,j-1,
i_xyz) * random_qy(k,i,j-1) * dd(k,i,j-1) ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1564 ) / gsqrt(k,i,j,
i_xyz)
1578 rhoq_t(k,i,j,iq) = 0.0_rp
1594 call file_history_in( tke(:,:,:),
'TKE_SMG',
'turbulent kinetic energy (Smagorinsky)',
'm2/s2', fill_halo=.true. )