29 use fv_mp_nlm_mod,
only: start_group_halo_update, complete_group_halo_update
40 #if defined (ADA_NUDGE) 41 use fv_ada_nudge_mod,
only: breed_slp_inline_ada
62 real,
allocatable,
dimension(:,:,:) ::
ut,
vt,
crx,
cry,
xfx,
yfx,
divgd, &
68 real,
allocatable ::
rf(:)
78 subroutine dyn_core(npx, npy, npz, ng, sphum, nq, bdt, n_split, zvir, cp, akap, cappa, grav, hydrostatic, &
79 u, v, w, delz, pt, q, delp, pe, pk, phis, ws, omga, ptop, pfull, ua, va, &
80 uc, vc, mfx, mfy, cx, cy, pkz, peln, q_con, ak, bk, dpx, &
81 ks, gridstruct, flagstruct, neststruct, idiag, bd, domain, &
82 init_step, i_pack, end_step, time_total)
83 integer,
intent(IN) :: npx
84 integer,
intent(IN) :: npy
85 integer,
intent(IN) :: npz
86 integer,
intent(IN) :: ng, nq, sphum
87 integer,
intent(IN) :: n_split
88 real ,
intent(IN) :: bdt
89 real ,
intent(IN) :: zvir, cp, akap, grav
90 real ,
intent(IN) :: ptop
91 logical,
intent(IN) :: hydrostatic
92 logical,
intent(IN) :: init_step, end_step
93 real,
intent(in) :: pfull(npz)
94 real,
intent(in),
dimension(npz+1) :: ak, bk
95 integer,
intent(IN) :: ks
96 type(group_halo_update_type),
intent(inout) :: i_pack(*)
98 real,
intent(inout),
dimension(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz):: u
99 real,
intent(inout),
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz):: v
100 real,
intent(inout) :: w( bd%isd:,bd%jsd:,1:)
101 real,
intent(inout) :: delz(bd%isd:,bd%jsd:,1:)
102 real,
intent(inout) :: cappa(bd%isd:,bd%jsd:,1:)
103 real,
intent(inout) :: pt( bd%isd:bd%ied ,bd%jsd:bd%jed ,npz)
104 real,
intent(inout) :: delp(bd%isd:bd%ied ,bd%jsd:bd%jed ,npz)
105 real,
intent(inout) :: q( bd%isd:bd%ied ,bd%jsd:bd%jed ,npz, nq)
106 real,
intent(in),
optional:: time_total
113 real,
intent(inout):: phis(bd%isd:bd%ied,bd%jsd:bd%jed)
114 real,
intent(inout):: pe(bd%is-1:bd%ie+1, npz+1,bd%js-1:bd%je+1)
115 real,
intent(inout):: peln(bd%is:bd%ie,npz+1,bd%js:bd%je)
116 real,
intent(inout):: pk(bd%is:bd%ie,bd%js:bd%je, npz+1)
117 real(kind=8),
intent(inout) :: dpx(bd%is:bd%ie,bd%js:bd%je)
121 real,
parameter:: near0 = 1.e-8
123 real,
parameter:: huge_r = 1.e8
125 real,
parameter:: huge_r = 1.e40
128 real,
intent(out ):: ws(bd%is:bd%ie,bd%js:bd%je)
129 real,
intent(inout):: omga(bd%isd:bd%ied,bd%jsd:bd%jed,npz)
130 real,
intent(inout):: uc(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
131 real,
intent(inout):: vc(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz)
132 real,
intent(inout),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz):: ua, va
133 real,
intent(inout):: q_con(bd%isd:, bd%jsd:, 1:)
136 real,
intent(inout):: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
137 real,
intent(inout):: mfy(bd%is:bd%ie , bd%js:bd%je+1, npz)
139 real,
intent(inout):: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
140 real,
intent(inout):: cy(bd%isd:bd%ied ,bd%js:bd%je+1, npz)
141 real,
intent(inout),
dimension(bd%is:bd%ie,bd%js:bd%je,npz):: pkz
147 type(
domain2d),
intent(INOUT) :: domain
149 real,
allocatable,
dimension(:,:,:):: pem, heat_source
151 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: ws3, z_rat
153 real:: zs(bd%isd:bd%ied,bd%jsd:bd%jed)
154 real:: om2d(bd%is:bd%ie,npz)
155 real wbuffer(npy+2,npz)
156 real ebuffer(npy+2,npz)
157 real nbuffer(npx+2,npz)
158 real sbuffer(npx+2,npz)
160 real divg2(bd%is:bd%ie+1,bd%js:bd%je+1)
161 real wk(bd%isd:bd%ied,bd%jsd:bd%jed)
162 real fz(bd%is: bd%ie+1,bd%js: bd%je+1)
163 real heat_s(bd%is:bd%ie,bd%js:bd%je)
165 integer nord_v(npz+1)
167 integer :: hord_m, hord_v, hord_t, hord_p
168 integer :: nord_k, nord_w, nord_t
171 integer :: i,j,k, it, iq, n_con, nf_ke
172 integer :: iep1, jep1
173 real :: beta, beta_d, d_con_k, damp_w, damp_t, kgb, cv_air
176 real :: k1k, rdg, dtmp, delt
177 logical :: last_step, remap_step
179 real :: split_timestep_bc
181 integer :: is, ie, js, je
182 integer :: isd, ied, jsd, jed
199 dt = bdt /
real(n_split)
202 ms =
max(1, flagstruct%m_split/2)
203 beta = flagstruct%beta
211 if ( .not.hydrostatic )
then 214 k1k = akap / (1.-akap)
218 dp_ref(k) = (ak(k+1)-ak(k)) + (bk(k+1)-bk(k))*1.e5
224 zs(i,j) = phis(i,j) *
rgrav 229 if ( init_step )
then 231 allocate(
gz(isd:ied, jsd:jed ,npz+1) )
233 allocate(
pkc(isd:ied, jsd:jed ,npz+1) )
234 allocate(
ptc(isd:ied, jsd:jed ,npz ) )
235 allocate(
crx(is :ie+1, jsd:jed, npz) )
236 allocate(
xfx(is :ie+1, jsd:jed, npz) )
237 allocate(
cry(isd:ied, js :je+1, npz) )
238 allocate(
yfx(isd:ied, js :je+1, npz) )
239 allocate(
divgd(isd:ied+1,jsd:jed+1,npz) )
240 allocate(
delpc(isd:ied, jsd:jed ,npz ) )
242 allocate(
ut(isd:ied, jsd:jed, npz) )
244 allocate(
vt(isd:ied, jsd:jed, npz) )
247 if ( .not. hydrostatic )
then 248 allocate(
zh(isd:ied, jsd:jed, npz+1) )
250 allocate (
pk3(isd:ied,jsd:jed,npz+1) )
253 if ( beta > near0 )
then 254 allocate(
du(isd:ied, jsd:jed+1,npz) )
256 allocate(
dv(isd:ied+1,jsd:jed, npz) )
267 if ( flagstruct%d_con > 1.0e-5 )
then 268 allocate( heat_source(isd:ied, jsd:jed, npz) )
269 call init_ijk_mem(isd, ied, jsd, jed, npz, heat_source, 0.)
272 if ( flagstruct%convert_ke .or. flagstruct%vtdm4> 1.e-4 )
then 275 if ( flagstruct%d2_bg_k1 < 1.e-3 )
then 278 if ( flagstruct%d2_bg_k2 < 1.e-3 )
then 292 call start_group_halo_update(i_pack(8), u, v, domain, gridtype=dgrid_ne)
294 if ( flagstruct%breed_vortex_inline .or. it==n_split )
then 300 if ( flagstruct%fv_debug )
then 301 if(is_master())
write(*,*)
'n_split loop, it=', it
302 if ( .not. flagstruct%hydrostatic ) &
303 call prt_mxm(
'delz', delz, is, ie, js, je, ng, npz, 1., gridstruct%area_64, domain)
304 call prt_mxm(
'PT', pt, is, ie, js, je, ng, npz, 1., gridstruct%area_64, domain)
307 if (gridstruct%nested)
then 310 split_timestep_bc =
real(n_split*flagstruct%k_split+neststruct%nest_timestep)
316 if ( flagstruct%inline_q )
then 317 call start_group_halo_update(i_pack(10), q, domain)
323 if ( .not. hydrostatic )
then 325 call start_group_halo_update(i_pack(7), w, domain)
329 if (gridstruct%nested)
then 333 gz(i,j,npz+1) = zs(i,j)
337 gz(i,j,k) =
gz(i,j,k+1) - delz(i,j,k)
345 gz(i,j,npz+1) = zs(i,j)
349 gz(i,j,k) =
gz(i,j,k+1) - delz(i,j,k)
355 call start_group_halo_update(i_pack(5),
gz, domain)
371 call complete_group_halo_update(i_pack(1), domain)
378 if ( it==n_split .and. end_step )
then 379 if ( flagstruct%use_old_omega )
then 380 allocate ( pem(is-1:ie+1,npz+1,js-1:je+1) )
388 pem(i,k+1,j) = pem(i,k,j) + delp(i,j,k)
399 call complete_group_halo_update(i_pack(8), domain)
400 if( .not. hydrostatic ) &
401 call complete_group_halo_update(i_pack(7), domain)
409 call c_sw(
delpc(isd,jsd,k), delp(isd,jsd,k),
ptc(isd,jsd,k), &
410 pt(isd,jsd,k), u(isd,jsd,k), v(isd,jsd,k), &
411 w(isd:,jsd:,k), uc(isd,jsd,k), vc(isd,jsd,k), &
412 ua(isd,jsd,k), va(isd,jsd,k), omga(isd,jsd,k), &
413 ut(isd,jsd,k),
vt(isd,jsd,k),
divgd(isd,jsd,k), &
414 flagstruct%nord, dt2, hydrostatic, .true., bd, &
415 gridstruct, flagstruct)
418 if ( flagstruct%nord > 0 )
then 420 call start_group_halo_update(i_pack(3),
divgd, domain, position=
corner)
424 if (gridstruct%nested)
then 426 0, 0, npx, npy, npz, bd, split_timestep_bc+0.5,
real(n_split*flagstruct%k_split), &
427 neststruct%delp_bc, bctype=neststruct%nestbctype)
430 0, 0, npx, npy, npz, bd, split_timestep_bc+0.5,
real(n_split*flagstruct%k_split), &
431 neststruct%pt_bc, bctype=neststruct%nestbctype )
434 if ( hydrostatic )
then 435 call geopk(ptop, pe, peln,
delpc,
pkc,
gz, phis,
ptc, q_con, pkz, npz, akap, .true., &
436 gridstruct%nested, .false., npx, npy, flagstruct%a2b_ord, bd)
442 call complete_group_halo_update(i_pack(5), domain)
450 zh(i,j,k) =
gz(i,j,k)
460 gz(i,j,k) =
zh(i,j,k)
466 call update_dz_c(is, ie, js, je, npz, ng, dt2, dp_ref, zs, gridstruct%area,
ut,
vt,
gz, ws3, &
467 npx, npy, gridstruct%sw_corner, gridstruct%se_corner, &
468 gridstruct%ne_corner, gridstruct%nw_corner, bd, gridstruct%grid_type)
472 call riem_solver_c( ms, dt2, is, ie, js, je, npz, ng, &
473 akap, cappa, cp, ptop, phis, omga,
ptc, &
474 q_con,
delpc,
gz,
pkc, ws3, flagstruct%p_fac, &
475 flagstruct%a_imp, flagstruct%scale_z )
478 if (gridstruct%nested)
then 480 0, 0, npx, npy, npz, bd, split_timestep_bc+0.5,
real(n_split*flagstruct%k_split), &
481 neststruct%delz_bc, bctype=neststruct%nestbctype )
487 call nest_halo_nh(ptop, grav, akap, cp,
delpc, delz,
ptc, phis, &
495 npx, npy, npz, gridstruct%nested, .false., .false., .false., bd)
503 call p_grad_c(dt2, npz,
delpc,
pkc,
gz, uc, vc, bd, gridstruct%rdxc, gridstruct%rdyc, hydrostatic)
506 call start_group_halo_update(i_pack(9), uc, vc, domain, gridtype=cgrid_ne)
516 if (flagstruct%inline_q .and. nq>0)
call complete_group_halo_update(i_pack(10), domain)
517 if (flagstruct%nord > 0)
call complete_group_halo_update(i_pack(3), domain)
518 call complete_group_halo_update(i_pack(9), domain)
521 if (gridstruct%nested)
then 534 0, 1, npx, npy, npz, bd, split_timestep_bc+0.5,
real(n_split*flagstruct%k_split), &
535 neststruct%vc_bc, bctype=neststruct%nestbctype )
537 1, 0, npx, npy, npz, bd, split_timestep_bc+0.5,
real(n_split*flagstruct%k_split), &
538 neststruct%uc_bc, bctype=neststruct%nestbctype )
542 1, 1, npx, npy, npz, bd, split_timestep_bc,
real(n_split*flagstruct%k_split), &
543 neststruct%divg_bc, bctype=neststruct%nestbctype )
551 if ( gridstruct%nested .and. flagstruct%inline_q )
then 554 0, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
555 neststruct%q_bc(iq), bctype=neststruct%nestbctype )
568 hord_m = flagstruct%hord_mt
569 hord_t = flagstruct%hord_tm
570 hord_v = flagstruct%hord_vt
571 hord_p = flagstruct%hord_dp
572 nord_k = flagstruct%nord
575 kgb = flagstruct%ke_bg
580 nord_v(k) =
min(2, flagstruct%nord)
582 d2_divg =
min(0.20, flagstruct%d2_bg)
584 if ( flagstruct%do_vort_damp )
then 585 damp_vt(k) = flagstruct%vtdm4
594 d_con_k = flagstruct%d_con
596 if ( npz==1 .or. flagstruct%n_sponge<0 )
then 597 d2_divg = flagstruct%d2_bg
603 nord_k=0; d2_divg =
max(0.01, flagstruct%d2_bg, flagstruct%d2_bg_k1)
605 nord_w=0; damp_w = d2_divg
606 if ( flagstruct%do_vort_damp )
then 610 damp_vt(k) = 0.5*d2_divg
614 elseif ( k==
max(2,flagstruct%n_sponge-1) .and. flagstruct%d2_bg_k2>0.01 )
then 615 nord_k=0; d2_divg =
max(flagstruct%d2_bg, flagstruct%d2_bg_k2)
616 nord_w=0; damp_w = d2_divg
617 if ( flagstruct%do_vort_damp )
then 620 damp_vt(k) = 0.5*d2_divg
624 elseif ( k==
max(3,flagstruct%n_sponge) .and. flagstruct%d2_bg_k2>0.05 )
then 625 nord_k=0; d2_divg =
max(flagstruct%d2_bg, 0.2*flagstruct%d2_bg_k2)
626 nord_w=0; damp_w = d2_divg
631 if( hydrostatic .and. (.not.flagstruct%use_old_omega) .and. last_step )
then 635 omga(i,j,k) = delp(i,j,k)
641 if ( flagstruct%d_ext > 0. ) &
642 call a2b_ord2(delp(isd,jsd,k), wk, gridstruct, npx, npy, is, &
643 ie, js, je, ng, .false.)
645 if ( .not.hydrostatic .and. flagstruct%do_f3d )
then 649 z_rat(i,j) = 1. + (
zh(i,j,k)+
zh(i,j,k+1))/
radius 653 call d_sw(
vt(isd,jsd,k), delp(isd,jsd,k),
ptc(isd,jsd,k), pt(isd,jsd,k), &
654 u(isd,jsd,k), v(isd,jsd,k), w(isd:,jsd:,k), uc(isd,jsd,k), &
655 vc(isd,jsd,k), ua(isd,jsd,k), va(isd,jsd,k),
divgd(isd,jsd,k), &
656 mfx(is, js, k), mfy(is, js, k), cx(is, jsd,k), cy(isd,js, k), &
657 crx(is, jsd,k),
cry(isd,js, k),
xfx(is, jsd,k),
yfx(isd,js, k), &
659 q_con(isd:,jsd:,k), z_rat(isd,jsd), &
661 q_con(isd:,jsd:,1), z_rat(isd,jsd), &
663 kgb, heat_s, dpx, zvir, sphum, nq, q, k, npz, flagstruct%inline_q, dt, &
664 flagstruct%hord_tr, hord_m, hord_v, hord_t, hord_p, &
665 nord_k, nord_v(k), nord_w, nord_t, flagstruct%dddmp, d2_divg, flagstruct%d4_bg, &
666 damp_vt(k), damp_w, damp_t, d_con_k, hydrostatic, gridstruct, flagstruct, bd)
668 if( hydrostatic .and. (.not.flagstruct%use_old_omega) .and. last_step )
then 672 omga(i,j,k) = omga(i,j,k)*(
xfx(i,j,k)-
xfx(i+1,j,k)+
yfx(i,j,k)-
yfx(i,j+1,k))*gridstruct%rarea(i,j)*rdt
677 if ( flagstruct%d_ext > 0. )
then 684 if ( flagstruct%d_con > 1.0e-5 )
then 688 heat_source(i,j,k) = heat_source(i,j,k) + heat_s(i,j)
696 if( flagstruct%fill_dp )
call mix_dp(hydrostatic, w, delp, pt, npz, ak, bk, .false., flagstruct%fv_debug, bd)
699 call start_group_halo_update(i_pack(1), delp, domain, complete=.false.)
700 call start_group_halo_update(i_pack(1), pt, domain, complete=.true.)
702 call start_group_halo_update(i_pack(11), q_con, domain)
706 if ( flagstruct%d_ext > 0. )
then 707 d2_divg = flagstruct%d_ext * gridstruct%da_min_c
712 divg2(i,j) = wk(i,j)*
vt(i,j,1)
716 wk(i,j) = wk(i,j) +
ptc(i,j,k)
717 divg2(i,j) = divg2(i,j) +
ptc(i,j,k)*
vt(i,j,k)
721 divg2(i,j) = d2_divg*divg2(i,j)/wk(i,j)
729 call complete_group_halo_update(i_pack(1), domain)
731 call complete_group_halo_update(i_pack(11), domain)
734 if ( flagstruct%fv_debug )
then 735 if ( .not. flagstruct%hydrostatic ) &
736 call prt_mxm(
'delz', delz, is, ie, js, je, ng, npz, 1., gridstruct%area_64, domain)
740 if (gridstruct%nested)
then 742 0, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
743 neststruct%delp_bc, bctype=neststruct%nestbctype )
748 0, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
749 neststruct%pt_bc, bctype=neststruct%nestbctype )
753 0, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
754 neststruct%q_con_bc, bctype=neststruct%nestbctype )
760 if ( hydrostatic )
then 761 call geopk(ptop, pe, peln, delp,
pkc,
gz, phis, pt, q_con, pkz, npz, akap, .false., &
762 gridstruct%nested, .true., npx, npy, flagstruct%a2b_ord, bd)
766 call update_dz_d(nord_v, damp_vt, flagstruct%hord_tm, is, ie, js, je, npz, ng, npx, npy, gridstruct%area, &
767 gridstruct%rarea, dp_ref, zs,
zh,
crx,
cry,
xfx,
yfx, delz, ws, rdt, gridstruct, bd)
769 if ( flagstruct%fv_debug )
then 770 if ( .not. flagstruct%hydrostatic ) &
771 call prt_mxm(
'delz updated', delz, is, ie, js, je, ng, npz, 1., gridstruct%area_64, domain)
774 if (idiag%id_ws>0 .and. last_step)
then 784 call riem_solver3(flagstruct%m_split, dt, is, ie, js, je, npz, ng, &
785 isd, ied, jsd, jed, &
786 akap, cappa, cp, ptop, zs, q_con, w, delz, pt, delp,
zh, &
787 pe,
pkc,
pk3, pk, peln, ws, &
788 flagstruct%scale_z, flagstruct%p_fac, flagstruct%a_imp, &
789 flagstruct%use_logp, remap_step, beta<-0.1)
792 if ( gridstruct%square_domain )
then 793 call start_group_halo_update(i_pack(4),
zh , domain)
794 call start_group_halo_update(i_pack(5),
pkc, domain, whalo=2, ehalo=2, shalo=2, nhalo=2)
796 call start_group_halo_update(i_pack(4),
zh , domain, complete=.false.)
797 call start_group_halo_update(i_pack(4),
pkc, domain, complete=.true.)
801 call pe_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, delp)
803 if ( flagstruct%use_logp )
then 804 call pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop,
pk3, delp)
806 call pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap,
pk3, delp)
808 if (gridstruct%nested)
then 810 0, 0, npx, npy, npz, bd, split_timestep_bc+1.,
real(n_split*flagstruct%k_split), &
811 neststruct%delz_bc, bctype=neststruct%nestbctype )
814 call nest_halo_nh(ptop, grav, akap, cp, delp, delz, pt, phis, &
821 pkc,
gz,
pk3, npx, npy, npz, gridstruct%nested, .true., .true., .true., bd)
825 call complete_group_halo_update(i_pack(4), domain)
831 gz(i,j,k) =
zh(i,j,k)*grav
835 if ( gridstruct%square_domain )
then 837 call complete_group_halo_update(i_pack(5), domain)
846 if ( remap_step .and. hydrostatic )
then 851 pk(i,j,k) =
pkc(i,j,k)
862 if ( hydrostatic )
then 863 if ( beta > 0. )
then 864 call grad1_p_update(divg2, u, v,
pkc,
gz, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta_d, flagstruct%a2b_ord)
866 call one_grad_p(u, v,
pkc,
gz, divg2, delp, dt, ng, gridstruct, bd, npx, npy, npz, ptop, hydrostatic, flagstruct%a2b_ord, flagstruct%d_ext)
872 if ( beta > 0. )
then 873 call split_p_grad( u, v,
pkc,
gz, delp,
pk3, beta_d, dt, ng, gridstruct, bd, npx, npy, npz, flagstruct%use_logp)
874 elseif ( beta < -0.1 )
then 875 call one_grad_p(u, v,
pkc,
gz, divg2, delp, dt, ng, gridstruct, bd, npx, npy, npz, ptop, hydrostatic, flagstruct%a2b_ord, flagstruct%d_ext)
877 call nh_p_grad(u, v,
pkc,
gz, delp,
pk3, dt, ng, gridstruct, bd, npx, npy, npz, flagstruct%use_logp)
881 if ( flagstruct%do_f3d )
then 886 ua(i,j,k) = -gridstruct%w00(i,j)*w(i,j,k)
896 call update_dwinds_phys(is, ie, js, je, isd, ied, jsd, jed, dt, ua, va, u, v, gridstruct, npx, npy, npz, domain)
904 if( flagstruct%tau > 0. ) &
905 call rayleigh_fast(abs(dt), npx, npy, npz, pfull, flagstruct%tau, u, v, w, ptop, hydrostatic, flagstruct%rf_cutoff, bd)
909 if ( flagstruct%breed_vortex_inline )
then 910 if ( .not. hydrostatic )
then 917 pkz(i,j,k) = exp(cappa(i,j,k)/(1.-cappa(i,j,k))*log(rdg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)) )
919 pkz(i,j,k) = exp( k1k*log(rdg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)) )
925 #if defined (ADA_NUDGE) 926 call breed_slp_inline_ada( it, dt, npz, ak, bk, phis, pe, pk, peln, pkz, &
927 delp, u, v, pt, q, flagstruct%nwat, zvir, gridstruct, ks, domain, bd )
929 call breed_slp_inline( it, dt, npz, ak, bk, phis, pe, pk, peln, pkz, delp, u, v, pt, q, &
930 flagstruct%nwat, zvir, gridstruct, ks, domain, bd, hydrostatic )
936 if( it==n_split .and. gridstruct%grid_type<4 .and. .not. gridstruct%nested)
then 939 nbufferx=nbuffer, gridtype=dgrid_ne )
943 u(i,je+1,k) = nbuffer(i-is+1,k)
946 v(ie+1,j,k) = ebuffer(j-js+1,k)
954 call start_group_halo_update(i_pack(8), u, v, domain, gridtype=dgrid_ne)
961 if ( gridstruct%nested )
then 962 neststruct%nest_timestep = neststruct%nest_timestep + 1
967 if ( hydrostatic .and. last_step )
then 968 if ( flagstruct%use_old_omega )
then 973 omga(i,j,k) = (pe(i,k+1,j) - pem(i,k+1,j)) * rdt
980 call adv_pe(ua, va, pem, omga, gridstruct, bd, npx, npy, npz, ng)
986 om2d(i,k) = omga(i,j,k)
991 om2d(i,k) = om2d(i,k-1) + omga(i,j,k)
996 omga(i,j,k) = om2d(i,k)
1001 if (idiag%id_ws>0 .and. hydrostatic)
then 1005 ws(i,j) = delz(i,j,npz)/delp(i,j,npz) * omga(i,j,npz)
1013 if (gridstruct%nested)
then 1018 if (.not. hydrostatic)
then 1020 0, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
1021 neststruct%w_bc, bctype=neststruct%nestbctype )
1025 0, 1, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
1026 neststruct%u_bc, bctype=neststruct%nestbctype )
1028 1, 0, npx, npy, npz, bd, split_timestep_bc+1,
real(n_split*flagstruct%k_split), &
1029 neststruct%v_bc, bctype=neststruct%nestbctype )
1036 if ( nq > 0 .and. .not. flagstruct%inline_q )
then 1039 call start_group_halo_update(i_pack(10), q, domain)
1044 if ( flagstruct%fv_debug )
then 1045 if(is_master())
write(*,*)
'End of n_split loop' 1049 if ( n_con/=0 .and. flagstruct%d_con > 1.e-5 )
then 1050 nf_ke =
min(3, flagstruct%nord+1)
1051 call del2_cubed(heat_source,
cnst_0p20*gridstruct%da_min, gridstruct, domain, npx, npy, npz, nf_ke, bd)
1054 if ( hydrostatic )
then 1064 pt(i,j,k) = pt(i,j,k) + heat_source(i,j,k)/(
cp_air*delp(i,j,k)*pkz(i,j,k))
1068 dtmp = heat_source(i,j,k) / (
cp_air*delp(i,j,k))
1069 pt(i,j,k) = pt(i,j,k) + sign(
min(abs(bdt)*flagstruct%delt_max,abs(dtmp)), dtmp)/pkz(i,j,k)
1079 delt = abs(bdt*flagstruct%delt_max)
1086 pkz(i,j,k) = exp( cappa(i,j,k)/(1.-cappa(i,j,k))*log(rdg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)) )
1088 pkz(i,j,k) = exp( k1k*log(rdg*delp(i,j,k)/delz(i,j,k)*pt(i,j,k)) )
1090 dtmp = heat_source(i,j,k) / (cv_air*delp(i,j,k))
1091 pt(i,j,k) = pt(i,j,k) + sign(
min(delt, abs(dtmp)),dtmp) / pkz(i,j,k)
1098 if (
allocated(heat_source))
deallocate( heat_source )
1101 if ( end_step )
then 1112 if(
allocated(
ut))
deallocate(
ut )
1113 if(
allocated(
vt))
deallocate(
vt )
1114 if (
allocated (
du) )
deallocate(
du )
1115 if (
allocated (
dv) )
deallocate(
dv )
1116 if ( .not. hydrostatic )
then 1118 if(
allocated(
pk3) )
deallocate (
pk3 )
1122 if(
allocated(pem) )
deallocate ( pem )
1126 subroutine pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap, pk3, delp)
1127 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed, npz
1128 real,
intent(in):: ptop, akap
1129 real,
intent(in ),
dimension(isd:ied,jsd:jed,npz):: delp
1130 real,
intent(inout),
dimension(isd:ied,jsd:jed,npz+1):: pk3
1142 pei(is-2) = pei(is-2) + delp(is-2,j,k)
1143 pei(is-1) = pei(is-1) + delp(is-1,j,k)
1144 pk3(is-2,j,k+1) = exp(akap*log(pei(is-2)))
1145 pk3(is-1,j,k+1) = exp(akap*log(pei(is-1)))
1150 pei(ie+1) = pei(ie+1) + delp(ie+1,j,k)
1151 pei(ie+2) = pei(ie+2) + delp(ie+2,j,k)
1152 pk3(ie+1,j,k+1) = exp(akap*log(pei(ie+1)))
1153 pk3(ie+2,j,k+1) = exp(akap*log(pei(ie+2)))
1163 pej(js-2) = pej(js-2) + delp(i,js-2,k)
1164 pej(js-1) = pej(js-1) + delp(i,js-1,k)
1165 pk3(i,js-2,k+1) = exp(akap*log(pej(js-2)))
1166 pk3(i,js-1,k+1) = exp(akap*log(pej(js-1)))
1171 pej(je+1) = pej(je+1) + delp(i,je+1,k)
1172 pej(je+2) = pej(je+2) + delp(i,je+2,k)
1173 pk3(i,je+1,k+1) = exp(akap*log(pej(je+1)))
1174 pk3(i,je+2,k+1) = exp(akap*log(pej(je+2)))
1180 subroutine pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3, delp)
1181 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed, npz
1182 real,
intent(in):: ptop
1183 real,
intent(in ),
dimension(isd:ied,jsd:jed,npz):: delp
1184 real,
intent(inout),
dimension(isd:ied,jsd:jed,npz+1):: pk3
1195 pet = pet + delp(i,j,k)
1196 pk3(i,j,k+1) = log(pet)
1202 pet = pet + delp(i,j,k)
1203 pk3(i,j,k+1) = log(pet)
1214 pet = pet + delp(i,j,k)
1215 pk3(i,j,k+1) = log(pet)
1221 pet = pet + delp(i,j,k)
1222 pk3(i,j,k+1) = log(pet)
1229 subroutine pe_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, delp)
1230 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed, npz
1231 real,
intent(in):: ptop
1232 real,
intent(in ),
dimension(isd:ied,jsd:jed,npz):: delp
1233 real,
intent(inout),
dimension(is-1:ie+1,npz+1,js-1:je+1):: pe
1242 pe(is-1,k+1,j) = pe(is-1,k,j) + delp(is-1,j,k)
1243 pe(ie+1,k+1,j) = pe(ie+1,k,j) + delp(ie+1,j,k)
1252 pe(i,k+1,js-1) = pe(i,k,js-1) + delp(i,js-1,k)
1253 pe(i,k+1,je+1) = pe(i,k,je+1) + delp(i,je+1,k)
1260 subroutine adv_pe(ua, va, pem, om, gridstruct, bd, npx, npy, npz, ng)
1262 integer,
intent(in) :: npx, npy, npz, ng
1263 type(fv_grid_bounds_type),
intent(IN) :: bd
1265 real,
intent(in),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz):: ua, va
1267 real,
intent(in) :: pem(bd%is-1:bd%ie+1,1:npz+1,bd%js-1:bd%je+1)
1268 real,
intent(inout) :: om(bd%isd:bd%ied,bd%jsd:bd%jed,npz)
1269 type(fv_grid_type),
intent(INOUT),
target :: gridstruct
1272 real,
dimension(bd%is:bd%ie,bd%js:bd%je):: up, vp
1273 real v3(3,bd%is:bd%ie,bd%js:bd%je)
1275 real pin(bd%isd:bd%ied,bd%jsd:bd%jed)
1276 real pb(bd%isd:bd%ied,bd%jsd:bd%jed)
1278 real grad(3,bd%is:bd%ie,bd%js:bd%je)
1279 real pdx(3,bd%is:bd%ie,bd%js:bd%je+1)
1280 real pdy(3,bd%is:bd%ie+1,bd%js:bd%je)
1283 integer :: is, ie, js, je
1296 up(i,j) = ua(i,j,npz)
1297 vp(i,j) = va(i,j,npz)
1303 up(i,j) = 0.5*(ua(i,j,k)+ua(i,j,k+1))
1304 vp(i,j) = 0.5*(va(i,j,k)+va(i,j,k+1))
1313 v3(n,i,j) = up(i,j)*gridstruct%ec1(n,i,j) + vp(i,j)*gridstruct%ec2(n,i,j)
1320 pin(i,j) = pem(i,k+1,j)
1325 call a2b_ord2(pin, pb, gridstruct, npx, npy, is, ie, js, je, ng)
1331 pdx(n,i,j) = (pb(i,j)+pb(i+1,j))*gridstruct%dx(i,j)*gridstruct%en1(n,i,j)
1338 pdy(n,i,j) = (pb(i,j)+pb(i,j+1))*gridstruct%dy(i,j)*gridstruct%en2(n,i,j)
1347 grad(n,i,j) = pdx(n,i,j+1) - pdx(n,i,j) - pdy(n,i,j) + pdy(n,i+1,j)
1355 om(i,j,k) = om(i,j,k) + 0.5*gridstruct%rarea(i,j)*(v3(1,i,j)*grad(1,i,j) + &
1356 v3(2,i,j)*grad(2,i,j) + v3(3,i,j)*grad(3,i,j))
1366 subroutine p_grad_c(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, rdyc, hydrostatic)
1368 integer,
intent(in):: npz
1369 real,
intent(in):: dt2
1370 type(fv_grid_bounds_type),
intent(IN) :: bd
1371 real,
intent(in),
dimension(bd%isd:, bd%jsd: ,: ):: delpc
1374 real,
intent(in),
dimension(bd%isd:bd%ied, bd%jsd:bd%jed ,npz+1):: pkc, gz
1375 real,
intent(inout):: uc(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
1376 real,
intent(inout):: vc(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz)
1377 real,
intent(IN) :: rdxc(bd%isd:bd%ied+1,bd%jsd:bd%jed+1)
1378 real,
intent(IN) :: rdyc(bd%isd:bd%ied ,bd%jsd:bd%jed)
1379 logical,
intent(in):: hydrostatic
1381 real:: wk(bd%is-1:bd%ie+1,bd%js-1:bd%je+1)
1384 integer :: is, ie, js, je
1395 if ( hydrostatic )
then 1398 wk(i,j) = pkc(i,j,k+1) - pkc(i,j,k)
1404 wk(i,j) = delpc(i,j,k)
1411 uc(i,j,k) = uc(i,j,k) + dt2*rdxc(i,j) / (wk(i-1,j)+wk(i,j)) * &
1412 ( (gz(i-1,j,k+1)-gz(i,j,k ))*(pkc(i,j,k+1)-pkc(i-1,j,k)) &
1413 + (gz(i-1,j,k) - gz(i,j,k+1))*(pkc(i-1,j,k+1)-pkc(i,j,k)) )
1418 vc(i,j,k) = vc(i,j,k) + dt2*rdyc(i,j) / (wk(i,j-1)+wk(i,j)) * &
1419 ( (gz(i,j-1,k+1)-gz(i,j,k ))*(pkc(i,j,k+1)-pkc(i,j-1,k)) &
1420 + (gz(i,j-1,k) - gz(i,j,k+1))*(pkc(i,j-1,k+1)-pkc(i,j,k)) )
1428 subroutine nh_p_grad(u, v, pp, gz, delp, pk, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
1429 integer,
intent(IN) :: ng, npx, npy, npz
1430 real,
intent(IN) :: dt
1431 logical,
intent(in) :: use_logp
1432 type(fv_grid_bounds_type),
intent(IN) :: bd
1433 real,
intent(inout) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1434 real,
intent(inout) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1435 real,
intent(inout) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1436 real,
intent(inout) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1437 real,
intent(inout) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1,npz)
1438 real,
intent(inout) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed, npz)
1439 type(fv_grid_type),
intent(INOUT),
target :: gridstruct
1441 real wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
1442 real wk(bd%is: bd%ie+1,bd%js: bd%je+1)
1443 real du1, dv1, top_value
1445 integer :: is, ie, js, je
1446 integer :: isd, ied, jsd, jed
1457 if ( use_logp )
then 1468 pk(i,j,1) = top_value
1476 call a2b_ord4(pp(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1477 call a2b_ord4(pk(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1479 call a2b_ord4( gz(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1486 call a2b_ord4(delp(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng)
1489 wk(i,j) = pk(i,j,k+1) - pk(i,j,k)
1496 du1 = dt / (wk(i,j)+wk(i+1,j)) * &
1497 ( (gz(i,j,k+1)-gz(i+1,j,k))*(pk(i+1,j,k+1)-pk(i,j,k)) + &
1498 (gz(i,j,k)-gz(i+1,j,k+1))*(pk(i,j,k+1)-pk(i+1,j,k)) )
1500 dul = (1.-0.5*(q_con(i,j-1,k)+q_con(i,j,k)))*
du 1503 u(i,j,k) = (u(i,j,k) + du1 + dt/(wk1(i,j)+wk1(i+1,j)) * &
1504 ((gz(i,j,k+1)-gz(i+1,j,k))*(pp(i+1,j,k+1)-pp(i,j,k)) &
1505 + (gz(i,j,k)-gz(i+1,j,k+1))*(pp(i,j,k+1)-pp(i+1,j,k))))*gridstruct%rdx(i,j)
1511 dv1 = dt / (wk(i,j)+wk(i,j+1)) * &
1512 ((gz(i,j,k+1)-gz(i,j+1,k))*(pk(i,j+1,k+1)-pk(i,j,k)) + &
1513 (gz(i,j,k)-gz(i,j+1,k+1))*(pk(i,j,k+1)-pk(i,j+1,k)))
1515 dvl = (1.-0.5*(q_con(i-1,j,k)+q_con(i,j,k)))*
dv 1518 v(i,j,k) = (v(i,j,k) + dv1 + dt/(wk1(i,j)+wk1(i,j+1)) * &
1519 ((gz(i,j,k+1)-gz(i,j+1,k))*(pp(i,j+1,k+1)-pp(i,j,k)) &
1520 + (gz(i,j,k)-gz(i,j+1,k+1))*(pp(i,j,k+1)-pp(i,j+1,k))))*gridstruct%rdy(i,j)
1528 subroutine split_p_grad( u, v, pp, gz, delp, pk, beta, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
1529 integer,
intent(IN) :: ng, npx, npy, npz
1530 real,
intent(IN) :: beta, dt
1531 logical,
intent(in):: use_logp
1532 type(fv_grid_bounds_type),
intent(IN) :: bd
1533 real,
intent(inout) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1534 real,
intent(inout) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1535 real,
intent(inout) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1536 real,
intent(inout) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1539 real,
intent(inout) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1,npz)
1540 real,
intent(inout) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed, npz)
1541 type(fv_grid_type),
intent(INOUT),
target :: gridstruct
1543 real wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
1544 real wk(bd%is: bd%ie+1,bd%js: bd%je+1)
1545 real alpha, top_value
1547 integer :: is, ie, js, je
1548 integer :: isd, ied, jsd, jed
1559 if ( use_logp )
then 1571 pk(i,j,1) = top_value
1579 call a2b_ord4(pp(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1580 call a2b_ord4(pk(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1582 call a2b_ord4( gz(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1589 call a2b_ord4(delp(isd,jsd,k), wk1, gridstruct, npx, npy, is, ie, js, je, ng)
1593 wk(i,j) = pk(i,j,k+1) - pk(i,j,k)
1599 u(i,j,k) = u(i,j,k) + beta*
du(i,j,k)
1603 du(i,j,k) = dt / (wk(i,j)+wk(i+1,j)) * &
1604 ((gz(i,j,k+1)-gz(i+1,j,k))*(pk(i+1,j,k+1)-pk(i,j,k)) + &
1605 (gz(i,j,k)-gz(i+1,j,k+1))*(pk(i,j,k+1)-pk(i+1,j,k)))
1607 du = (1.-0.5*(q_con(i,j-1,k)+q_con(i,j,k)))*
du 1611 u(i,j,k) = (u(i,j,k) + alpha*
du(i,j,k) + dt/(wk1(i,j)+wk1(i+1,j)) * &
1612 ((gz(i,j,k+1)-gz(i+1,j,k))*(pp(i+1,j,k+1)-pp(i,j,k)) &
1613 + (gz(i,j,k)-gz(i+1,j,k+1))*(pp(i,j,k+1)-pp(i+1,j,k))))*gridstruct%rdx(i,j)
1618 v(i,j,k) = v(i,j,k) + beta*
dv(i,j,k)
1621 dv(i,j,k) = dt / (wk(i,j)+wk(i,j+1)) * &
1622 ((gz(i,j,k+1)-gz(i,j+1,k))*(pk(i,j+1,k+1)-pk(i,j,k)) + &
1623 (gz(i,j,k)-gz(i,j+1,k+1))*(pk(i,j,k+1)-pk(i,j+1,k)))
1625 dv = (1.-0.5*(q_con(i-1,j,k)+q_con(i,j,k)))*
dv 1629 v(i,j,k) = (v(i,j,k) + alpha*
dv(i,j,k) + dt/(wk1(i,j)+wk1(i,j+1)) * &
1630 ((gz(i,j,k+1)-gz(i,j+1,k))*(pp(i,j+1,k+1)-pp(i,j,k)) &
1631 + (gz(i,j,k)-gz(i,j+1,k+1))*(pp(i,j,k+1)-pp(i,j+1,k))))*gridstruct%rdy(i,j)
1642 subroutine one_grad_p(u, v, pk, gz, divg2, delp, dt, ng, gridstruct, bd, npx, npy, npz, &
1643 ptop, hydrostatic, a2b_ord, d_ext)
1645 integer,
intent(IN) :: ng, npx, npy, npz, a2b_ord
1646 real,
intent(IN) :: dt, ptop, d_ext
1647 logical,
intent(in) :: hydrostatic
1648 type(fv_grid_bounds_type),
intent(IN) :: bd
1649 real,
intent(in) :: divg2(bd%is:bd%ie+1,bd%js:bd%je+1)
1650 real,
intent(inout) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed ,npz+1)
1651 real,
intent(inout) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed ,npz+1)
1652 real,
intent(inout) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed ,npz)
1653 real,
intent(inout) :: u(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz)
1654 real,
intent(inout) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
1655 type(fv_grid_type),
intent(INOUT),
target :: gridstruct
1657 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed):: wk
1658 real:: wk1(bd%is:bd%ie+1,bd%js:bd%je+1)
1659 real:: wk2(bd%is:bd%ie,bd%js:bd%je+1)
1663 integer :: is, ie, js, je
1664 integer :: isd, ied, jsd, jed
1675 if ( hydrostatic )
then 1686 pk(i,j,1) = top_value
1693 if ( a2b_ord==4 )
then 1694 call a2b_ord4(pk(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1696 call a2b_ord2(pk(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1703 if ( a2b_ord==4 )
then 1704 call a2b_ord4( gz(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1706 call a2b_ord2( gz(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1710 if ( d_ext > 0. )
then 1715 wk2(i,j) = divg2(i,j)-divg2(i+1,j)
1722 wk1(i,j) = divg2(i,j)-divg2(i,j+1)
1745 if ( hydrostatic )
then 1748 wk(i,j) = pk(i,j,k+1) - pk(i,j,k)
1752 if ( a2b_ord==4 )
then 1753 call a2b_ord4(delp(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng)
1755 call a2b_ord2(delp(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng)
1761 u(i,j,k) = gridstruct%rdx(i,j)*(wk2(i,j)+u(i,j,k) + dt/(wk(i,j)+wk(i+1,j)) * &
1762 ((gz(i,j,k+1)-gz(i+1,j,k))*(pk(i+1,j,k+1)-pk(i,j,k)) &
1763 + (gz(i,j,k)-gz(i+1,j,k+1))*(pk(i,j,k+1)-pk(i+1,j,k))))
1768 v(i,j,k) = gridstruct%rdy(i,j)*(wk1(i,j)+v(i,j,k) + dt/(wk(i,j)+wk(i,j+1)) * &
1769 ((gz(i,j,k+1)-gz(i,j+1,k))*(pk(i,j+1,k+1)-pk(i,j,k)) &
1770 + (gz(i,j,k)-gz(i,j+1,k+1))*(pk(i,j,k+1)-pk(i,j+1,k))))
1778 subroutine grad1_p_update(divg2, u, v, pk, gz, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
1780 integer,
intent(in) :: ng, npx, npy, npz, a2b_ord
1781 real,
intent(in) :: dt, ptop, beta
1782 type(fv_grid_bounds_type),
intent(IN) :: bd
1783 real,
intent(in):: divg2(bd%is:bd%ie+1,bd%js:bd%je+1)
1784 real,
intent(inout) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed ,npz+1)
1785 real,
intent(inout) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed ,npz+1)
1786 real,
intent(inout) :: u(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz)
1787 real,
intent(inout) :: v(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
1788 type(fv_grid_type),
intent(INOUT),
target :: gridstruct
1791 real:: wk(bd%isd:bd%ied,bd%jsd:bd%jed)
1792 real top_value, alpha
1795 integer :: is, ie, js, je
1796 integer :: isd, ied, jsd, jed
1815 pk(i,j,1) = top_value
1821 if ( a2b_ord==4 )
then 1822 call a2b_ord4(pk(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1824 call a2b_ord2(pk(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1831 if ( a2b_ord==4 )
then 1832 call a2b_ord4( gz(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1834 call a2b_ord2( gz(isd,jsd,k), wk, gridstruct, npx, npy, is, ie, js, je, ng, .true.)
1845 wk(i,j) = pk(i,j,k+1) - pk(i,j,k)
1851 u(i,j,k) = u(i,j,k) + beta*
du(i,j,k)
1852 du(i,j,k) = dt/(wk(i,j)+wk(i+1,j)) * &
1853 ((gz(i,j,k+1)-gz(i+1,j,k))*(pk(i+1,j,k+1)-pk(i,j,k)) &
1854 + (gz(i,j,k)-gz(i+1,j,k+1))*(pk(i,j,k+1)-pk(i+1,j,k)))
1855 u(i,j,k) = (u(i,j,k) + divg2(i,j)-divg2(i+1,j) + alpha*
du(i,j,k))*gridstruct%rdx(i,j)
1860 v(i,j,k) = v(i,j,k) + beta*
dv(i,j,k)
1861 dv(i,j,k) = dt/(wk(i,j)+wk(i,j+1)) * &
1862 ((gz(i,j,k+1)-gz(i,j+1,k))*(pk(i,j+1,k+1)-pk(i,j,k)) &
1863 + (gz(i,j,k)-gz(i,j+1,k+1))*(pk(i,j,k+1)-pk(i,j+1,k)))
1864 v(i,j,k) = (v(i,j,k) + divg2(i,j)-divg2(i,j+1) + alpha*
dv(i,j,k))*gridstruct%rdy(i,j)
1872 subroutine mix_dp(hydrostatic, w, delp, pt, km, ak, bk, CG, fv_debug, bd)
1873 integer,
intent(IN) :: km
1874 real ,
intent(IN) :: ak(km+1), bk(km+1)
1875 type(fv_grid_bounds_type),
intent(IN) :: bd
1876 real,
intent(INOUT),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,km):: pt, delp
1877 real,
intent(INOUT),
dimension(bd%isd:,bd%jsd:,1:):: w
1878 logical,
intent(IN) :: hydrostatic, CG, fv_debug
1882 integer ifirst, ilast
1883 integer jfirst, jlast
1885 integer :: is, ie, js, je
1886 integer :: isd, ied, jsd, jed
1899 ifirst = is-1; ilast = ie+1
1900 jfirst = js-1; jlast = je+1
1902 ifirst = is; ilast = ie
1903 jfirst = js; jlast = je
1910 do 1000 j=jfirst,jlast
1915 dpmin = 0.01 * ( ak(k+1)-ak(k) + (bk(k+1)-bk(k))*1.e5 )
1917 if(delp(i,j,k) < dpmin)
then 1918 if (fv_debug)
write(*,*)
'Mix_dp: ', i, j, k, mpp_pe(), delp(i,j,k), pt(i,j,k)
1920 dp = dpmin - delp(i,j,k)
1921 pt(i,j,k) = (pt(i,j,k)*delp(i,j,k) + pt(i,j,k+1)*dp) / dpmin
1922 if ( .not.hydrostatic ) w(i,j,k) = (w(i,j,k)*delp(i,j,k) + w(i,j,k+1)*dp) / dpmin
1924 delp(i,j,k+1) = delp(i,j,k+1) - dp
1931 dpmin = 0.01 * ( ak(km+1)-ak(km) + (bk(km+1)-bk(km))*1.e5 )
1933 if(delp(i,j,km) < dpmin)
then 1934 if (fv_debug)
write(*,*)
'Mix_dp: ', i, j, km, mpp_pe(), delp(i,j,km), pt(i,j,km)
1936 dp = dpmin - delp(i,j,km)
1937 pt(i,j,km) = (pt(i,j,km)*delp(i,j,km) + pt(i,j,km-1)*dp)/dpmin
1938 if ( .not.hydrostatic ) w(i,j,km) = (w(i,j,km)*delp(i,j,km) + w(i,j,km-1)*dp) / dpmin
1939 delp(i,j,km) = dpmin
1940 delp(i,j,km-1) = delp(i,j,km-1) - dp
1944 if ( fv_debug .and. ip/=0 )
write(*,*)
'Warning: Mix_dp', mpp_pe(), j, ip
1951 subroutine geopk(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz, km, akap, CG, nested, computehalo, npx, npy, a2b_ord, bd)
1953 integer,
intent(IN) :: km, npx, npy, a2b_ord
1954 real ,
intent(IN) :: akap, ptop
1955 type(fv_grid_bounds_type),
intent(IN) :: bd
1956 real ,
intent(IN) :: hs(bd%isd:bd%ied,bd%jsd:bd%jed)
1957 real,
intent(IN),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,km):: pt, delp
1958 real,
intent(IN),
dimension(bd%isd:,bd%jsd:,1:):: q_con
1959 logical,
intent(IN) :: CG, nested, computehalo
1961 real,
intent(OUT),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,km+1):: gz, pk
1962 real,
intent(OUT) :: pe(bd%is-1:bd%ie+1,km+1,bd%js-1:bd%je+1)
1963 real,
intent(out) :: peln(bd%is:bd%ie,km+1,bd%js:bd%je)
1964 real,
intent(out) :: pkz(bd%is:bd%ie,bd%js:bd%je,km)
1968 real peg(bd%isd:bd%ied,km+1)
1969 real pkg(bd%isd:bd%ied,km+1)
1970 real(kind=8) p1d(bd%isd:bd%ied)
1971 real(kind=8) g1d(bd%isd:bd%ied)
1972 real logp(bd%isd:bd%ied)
1974 integer ifirst, ilast
1975 integer jfirst, jlast
1977 integer :: is, ie, js, je
1978 integer :: isd, ied, jsd, jed
1989 if ( (.not. cg .and. a2b_ord==4) .or. (nested .and. .not. cg) )
then 1990 ifirst = is-2; ilast = ie+2
1991 jfirst = js-2; jlast = je+2
1993 ifirst = is-1; ilast = ie+1
1994 jfirst = js-1; jlast = je+1
1997 if (nested .and. computehalo)
then 1998 if (is == 1) ifirst = isd
1999 if (ie == npx-1) ilast = ied
2000 if (js == 1) jfirst = jsd
2001 if (je == npy-1) jlast = jed
2007 do 2000 j=jfirst,jlast
2013 gz(i,j,km+1) = hs(i,j)
2021 if( j>=js .and. j<=je)
then 2028 if( j>(js-2) .and. j<(je+2) )
then 2029 do i=
max(ifirst,is-1),
min(ilast,ie+1)
2037 p1d(i) = p1d(i) + delp(i,j,k-1)
2038 logp(i) = log(p1d(i))
2039 pk(i,j,k) = exp( akap*logp(i) )
2041 peg(i,k) = peg(i,k-1) + delp(i,j,k-1)*(1.-q_con(i,j,k-1))
2042 pkg(i,k) = exp( akap*log(peg(i,k)) )
2046 if( j>(js-2) .and. j<(je+2) )
then 2047 do i=
max(ifirst,is-1),
min(ilast,ie+1)
2050 if( j>=js .and. j<=je)
then 2052 peln(i,k,j) = logp(i)
2063 g1d(i) = g1d(i) + pt(i,j,k)*(pk(i,j,k+1)-pk(i,j,k))
2066 g1d(i) = g1d(i) +
cp_air*pt(i,j,k)*(pkg(i,k+1)-pkg(i,k))
2068 g1d(i) = g1d(i) +
cp_air*pt(i,j,k)*(pk(i,j,k+1)-pk(i,j,k))
2075 if ( .not. cg .and. j .ge. js .and. j .le. je )
then 2078 pkz(i,j,k) = (pk(i,j,k+1)-pk(i,j,k))/(akap*(peln(i,k+1,j)-peln(i,k,j)))
2084 end subroutine geopk 2087 subroutine del2_cubed(q, cd, gridstruct, domain, npx, npy, km, nmax, bd)
2091 integer,
intent(in):: npx, npy, km, nmax
2092 real(kind=R_GRID),
intent(in):: cd
2094 real,
intent(inout):: q(bd%isd:bd%ied,bd%jsd:bd%jed,km)
2096 type(
domain2d),
intent(INOUT) :: domain
2097 real,
parameter:: r3 = 1./3.
2098 real :: fx(bd%isd:bd%ied+1,bd%jsd:bd%jed), fy(bd%isd:bd%ied,bd%jsd:bd%jed+1)
2099 real :: q2(bd%isd:bd%ied,bd%jsd:bd%jed)
2100 integer i,j,k, n, nt, ntimes
2101 integer :: is, ie, js, je
2102 integer :: isd, ied, jsd, jed
2127 ntimes =
min(3, nmax)
2143 if ( gridstruct%sw_corner )
then 2144 q(1,1,k) = (q(1,1,k)+q(0,1,k)+q(1,0,k)) * r3
2148 if ( gridstruct%se_corner )
then 2149 q(ie, 1,k) = (q(ie,1,k)+q(npx,1,k)+q(ie,0,k)) * r3
2150 q(npx,1,k) = q(ie,1,k)
2151 q(ie, 0,k) = q(ie,1,k)
2153 if ( gridstruct%ne_corner )
then 2154 q(ie, je,k) = (q(ie,je,k)+q(npx,je,k)+q(ie,npy,k)) * r3
2155 q(npx,je,k) = q(ie,je,k)
2156 q(ie,npy,k) = q(ie,je,k)
2158 if ( gridstruct%nw_corner )
then 2159 q(1, je,k) = (q(1,je,k)+q(0,je,k)+q(1,npy,k)) * r3
2160 q(0, je,k) = q(1,je,k)
2161 q(1,npy,k) = q(1,je,k)
2164 if(nt>0)
call copy_corners(q(isd,jsd,k), npx, npy, 1, gridstruct%nested, bd, &
2165 gridstruct%sw_corner, gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner )
2169 fx(i,j) = gridstruct%dy(i,j)*gridstruct%sina_u(i,j)*(q(i-1,j,k)-q(i,j,k))*gridstruct%rdxc(i,j)
2171 fx(i,j) = gridstruct%del6_v(i,j)*(q(i-1,j,k)-q(i,j,k))
2176 if(nt>0)
call copy_corners(q(isd,jsd,k), npx, npy, 2, gridstruct%nested, bd, &
2177 gridstruct%sw_corner, gridstruct%se_corner, gridstruct%nw_corner, gridstruct%ne_corner)
2181 fy(i,j) = gridstruct%dx(i,j)*gridstruct%sina_v(i,j)*(q(i,j-1,k)-q(i,j,k))*gridstruct%rdyc(i,j)
2183 fy(i,j) = gridstruct%del6_u(i,j)*(q(i,j-1,k)-q(i,j,k))
2190 q(i,j,k) = q(i,j,k) + cd*gridstruct%rarea(i,j)*(fx(i,j)-fx(i+1,j)+fy(i,j)-fy(i,j+1))
2198 subroutine init_ijk_mem(i1, i2, j1, j2, km, array, var)
2199 integer,
intent(in):: i1, i2, j1, j2, km
2200 real,
intent(inout):: array(i1:i2,j1:j2,km)
2201 real,
intent(in):: var
2216 subroutine rayleigh_fast(dt, npx, npy, npz, pfull, tau, u, v, w, &
2217 ptop, hydrostatic, rf_cutoff, bd)
2219 real,
intent(in):: dt
2220 real,
intent(in):: tau
2221 real,
intent(in):: ptop, rf_cutoff
2222 real,
intent(in),
dimension(npz):: pfull
2223 integer,
intent(in):: npx, npy, npz
2224 logical,
intent(in):: hydrostatic
2225 type(fv_grid_bounds_type),
intent(IN) :: bd
2226 real,
intent(inout):: u(bd%isd:bd%ied ,bd%jsd:bd%jed+1,npz)
2227 real,
intent(inout):: v(bd%isd:bd%ied+1,bd%jsd:bd%jed,npz)
2228 real,
intent(inout):: w(bd%isd: ,bd%jsd: ,1: )
2230 real(kind=R_GRID):: rff(npz)
2231 real,
parameter:: sday = 86400.
2235 integer :: is, ie, js, je
2236 integer :: isd, ied, jsd, jed
2252 if( is_master() )
write(6,*)
'Fast Rayleigh friction E-folding time (days):' 2254 if ( pfull(k) < rf_cutoff )
then 2255 rff(k) = dt/tau0*sin(0.5*
pi*log(rf_cutoff/pfull(k))/log(rf_cutoff/ptop))**2
2257 if( is_master() )
write(6,*) k, 0.01*pfull(k), dt/(rff(k)*sday)
2259 rff(k) = 1.d0 / (1.0d0+rff(k))
2270 if ( pfull(k) < rf_cutoff )
then 2273 u(i,j,k) =
rf(k)*u(i,j,k)
2278 v(i,j,k) =
rf(k)*v(i,j,k)
2281 if ( .not. hydrostatic )
then 2284 w(i,j,k) =
rf(k)*w(i,j,k)
subroutine, public del2_cubed(q, cd, gridstruct, domain, npx, npy, km, nmax, bd)
real, dimension(:,:,:), allocatable pk3
real, parameter, public radius
Radius of the Earth [m].
real, dimension(:,:,:), allocatable dv
real, dimension(:,:,:), allocatable divgd
subroutine rayleigh_fast(dt, npx, npy, npz, pfull, tau, u, v, w, ptop, hydrostatic, rf_cutoff, bd)
real, dimension(:,:,:), allocatable ptc
real, dimension(:,:,:), allocatable zh
subroutine, public nested_grid_bc_apply_intt(var_nest, istag, jstag, npx, npy, npz, bd, step, split, BC, bctype)
subroutine, public case9_forcing1(phis, time_since_start)
integer, parameter, public corner
real, dimension(:,:,:), allocatable du
subroutine, public case9_forcing2(phis)
real, dimension(:,:,:), allocatable crx
real, dimension(:,:,:), allocatable yfx
subroutine pe_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, delp)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
subroutine adv_pe(ua, va, pem, om, gridstruct, bd, npx, npy, npz, ng)
real, dimension(:,:,:), allocatable gz
subroutine split_p_grad(u, v, pp, gz, delp, pk, beta, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, double *qout, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
subroutine grad1_p_update(divg2, u, v, pk, gz, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
real, dimension(:,:,:), allocatable xfx
real(kind=r_grid), parameter cnst_0p20
subroutine, public breed_slp_inline(nstep, dt, npz, ak, bk, phis, pe, pk, peln, pkz, delp, u, v, pt, q, nwat, zvir, gridstruct, ks, domain_local, bd, hydrostatic)
real, parameter, public pi
Ratio of circle circumference to diameter [N/A].
real, dimension(:,:,:), allocatable vt
subroutine geopk(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz, km, akap, CG, nested, computehalo, npx, npy, a2b_ord, bd)
subroutine p_grad_c(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, rdyc, hydrostatic)
real, dimension(:,:,:), allocatable delpc
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine timing_on(blk_name)
subroutine mix_dp(hydrostatic, w, delp, pt, km, ak, bk, CG, fv_debug, bd)
subroutine pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap, pk3, delp)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
integer, parameter, public r_grid
subroutine, public extrapolation_bc(q, istag, jstag, npx, npy, bd, pd_in, debug_in)
logical, public do_adiabatic_init
real, dimension(:,:,:), allocatable pkc
subroutine, public dyn_core(npx, npy, npz, ng, sphum, nq, bdt, n_split, zvir, cp, akap, cappa, grav, hydrostatic, u, v, w, delz, pt, q, delp, pe, pk, phis, ws, omga, ptop, pfull, ua, va, uc, vc, mfx, mfy, cx, cy, pkz, peln, q_con, ak, bk, dpx, ks, gridstruct, flagstruct, neststruct, idiag, bd, domain, init_step, i_pack, end_step, time_total)
real, dimension(:,:,:), allocatable cry
subroutine, public c_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, wc, ut, vt, divg_d, nord, dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
real, dimension(:,:,:), allocatable ut
subroutine pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3, delp)
real, dimension(:), allocatable rf
subroutine update_dwinds_phys(is, ie, js, je, isd, ied, jsd, jed, dt, u_dt, v_dt, u, v, gridstruct, npx, npy, npz, domain)
subroutine, public prt_mxm(qname, q, is, ie, js, je, n_g, km, fac, area, domain)
subroutine, public copy_corners(q, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine, public prt_maxmin(qname, q, is, ie, js, je, n_g, km, fac)
integer, public test_case
subroutine, public init_ijk_mem(i1, i2, j1, j2, km, array, var)
subroutine one_grad_p(u, v, pk, gz, divg2, delp, dt, ng, gridstruct, bd, npx, npy, npz, ptop, hydrostatic, a2b_ord, d_ext)
subroutine, public d_sw(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, divg_d, xflux, yflux, cx, cy, crx_adv, cry_adv, xfx_adv, yfx_adv, q_con, z_rat, kgb, heat_source, dpx, zvir, sphum, nq, q, k, km, inline_q, dt, hord_tr, hord_mt, hord_vt, hord_tm, hord_dp, nord, nord_v, nord_w, nord_t, dddmp, d2_bg, d4_bg, damp_v, damp_w, damp_t, d_con, hydrostatic, gridstruct, flagstruct, bd)
subroutine, public riem_solver3(ms, dt, is, ie, js, je, km, ng, isd, ied, jsd, jed, akap, cappa, cp, ptop, zs, q_con, w, delz, pt, delp, zh, pe, ppe, pk3, pk, peln, ws, scale_m, p_fac, a_imp, use_logp, last_call, fp_out)
type(time_type), public fv_time
subroutine nh_p_grad(u, v, pp, gz, delp, pk, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine timing_off(blk_name)