264 real(RP),
intent(out) :: qflx_sgs_momz(KA,IA,JA,3)
265 real(RP),
intent(out) :: qflx_sgs_momx(KA,IA,JA,3)
266 real(RP),
intent(out) :: qflx_sgs_momy(KA,IA,JA,3)
267 real(RP),
intent(out) :: qflx_sgs_rhot(KA,IA,JA,3)
268 real(RP),
intent(out) :: qflx_sgs_rhoq(KA,IA,JA,3,QA)
270 real(RP),
intent(out) :: MOMZ_t (KA,IA,JA)
271 real(RP),
intent(out) :: MOMX_t (KA,IA,JA)
272 real(RP),
intent(out) :: MOMY_t (KA,IA,JA)
273 real(RP),
intent(out) :: RHOT_t (KA,IA,JA)
274 real(RP),
intent(out) :: RHOQ_t (KA,IA,JA,QA)
276 real(RP),
intent(out) :: nu (KA,IA,JA)
277 real(RP),
intent(out) :: Ri (KA,IA,JA)
278 real(RP),
intent(out) :: Pr (KA,IA,JA)
280 real(RP),
intent(in) :: MOMZ (KA,IA,JA)
281 real(RP),
intent(in) :: MOMX (KA,IA,JA)
282 real(RP),
intent(in) :: MOMY (KA,IA,JA)
283 real(RP),
intent(in) :: POTT (KA,IA,JA)
284 real(RP),
intent(in) :: DENS (KA,IA,JA)
285 real(RP),
intent(in) :: QTRC (KA,IA,JA,QA)
286 real(RP),
intent(in) :: N2 (KA,IA,JA)
288 real(RP),
intent(in) :: FZ (0:KA,IA,JA)
289 real(RP),
intent(in) :: FDZ (KA-1)
290 real(RP),
intent(in) :: RCDZ (KA)
291 real(RP),
intent(in) :: RFDZ (KA-1)
292 real(RP),
intent(in) :: CDX (IA)
293 real(RP),
intent(in) :: FDX (IA-1)
294 real(RP),
intent(in) :: CDY (JA)
295 real(RP),
intent(in) :: FDY (JA-1)
297 real(RP),
intent(in) :: GSQRT (KA,IA,JA,7)
298 real(RP),
intent(in) :: J13G (KA,IA,JA,7)
299 real(RP),
intent(in) :: J23G (KA,IA,JA,7)
300 real(RP),
intent(in) :: J33G
301 real(RP),
intent(in) :: MAPF(IA,JA,2,4)
302 real(DP),
intent(in) :: dt
305 real(RP) :: TKE(KA,IA,JA)
308 real(RP) :: S33_C(KA,IA,JA)
309 real(RP) :: S11_C(KA,IA,JA)
310 real(RP) :: S22_C(KA,IA,JA)
311 real(RP) :: S31_C(KA,IA,JA)
312 real(RP) :: S12_C(KA,IA,JA)
313 real(RP) :: S23_C(KA,IA,JA)
314 real(RP) :: S12_Z(KA,IA,JA)
315 real(RP) :: S23_X(KA,IA,JA)
316 real(RP) :: S31_Y(KA,IA,JA)
317 real(RP) :: S2 (KA,IA,JA)
319 real(RP) :: Kh(KA,IA,JA)
323 real(RP) :: lambda_r(KA)
330 real(RP) :: TEND(KA,IA,JA)
331 real(RP) :: a (KA,IA,JA)
332 real(RP) :: b (KA,IA,JA)
333 real(RP) :: c (KA,IA,JA)
338 real(RP) :: random (KA,IA,JA)
339 real(RP) :: random_mz(KA,IA,JA)
340 real(RP) :: random_mx(KA,IA,JA)
341 real(RP) :: random_my(KA,IA,JA)
342 real(RP) :: random_qz(KA,IA,JA)
343 real(RP) :: random_qx(KA,IA,JA)
344 real(RP) :: random_qy(KA,IA,JA)
345 real(RP) :: dd (KA,IA,JA)
347 real(RP) :: dz, dx, dy
354 integer :: k, i, j, iq
357 log_progress(*)
'atmosphere / physics / turbulence / Smagorinsky'
360 qflx_sgs_momz(:,:,:,:) = undef
361 qflx_sgs_momx(:,:,:,:) = undef
362 qflx_sgs_momy(:,:,:,:) = undef
363 qflx_sgs_rhot(:,:,:,:) = undef
364 qflx_sgs_rhoq(:,:,:,:,:) = undef
374 qflx_sgs_momz(ks:ke, 1:is-1, : ,:) = undef
375 qflx_sgs_momz(ks:ke,ie+1:ia , : ,:) = undef
376 qflx_sgs_momz(ks:ke, : , 1:js-1,:) = undef
377 qflx_sgs_momz(ks:ke, : ,je+1:ja ,:) = undef
378 qflx_sgs_momx(ks:ke, 1:is-1, : ,:) = undef
379 qflx_sgs_momx(ks:ke,ie+1:ia , : ,:) = undef
380 qflx_sgs_momx(ks:ke, : , 1:js-1,:) = undef
381 qflx_sgs_momx(ks:ke, : ,je+1:ja ,:) = undef
382 qflx_sgs_momy(ks:ke, 1:is-1, : ,:) = undef
383 qflx_sgs_momy(ks:ke,ie+1:ia , : ,:) = undef
384 qflx_sgs_momy(ks:ke, : , 1:js-1,:) = undef
385 qflx_sgs_momy(ks:ke, : ,je+1:ja ,:) = undef
391 call calc_strain_tensor( &
392 s33_c, s11_c, s22_c, &
393 s31_c, s12_c, s23_c, &
394 s12_z, s23_x, s31_y, &
396 dens, momz, momx, momy, &
397 gsqrt, j13g, j23g, j33g, mapf )
399 if ( atmos_phy_tb_smg_backscatter )
then
401 call random_normal( random(:,:,:) )
407 random_mz(k,i,j) = ( random(k,i,j) * 2.0_rp &
408 + random(k+1,i,j) + random(k-1,i,j) &
409 + random(k,i+1,j) + random(k,i-1,j) &
410 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
412 random_mz(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
414 + random(ks,i+1,j) + random(ks,i-1,j) &
415 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
416 random_mz(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
418 + random(ke,i+1,j) + random(ke,i-1,j) &
419 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
423 call random_normal( random(:,:,:) )
429 random_mx(k,i,j) = ( random(k,i,j) * 2.0_rp &
430 + random(k+1,i,j) + random(k-1,i,j) &
431 + random(k,i+1,j) + random(k,i-1,j) &
432 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
434 random_mx(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
436 + random(ks,i+1,j) + random(ks,i-1,j) &
437 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
438 random_mx(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
440 + random(ke,i+1,j) + random(ke,i-1,j) &
441 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
445 call random_normal( random(:,:,:) )
451 random_my(k,i,j) = ( random(k,i,j) * 2.0_rp &
452 + random(k+1,i,j) + random(k-1,i,j) &
453 + random(k,i+1,j) + random(k,i-1,j) &
454 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
456 random_my(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
458 + random(ks,i+1,j) + random(ks,i-1,j) &
459 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
460 random_my(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
462 + random(ke,i+1,j) + random(ke,i-1,j) &
463 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
467 call random_normal( random(:,:,:) )
473 random_qz(k,i,j) = ( random(k,i,j) * 2.0_rp &
474 + random(k+1,i,j) + random(k-1,i,j) &
475 + random(k,i+1,j) + random(k,i-1,j) &
476 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
478 random_qz(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
480 + random(ks,i+1,j) + random(ks,i-1,j) &
481 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
482 random_qz(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
484 + random(ke,i+1,j) + random(ke,i-1,j) &
485 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
489 call random_normal( random(:,:,:) )
495 random_qx(k,i,j) = ( random(k,i,j) * 2.0_rp &
496 + random(k+1,i,j) + random(k-1,i,j) &
497 + random(k,i+1,j) + random(k,i-1,j) &
498 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
500 random_qx(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
502 + random(ks,i+1,j) + random(ks,i-1,j) &
503 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
504 random_qx(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
506 + random(ke,i+1,j) + random(ke,i-1,j) &
507 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
511 call random_normal( random(:,:,:) )
517 random_qy(k,i,j) = ( random(k,i,j) * 2.0_rp &
518 + random(k+1,i,j) + random(k-1,i,j) &
519 + random(k,i+1,j) + random(k,i-1,j) &
520 + random(k,i,j+1) + random(k,i,j-1) ) / 8.0_rp
522 random_qy(ks,i,j) = ( random(ks,i,j) * 2.0_rp &
524 + random(ks,i+1,j) + random(ks,i-1,j) &
525 + random(ks,i,j+1) + random(ks,i,j-1) ) / 7.0_rp
526 random_qy(ke,i,j) = ( random(ke,i,j) * 2.0_rp &
528 + random(ke,i+1,j) + random(ke,i-1,j) &
529 + random(ke,i,j+1) + random(ke,i,j-1) ) / 7.0_rp
544 ri(k,i,j) = n2(k,i,j) / max(s2(k,i,j), eps)
550 if ( ri(k,i,j) < 0.0_rp )
then
551 fm(k) = sqrt( 1.0_rp - fmc * ri(k,i,j) )
552 nu(k,i,j) = lambda(k,i,j)**2 * sqrt( s2(k,i,j) ) * fm(k)
553 pr(k,i,j) = fm(k) / sqrt( 1.0_rp - fhb*ri(k,i,j) ) * prn
554 else if ( ri(k,i,j) < ric )
then
555 fm(k) = ( 1.0_rp - ri(k,i,j)*rric )**4
556 nu(k,i,j) = lambda(k,i,j)**2 * sqrt( s2(k,i,j) ) * fm(k)
557 pr(k,i,j) = prn / ( 1.0_rp - prnovric * ri(k,i,j) )
565 if ( ri(k,i,j) < ric )
then
566 kh(k,i,j) = max( min( nu(k,i,j) / pr(k,i,j), atmos_phy_tb_smg_nu_max ), eps )
567 nu(k,i,j) = max( min( nu(k,i,j), atmos_phy_tb_smg_nu_max ), eps )
568 pr(k,i,j) = nu(k,i,j) / kh(k,i,j)
569 rf = ri(k,i,j) / pr(k,i,j)
570 lambda_r(k) = lambda(k,i,j) * sqrt( fm(k) / sqrt( 1.0_rp - rf ) )
577 if ( atmos_phy_tb_smg_backscatter )
then
580 lambda_r(k) = min( 1.8_rp * lambda0(k,i,j), lambda_r(k) )
581 leovleo5 = ( lambda_r(k) / lambda0(k,i,j) )**5
582 c2 = cb * leovleo5 / ( 1.0_rp + cb * leovleo5 )
583 d2 = cbt * leovleo5 / ( 1.0_rp + cbt * leovleo5 )
584 c1(k) = c1o / sqrt( 1.0_rp - c2 )
586 e(k) = nu(k,i,j)**3 * ( 1.0_rp - c2 ) / ( lambda_r(k)**4 + eps )
587 et = kh(k,i,j) * ( 1.0_rp - d2 )
589 dz = fz(k,i,j) - fz(k-1,i,j)
590 dx = cdx(i) / mapf(i,j,1,
i_xy)
591 dy = cdy(j) / mapf(i,j,2,
i_xy)
593 fact = sqrt( cb * leovleo5 * e(k) / ( 3.0_rp * dt ) ) * dens(k,i,j)
594 random_mz(k,i,j) = random_mz(k,i,j) * fact * dx * dy / sqrt( dx**2 + dy**2 )
595 random_mx(k,i,j) = random_mx(k,i,j) * fact * dy * dz / sqrt( dy**2 + dz**2 )
596 random_my(k,i,j) = random_my(k,i,j) * fact * dz * dx / sqrt( dz**2 + dx**2 )
598 fact = sqrt( cbt * leovleo5 * et / ( 3.0_rp * dt ) ) * dens(k,i,j)
599 random_qz(k,i,j) = random_qz(k,i,j) * fact * dz
600 random_qx(k,i,j) = random_qx(k,i,j) * fact * dx
601 random_qy(k,i,j) = random_qy(k,i,j) * fact * dy
607 e(k) = nu(k,i,j)**3 / ( lambda_r(k)**4 + eps )
615 tke(k,i,j) = ( e(k) * lambda_r(k) / c1(k) )**twooverthree
621 i = iundef; j = iundef; k = iundef
633 if ( atmos_phy_tb_smg_horizontal )
then
634 qflx_sgs_momz(:,:,:,
zdir) = 0.0_rp
641 call check( __line__, dens(k,i,j) )
642 call check( __line__, nu(k,i,j) )
643 call check( __line__, s33_c(k,i,j) )
644 call check( __line__, s11_c(k,i,j) )
645 call check( __line__, s22_c(k,i,j) )
646 call check( __line__, tke(k,i,j) )
648 qflx_sgs_momz(k,i,j,
zdir) = dens(k,i,j) * ( &
649 - 2.0_rp * nu(k,i,j) &
650 * ( s33_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
651 + twooverthree * tke(k,i,j) * tke_fact )
656 i = iundef; j = iundef; k = iundef
662 qflx_sgs_momz(ks,i,j,
zdir) = dens(ks,i,j) * twooverthree * tke(ks,i,j) * tke_fact
663 qflx_sgs_momz(ke,i,j,
zdir) = dens(ke,i,j) * twooverthree * tke(ke,i,j) * tke_fact
668 i = iundef; j = iundef; k = iundef
677 call check( __line__, dens(k,i,j) )
678 call check( __line__, dens(k,i+1,j) )
679 call check( __line__, dens(k+1,i,j) )
680 call check( __line__, dens(k+1,i+1,j) )
681 call check( __line__, nu(k,i,j) )
682 call check( __line__, nu(k,i+1,j) )
683 call check( __line__, nu(k+1,i,j) )
684 call check( __line__, nu(k+1,i+1,j) )
685 call check( __line__, s31_y(k,i,j) )
687 qflx_sgs_momz(k,i,j,
xdir) = - 0.125_rp &
688 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i+1,j)+dens(k+1,i+1,j) ) &
689 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i+1,j)+nu(k+1,i+1,j)) &
695 i = iundef; j = iundef; k = iundef
705 call check( __line__, dens(k,i,j) )
706 call check( __line__, dens(k,i,j+1) )
707 call check( __line__, dens(k+1,i,j) )
708 call check( __line__, dens(k+1,i,j+1) )
709 call check( __line__, nu(k,i,j) )
710 call check( __line__, nu(k,i,j+1) )
711 call check( __line__, nu(k+1,i,j) )
712 call check( __line__, nu(k+1,i,j+1) )
713 call check( __line__, s23_x(k,i,j) )
715 qflx_sgs_momz(k,i,j,
ydir) = - 0.125_rp &
716 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i,j+1)+dens(k+1,i,j+1) ) &
717 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i,j+1)+nu(k+1,i,j+1) ) &
723 i = iundef; j = iundef; k = iundef
726 if ( atmos_phy_tb_smg_implicit )
then
728 call calc_tend_momz( tend, &
730 gsqrt, j13g, j23g, j33g, mapf, &
738 ap = - fouroverthree * dt &
739 * dens(ks+1,i,j)*nu(ks+1,i,j) &
740 * rcdz(ks+1) / gsqrt(ks+1,i,j,
i_xyz)
741 a(ks,i,j) = ap * rfdz(ks) / gsqrt(ks,i,j,
i_xyw)
743 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks+1,i,j) )
745 c(k,i,j) = ap * rfdz(k+1) / gsqrt(k+1,i,j,
i_xyw)
746 ap = - fouroverthree * dt &
747 * dens(k+1,i,j)*nu(k+1,i,j) &
748 * rcdz(k+1) / gsqrt(k+1,i,j,
i_xyz)
749 a(k,i,j) = ap * rfdz(k) / gsqrt(k,i,j,
i_xyw)
750 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k+1,i,j) )
753 c(ke-1,i,j) = ap * rfdz(ke) / gsqrt(ke,i,j,
i_xyw)
754 b(ke-1,i,j) = - c(ke-1,i,j) + 0.5_rp * ( dens(ke-1,i,j)+dens(ke,i,j) )
760 call diffusion_solver( &
762 a(:,i,j), b(:,i,j), c(:,i,j), d, &
766 qflx_sgs_momz(k,i,j,
zdir) = qflx_sgs_momz(k,i,j,
zdir) &
767 - fouroverthree * dens(k,i,j) * nu(k,i,j) * dt &
768 * ( tend(k,i,j) - tend(k-1,i,j) ) * rcdz(k) / gsqrt(k,i,j,
i_xyz)
778 if ( atmos_phy_tb_smg_horizontal )
then
779 qflx_sgs_momx(:,:,:,
zdir) = 0.0_rp
786 call check( __line__, dens(k,i,j) )
787 call check( __line__, dens(k,i+1,j) )
788 call check( __line__, dens(k+1,i,j) )
789 call check( __line__, dens(k+1,i+1,j) )
790 call check( __line__, nu(k,i,j) )
791 call check( __line__, nu(k,i+1,j) )
792 call check( __line__, nu(k+1,i,j) )
793 call check( __line__, nu(k+1,i+1,j) )
794 call check( __line__, s31_y(k,i,j) )
796 qflx_sgs_momx(k,i,j,
zdir) = - 0.125_rp &
797 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i+1,j)+dens(k+1,i+1,j) ) &
798 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i+1,j)+nu(k+1,i+1,j) ) &
804 i = iundef; j = iundef; k = iundef
809 qflx_sgs_momx(ks-1,i,j,
zdir) = 0.0_rp
810 qflx_sgs_momx(ke ,i,j,
zdir) = 0.0_rp
814 i = iundef; j = iundef; k = iundef
825 call check( __line__, dens(k,i,j) )
826 call check( __line__, nu(k,i,j) )
827 call check( __line__, s11_c(k,i,j) )
828 call check( __line__, s22_c(k,i,j) )
829 call check( __line__, s33_c(k,i,j) )
830 call check( __line__, tke(k,i,j) )
832 qflx_sgs_momx(k,i,j,
xdir) = dens(k,i,j) * ( &
833 - 2.0_rp * nu(k,i,j) &
834 * ( s11_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
835 + twooverthree * tke(k,i,j) * tke_fact )
840 i = iundef; j = iundef; k = iundef
850 call check( __line__, dens(k,i,j) )
851 call check( __line__, dens(k,i+1,j) )
852 call check( __line__, dens(k,i,j+1) )
853 call check( __line__, dens(k,i+1,j+1) )
854 call check( __line__, nu(k,i,j) )
855 call check( __line__, nu(k,i+1,j) )
856 call check( __line__, nu(k,i,j+1) )
857 call check( __line__, nu(k,i+1,j+1) )
858 call check( __line__, s12_z(k,i,j) )
860 qflx_sgs_momx(k,i,j,
ydir) = - 0.125_rp &
861 * ( dens(k,i,j)+dens(k,i+1,j)+dens(k,i,j+1)+dens(k,i+1,j+1) ) &
862 * ( nu(k,i,j)+nu(k,i+1,j)+nu(k,i,j+1)+nu(k,i+1,j+1) ) &
868 i = iundef; j = iundef; k = iundef
871 if ( atmos_phy_tb_smg_implicit )
then
872 call calc_tend_momx( tend, &
874 gsqrt, j13g, j23g, j33g, mapf, &
882 ap = - dt * 0.25_rp * ( dens(ks ,i ,j)*nu(ks ,i ,j) &
883 + dens(ks+1,i ,j)*nu(ks+1,i ,j) &
884 + dens(ks ,i+1,j)*nu(ks ,i+1,j) &
885 + dens(ks+1,i+1,j)*nu(ks+1,i+1,j) ) &
886 * rfdz(ks) / gsqrt(ks,i,j,
i_uyw)
887 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_uyz)
889 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks,i+1,j) )
891 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_uyz)
892 ap = - dt * 0.25_rp * ( dens(k ,i ,j)*nu(k ,i ,j) &
893 + dens(k+1,i ,j)*nu(k+1,i ,j) &
894 + dens(k ,i+1,j)*nu(k ,i+1,j) &
895 + dens(k+1,i+1,j)*nu(k+1,i+1,j) ) &
896 * rfdz(k) / gsqrt(k,i,j,
i_uyw)
897 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_uyz)
898 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k,i+1,j) )
901 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_uyz)
902 b(ke,i,j) = - c(ke,i,j) + 0.5_rp * ( dens(ke,i,j)+dens(ke,i+1,j) )
908 call diffusion_solver( &
910 a(:,i,j), b(:,i,j), c(:,i,j), d, &
914 qflx_sgs_momx(k,i,j,
zdir) = qflx_sgs_momx(k,i,j,
zdir) &
915 - 0.25_rp * ( dens(k ,i ,j)*nu(k ,i ,j) &
916 + dens(k+1,i ,j)*nu(k+1,i ,j) &
917 + dens(k ,i+1,j)*nu(k ,i+1,j) &
918 + dens(k+1,i+1,j)*nu(k+1,i+1,j) ) &
919 * dt * ( tend(k+1,i,j) - tend(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_uyw)
929 if ( atmos_phy_tb_smg_horizontal )
then
930 qflx_sgs_momy(:,:,:,
zdir) = 0.0_rp
937 call check( __line__, dens(k,i,j) )
938 call check( __line__, dens(k,i,j+1) )
939 call check( __line__, dens(k+1,i,j) )
940 call check( __line__, dens(k+1,i,j+1) )
941 call check( __line__, nu(k,i,j) )
942 call check( __line__, nu(k,i,j+1) )
943 call check( __line__, nu(k+1,i,j) )
944 call check( __line__, nu(k+1,i,j+1) )
945 call check( __line__, s23_x(k,i,j) )
947 qflx_sgs_momy(k,i,j,
zdir) = - 0.125_rp &
948 * ( dens(k,i,j)+dens(k+1,i,j)+dens(k,i,j+1)+dens(k+1,i,j+1) ) &
949 * ( nu(k,i,j)+nu(k+1,i,j)+nu(k,i,j+1)+nu(k+1,i,j+1) ) &
955 i = iundef; j = iundef; k = iundef
960 qflx_sgs_momy(ks-1,i,j,
zdir) = 0.0_rp
961 qflx_sgs_momy(ke ,i,j,
zdir) = 0.0_rp
965 i = iundef; j = iundef; k = iundef
977 call check( __line__, dens(k,i,j) )
978 call check( __line__, dens(k,i+1,j) )
979 call check( __line__, dens(k,i,j+1) )
980 call check( __line__, dens(k,i+1,j+1) )
981 call check( __line__, nu(k,i,j) )
982 call check( __line__, nu(k,i+1,j) )
983 call check( __line__, nu(k,i,j+1) )
984 call check( __line__, nu(k,i+1,j+1) )
985 call check( __line__, s12_z(k,i,j) )
987 qflx_sgs_momy(k,i,j,
xdir) = - 0.125_rp &
988 * ( dens(k,i,j)+dens(k,i+1,j)+dens(k,i,j+1)+dens(k,i+1,j+1) ) &
989 * ( nu(k,i,j)+nu(k,i+1,j)+nu(k,i,j+1)+nu(k,i+1,j+1) ) &
995 i = iundef; j = iundef; k = iundef
1006 call check( __line__, dens(k,i,j) )
1007 call check( __line__, nu(k,i,j) )
1008 call check( __line__, s11_c(k,i,j) )
1009 call check( __line__, s22_c(k,i,j) )
1010 call check( __line__, s33_c(k,i,j) )
1011 call check( __line__, tke(k,i,j) )
1013 qflx_sgs_momy(k,i,j,
ydir) = dens(k,i,j) * ( &
1014 - 2.0_rp * nu(k,i,j) &
1015 * ( s22_c(k,i,j) - ( s11_c(k,i,j) + s22_c(k,i,j) + s33_c(k,i,j) ) * oneoverthree ) &
1016 + twooverthree * tke(k,i,j) * tke_fact)
1021 i = iundef; j = iundef; k = iundef
1024 if ( atmos_phy_tb_smg_implicit )
then
1025 call calc_tend_momy( tend, &
1027 gsqrt, j13g, j23g, j33g, mapf, &
1028 iis, iie, jjs, jje )
1035 ap = - dt * 0.25_rp * ( dens(ks ,i,j )*nu(ks ,i,j ) &
1036 + dens(ks+1,i,j )*nu(ks+1,i,j ) &
1037 + dens(ks ,i,j+1)*nu(ks ,i,j+1) &
1038 + dens(ks+1,i,j+1)*nu(ks+1,i,j+1) ) &
1039 * rfdz(ks) / gsqrt(ks,i,j,
i_xvw)
1040 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_xvz)
1042 b(ks,i,j) = - a(ks,i,j) + 0.5_rp * ( dens(ks,i,j)+dens(ks,i,j+1) )
1044 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xvz)
1045 ap = - dt * 0.25_rp * ( dens(k ,i,j )*nu(k ,i,j ) &
1046 + dens(k+1,i,j )*nu(k+1,i,j ) &
1047 + dens(k ,i,j+1)*nu(k ,i,j+1) &
1048 + dens(k+1,i,j+1)*nu(k+1,i,j+1) ) &
1049 * rfdz(k) / gsqrt(k,i,j,
i_xvw)
1050 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xvz)
1051 b(k,i,j) = - a(k,i,j) - c(k,i,j) + 0.5_rp * ( dens(k,i,j)+dens(k,i,j+1) )
1054 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_xvz)
1055 b(ke,i,j) = - c(ke,i,j) + 0.5_rp * ( dens(ke,i,j)+dens(ke,i,j+1) )
1061 call diffusion_solver( &
1063 a(:,i,j), b(:,i,j), c(:,i,j), d, &
1067 qflx_sgs_momy(k,i,j,
zdir) = qflx_sgs_momy(k,i,j,
zdir) &
1068 - 0.25_rp * ( dens(k ,i,j )*nu(k ,i,j ) &
1069 + dens(k+1,i,j )*nu(k+1,i,j ) &
1070 + dens(k ,i,j+1)*nu(k ,i,j+1) &
1071 + dens(k+1,i,j+1)*nu(k+1,i,j+1) ) &
1072 * dt * ( tend(k+1,i,j) - tend(k,i,j) ) * rfdz(k) / gsqrt(k,i,j,
i_xvw)
1080 if ( atmos_phy_tb_smg_backscatter )
then
1082 #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) ) )
1089 flxz(k) = j13g(k,i,j,
i_xyz) * random_my(k,i,j) &
1090 - j23g(k,i,j,
i_xyz) * random_mx(k,i,j)
1095 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) &
1096 + f2h(k,i+1,j,2) * random_my(k,i+1,j) ) &
1097 - gsqrt(k,i-1,j,
i_xyw) * ( f2h(k,i-1,j,1) * random_my(k+1,i-1,j) &
1098 + f2h(k,i-1,j,2) * random_my(k,i-1,j) ) &
1099 ) / ( fdx(i) + fdx(i-1) ) * mapf(i,j,1,
i_xy) &
1100 - ( gsqrt(k,i,j+1,
i_xyw) * ( f2h(k,i,j+1,1) * random_mx(k+1,i,j+1) &
1101 + f2h(k,i,j+1,2) * random_mx(k,i,j+1) ) &
1102 - gsqrt(k,i,j-1,
i_xyw) * ( f2h(k,i,j-1,1) * random_mx(k+1,i,j-1) &
1103 + f2h(k,i,j+1,2) * random_mx(k,i,j-1) ) &
1104 ) / ( fdy(j) + fdy(j-1) ) * mapf(i,j,2,
i_xy) &
1105 + ( flxz(k+1) - flxz(k) ) * rfdz(k) &
1106 ) / gsqrt(k,i,j,
i_xyw)
1108 momz_t(ke,i,j) = 0.0_rp
1118 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) &
1119 + f2h(k,i ,j,1) * random_mz(k+1,i ,j) + f2h(k,i ,j,2) * random_mz(k,i ,j) ) * 0.5_rp &
1120 - 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) &
1121 + f2h(k,i ,j,1) * random_my(k+1,i ,j) + f2h(k,i ,j,2) * random_my(k,i ,j) ) * 0.5_rp
1126 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 &
1127 - 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) &
1128 + ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1129 ) / gsqrt(k,i,j,
i_uyz)
1140 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) &
1141 + f2h(k,i,j ,1) * random_mx(k+1,i,j ) + f2h(k,i,j ,2) * random_mx(k,i,j ) ) * 0.5_rp &
1142 - 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) &
1143 + f2h(k,i,j ,1) * random_mz(k+1,i,j ) + f2h(k,i,j ,2) * random_mz(k,i,j ) ) * 0.5_rp
1148 momy_t(k,i,j) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1149 - ( gsqrt(k,i+1,j,
i_xvz) * ( random_mz(k,i+1,j+1) + random_mz(k,i+1,j) ) * 0.5_rp &
1150 - 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) &
1151 ) / gsqrt(k,i,j,
i_xvz)
1163 momz_t(k,i,j) = 0.0_rp
1172 momx_t(k,i,j) = 0.0_rp
1181 momy_t(k,i,j) = 0.0_rp
1190 if ( atmos_phy_tb_smg_implicit )
then
1197 ap = - dt * 0.25_rp * ( dens(ks,i,j)+dens(ks+1,i,j) ) &
1198 * ( kh(ks,i,j)+kh(ks+1,i,j) ) &
1199 * rfdz(ks) / gsqrt(ks,i,j,
i_xyw)
1200 a(ks,i,j) = ap * rcdz(ks) / gsqrt(ks,i,j,
i_xyz)
1202 b(ks,i,j) = - a(ks,i,j) + dens(ks,i,j)
1204 c(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xyz)
1205 ap = - dt * 0.25_rp * ( dens(k,i,j)+dens(k+1,i,j) ) &
1206 * ( kh(k,i,j)+kh(k+1,i,j) ) &
1207 * rfdz(k) / gsqrt(k,i,j,
i_xyw)
1208 a(k,i,j) = ap * rcdz(k) / gsqrt(k,i,j,
i_xyz)
1209 b(k,i,j) = - a(k,i,j) - c(k,i,j) + dens(k,i,j)
1212 c(ke,i,j) = ap * rcdz(ke) / gsqrt(ke,i,j,
i_xyz)
1213 b(ke,i,j) = - c(ke,i,j) + dens(ke,i,j)
1220 call calc_flux_phi( &
1222 dens, pott, kh, 1.0_rp, &
1223 gsqrt, j13g, j23g, j33g, mapf, &
1224 atmos_phy_tb_smg_horizontal, &
1225 atmos_phy_tb_smg_implicit, &
1227 iis, iie, jjs, jje )
1229 if ( atmos_phy_tb_smg_backscatter )
then
1236 dd(k,i,j) = sqrt( ( ( pott(k+1,i,j) - pott(k-1,i,j) ) * j33g / ( fdz(k) + fdz(k-1) ) )**2 &
1237 + ( ( ( 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) ) &
1238 + ( 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 &
1239 + ( ( ( 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) ) &
1240 + ( 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 &
1241 ) / gsqrt(k,i,j,
i_xyz)
1243 dd(ks,i,j) = sqrt( ( ( pott(ks+1,i,j) - pott(ks,i,j) ) * j33g * rfdz(ks) )**2 &
1244 + ( ( ( 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) ) &
1245 + ( 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 &
1246 + ( ( ( 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) ) &
1247 + ( 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 &
1248 ) / gsqrt(ks,i,j,
i_xyz)
1249 dd(ke,i,j) = sqrt( ( ( pott(ke,i,j) - pott(ke-1,i,j) ) * j33g * rfdz(ke-1) )**2 &
1250 + ( ( ( 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) ) &
1251 + ( 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 &
1252 + ( ( ( 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) ) &
1253 + ( 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 &
1254 ) / gsqrt(ke,i,j,
i_xyz)
1264 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) ) &
1265 + 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) ) &
1266 + 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) )
1271 rhot_t(k,i,j) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1272 + ( 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) &
1273 + ( 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) &
1274 ) / gsqrt(k,i,j,
i_xyz)
1286 rhot_t(k,i,j) = 0.0_rp
1306 call calc_flux_phi( &
1307 qflx_sgs_rhoq(:,:,:,:,iq), &
1308 dens, qtrc(:,:,:,iq), kh, 1.0_rp, &
1309 gsqrt, j13g, j23g, j33g, mapf, &
1310 atmos_phy_tb_smg_horizontal, &
1311 atmos_phy_tb_smg_implicit, &
1313 iis, iie, jjs, jje )
1316 if ( atmos_phy_tb_smg_backscatter .and. iq == i_qv )
then
1323 dd(k,i,j) = sqrt( ( ( qtrc(k+1,i,j,iq) - qtrc(k-1,i,j,iq) ) * j33g / ( fdz(k) + fdz(k-1) ) )**2 &
1324 + ( ( ( 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) ) &
1325 + ( 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 &
1326 + ( ( ( 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) ) &
1327 + ( 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 &
1328 ) / gsqrt(k,i,j,
i_xyz)
1330 dd(ks,i,j) = sqrt( ( ( qtrc(ks+1,i,j,iq) - qtrc(ks,i,j,iq) ) * j33g * rfdz(ks) )**2 &
1331 + ( ( ( 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) ) &
1332 + ( 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 &
1333 + ( ( ( 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) ) &
1334 + ( 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 &
1335 ) / gsqrt(ks,i,j,
i_xyz)
1336 dd(ke,i,j) = sqrt( ( ( qtrc(ke,i,j,iq) - qtrc(ke-1,i,j,iq) ) * j33g * rfdz(ke-1) )**2 &
1337 + ( ( ( 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) ) &
1338 + ( 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 &
1339 + ( ( ( 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) ) &
1340 + ( 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 &
1341 ) / gsqrt(ke,i,j,
i_xyz)
1351 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) ) &
1352 + 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) ) &
1353 + 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) )
1358 rhoq_t(k,i,j,iq) = ( ( flxz(k) - flxz(k-1) ) * rcdz(k) &
1359 + ( 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) &
1360 + ( 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) &
1361 ) / gsqrt(k,i,j,
i_xyz)
1373 rhoq_t(k,i,j,iq) = 0.0_rp
1388 call file_history_in( tke(:,:,:),
'TKE_SMG',
'turbulent kinetic energy (Smagorinsky)',
'm2/s2', fill_halo=.true. )