46 #if defined (ADA_NUDGE) 47 use fv_ada_nudge_mod,
only: breed_slp_inline_ada
115 SUBROUTINE dyn_core_fwd(npx, npy, npz, ng, sphum, nq, bdt, n_split, &
116 & zvir, cp, akap, cappa, grav, hydrostatic, u, v, w, delz, pt, q, delp&
117 & , pe, pk, phis, ws, omga, ptop, pfull, ua, va, uc, vc, mfx, mfy, cx&
118 & , cy, pkz, peln, q_con, ak, bk, dpx, ks, gridstruct, flagstruct, &
119 & flagstructp, neststruct, idiag, bd, domain, init_step, i_pack, &
120 & end_step, gz, pkc, ptc, crx, xfx, cry, yfx, divgd, delpc, ut, vt, zh&
121 & , pk3, du, dv, time_total)
164 INTEGER,
INTENT(IN) :: npx
165 INTEGER,
INTENT(IN) :: npy
166 INTEGER,
INTENT(IN) :: npz
167 INTEGER,
INTENT(IN) :: ng, nq, sphum
168 INTEGER,
INTENT(IN) :: n_split
169 REAL,
INTENT(IN) :: bdt
170 REAL,
INTENT(IN) :: zvir, cp, akap, grav
171 REAL,
INTENT(IN) :: ptop
172 LOGICAL,
INTENT(IN) :: hydrostatic
173 LOGICAL,
INTENT(IN) :: init_step, end_step
174 REAL,
INTENT(IN) :: pfull(npz)
175 REAL,
DIMENSION(npz+1),
INTENT(IN) :: ak, bk
176 INTEGER,
INTENT(IN) :: ks
177 TYPE(group_halo_update_type),
INTENT(INOUT) :: i_pack(*)
180 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz),
INTENT(INOUT) &
183 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz),
INTENT(INOUT) &
186 REAL,
INTENT(INOUT) :: w(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
188 REAL,
INTENT(INOUT) :: delz(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
190 REAL,
INTENT(INOUT) :: cappa(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
192 REAL,
INTENT(INOUT) :: pt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
194 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
196 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
198 REAL,
INTENT(IN),
OPTIONAL :: time_total
205 REAL,
INTENT(INOUT) :: phis(bd%isd:bd%ied, bd%jsd:bd%jed)
207 REAL,
INTENT(INOUT) :: pe(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
209 REAL,
INTENT(INOUT) :: peln(bd%is:bd%ie, npz+1, bd%js:bd%je)
211 REAL,
INTENT(INOUT) :: pk(bd%is:bd%ie, bd%js:bd%je, npz+1)
212 REAL(kind=8),
INTENT(INOUT) :: dpx(bd%is:bd%ie, bd%js:bd%je)
215 REAL,
PARAMETER :: near0=1.e-8
216 REAL,
PARAMETER :: huge_r=1.e8
219 REAL :: ws(bd%is:bd%ie, bd%js:bd%je)
221 REAL,
INTENT(INOUT) :: omga(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
223 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
224 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
225 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(INOUT) ::&
227 REAL,
INTENT(INOUT) :: q_con(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
229 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
230 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
232 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
233 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
234 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je, npz),
INTENT(INOUT) :: pkz
240 TYPE(
domain2d),
INTENT(INOUT) :: domain
242 REAL :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1), heat_source(bd&
243 & %isd:bd%ied, bd%jsd:bd%jed, npz)
245 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ws3, z_rat
248 REAL :: zs(bd%isd:bd%ied, bd%jsd:bd%jed)
249 REAL :: p1d(bd%is:bd%ie)
250 REAL :: om2d(bd%is:bd%ie, npz)
251 REAL :: wbuffer(npy+2, npz)
252 REAL :: ebuffer(npy+2, npz)
253 REAL :: nbuffer(npx+2, npz)
254 REAL :: sbuffer(npx+2, npz)
256 REAL :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
257 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
258 REAL :: fz(bd%is:bd%ie+1, bd%js:bd%je+1)
259 REAL :: heat_s(bd%is:bd%ie, bd%js:bd%je)
260 REAL :: damp_vt(npz+1)
261 INTEGER :: nord_v(npz+1)
263 INTEGER :: hord_m, hord_v, hord_t, hord_p
264 INTEGER :: nord_k, nord_w, nord_t
267 INTEGER :: hord_m_pert, hord_v_pert, hord_t_pert, hord_p_pert
268 INTEGER :: nord_k_pert, nord_w_pert, nord_t_pert, nord_v_pert(npz+1)
269 REAL :: d2_divg_pert, damp_vt_pert(npz+1), damp_w_pert, damp_t_pert
271 INTEGER :: i, j, k, it, iq, n_con, nf_ke
272 INTEGER :: iep1, jep1
273 REAL :: beta, beta_d, d_con_k, damp_w, damp_t, kgb, cv_air
276 REAL :: k1k, rdg, dtmp, delt
277 LOGICAL :: last_step, remap_step
279 REAL :: split_timestep_bc
280 INTEGER :: is, ie, js, je
281 INTEGER :: isd, ied, jsd, jed
282 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
283 REAL,
INTENT(INOUT) :: pkc(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
284 REAL,
INTENT(INOUT) :: ptc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
285 REAL,
INTENT(INOUT) :: crx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
286 REAL,
INTENT(INOUT) :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
287 REAL,
INTENT(INOUT) :: cry(bd%isd:bd%ied, bd%js:bd%je+1, npz)
288 REAL,
INTENT(INOUT) :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
289 REAL,
INTENT(INOUT) :: divgd(bd%isd:bd%ied+1, bd%jsd:bd%jed+1, npz)
290 REAL,
INTENT(INOUT) :: delpc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
291 REAL,
INTENT(INOUT) :: ut(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
292 REAL,
INTENT(INOUT) :: vt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
293 REAL,
INTENT(INOUT) :: zh(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
294 REAL,
INTENT(INOUT) :: pk3(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
295 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
296 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
355 split_timestep_bc = 0.0
409 dt = bdt/
REAL(n_split)
412 IF (1 .LT. flagstruct%m_split/2)
THEN 413 ms = flagstruct%m_split/2
417 beta = flagstruct%beta
423 IF (.NOT.hydrostatic)
THEN 429 dp_ref(k) = ak(k+1) - ak(k) + (bk(k+1)-bk(k))*1.e5
434 zs(i, j) = phis(i, j)*
rgrav 450 CALL pushrealarray(cx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
453 CALL pushrealarray(cy, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
455 IF (flagstruct%d_con .GT. 1.0e-5) heat_source = 0.0
458 IF (flagstruct%convert_ke .OR. flagstruct%vtdm4 .GT. 1.e-4)
THEN 461 ELSE IF (flagstruct%d2_bg_k1 .LT. 1.e-3)
THEN 464 ELSE IF (flagstruct%d2_bg_k2 .LT. 1.e-3)
THEN 474 IF (flagstruct%breed_vortex_inline .OR. it .EQ. n_split)
THEN 479 IF (flagstruct%fv_debug)
THEN 483 WRITE(*, *)
'n_split loop, it=', it
490 IF (gridstruct%nested) split_timestep_bc =
REAL(n_split*flagstruct&
491 & %k_split + neststruct%nest_timestep)
495 IF (flagstruct%inline_q)
THEN 496 CALL pushrealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz&
506 IF (.NOT.hydrostatic)
THEN 507 CALL pushrealarray(w, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
510 IF (gridstruct%nested)
THEN 515 gz(i, j, npz+1) = zs(i, j)
520 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)
530 gz(i, j, npz+1) = zs(i, j)
535 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)
541 CALL pushrealarray(gz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
560 IF (it .EQ. n_split .AND. end_step)
THEN 561 IF (flagstruct%use_old_omega)
THEN 571 pem(i, k+1, j) = pem(i, k, j) + delp(i, j, k)
588 CALL c_sw_fwd(delpc(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed&
589 & , k), ptc(isd:ied, jsd:jed, k), pt(isd:ied, jsd:jed, k)&
590 & , u(isd:ied, jsd:jed+1, k), v(isd:ied+1, jsd:jed, k), w(&
591 & isd:ied, jsd:jed, k), uc(isd:ied+1, jsd:jed, k), vc(isd:&
592 & ied, jsd:jed+1, k), ua(isd:ied, jsd:jed, k), va(isd:ied&
593 & , jsd:jed, k), omga(isd:ied, jsd:jed, k), ut(isd:ied, &
594 & jsd:jed, k), vt(isd:ied, jsd:jed, k), divgd(isd:ied+1, &
595 & jsd:jed+1, k), flagstruct%nord, dt2, hydrostatic, .true.&
596 & , bd, gridstruct, flagstruct)
598 IF (flagstruct%nord .GT. 0)
THEN 605 IF (gridstruct%nested)
THEN 606 arg1 = split_timestep_bc + 0.5
607 arg2 =
REAL(n_split*flagstruct%k_split)
608 CALL pushrealarray(delpc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
610 CALL nested_grid_bc_apply_intt(delpc, 0, 0, npx, npy, npz, bd, &
611 & split_timestep_bc + 0.5,
REAL(n_split*&
& flagstruct%k_split), neststruct%delp_bc&
612 & , bctype=neststruct%nestbctype)
613 arg1 = split_timestep_bc + 0.5
614 arg2 =
REAL(n_split*flagstruct%k_split)
615 CALL pushrealarray(ptc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz&
617 CALL nested_grid_bc_apply_intt(ptc, 0, 0, npx, npy, npz, bd, &
618 & split_timestep_bc + 0.5,
REAL(n_split*&
& flagstruct%k_split), neststruct%pt_bc, &
619 & bctype=neststruct%nestbctype)
625 IF (hydrostatic)
THEN 626 CALL geopk_fwd(ptop, pe, peln, delpc, pkc, gz, phis, ptc, q_con&
627 & , pkz, npz, akap, .true., gridstruct%nested, .false., &
628 & npx, npy, flagstruct%a2b_ord, bd)
637 zh(i, j, k) = gz(i, j, k)
648 gz(i, j, k) = zh(i, j, k)
654 CALL update_dz_c_fwd(is, ie, js, je, npz, ng, dt2, dp_ref, zs, &
655 & gridstruct%area, ut, vt, gz, ws3, npx, npy, &
656 & gridstruct%sw_corner, gridstruct%se_corner, &
657 & gridstruct%ne_corner, gridstruct%nw_corner, bd, &
658 & gridstruct%grid_type)
659 CALL riem_solver_c_fwd(ms, dt2, is, ie, js, je, npz, ng, akap, &
660 & cappa, cp, ptop, phis, omga, ptc, q_con, delpc&
661 & , gz, pkc, ws3, flagstruct%p_fac, flagstruct%&
662 & a_imp, flagstruct%scale_z)
663 IF (gridstruct%nested)
THEN 664 arg1 = split_timestep_bc + 0.5
665 arg2 =
REAL(n_split*flagstruct%k_split)
666 CALL pushrealarray(delz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
668 CALL nested_grid_bc_apply_intt(delz, 0, 0, npx, npy, npz, bd, &
669 & split_timestep_bc + 0.5,
REAL(n_split&
& *flagstruct%k_split), neststruct%&
670 & delz_bc, bctype=neststruct%nestbctype&
675 CALL nest_halo_nh_fwd(ptop, grav, akap, cp, delpc, delz, ptc, &
676 & phis, pkc, gz, pk3, npx, npy, npz, gridstruct%&
677 & nested, .false., .false., .false., bd)
683 CALL p_grad_c_fwd(dt2, npz, delpc, pkc, gz, uc, vc, bd, gridstruct&
684 & %rdxc, gridstruct%rdyc, hydrostatic)
687 IF (gridstruct%nested)
THEN 697 arg1 = split_timestep_bc + 0.5
698 arg2 =
REAL(n_split*flagstruct%k_split)
699 CALL nested_grid_bc_apply_intt(vc, 0, 1, npx, npy, npz, bd, &
700 & split_timestep_bc + 0.5,
REAL(n_split*&
& flagstruct%k_split), neststruct%vc_bc, &
701 & bctype=neststruct%nestbctype)
702 arg1 = split_timestep_bc + 0.5
703 arg2 =
REAL(n_split*flagstruct%k_split)
704 CALL nested_grid_bc_apply_intt(uc, 1, 0, npx, npy, npz, bd, &
705 & split_timestep_bc + 0.5,
REAL(n_split*&
& flagstruct%k_split), neststruct%uc_bc, &
706 & bctype=neststruct%nestbctype)
708 arg1 =
REAL(n_split*flagstruct%k_split)
709 CALL nested_grid_bc_apply_intt(divgd, 1, 1, npx, npy, npz, bd, &
710 & split_timestep_bc,
REAL(n_split*&
& flagstruct%k_split), neststruct%divg_bc&
711 & , bctype=neststruct%nestbctype)
720 IF (gridstruct%nested .AND. flagstruct%inline_q)
THEN 722 arg1 = split_timestep_bc + 1
723 arg2 =
REAL(n_split*flagstruct%k_split)
724 CALL pushrealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
726 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
727 & 0, npx, npy, npz, bd, &
728 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%q_bc(&
729 & iq), bctype=neststruct%nestbctype)
743 hord_m = flagstruct%hord_mt
744 hord_t = flagstruct%hord_tm
745 hord_v = flagstruct%hord_vt
746 hord_p = flagstruct%hord_dp
748 nord_k = flagstruct%nord
750 kgb = flagstruct%ke_bg
751 IF (2 .GT. flagstruct%nord)
THEN 753 nord_v(k) = flagstruct%nord
760 IF (0.20 .GT. flagstruct%d2_bg)
THEN 762 d2_divg = flagstruct%d2_bg
769 IF (flagstruct%do_vort_damp)
THEN 772 damp_vt(k) = flagstruct%vtdm4
785 d_con_k = flagstruct%d_con
786 IF (npz .EQ. 1 .OR. flagstruct%n_sponge .LT. 0)
THEN 788 d2_divg = flagstruct%d2_bg
789 ELSE IF (k .EQ. 1)
THEN 794 IF (0.01 .LT. flagstruct%d2_bg)
THEN 795 IF (flagstruct%d2_bg .LT. flagstruct%d2_bg_k1)
THEN 797 d2_divg = flagstruct%d2_bg_k1
800 d2_divg = flagstruct%d2_bg
802 ELSE IF (0.01 .LT. flagstruct%d2_bg_k1)
THEN 804 d2_divg = flagstruct%d2_bg_k1
812 IF (flagstruct%do_vort_damp)
THEN 817 damp_vt(k) = 0.5*d2_divg
824 IF (2 .LT. flagstruct%n_sponge - 1)
THEN 825 max1 = flagstruct%n_sponge - 1
829 IF (k .EQ. max1 .AND. flagstruct%d2_bg_k2 .GT. 0.01)
THEN 831 IF (flagstruct%d2_bg .LT. flagstruct%d2_bg_k2)
THEN 832 d2_divg = flagstruct%d2_bg_k2
834 d2_divg = flagstruct%d2_bg
838 IF (flagstruct%do_vort_damp)
THEN 842 damp_vt(k) = 0.5*d2_divg
849 IF (3 .LT. flagstruct%n_sponge)
THEN 850 max2 = flagstruct%n_sponge
854 IF (k .EQ. max2 .AND. flagstruct%d2_bg_k2 .GT. 0.05)
THEN 856 IF (flagstruct%d2_bg .LT. 0.2*flagstruct%d2_bg_k2)
THEN 858 d2_divg = 0.2*flagstruct%d2_bg_k2
861 d2_divg = flagstruct%d2_bg
872 hord_m_pert = flagstructp%hord_mt_pert
874 hord_t_pert = flagstructp%hord_tm_pert
876 hord_v_pert = flagstructp%hord_vt_pert
878 hord_p_pert = flagstructp%hord_dp_pert
880 nord_k_pert = flagstructp%nord_pert
881 IF (2 .GT. flagstructp%nord_pert)
THEN 883 nord_v_pert(k) = flagstructp%nord_pert
890 IF (0.20 .GT. flagstructp%d2_bg_pert)
THEN 892 d2_divg_pert = flagstructp%d2_bg_pert
899 IF (flagstructp%do_vort_damp_pert)
THEN 902 damp_vt_pert(k) = flagstructp%vtdm4_pert
910 nord_t_pert = nord_v_pert(k)
912 damp_t_pert = damp_vt_pert(k)
914 IF (k .LE. flagstructp%n_sponge_pert)
THEN 915 IF (k .LE. flagstructp%n_sponge_pert - 1)
THEN 916 IF (flagstructp%hord_ks_traj)
THEN 917 hord_m = flagstructp%hord_mt_ks_traj
918 hord_t = flagstructp%hord_tm_ks_traj
919 hord_v = flagstructp%hord_vt_ks_traj
920 hord_p = flagstructp%hord_dp_ks_traj
922 IF (flagstructp%hord_ks_pert)
THEN 924 hord_m_pert = flagstructp%hord_mt_ks_pert
925 hord_t_pert = flagstructp%hord_tm_ks_pert
926 hord_v_pert = flagstructp%hord_vt_ks_pert
927 hord_p_pert = flagstructp%hord_dp_ks_pert
936 IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 937 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_k1_pert&
940 d2_divg_pert = flagstructp%d2_bg_k1_pert
943 d2_divg_pert = flagstructp%d2_bg_pert
945 ELSE IF (0.01 .LT. flagstructp%d2_bg_k1_pert)
THEN 947 d2_divg_pert = flagstructp%d2_bg_k1_pert
952 ELSE IF (k .EQ. 2)
THEN 953 IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 954 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_k2_pert&
957 d2_divg_pert = flagstructp%d2_bg_k2_pert
960 d2_divg_pert = flagstructp%d2_bg_pert
962 ELSE IF (0.01 .LT. flagstructp%d2_bg_k2_pert)
THEN 964 d2_divg_pert = flagstructp%d2_bg_k2_pert
969 ELSE IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 970 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_ks_pert) &
973 d2_divg_pert = flagstructp%d2_bg_ks_pert
976 d2_divg_pert = flagstructp%d2_bg_pert
978 ELSE IF (0.01 .LT. flagstructp%d2_bg_ks_pert)
THEN 980 d2_divg_pert = flagstructp%d2_bg_ks_pert
985 IF (flagstructp%do_vort_damp_pert)
THEN 989 damp_vt_pert(k) = 0.5*d2_divg_pert
999 damp_vt(npz+1) = damp_vt(npz)
1001 damp_vt_pert(npz+1) = damp_vt_pert(npz)
1003 nord_v(npz+1) = nord_v(npz)
1005 nord_v_pert(npz+1) = nord_v_pert(npz)
1006 IF (hydrostatic .AND. (.NOT.flagstruct%use_old_omega) .AND. &
1012 omga(i, j, k) = delp(i, j, k)
1020 IF (flagstruct%d_ext .GT. 0.)
THEN 1021 CALL a2b_ord2_fwd(delp(isd:ied, jsd:jed, k), wk, gridstruct, &
1022 & npx, npy, is, ie, js, je, ng, .false.)
1027 IF (.NOT.hydrostatic .AND. flagstruct%do_f3d)
THEN 1031 z_rat(i, j) = 1. + (zh(i, j, k)+zh(i, j, k+1))/
radius 1038 CALL d_sw_fwd(vt(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k)&
1039 & , ptc(isd:ied, jsd:jed, k), pt(isd:ied, jsd:jed, k), u(&
1040 & isd:ied, jsd:jed+1, k), v(isd:ied+1, jsd:jed, k), w(isd:&
1041 & ied, jsd:jed, k), uc(isd:ied+1, jsd:jed, k), vc(isd:ied&
1042 & , jsd:jed+1, k), ua(isd:ied, jsd:jed, k), va(isd:ied, &
1043 & jsd:jed, k), divgd(isd:ied+1, jsd:jed+1, k), mfx(is:ie+1&
1044 & , js:je, k), mfy(is:ie, js:je+1, k), cx(is:ie+1, jsd:jed&
1045 & , k), cy(isd:ied, js:je+1, k), crx(is:ie+1, jsd:jed, k)&
1046 & , cry(isd:ied, js:je+1, k), xfx(is:ie+1, jsd:jed, k), &
1047 & yfx(isd:ied, js:je+1, k), q_con(isd:ied, jsd:jed, 1), &
1048 & z_rat(isd:ied, jsd:jed), kgb, heat_s, dpx, zvir, sphum, &
1049 & nq, q, k, npz, flagstruct%inline_q, dt, flagstruct%&
1050 & hord_tr, hord_m, hord_v, hord_t, hord_p, nord_k, nord_v(&
1051 & k), nord_w, nord_t, flagstruct%dddmp, d2_divg, &
1052 & flagstruct%d4_bg, damp_vt(k), damp_w, damp_t, d_con_k, &
1053 & hydrostatic, gridstruct, flagstruct, bd, flagstructp%&
1054 & hord_tr_pert, hord_m_pert, hord_v_pert, hord_t_pert, &
1055 & hord_p_pert, flagstructp%split_damp, nord_k_pert, &
1056 & nord_v_pert(k), nord_w_pert, nord_t_pert, flagstructp%&
1057 & dddmp_pert, d2_divg_pert, flagstructp%d4_bg_pert, &
1058 & damp_vt_pert(k), damp_w_pert, damp_t_pert)
1059 IF (hydrostatic .AND. (.NOT.flagstruct%use_old_omega) .AND. &
1065 omga(i, j, k) = omga(i, j, k)*(xfx(i, j, k)-xfx(i+1, j, k)&
1066 & +yfx(i, j, k)-yfx(i, j+1, k))*gridstruct%rarea(i, j)*rdt
1073 IF (flagstruct%d_ext .GT. 0.)
THEN 1078 ptc(i, j, k) = wk(i, j)
1085 IF (flagstruct%d_con .GT. 1.0e-5)
THEN 1089 heat_source(i, j, k) = heat_source(i, j, k) + heat_s(i, j)
1098 IF (flagstruct%fill_dp)
THEN 1099 CALL mix_dp_fwd(hydrostatic, w, delp, pt, npz, ak, bk, .false., &
1100 & flagstruct%fv_debug, bd)
1105 CALL pushrealarray(delp, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
1108 CALL pushrealarray(pt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
1111 IF (flagstruct%d_ext .GT. 0.)
THEN 1113 d2_divg = flagstruct%d_ext*gridstruct%da_min_c
1118 wk(i, j) = ptc(i, j, 1)
1119 divg2(i, j) = wk(i, j)*vt(i, j, 1)
1124 wk(i, j) = wk(i, j) + ptc(i, j, k)
1125 divg2(i, j) = divg2(i, j) + ptc(i, j, k)*vt(i, j, k)
1130 divg2(i, j) = d2_divg*divg2(i, j)/wk(i, j)
1139 IF (gridstruct%nested)
THEN 1140 arg1 = split_timestep_bc + 1
1141 arg2 =
REAL(n_split*flagstruct%k_split)
1142 CALL nested_grid_bc_apply_intt(delp, 0, 0, npx, npy, npz, bd, &
1143 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%delp_bc&
1144 & , bctype=neststruct%nestbctype)
1145 arg1 = split_timestep_bc + 1
1146 arg2 =
REAL(n_split*flagstruct%k_split)
1147 CALL nested_grid_bc_apply_intt(pt, 0, 0, npx, npy, npz, bd, &
1148 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%pt_bc, &
1149 & bctype=neststruct%nestbctype)
1155 IF (hydrostatic)
THEN 1156 CALL geopk_fwd(ptop, pe, peln, delp, pkc, gz, phis, pt, q_con, &
1157 & pkz, npz, akap, .false., gridstruct%nested, .true., npx&
1158 & , npy, flagstruct%a2b_ord, bd)
1161 CALL update_dz_d_fwd(nord_v, damp_vt, flagstruct%hord_tm, is, ie&
1162 & , js, je, npz, ng, npx, npy, gridstruct%area, &
1163 & gridstruct%rarea, dp_ref, zs, zh, crx, cry, xfx, &
1164 & yfx, delz, ws, rdt, gridstruct, bd, flagstructp%&
1166 arg10 = beta .LT. -0.1
1167 CALL riem_solver3_fwd(flagstruct%m_split, dt, is, ie, js, je, &
1168 & npz, ng, isd, ied, jsd, jed, akap, cappa, cp, &
1169 & ptop, zs, q_con, w, delz, pt, delp, zh, pe, pkc&
1170 & , pk3, pk, peln, ws, flagstruct%scale_z, &
1171 & flagstruct%p_fac, flagstruct%a_imp, flagstruct%&
1172 & use_logp, remap_step, arg10)
1173 IF (gridstruct%square_domain)
THEN 1174 CALL pushrealarray(zh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
1177 CALL pushrealarray(pkc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
1180 & ehalo=2, shalo=2, nhalo=2)
1183 CALL pushrealarray(zh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
1187 CALL pushrealarray(pkc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
1193 IF (remap_step)
THEN 1194 CALL pe_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop&
1200 IF (flagstruct%use_logp)
THEN 1201 CALL pln_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, &
1205 CALL pk3_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, &
1206 & ptop, akap, pk3, delp)
1209 IF (gridstruct%nested)
THEN 1210 arg1 = split_timestep_bc + 1.
1211 arg2 =
REAL(n_split*flagstruct%k_split)
1212 CALL pushrealarray(delz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
1214 CALL nested_grid_bc_apply_intt(delz, 0, 0, npx, npy, npz, bd, &
1215 & split_timestep_bc + 1.,
REAL(n_split*&
& flagstruct%k_split), neststruct%&
1216 & delz_bc, bctype=neststruct%nestbctype&
1219 CALL nest_halo_nh_fwd(ptop, grav, akap, cp, delp, delz, pt, &
1220 & phis, pkc, gz, pk3, npx, npy, npz, gridstruct%&
1221 & nested, .true., .true., .true., bd)
1231 gz(i, j, k) = zh(i, j, k)*grav
1237 IF (remap_step .AND. hydrostatic)
THEN 1243 pk(i, j, k) = pkc(i, j, k)
1254 IF (hydrostatic)
THEN 1255 IF (beta .GT. 0.)
THEN 1257 & gridstruct, bd, npx, npy, npz, ptop, beta_d&
1258 & , flagstruct%a2b_ord)
1262 & gridstruct, bd, npx, npy, npz, ptop, hydrostatic&
1263 & , flagstruct%a2b_ord, flagstruct%d_ext)
1266 ELSE IF (beta .GT. 0.)
THEN 1268 & dt, ng, gridstruct, bd, npx, npy, npz, &
1269 & flagstruct%use_logp)
1271 ELSE IF (beta .LT. -0.1)
THEN 1273 & gridstruct, bd, npx, npy, npz, ptop, hydrostatic, &
1274 & flagstruct%a2b_ord, flagstruct%d_ext)
1277 CALL nh_p_grad_fwd(u, v, pkc, gz, delp, pk3, dt, ng, gridstruct&
1278 & , bd, npx, npy, npz, flagstruct%use_logp)
1283 IF (flagstruct%breed_vortex_inline)
THEN 1284 IF (.NOT.hydrostatic)
THEN 1291 pkz(i, j, k) = exp(k1k*log(rdg*delp(i, j, k)/delz(i, j, &
1304 IF (it .EQ. n_split .AND. gridstruct%grid_type .LT. 4 .AND. (.NOT.&
1305 & gridstruct%nested))
THEN 1307 CALL pushrealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
1308 CALL pushrealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
1310 & nbuffer, gridtype=dgrid_ne)
1314 u(i, je+1, k) = nbuffer(i-is+1, k)
1317 v(ie+1, j, k) = ebuffer(j-js+1, k)
1324 IF (it .NE. n_split)
THEN 1325 CALL pushrealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
1326 CALL pushrealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
1333 IF (gridstruct%nested) neststruct%nest_timestep = neststruct%&
1335 IF (hydrostatic .AND. last_step)
THEN 1336 IF (flagstruct%use_old_omega)
THEN 1342 omga(i, j, k) = (pe(i, k+1, j)-pem(i, k+1, j))*rdt
1349 CALL adv_pe_fwd(ua, va, pem, omga, gridstruct, bd, npx, npy, &
1357 om2d(i, k) = omga(i, j, k)
1362 om2d(i, k) = om2d(i, k-1) + omga(i, j, k)
1368 omga(i, j, k) = om2d(i, k)
1374 IF (idiag%id_ws .GT. 0 .AND. hydrostatic)
THEN 1379 ws(i, j) = delz(i, j, npz)/delp(i, j, npz)*omga(i, j, npz)
1389 IF (gridstruct%nested)
THEN 1390 IF (.NOT.hydrostatic)
THEN 1391 arg1 = split_timestep_bc + 1
1392 arg2 =
REAL(n_split*flagstruct%k_split)
1393 CALL pushrealarray(w, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz&
1395 CALL nested_grid_bc_apply_intt(w, 0, 0, npx, npy, npz, bd, &
1396 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%w_bc&
1397 & , bctype=neststruct%nestbctype)
1402 arg1 = split_timestep_bc + 1
1403 arg2 =
REAL(n_split*flagstruct%k_split)
1404 CALL pushrealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
1405 CALL nested_grid_bc_apply_intt(u, 0, 1, npx, npy, npz, bd, &
1406 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%u_bc, &
1407 & bctype=neststruct%nestbctype)
1408 arg1 = split_timestep_bc + 1
1409 arg2 =
REAL(n_split*flagstruct%k_split)
1410 CALL pushrealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
1411 CALL nested_grid_bc_apply_intt(v, 1, 0, npx, npy, npz, bd, &
1412 & split_timestep_bc + 1,
REAL(n_split*&
& flagstruct%k_split), neststruct%v_bc, &
1413 & bctype=neststruct%nestbctype)
1422 IF (nq .GT. 0 .AND. (.NOT.flagstruct%inline_q))
THEN 1423 CALL pushrealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*nq)
1429 IF (flagstruct%fv_debug)
THEN 1433 WRITE(*, *)
'End of n_split loop' 1440 IF (n_con .NE. 0 .AND. flagstruct%d_con .GT. 1.e-5)
THEN 1441 IF (3 .GT. flagstruct%nord + 1)
THEN 1442 nf_ke = flagstruct%nord + 1
1447 CALL del2_cubed_fwd(heat_source, arg11, gridstruct, domain, npx, &
1448 & npy, npz, nf_ke, bd)
1450 IF (hydrostatic)
THEN 1462 pt(i, j, k) = pt(i, j, k) + heat_source(i, j, k)/(
cp_air&
1463 & *delp(i, j, k)*pkz(i, j, k))
1468 dtmp = heat_source(i, j, k)/(
cp_air*delp(i, j, k))
1469 IF (bdt .GE. 0.)
THEN 1474 x1 = abs0*flagstruct%delt_max
1475 IF (dtmp .GE. 0.)
THEN 1482 IF (x1 .GT. y1)
THEN 1492 pt(i, j, k) = pt(i, j, k) + sign(min1, dtmp)/pkz(i, j, k&
1507 CALL pushrealarray(heat_source, (bd%ied-bd%isd+1)*(bd%jed-bd%&
1514 CALL pushrealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
1539 IF (bdt*flagstruct%delt_max .GE. 0.)
THEN 1540 delt = bdt*flagstruct%delt_max
1542 delt = -(bdt*flagstruct%delt_max)
1550 pkz(i, j, k) = exp(k1k*log(rdg*delp(i, j, k)/delz(i, j, k)&
1552 dtmp = heat_source(i, j, k)/(cv_air*delp(i, j, k))
1553 IF (dtmp .GE. 0.)
THEN 1560 IF (delt .GT. y2)
THEN 1570 pt(i, j, k) = pt(i, j, k) + sign(min2, dtmp)/pkz(i, j, k)
1582 CALL pushrealarray(heat_source, (bd%ied-bd%isd+1)*(bd%jed-bd%&
1589 CALL pushrealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
1624 CALL pushrealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
1673 SUBROUTINE dyn_core_bwd(npx, npy, npz, ng, sphum, nq, bdt, n_split, &
1674 & zvir, cp, akap, cappa, grav, hydrostatic, u, u_ad, v, v_ad, w, w_ad&
1675 & , delz, delz_ad, pt, pt_ad, q, q_ad, delp, delp_ad, pe, pe_ad, pk, &
1676 & pk_ad, phis, ws, ws_ad, omga, omga_ad, ptop, pfull, ua, ua_ad, va, &
1677 & va_ad, uc, uc_ad, vc, vc_ad, mfx, mfx_ad, mfy, mfy_ad, cx, cx_ad, cy&
1678 & , cy_ad, pkz, pkz_ad, peln, peln_ad, q_con, ak, bk, dpx, dpx_ad, ks&
1679 & , gridstruct, flagstruct, flagstructp, neststruct, idiag, bd, domain&
1680 & , init_step, i_pack, end_step, gz, gz_ad, pkc, pkc_ad, ptc, ptc_ad, &
1681 & crx, crx_ad, xfx, xfx_ad, cry, cry_ad, yfx, yfx_ad, divgd, divgd_ad&
1682 & , delpc, delpc_ad, ut, ut_ad, vt, vt_ad, zh, zh_ad, pk3, pk3_ad, du&
1683 & , du_ad, dv, dv_ad, time_total)
1726 INTEGER,
INTENT(IN) :: npx
1727 INTEGER,
INTENT(IN) :: npy
1728 INTEGER,
INTENT(IN) :: npz
1729 INTEGER,
INTENT(IN) :: ng, nq, sphum
1730 INTEGER,
INTENT(IN) :: n_split
1731 REAL,
INTENT(IN) :: bdt
1732 REAL,
INTENT(IN) :: zvir, cp, akap, grav
1733 REAL,
INTENT(IN) :: ptop
1734 LOGICAL,
INTENT(IN) :: hydrostatic
1735 LOGICAL,
INTENT(IN) :: init_step, end_step
1736 REAL,
INTENT(IN) :: pfull(npz)
1737 REAL,
DIMENSION(npz+1),
INTENT(IN) :: ak, bk
1738 INTEGER,
INTENT(IN) :: ks
1739 TYPE(group_halo_update_type),
INTENT(INOUT) :: i_pack(*)
1741 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz),
INTENT(INOUT) &
1743 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz),
INTENT(INOUT) &
1745 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz),
INTENT(INOUT) &
1747 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz),
INTENT(INOUT) &
1749 REAL,
INTENT(INOUT) :: w(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1750 REAL,
INTENT(INOUT) :: w_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1751 REAL,
INTENT(INOUT) :: delz(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1752 REAL,
INTENT(INOUT) :: delz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1753 REAL,
INTENT(INOUT) :: cappa(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1754 REAL,
INTENT(INOUT) :: pt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1755 REAL,
INTENT(INOUT) :: pt_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1756 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1757 REAL,
INTENT(INOUT) :: delp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1758 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
1759 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
1760 REAL,
INTENT(IN),
OPTIONAL :: time_total
1761 REAL,
INTENT(INOUT) :: phis(bd%isd:bd%ied, bd%jsd:bd%jed)
1762 REAL,
INTENT(INOUT) :: pe(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
1763 REAL,
INTENT(INOUT) :: pe_ad(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1&
1765 REAL,
INTENT(INOUT) :: peln(bd%is:bd%ie, npz+1, bd%js:bd%je)
1766 REAL,
INTENT(INOUT) :: peln_ad(bd%is:bd%ie, npz+1, bd%js:bd%je)
1767 REAL,
INTENT(INOUT) :: pk(bd%is:bd%ie, bd%js:bd%je, npz+1)
1768 REAL,
INTENT(INOUT) :: pk_ad(bd%is:bd%ie, bd%js:bd%je, npz+1)
1769 REAL(kind=8),
INTENT(INOUT) :: dpx(bd%is:bd%ie, bd%js:bd%je)
1770 REAL(kind=8),
INTENT(INOUT) :: dpx_ad(bd%is:bd%ie, bd%js:bd%je)
1771 REAL,
PARAMETER :: near0=1.e-8
1772 REAL,
PARAMETER :: huge_r=1.e8
1773 REAL :: ws(bd%is:bd%ie, bd%js:bd%je)
1774 REAL :: ws_ad(bd%is:bd%ie, bd%js:bd%je)
1775 REAL,
INTENT(INOUT) :: omga(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1776 REAL,
INTENT(INOUT) :: omga_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1777 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
1778 REAL,
INTENT(INOUT) :: uc_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
1779 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
1780 REAL,
INTENT(INOUT) :: vc_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
1781 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(INOUT) ::&
1783 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(INOUT) ::&
1785 REAL,
INTENT(INOUT) :: q_con(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1786 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
1787 REAL,
INTENT(INOUT) :: mfx_ad(bd%is:bd%ie+1, bd%js:bd%je, npz)
1788 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
1789 REAL,
INTENT(INOUT) :: mfy_ad(bd%is:bd%ie, bd%js:bd%je+1, npz)
1790 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1791 REAL,
INTENT(INOUT) :: cx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1792 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1793 REAL,
INTENT(INOUT) :: cy_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1794 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je, npz),
INTENT(INOUT) :: pkz
1795 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je, npz),
INTENT(INOUT) :: &
1797 TYPE(
fv_grid_type),
INTENT(INOUT),
TARGET :: gridstruct
1802 TYPE(
domain2d),
INTENT(INOUT) :: domain
1803 REAL :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1), heat_source(bd&
1804 & %isd:bd%ied, bd%jsd:bd%jed, npz)
1805 REAL :: pem_ad(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1), &
1806 & heat_source_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1807 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ws3, z_rat
1808 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ws3_ad, z_rat_ad
1810 REAL :: zs(bd%isd:bd%ied, bd%jsd:bd%jed)
1811 REAL :: p1d(bd%is:bd%ie)
1812 REAL :: om2d(bd%is:bd%ie, npz)
1813 REAL :: om2d_ad(bd%is:bd%ie, npz)
1814 REAL :: wbuffer(npy+2, npz)
1815 REAL :: ebuffer(npy+2, npz)
1816 REAL :: ebuffer_ad(npy+2, npz)
1817 REAL :: nbuffer(npx+2, npz)
1818 REAL :: nbuffer_ad(npx+2, npz)
1819 REAL :: sbuffer(npx+2, npz)
1820 REAL :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
1821 REAL :: divg2_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
1822 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
1823 REAL :: wk_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
1824 REAL :: fz(bd%is:bd%ie+1, bd%js:bd%je+1)
1825 REAL :: heat_s(bd%is:bd%ie, bd%js:bd%je)
1826 REAL :: heat_s_ad(bd%is:bd%ie, bd%js:bd%je)
1827 REAL :: damp_vt(npz+1)
1828 INTEGER :: nord_v(npz+1)
1829 INTEGER :: hord_m, hord_v, hord_t, hord_p
1830 INTEGER :: nord_k, nord_w, nord_t
1832 INTEGER :: hord_m_pert, hord_v_pert, hord_t_pert, hord_p_pert
1833 INTEGER :: nord_k_pert, nord_w_pert, nord_t_pert, nord_v_pert(npz+1)
1834 REAL :: d2_divg_pert, damp_vt_pert(npz+1), damp_w_pert, damp_t_pert
1835 INTEGER :: i, j, k, it, iq, n_con, nf_ke
1836 INTEGER :: iep1, jep1
1837 REAL :: beta, beta_d, d_con_k, damp_w, damp_t, kgb, cv_air
1838 REAL :: dt, dt2, rdt
1840 REAL :: k1k, rdg, dtmp, delt
1842 LOGICAL :: last_step, remap_step
1844 REAL :: split_timestep_bc
1845 INTEGER :: is, ie, js, je
1846 INTEGER :: isd, ied, jsd, jed
1847 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1848 REAL,
INTENT(INOUT) :: gz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1849 REAL,
INTENT(INOUT) :: pkc(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1850 REAL,
INTENT(INOUT) :: pkc_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1851 REAL,
INTENT(INOUT) :: ptc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1852 REAL,
INTENT(INOUT) :: ptc_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1853 REAL,
INTENT(INOUT) :: crx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1854 REAL,
INTENT(INOUT) :: crx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1855 REAL,
INTENT(INOUT) :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1856 REAL,
INTENT(INOUT) :: xfx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1857 REAL,
INTENT(INOUT) :: cry(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1858 REAL,
INTENT(INOUT) :: cry_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1859 REAL,
INTENT(INOUT) :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1860 REAL,
INTENT(INOUT) :: yfx_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1861 REAL,
INTENT(INOUT) :: divgd(bd%isd:bd%ied+1, bd%jsd:bd%jed+1, npz)
1862 REAL,
INTENT(INOUT) :: divgd_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed+1, &
1864 REAL,
INTENT(INOUT) :: delpc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1865 REAL,
INTENT(INOUT) :: delpc_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1866 REAL,
INTENT(INOUT) :: ut(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1867 REAL,
INTENT(INOUT) :: ut_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1868 REAL,
INTENT(INOUT) :: vt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1869 REAL,
INTENT(INOUT) :: vt_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1870 REAL,
INTENT(INOUT) :: zh(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1871 REAL,
INTENT(INOUT) :: zh_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1872 REAL,
INTENT(INOUT) :: pk3(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1873 REAL,
INTENT(INOUT) :: pk3_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
1874 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
1875 REAL,
INTENT(INOUT) :: du_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
1876 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
1877 REAL,
INTENT(INOUT) :: dv_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
1958 split_timestep_bc = 0.0
2004 IF (branch .EQ. 0)
THEN 2022 CALL poprealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2034 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2035 heat_source_ad = 0.0
2037 IF (branch .EQ. 1)
THEN 2056 CALL poprealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2062 CALL poprealarray(heat_source, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd&
2071 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2072 heat_source_ad = 0.0
2076 IF (branch .EQ. 0)
THEN 2078 dtmp = heat_source(i, j, k)/(
cp_air*delp(i, j, k))
2080 temp_ad5 = pt_ad(i, j, k)/pkz(i, j, k)
2081 min1_ad = sign(1.d0, min1*dtmp)*temp_ad5
2082 pkz_ad(i, j, k) = pkz_ad(i, j, k) - sign(min1, dtmp)*&
2083 & temp_ad5/pkz(i, j, k)
2085 IF (branch .EQ. 0)
THEN 2093 IF (branch .EQ. 0)
THEN 2098 temp4 =
cp_air*delp(i, j, k)
2099 heat_source_ad(i, j, k) = heat_source_ad(i, j, k) + &
2101 delp_ad(i, j, k) = delp_ad(i, j, k) - heat_source(i, j, &
2102 & k)*
cp_air*dtmp_ad/temp4**2
2107 temp3 =
cp_air*delp(i, j, k)
2108 temp2 = temp3*pkz(i, j, k)
2109 temp_ad4 = -(heat_source(i, j, k)*pt_ad(i, j, k)/temp2**&
2111 heat_source_ad(i, j, k) = heat_source_ad(i, j, k) + &
2112 & pt_ad(i, j, k)/temp2
2113 delp_ad(i, j, k) = delp_ad(i, j, k) + pkz(i, j, k)*&
2115 pkz_ad(i, j, k) = pkz_ad(i, j, k) + temp3*temp_ad4
2140 CALL poprealarray(ws3, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2146 CALL poprealarray(heat_source, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd&
2155 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
2156 heat_source_ad = 0.0
2160 dtmp = heat_source(i, j, k)/(cv_air*delp(i, j, k))
2162 temp_ad7 = pt_ad(i, j, k)/pkz(i, j, k)
2163 min2_ad = sign(1.d0, min2*dtmp)*temp_ad7
2164 pkz_ad(i, j, k) = pkz_ad(i, j, k) - sign(min2, dtmp)*&
2165 & temp_ad7/pkz(i, j, k)
2167 IF (branch .EQ. 0)
THEN 2175 IF (branch .EQ. 0)
THEN 2180 temp7 = delz(i, j, k)
2181 temp6 = delp(i, j, k)*pt(i, j, k)
2183 temp_ad6 = k1k*exp(k1k*log(rdg*temp5))*pkz_ad(i, j, k)/(&
2185 temp8 = cv_air*delp(i, j, k)
2186 heat_source_ad(i, j, k) = heat_source_ad(i, j, k) + &
2188 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*temp_ad6&
2189 & - heat_source(i, j, k)*cv_air*dtmp_ad/temp8**2
2191 pt_ad(i, j, k) = pt_ad(i, j, k) + delp(i, j, k)*temp_ad6
2192 delz_ad(i, j, k) = delz_ad(i, j, k) - temp5*temp_ad6
2193 pkz_ad(i, j, k) = 0.0
2199 CALL del2_cubed_bwd(heat_source, heat_source_ad, arg11, gridstruct&
2200 & , domain, npx, npy, npz, nf_ke, bd)
2204 IF (branch .EQ. 0)
THEN 2205 CALL poprealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*nq)
2223 IF (branch .NE. 0)
THEN 2224 CALL poprealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
2226 & , bd, arg1, arg2, neststruct%v_bc, &
2227 & neststruct%nestbctype)
2228 CALL poprealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
2230 & , bd, arg1, arg2, neststruct%u_bc, &
2231 & neststruct%nestbctype)
2233 IF (branch .EQ. 0)
THEN 2234 CALL poprealarray(w, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
2236 & npz, bd, arg1, arg2, neststruct%&
2237 & w_bc, neststruct%nestbctype)
2241 IF (branch .EQ. 0)
THEN 2245 temp_ad3 = ws_ad(i, j)/delp(i, j, npz)
2246 delz_ad(i, j, npz) = delz_ad(i, j, npz) + omga(i, j, npz)*&
2248 omga_ad(i, j, npz) = omga_ad(i, j, npz) + delz(i, j, npz)*&
2250 delp_ad(i, j, npz) = delp_ad(i, j, npz) - delz(i, j, npz)*&
2251 & omga(i, j, npz)*temp_ad3/delp(i, j, npz)
2255 ELSE IF (branch .NE. 1)
THEN 2259 IF (branch .EQ. 0)
THEN 2260 CALL adv_pe_bwd(ua, ua_ad, va, va_ad, pem, pem_ad, omga, omga_ad&
2261 & , gridstruct, bd, npx, npy, npz, ng)
2266 pe_ad(i, k+1, j) = pe_ad(i, k+1, j) + rdt*omga_ad(i, j, k)
2267 pem_ad(i, k+1, j) = pem_ad(i, k+1, j) - rdt*omga_ad(i, j, &
2269 omga_ad(i, j, k) = 0.0
2278 om2d_ad(i, k) = om2d_ad(i, k) + omga_ad(i, j, k)
2279 omga_ad(i, j, k) = 0.0
2284 om2d_ad(i, k-1) = om2d_ad(i, k-1) + om2d_ad(i, k)
2285 omga_ad(i, j, k) = omga_ad(i, j, k) + om2d_ad(i, k)
2291 omga_ad(i, j, k) = omga_ad(i, j, k) + om2d_ad(i, k)
2298 IF (branch .EQ. 0)
THEN 2299 CALL poprealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
2300 CALL poprealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
2302 & domain, gridtype=dgrid_ne)
2305 IF (branch .EQ. 0)
THEN 2310 ebuffer_ad(j-js+1, k) = ebuffer_ad(j-js+1, k) + v_ad(ie+1, j&
2312 v_ad(ie+1, j, k) = 0.0
2315 nbuffer_ad(i-is+1, k) = nbuffer_ad(i-is+1, k) + u_ad(i, je+1&
2317 u_ad(i, je+1, k) = 0.0
2320 CALL poprealarray(u, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+2)*npz)
2321 CALL poprealarray(v, (bd%ied-bd%isd+2)*(bd%jed-bd%jsd+1)*npz)
2323 & ebuffer, ebuffery_ad=ebuffer_ad, nbufferx=&
2324 & nbuffer, nbufferx_ad=nbuffer_ad, gridtype=&
2328 IF (branch .EQ. 0)
THEN 2333 temp1 = delz(i, j, k)
2334 temp0 = delp(i, j, k)*pt(i, j, k)
2336 temp_ad2 = k1k*exp(k1k*log(rdg*temp))*pkz_ad(i, j, k)/(&
2338 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*temp_ad2
2339 pt_ad(i, j, k) = pt_ad(i, j, k) + delp(i, j, k)*temp_ad2
2340 delz_ad(i, j, k) = delz_ad(i, j, k) - temp*temp_ad2
2341 pkz_ad(i, j, k) = 0.0
2347 IF (branch .LT. 2)
THEN 2348 IF (branch .EQ. 0)
THEN 2350 & , pkc_ad, gz, gz_ad, du, du_ad, dv, dv_ad, &
2351 & dt, ng, gridstruct, bd, npx, npy, npz, ptop&
2352 & , beta_d, flagstruct%a2b_ord)
2355 & divg2, divg2_ad, delp, delp_ad, dt, ng, &
2356 & gridstruct, bd, npx, npy, npz, ptop, hydrostatic&
2357 & , flagstruct%a2b_ord, flagstruct%d_ext)
2359 ELSE IF (branch .EQ. 2)
THEN 2361 & du, du_ad, dv, dv_ad, delp, delp_ad, pk3, pk3_ad&
2362 & , beta_d, dt, ng, gridstruct, bd, npx, npy, npz&
2363 & , flagstruct%use_logp)
2364 ELSE IF (branch .EQ. 3)
THEN 2366 & divg2, divg2_ad, delp, delp_ad, dt, ng, gridstruct&
2367 & , bd, npx, npy, npz, ptop, hydrostatic, flagstruct&
2368 & %a2b_ord, flagstruct%d_ext)
2370 CALL nh_p_grad_bwd(u, u_ad, v, v_ad, pkc, pkc_ad, gz, gz_ad, &
2371 & delp, delp_ad, pk3, pk3_ad, dt, ng, gridstruct, bd&
2372 & , npx, npy, npz, flagstruct%use_logp)
2375 IF (branch .EQ. 0)
THEN 2380 pkc_ad(i, j, k) = pkc_ad(i, j, k) + pk_ad(i, j, k)
2381 pk_ad(i, j, k) = 0.0
2387 IF (branch .EQ. 0)
THEN 2388 CALL geopk_bwd(ptop, pe, pe_ad, peln, peln_ad, delp, delp_ad, &
2389 & pkc, pkc_ad, gz, gz_ad, phis, pt, pt_ad, q_con, pkz, &
2390 & pkz_ad, npz, akap, .false., gridstruct%nested, .true., &
2391 & npx, npy, flagstruct%a2b_ord, bd)
2397 zh_ad(i, j, k) = zh_ad(i, j, k) + grav*gz_ad(i, j, k)
2398 gz_ad(i, j, k) = 0.0
2403 IF (branch .EQ. 0)
THEN 2404 CALL nest_halo_nh_bwd(ptop, grav, akap, cp, delp, delp_ad, &
2405 & delz, delz_ad, pt, pt_ad, phis, pkc, pkc_ad, &
2406 & gz, gz_ad, pk3, pk3_ad, npx, npy, npz, &
2407 & gridstruct%nested, .true., .true., .true., bd)
2408 CALL poprealarray(delz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
2411 & npy, npz, bd, arg1, arg2, &
2412 & neststruct%delz_bc, neststruct%&
2416 IF (branch .EQ. 0)
THEN 2417 CALL pln_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, &
2418 & ptop, pk3, pk3_ad, delp, delp_ad)
2420 CALL pk3_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, &
2421 & ptop, akap, pk3, pk3_ad, delp, delp_ad)
2424 IF (branch .EQ. 0)
CALL pe_halo_bwd(is, ie, js, je, isd, ied, &
2425 & jsd, jed, npz, ptop, pe, pe_ad, &
2428 IF (branch .EQ. 0)
THEN 2429 CALL poprealarray(pkc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
2432 & domain, whalo=2, ehalo=2, shalo=2, &
2434 CALL poprealarray(zh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
2438 CALL poprealarray(pkc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
2441 & domain, complete=.true.)
2442 CALL poprealarray(zh, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(&
2445 & , complete=.true.)
2448 & npz, ng, isd, ied, jsd, jed, akap, cappa, cp, &
2449 & ptop, zs, q_con, w, w_ad, delz, delz_ad, pt, &
2450 & pt_ad, delp, delp_ad, zh, zh_ad, pe, pe_ad, pkc&
2451 & , pkc_ad, pk3, pk3_ad, pk, pk_ad, peln, peln_ad&
2452 & , ws, ws_ad, flagstruct%scale_z, flagstruct%&
2453 & p_fac, flagstruct%a_imp, flagstruct%use_logp, &
2454 & remap_step, arg10)
2455 CALL update_dz_d_bwd(nord_v, damp_vt, flagstruct%hord_tm, is, ie&
2456 & , js, je, npz, ng, npx, npy, gridstruct%area, &
2457 & gridstruct%rarea, dp_ref, zs, zh, zh_ad, crx, &
2458 & crx_ad, cry, cry_ad, xfx, xfx_ad, yfx, yfx_ad, &
2459 & delz, ws, ws_ad, rdt, gridstruct, bd, flagstructp&
2463 IF (branch .EQ. 0)
THEN 2465 & npz, bd, arg1, arg2, neststruct%&
2466 & pt_bc, neststruct%nestbctype)
2468 & , npz, bd, arg1, arg2, neststruct%&
2469 & delp_bc, neststruct%nestbctype)
2472 IF (branch .EQ. 0)
THEN 2476 temp_ad1 = d2_divg*divg2_ad(i, j)/wk(i, j)
2477 wk_ad(i, j) = wk_ad(i, j) - divg2(i, j)*temp_ad1/wk(i, j)
2478 divg2_ad(i, j) = temp_ad1
2482 ptc_ad(i, j, k) = ptc_ad(i, j, k) + wk_ad(i, j) + vt(i, j&
2483 & , k)*divg2_ad(i, j)
2484 vt_ad(i, j, k) = vt_ad(i, j, k) + ptc(i, j, k)*divg2_ad(i&
2490 wk_ad(i, j) = wk_ad(i, j) + vt(i, j, 1)*divg2_ad(i, j)
2491 vt_ad(i, j, 1) = vt_ad(i, j, 1) + wk(i, j)*divg2_ad(i, j)
2492 divg2_ad(i, j) = 0.0
2494 ptc_ad(i, j, 1) = ptc_ad(i, j, 1) + wk_ad(i, j)
2502 CALL poprealarray(pt, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
2505 CALL poprealarray(delp, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
2507 & , complete=.true.)
2509 IF (branch .EQ. 0)
CALL mix_dp_bwd(hydrostatic, w, w_ad, delp, &
2510 & delp_ad, pt, pt_ad, npz, ak, bk, &
2511 & .false., flagstruct%fv_debug, bd)
2514 IF (branch .NE. 0)
THEN 2517 heat_s_ad(i, j) = heat_s_ad(i, j) + heat_source_ad(i, j, k&
2523 IF (branch .EQ. 0)
THEN 2527 wk_ad(i, j) = wk_ad(i, j) + ptc_ad(i, j, k)
2528 ptc_ad(i, j, k) = 0.0
2533 IF (branch .EQ. 0)
THEN 2537 temp_ad = gridstruct%rarea(i, j)*rdt*omga_ad(i, j, k)
2538 temp_ad0 = omga(i, j, k)*temp_ad
2539 xfx_ad(i, j, k) = xfx_ad(i, j, k) + temp_ad0
2540 xfx_ad(i+1, j, k) = xfx_ad(i+1, j, k) - temp_ad0
2541 yfx_ad(i, j, k) = yfx_ad(i, j, k) + temp_ad0
2542 yfx_ad(i, j+1, k) = yfx_ad(i, j+1, k) - temp_ad0
2543 omga_ad(i, j, k) = (xfx(i, j, k)-xfx(i+1, j, k)+yfx(i, j, &
2544 & k)-yfx(i, j+1, k))*temp_ad
2548 CALL d_sw_bwd(vt(isd:ied, jsd:jed, k), vt_ad(isd:ied, jsd:jed, k&
2549 & ), delp(isd:ied, jsd:jed, k), delp_ad(isd:ied, jsd:jed, &
2550 & k), ptc(isd:ied, jsd:jed, k), ptc_ad(isd:ied, jsd:jed, k&
2551 & ), pt(isd:ied, jsd:jed, k), pt_ad(isd:ied, jsd:jed, k), &
2552 & u(isd:ied, jsd:jed+1, k), u_ad(isd:ied, jsd:jed+1, k), v&
2553 & (isd:ied+1, jsd:jed, k), v_ad(isd:ied+1, jsd:jed, k), w(&
2554 & isd:ied, jsd:jed, k), w_ad(isd:ied, jsd:jed, k), uc(isd:&
2555 & ied+1, jsd:jed, k), uc_ad(isd:ied+1, jsd:jed, k), vc(isd&
2556 & :ied, jsd:jed+1, k), vc_ad(isd:ied, jsd:jed+1, k), ua(&
2557 & isd:ied, jsd:jed, k), ua_ad(isd:ied, jsd:jed, k), va(isd&
2558 & :ied, jsd:jed, k), va_ad(isd:ied, jsd:jed, k), divgd(isd&
2559 & :ied+1, jsd:jed+1, k), divgd_ad(isd:ied+1, jsd:jed+1, k)&
2560 & , mfx(is:ie+1, js:je, k), mfx_ad(is:ie+1, js:je, k), mfy&
2561 & (is:ie, js:je+1, k), mfy_ad(is:ie, js:je+1, k), cx(is:ie&
2562 & +1, jsd:jed, k), cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied&
2563 & , js:je+1, k), cy_ad(isd:ied, js:je+1, k), crx(is:ie+1, &
2564 & jsd:jed, k), crx_ad(is:ie+1, jsd:jed, k), cry(isd:ied, &
2565 & js:je+1, k), cry_ad(isd:ied, js:je+1, k), xfx(is:ie+1, &
2566 & jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), yfx(isd:ied, &
2567 & js:je+1, k), yfx_ad(isd:ied, js:je+1, k), q_con(isd:ied&
2568 & , jsd:jed, 1), z_rat(isd:ied, jsd:jed), z_rat_ad(isd:ied&
2569 & , jsd:jed), kgb, heat_s, heat_s_ad, dpx, dpx_ad, zvir, &
2570 & sphum, nq, q, q_ad, k, npz, flagstruct%inline_q, dt, &
2571 & flagstruct%hord_tr, hord_m, hord_v, hord_t, hord_p, &
2572 & nord_k, nord_v(k), nord_w, nord_t, flagstruct%dddmp, &
2573 & d2_divg, flagstruct%d4_bg, damp_vt(k), damp_w, damp_t, &
2574 & d_con_k, hydrostatic, gridstruct, flagstruct, bd, &
2575 & flagstructp%hord_tr_pert, hord_m_pert, hord_v_pert, &
2576 & hord_t_pert, hord_p_pert, flagstructp%split_damp, &
2577 & nord_k_pert, nord_v_pert(k), nord_w_pert, nord_t_pert, &
2578 & flagstructp%dddmp_pert, d2_divg_pert, flagstructp%&
2579 & d4_bg_pert, damp_vt_pert(k), damp_w_pert, damp_t_pert)
2581 IF (branch .EQ. 0)
THEN 2584 zh_ad(i, j, k) = zh_ad(i, j, k) + z_rat_ad(i, j)/
radius 2585 zh_ad(i, j, k+1) = zh_ad(i, j, k+1) + z_rat_ad(i, j)/&
2587 z_rat_ad(i, j) = 0.0
2592 IF (branch .EQ. 0)
CALL a2b_ord2_bwd(delp(isd:ied, jsd:jed, k), &
2593 & delp_ad(isd:ied, jsd:jed, k), wk&
2594 & , wk_ad, gridstruct, npx, npy, is&
2595 & , ie, js, je, ng, .false.)
2597 IF (branch .EQ. 0)
THEN 2601 delp_ad(i, j, k) = delp_ad(i, j, k) + omga_ad(i, j, k)
2602 omga_ad(i, j, k) = 0.0
2611 IF (branch .EQ. 0)
THEN 2614 ELSE IF (branch .NE. 1)
THEN 2622 IF (branch .EQ. 0)
THEN 2628 IF (branch .EQ. 0)
THEN 2634 IF (branch .EQ. 0)
THEN 2645 IF (branch .LT. 3)
THEN 2646 IF (branch .NE. 0)
THEN 2647 IF (branch .NE. 1)
THEN 2653 IF (branch .LT. 5)
THEN 2654 IF (branch .EQ. 3)
THEN 2660 ELSE IF (branch .NE. 5)
THEN 2668 IF (branch .EQ. 0)
THEN 2674 IF (branch .EQ. 0)
THEN 2680 IF (branch .EQ. 0)
THEN 2688 IF (branch .EQ. 0)
THEN 2690 CALL poprealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
2693 & , q_ad(isd:ied, jsd:jed, :, iq), &
2694 & 0, 0, npx, npy, npz, bd, arg1, &
2695 & arg2, neststruct%q_bc(iq), &
2696 & neststruct%nestbctype)
2700 IF (branch .EQ. 0)
THEN 2702 & npy, npz, bd, split_timestep_bc, &
2703 & arg1, neststruct%divg_bc, &
2704 & neststruct%nestbctype)
2706 & npz, bd, arg1, arg2, neststruct%&
2707 & uc_bc, neststruct%nestbctype)
2709 & npz, bd, arg1, arg2, neststruct%&
2710 & vc_bc, neststruct%nestbctype)
2713 & domain, gridtype=cgrid_ne)
2714 CALL p_grad_c_bwd(dt2, npz, delpc, delpc_ad, pkc, pkc_ad, gz, &
2715 & gz_ad, uc, uc_ad, vc, vc_ad, bd, gridstruct%rdxc, &
2716 & gridstruct%rdyc, hydrostatic)
2718 IF (branch .EQ. 0)
THEN 2719 CALL geopk_bwd(ptop, pe, pe_ad, peln, peln_ad, delpc, delpc_ad, &
2720 & pkc, pkc_ad, gz, gz_ad, phis, ptc, ptc_ad, q_con, pkz, &
2721 & pkz_ad, npz, akap, .true., gridstruct%nested, .false., &
2722 & npx, npy, flagstruct%a2b_ord, bd)
2724 IF (branch .EQ. 1)
THEN 2725 CALL nest_halo_nh_bwd(ptop, grav, akap, cp, delpc, delpc_ad, &
2726 & delz, delz_ad, ptc, ptc_ad, phis, pkc, pkc_ad&
2727 & , gz, gz_ad, pk3, pk3_ad, npx, npy, npz, &
2728 & gridstruct%nested, .false., .false., .false., &
2730 CALL poprealarray(delz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
2733 & npy, npz, bd, arg1, arg2, &
2734 & neststruct%delz_bc, neststruct%&
2737 CALL riem_solver_c_bwd(ms, dt2, is, ie, js, je, npz, ng, akap, &
2738 & cappa, cp, ptop, phis, omga, omga_ad, ptc, &
2739 & ptc_ad, q_con, delpc, delpc_ad, gz, gz_ad, pkc&
2740 & , pkc_ad, ws3, ws3_ad, flagstruct%p_fac, &
2741 & flagstruct%a_imp, flagstruct%scale_z)
2742 CALL update_dz_c_bwd(is, ie, js, je, npz, ng, dt2, dp_ref, zs, &
2743 & gridstruct%area, ut, ut_ad, vt, vt_ad, gz, gz_ad&
2744 & , ws3, ws3_ad, npx, npy, gridstruct%sw_corner, &
2745 & gridstruct%se_corner, gridstruct%ne_corner, &
2746 & gridstruct%nw_corner, bd, gridstruct%grid_type)
2748 IF (branch .EQ. 0)
THEN 2752 gz_ad(i, j, k) = gz_ad(i, j, k) + zh_ad(i, j, k)
2753 zh_ad(i, j, k) = 0.0
2762 zh_ad(i, j, k) = zh_ad(i, j, k) + gz_ad(i, j, k)
2763 gz_ad(i, j, k) = 0.0
2770 IF (branch .EQ. 0)
THEN 2771 CALL poprealarray(ptc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
2773 & npz, bd, arg1, arg2, neststruct%&
2774 & pt_bc, neststruct%nestbctype)
2775 CALL poprealarray(delpc, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
2778 & npy, npz, bd, arg1, arg2, &
2779 & neststruct%delp_bc, neststruct%&
2784 & divgd, divgd_ad, &
2785 & domain, position=&
2788 CALL c_sw_bwd(delpc(isd:ied, jsd:jed, k), delpc_ad(isd:ied, jsd:&
2789 & jed, k), delp(isd:ied, jsd:jed, k), delp_ad(isd:ied, jsd&
2790 & :jed, k), ptc(isd:ied, jsd:jed, k), ptc_ad(isd:ied, jsd:&
2791 & jed, k), pt(isd:ied, jsd:jed, k), pt_ad(isd:ied, jsd:jed&
2792 & , k), u(isd:ied, jsd:jed+1, k), u_ad(isd:ied, jsd:jed+1&
2793 & , k), v(isd:ied+1, jsd:jed, k), v_ad(isd:ied+1, jsd:jed&
2794 & , k), w(isd:ied, jsd:jed, k), w_ad(isd:ied, jsd:jed, k)&
2795 & , uc(isd:ied+1, jsd:jed, k), uc_ad(isd:ied+1, jsd:jed, k&
2796 & ), vc(isd:ied, jsd:jed+1, k), vc_ad(isd:ied, jsd:jed+1, &
2797 & k), ua(isd:ied, jsd:jed, k), ua_ad(isd:ied, jsd:jed, k)&
2798 & , va(isd:ied, jsd:jed, k), va_ad(isd:ied, jsd:jed, k), &
2799 & omga(isd:ied, jsd:jed, k), omga_ad(isd:ied, jsd:jed, k)&
2800 & , ut(isd:ied, jsd:jed, k), ut_ad(isd:ied, jsd:jed, k), &
2801 & vt(isd:ied, jsd:jed, k), vt_ad(isd:ied, jsd:jed, k), &
2802 & divgd(isd:ied+1, jsd:jed+1, k), divgd_ad(isd:ied+1, jsd:&
2803 & jed+1, k), flagstruct%nord, dt2, hydrostatic, .true., bd&
2804 & , gridstruct, flagstruct)
2807 IF (branch .EQ. 0)
THEN 2811 pem_ad(i, k, j) = pem_ad(i, k, j) + pem_ad(i, k+1, j)
2812 delp_ad(i, j, k) = delp_ad(i, j, k) + pem_ad(i, k+1, j)
2813 pem_ad(i, k+1, j) = 0.0
2817 pem_ad(i, 1, j) = 0.0
2823 IF (branch .EQ. 0)
THEN 2829 IF (branch .EQ. 0)
THEN 2830 CALL poprealarray(gz, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*(npz+&
2834 IF (branch .EQ. 0)
THEN 2839 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + gz_ad(i, j, k)
2840 delz_ad(i, j, k) = delz_ad(i, j, k) - gz_ad(i, j, k)
2841 gz_ad(i, j, k) = 0.0
2846 gz_ad(i, j, npz+1) = 0.0
2854 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + gz_ad(i, j, k)
2855 delz_ad(i, j, k) = delz_ad(i, j, k) - gz_ad(i, j, k)
2856 gz_ad(i, j, k) = 0.0
2861 gz_ad(i, j, npz+1) = 0.0
2865 ELSE IF (branch .NE. 1)
THEN 2868 CALL poprealarray(w, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz)
2871 IF (branch .EQ. 0)
THEN 2872 CALL poprealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*nq&
2879 CALL poprealarray(cy, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
2880 CALL poprealarray(cx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
2881 CALL poprealarray(mfy, (bd%ie-bd%is+1)*(bd%je-bd%js+2)*npz)
2882 CALL poprealarray(mfx, (bd%ie-bd%is+2)*(bd%je-bd%js+1)*npz)
2887 SUBROUTINE dyn_core(npx, npy, npz, ng, sphum, nq, bdt, n_split, zvir, &
2888 & cp, akap, cappa, grav, hydrostatic, u, v, w, delz, pt, q, delp, pe, &
2889 & pk, phis, ws, omga, ptop, pfull, ua, va, uc, vc, mfx, mfy, cx, cy, &
2890 & pkz, peln, q_con, ak, bk, dpx, ks, gridstruct, flagstruct, &
2891 & flagstructp, neststruct, idiag, bd, domain, init_step, i_pack, &
2892 & end_step, gz, pkc, ptc, crx, xfx, cry, yfx, divgd, delpc, ut, vt, zh&
2893 & , pk3, du, dv, time_total)
2936 INTEGER,
INTENT(IN) :: npx
2937 INTEGER,
INTENT(IN) :: npy
2938 INTEGER,
INTENT(IN) :: npz
2939 INTEGER,
INTENT(IN) :: ng, nq, sphum
2940 INTEGER,
INTENT(IN) :: n_split
2941 REAL,
INTENT(IN) :: bdt
2942 REAL,
INTENT(IN) :: zvir, cp, akap, grav
2943 REAL,
INTENT(IN) :: ptop
2944 LOGICAL,
INTENT(IN) :: hydrostatic
2945 LOGICAL,
INTENT(IN) :: init_step, end_step
2946 REAL,
INTENT(IN) :: pfull(npz)
2947 REAL,
DIMENSION(npz+1),
INTENT(IN) :: ak, bk
2948 INTEGER,
INTENT(IN) :: ks
2949 TYPE(group_halo_update_type),
INTENT(INOUT) :: i_pack(*)
2952 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz),
INTENT(INOUT) &
2955 REAL,
DIMENSION(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz),
INTENT(INOUT) &
2958 REAL,
INTENT(INOUT) :: w(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2960 REAL,
INTENT(INOUT) :: delz(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2962 REAL,
INTENT(INOUT) :: cappa(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2964 REAL,
INTENT(INOUT) :: pt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2966 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2968 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
2970 REAL,
INTENT(IN),
OPTIONAL :: time_total
2977 REAL,
INTENT(INOUT) :: phis(bd%isd:bd%ied, bd%jsd:bd%jed)
2979 REAL,
INTENT(INOUT) :: pe(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
2981 REAL,
INTENT(INOUT) :: peln(bd%is:bd%ie, npz+1, bd%js:bd%je)
2983 REAL,
INTENT(INOUT) :: pk(bd%is:bd%ie, bd%js:bd%je, npz+1)
2984 REAL(kind=8),
INTENT(INOUT) :: dpx(bd%is:bd%ie, bd%js:bd%je)
2987 REAL,
PARAMETER :: near0=1.e-8
2988 REAL,
PARAMETER :: huge_r=1.e8
2991 REAL,
INTENT(OUT) :: ws(bd%is:bd%ie, bd%js:bd%je)
2993 REAL,
INTENT(INOUT) :: omga(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2995 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
2996 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
2997 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(INOUT) ::&
2999 REAL,
INTENT(INOUT) :: q_con(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3001 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
3002 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
3004 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
3005 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
3006 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je, npz),
INTENT(INOUT) :: pkz
3007 TYPE(
fv_grid_type),
INTENT(INOUT),
TARGET :: gridstruct
3012 TYPE(
domain2d),
INTENT(INOUT) :: domain
3014 REAL :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1), heat_source(bd&
3015 & %isd:bd%ied, bd%jsd:bd%jed, npz)
3017 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: ws3, z_rat
3020 REAL :: zs(bd%isd:bd%ied, bd%jsd:bd%jed)
3021 REAL :: p1d(bd%is:bd%ie)
3022 REAL :: om2d(bd%is:bd%ie, npz)
3023 REAL :: wbuffer(npy+2, npz)
3024 REAL :: ebuffer(npy+2, npz)
3025 REAL :: nbuffer(npx+2, npz)
3026 REAL :: sbuffer(npx+2, npz)
3028 REAL :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
3029 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
3030 REAL :: fz(bd%is:bd%ie+1, bd%js:bd%je+1)
3031 REAL :: heat_s(bd%is:bd%ie, bd%js:bd%je)
3032 REAL :: damp_vt(npz+1)
3033 INTEGER :: nord_v(npz+1)
3035 INTEGER :: hord_m, hord_v, hord_t, hord_p
3036 INTEGER :: nord_k, nord_w, nord_t
3039 INTEGER :: hord_m_pert, hord_v_pert, hord_t_pert, hord_p_pert
3040 INTEGER :: nord_k_pert, nord_w_pert, nord_t_pert, nord_v_pert(npz+1)
3041 REAL :: d2_divg_pert, damp_vt_pert(npz+1), damp_w_pert, damp_t_pert
3043 INTEGER :: i, j, k, it, iq, n_con, nf_ke
3044 INTEGER :: iep1, jep1
3045 REAL :: beta, beta_d, d_con_k, damp_w, damp_t, kgb, cv_air
3046 REAL :: dt, dt2, rdt
3048 REAL :: k1k, rdg, dtmp, delt
3049 LOGICAL :: last_step, remap_step
3051 REAL :: split_timestep_bc
3052 INTEGER :: is, ie, js, je
3053 INTEGER :: isd, ied, jsd, jed
3054 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
3055 REAL,
INTENT(INOUT) :: pkc(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
3056 REAL,
INTENT(INOUT) :: ptc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3057 REAL,
INTENT(INOUT) :: crx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
3058 REAL,
INTENT(INOUT) :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
3059 REAL,
INTENT(INOUT) :: cry(bd%isd:bd%ied, bd%js:bd%je+1, npz)
3060 REAL,
INTENT(INOUT) :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
3061 REAL,
INTENT(INOUT) :: divgd(bd%isd:bd%ied+1, bd%jsd:bd%jed+1, npz)
3062 REAL,
INTENT(INOUT) :: delpc(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3063 REAL,
INTENT(INOUT) :: ut(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3064 REAL,
INTENT(INOUT) :: vt(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3065 REAL,
INTENT(INOUT) :: zh(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
3066 REAL,
INTENT(INOUT) :: pk3(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
3067 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
3068 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
3098 dt = bdt/
REAL(n_split)
3101 IF (1 .LT. flagstruct%m_split/2)
THEN 3102 ms = flagstruct%m_split/2
3106 beta = flagstruct%beta
3112 IF (.NOT.hydrostatic)
THEN 3115 k1k = akap/(1.-akap)
3118 dp_ref(k) = ak(k+1) - ak(k) + (bk(k+1)-bk(k))*1.e5
3123 zs(i, j) = phis(i, j)*
rgrav 3140 IF (flagstruct%d_con .GT. 1.0e-5) heat_source = 0.0
3143 IF (flagstruct%convert_ke .OR. flagstruct%vtdm4 .GT. 1.e-4)
THEN 3145 ELSE IF (flagstruct%d2_bg_k1 .LT. 1.e-3)
THEN 3147 ELSE IF (flagstruct%d2_bg_k2 .LT. 1.e-3)
THEN 3155 IF (flagstruct%breed_vortex_inline .OR. it .EQ. n_split)
THEN 3158 remap_step = .false.
3160 IF (flagstruct%fv_debug)
THEN 3161 IF (is_master())
WRITE(*, *)
'n_split loop, it=', it
3162 IF (.NOT.flagstruct%hydrostatic)
CALL prt_mxm(
'delz', delz, is, &
3163 & ie, js, je, ng, npz, 1.&
3164 & , gridstruct%area_64, &
3166 CALL prt_mxm(
'PT', pt, is, ie, js, je, ng, npz, 1., gridstruct%&
3169 IF (gridstruct%nested) split_timestep_bc =
REAL(n_split*flagstruct&
3170 & %k_split + neststruct%nest_timestep)
3181 IF (.NOT.hydrostatic)
THEN 3186 IF (gridstruct%nested)
THEN 3190 gz(i, j, npz+1) = zs(i, j)
3194 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)
3202 gz(i, j, npz+1) = zs(i, j)
3206 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)
3218 CALL complete_group_halo_update(i_pack(1), domain)
3224 IF (it .EQ. n_split .AND. end_step)
THEN 3225 IF (flagstruct%use_old_omega)
THEN 3235 pem(i, k+1, j) = pem(i, k, j) + delp(i, j, k)
3245 CALL complete_group_halo_update(i_pack(8), domain)
3246 IF (.NOT.hydrostatic)
CALL complete_group_halo_update(i_pack(7), &
3254 CALL c_sw(delpc(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k)&
3255 & , ptc(isd:ied, jsd:jed, k), pt(isd:ied, jsd:jed, k), u(isd:&
3256 & ied, jsd:jed+1, k), v(isd:ied+1, jsd:jed, k), w(isd:ied, jsd&
3257 & :jed, k), uc(isd:ied+1, jsd:jed, k), vc(isd:ied, jsd:jed+1, &
3258 & k), ua(isd:ied, jsd:jed, k), va(isd:ied, jsd:jed, k), omga(&
3259 & isd:ied, jsd:jed, k), ut(isd:ied, jsd:jed, k), vt(isd:ied, &
3260 & jsd:jed, k), divgd(isd:ied+1, jsd:jed+1, k), flagstruct%nord&
3261 & , dt2, hydrostatic, .true., bd, gridstruct, flagstruct)
3264 IF (flagstruct%nord .GT. 0)
THEN 3270 IF (gridstruct%nested)
THEN 3271 arg1 = split_timestep_bc + 0.5
3272 arg2 =
REAL(n_split*flagstruct%k_split)
3273 CALL nested_grid_bc_apply_intt(delpc, 0, 0, npx, npy, npz, bd, &
3274 & arg1, arg2, neststruct%delp_bc, &
3275 & neststruct%nestbctype)
3276 arg1 = split_timestep_bc + 0.5
3277 arg2 =
REAL(n_split*flagstruct%k_split)
3278 CALL nested_grid_bc_apply_intt(ptc, 0, 0, npx, npy, npz, bd, &
3279 & arg1, arg2, neststruct%pt_bc, &
3280 & neststruct%nestbctype)
3283 IF (hydrostatic)
THEN 3284 CALL geopk(ptop, pe, peln, delpc, pkc, gz, phis, ptc, q_con, pkz&
3285 & , npz, akap, .true., gridstruct%nested, .false., npx, npy, &
3286 & flagstruct%a2b_ord, bd)
3290 CALL complete_group_halo_update(i_pack(5), domain)
3297 zh(i, j, k) = gz(i, j, k)
3306 gz(i, j, k) = zh(i, j, k)
3312 CALL update_dz_c(is, ie, js, je, npz, ng, dt2, dp_ref, zs, &
3313 & gridstruct%area, ut, vt, gz, ws3, npx, npy, &
3314 & gridstruct%sw_corner, gridstruct%se_corner, &
3315 & gridstruct%ne_corner, gridstruct%nw_corner, bd, &
3316 & gridstruct%grid_type)
3319 CALL riem_solver_c(ms, dt2, is, ie, js, je, npz, ng, akap, cappa&
3320 & , cp, ptop, phis, omga, ptc, q_con, delpc, gz, pkc&
3321 & , ws3, flagstruct%p_fac, flagstruct%a_imp, &
3322 & flagstruct%scale_z)
3324 IF (gridstruct%nested)
THEN 3325 arg1 = split_timestep_bc + 0.5
3326 arg2 =
REAL(n_split*flagstruct%k_split)
3327 CALL nested_grid_bc_apply_intt(delz, 0, 0, npx, npy, npz, bd, &
3328 & arg1, arg2, neststruct%delz_bc, &
3329 & neststruct%nestbctype)
3333 CALL nest_halo_nh(ptop, grav, akap, cp, delpc, delz, ptc, phis&
3334 & , pkc, gz, pk3, npx, npy, npz, gridstruct%nested, &
3335 & .false., .false., .false., bd)
3338 CALL p_grad_c(dt2, npz, delpc, pkc, gz, uc, vc, bd, gridstruct%&
3339 & rdxc, gridstruct%rdyc, hydrostatic)
3345 IF (flagstruct%inline_q .AND. nq .GT. 0)
CALL &
3346 & complete_group_halo_update(i_pack(10), domain)
3347 IF (flagstruct%nord .GT. 0)
CALL complete_group_halo_update(i_pack&
3349 CALL complete_group_halo_update(i_pack(9), domain)
3351 IF (gridstruct%nested)
THEN 3361 arg1 = split_timestep_bc + 0.5
3362 arg2 =
REAL(n_split*flagstruct%k_split)
3363 CALL nested_grid_bc_apply_intt(vc, 0, 1, npx, npy, npz, bd, arg1&
3364 & , arg2, neststruct%vc_bc, neststruct%&
3366 arg1 = split_timestep_bc + 0.5
3367 arg2 =
REAL(n_split*flagstruct%k_split)
3368 CALL nested_grid_bc_apply_intt(uc, 1, 0, npx, npy, npz, bd, arg1&
3369 & , arg2, neststruct%uc_bc, neststruct%&
3372 arg1 =
REAL(n_split*flagstruct%k_split)
3373 CALL nested_grid_bc_apply_intt(divgd, 1, 1, npx, npy, npz, bd, &
3374 & split_timestep_bc, arg1, neststruct%&
3375 & divg_bc, neststruct%nestbctype)
3381 IF (gridstruct%nested .AND. flagstruct%inline_q)
THEN 3383 arg1 = split_timestep_bc + 1
3384 arg2 =
REAL(n_split*flagstruct%k_split)
3385 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
3386 & 0, npx, npy, npz, bd, arg1, arg2, &
3387 & neststruct%q_bc(iq), neststruct%&
3400 hord_m = flagstruct%hord_mt
3401 hord_t = flagstruct%hord_tm
3402 hord_v = flagstruct%hord_vt
3403 hord_p = flagstruct%hord_dp
3404 nord_k = flagstruct%nord
3406 kgb = flagstruct%ke_bg
3407 IF (2 .GT. flagstruct%nord)
THEN 3408 nord_v(k) = flagstruct%nord
3412 IF (0.20 .GT. flagstruct%d2_bg)
THEN 3413 d2_divg = flagstruct%d2_bg
3417 IF (flagstruct%do_vort_damp)
THEN 3419 damp_vt(k) = flagstruct%vtdm4
3427 d_con_k = flagstruct%d_con
3428 IF (npz .EQ. 1 .OR. flagstruct%n_sponge .LT. 0)
THEN 3429 d2_divg = flagstruct%d2_bg
3430 ELSE IF (k .EQ. 1)
THEN 3435 IF (0.01 .LT. flagstruct%d2_bg)
THEN 3436 IF (flagstruct%d2_bg .LT. flagstruct%d2_bg_k1)
THEN 3437 d2_divg = flagstruct%d2_bg_k1
3439 d2_divg = flagstruct%d2_bg
3441 ELSE IF (0.01 .LT. flagstruct%d2_bg_k1)
THEN 3442 d2_divg = flagstruct%d2_bg_k1
3449 IF (flagstruct%do_vort_damp)
THEN 3452 damp_vt(k) = 0.5*d2_divg
3456 IF (2 .LT. flagstruct%n_sponge - 1)
THEN 3457 max1 = flagstruct%n_sponge - 1
3461 IF (k .EQ. max1 .AND. flagstruct%d2_bg_k2 .GT. 0.01)
THEN 3463 IF (flagstruct%d2_bg .LT. flagstruct%d2_bg_k2)
THEN 3464 d2_divg = flagstruct%d2_bg_k2
3466 d2_divg = flagstruct%d2_bg
3470 IF (flagstruct%do_vort_damp)
THEN 3472 damp_vt(k) = 0.5*d2_divg
3476 IF (3 .LT. flagstruct%n_sponge)
THEN 3477 max2 = flagstruct%n_sponge
3481 IF (k .EQ. max2 .AND. flagstruct%d2_bg_k2 .GT. 0.05)
THEN 3483 IF (flagstruct%d2_bg .LT. 0.2*flagstruct%d2_bg_k2)
THEN 3484 d2_divg = 0.2*flagstruct%d2_bg_k2
3486 d2_divg = flagstruct%d2_bg
3494 hord_m_pert = flagstructp%hord_mt_pert
3495 hord_t_pert = flagstructp%hord_tm_pert
3496 hord_v_pert = flagstructp%hord_vt_pert
3497 hord_p_pert = flagstructp%hord_dp_pert
3498 nord_k_pert = flagstructp%nord_pert
3499 IF (2 .GT. flagstructp%nord_pert)
THEN 3500 nord_v_pert(k) = flagstructp%nord_pert
3504 IF (0.20 .GT. flagstructp%d2_bg_pert)
THEN 3505 d2_divg_pert = flagstructp%d2_bg_pert
3509 IF (flagstructp%do_vort_damp_pert)
THEN 3511 damp_vt_pert(k) = flagstructp%vtdm4_pert
3513 damp_vt_pert(k) = 0.
3515 nord_w_pert = nord_v_pert(k)
3516 nord_t_pert = nord_v_pert(k)
3517 damp_w_pert = damp_vt_pert(k)
3518 damp_t_pert = damp_vt_pert(k)
3520 IF (k .LE. flagstructp%n_sponge_pert)
THEN 3521 IF (k .LE. flagstructp%n_sponge_pert - 1)
THEN 3522 IF (flagstructp%hord_ks_traj)
THEN 3523 hord_m = flagstructp%hord_mt_ks_traj
3524 hord_t = flagstructp%hord_tm_ks_traj
3525 hord_v = flagstructp%hord_vt_ks_traj
3526 hord_p = flagstructp%hord_dp_ks_traj
3528 IF (flagstructp%hord_ks_pert)
THEN 3529 hord_m_pert = flagstructp%hord_mt_ks_pert
3530 hord_t_pert = flagstructp%hord_tm_ks_pert
3531 hord_v_pert = flagstructp%hord_vt_ks_pert
3532 hord_p_pert = flagstructp%hord_dp_ks_pert
3537 IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 3538 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_k1_pert&
3540 d2_divg_pert = flagstructp%d2_bg_k1_pert
3542 d2_divg_pert = flagstructp%d2_bg_pert
3544 ELSE IF (0.01 .LT. flagstructp%d2_bg_k1_pert)
THEN 3545 d2_divg_pert = flagstructp%d2_bg_k1_pert
3549 ELSE IF (k .EQ. 2)
THEN 3550 IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 3551 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_k2_pert&
3553 d2_divg_pert = flagstructp%d2_bg_k2_pert
3555 d2_divg_pert = flagstructp%d2_bg_pert
3557 ELSE IF (0.01 .LT. flagstructp%d2_bg_k2_pert)
THEN 3558 d2_divg_pert = flagstructp%d2_bg_k2_pert
3562 ELSE IF (0.01 .LT. flagstructp%d2_bg_pert)
THEN 3563 IF (flagstructp%d2_bg_pert .LT. flagstructp%d2_bg_ks_pert) &
3565 d2_divg_pert = flagstructp%d2_bg_ks_pert
3567 d2_divg_pert = flagstructp%d2_bg_pert
3569 ELSE IF (0.01 .LT. flagstructp%d2_bg_ks_pert)
THEN 3570 d2_divg_pert = flagstructp%d2_bg_ks_pert
3575 damp_w_pert = d2_divg_pert
3576 IF (flagstructp%do_vort_damp_pert)
THEN 3578 damp_vt_pert(k) = 0.5*d2_divg_pert
3582 damp_vt(npz+1) = damp_vt(npz)
3583 damp_vt_pert(npz+1) = damp_vt_pert(npz)
3584 nord_v(npz+1) = nord_v(npz)
3585 nord_v_pert(npz+1) = nord_v_pert(npz)
3586 IF (hydrostatic .AND. (.NOT.flagstruct%use_old_omega) .AND. &
3591 omga(i, j, k) = delp(i, j, k)
3596 IF (flagstruct%d_ext .GT. 0.)
CALL a2b_ord2(delp(isd:ied, jsd:&
3597 & jed, k), wk, gridstruct, &
3598 & npx, npy, is, ie, js, je, &
3600 IF (.NOT.hydrostatic .AND. flagstruct%do_f3d)
THEN 3604 z_rat(i, j) = 1. + (zh(i, j, k)+zh(i, j, k+1))/
radius 3608 CALL d_sw(vt(isd:ied, jsd:jed, k), delp(isd:ied, jsd:jed, k), &
3609 & ptc(isd:ied, jsd:jed, k), pt(isd:ied, jsd:jed, k), u(isd:ied&
3610 & , jsd:jed+1, k), v(isd:ied+1, jsd:jed, k), w(isd:ied, jsd:&
3611 & jed, k), uc(isd:ied+1, jsd:jed, k), vc(isd:ied, jsd:jed+1, k&
3612 & ), ua(isd:ied, jsd:jed, k), va(isd:ied, jsd:jed, k), divgd(&
3613 & isd:ied+1, jsd:jed+1, k), mfx(is:ie+1, js:je, k), mfy(is:ie&
3614 & , js:je+1, k), cx(is:ie+1, jsd:jed, k), cy(isd:ied, js:je+1&
3615 & , k), crx(is:ie+1, jsd:jed, k), cry(isd:ied, js:je+1, k), &
3616 & xfx(is:ie+1, jsd:jed, k), yfx(isd:ied, js:je+1, k), q_con(&
3617 & isd:ied, jsd:jed, 1), z_rat(isd:ied, jsd:jed), kgb, heat_s, &
3618 & dpx, zvir, sphum, nq, q, k, npz, flagstruct%inline_q, dt, &
3619 & flagstruct%hord_tr, hord_m, hord_v, hord_t, hord_p, nord_k, &
3620 & nord_v(k), nord_w, nord_t, flagstruct%dddmp, d2_divg, &
3621 & flagstruct%d4_bg, damp_vt(k), damp_w, damp_t, d_con_k, &
3622 & hydrostatic, gridstruct, flagstruct, bd, flagstructp%&
3623 & hord_tr_pert, hord_m_pert, hord_v_pert, hord_t_pert, &
3624 & hord_p_pert, flagstructp%split_damp, nord_k_pert, &
3625 & nord_v_pert(k), nord_w_pert, nord_t_pert, flagstructp%&
3626 & dddmp_pert, d2_divg_pert, flagstructp%d4_bg_pert, &
3627 & damp_vt_pert(k), damp_w_pert, damp_t_pert)
3628 IF (hydrostatic .AND. (.NOT.flagstruct%use_old_omega) .AND. &
3633 omga(i, j, k) = omga(i, j, k)*(xfx(i, j, k)-xfx(i+1, j, k)&
3634 & +yfx(i, j, k)-yfx(i, j+1, k))*gridstruct%rarea(i, j)*rdt
3638 IF (flagstruct%d_ext .GT. 0.)
THEN 3642 ptc(i, j, k) = wk(i, j)
3646 IF (flagstruct%d_con .GT. 1.0e-5)
THEN 3650 heat_source(i, j, k) = heat_source(i, j, k) + heat_s(i, j)
3657 IF (flagstruct%fill_dp)
CALL mix_dp(hydrostatic, w, delp, pt, npz&
3658 & , ak, bk, .false., flagstruct%&
3666 IF (flagstruct%d_ext .GT. 0.)
THEN 3667 d2_divg = flagstruct%d_ext*gridstruct%da_min_c
3671 wk(i, j) = ptc(i, j, 1)
3672 divg2(i, j) = wk(i, j)*vt(i, j, 1)
3676 wk(i, j) = wk(i, j) + ptc(i, j, k)
3677 divg2(i, j) = divg2(i, j) + ptc(i, j, k)*vt(i, j, k)
3681 divg2(i, j) = d2_divg*divg2(i, j)/wk(i, j)
3688 CALL complete_group_halo_update(i_pack(1), domain)
3690 IF (flagstruct%fv_debug)
THEN 3691 IF (.NOT.flagstruct%hydrostatic)
CALL prt_mxm(
'delz', delz, is, &
3692 & ie, js, je, ng, npz, 1.&
3693 & , gridstruct%area_64, &
3697 IF (gridstruct%nested)
THEN 3698 arg1 = split_timestep_bc + 1
3699 arg2 =
REAL(n_split*flagstruct%k_split)
3700 CALL nested_grid_bc_apply_intt(delp, 0, 0, npx, npy, npz, bd, &
3701 & arg1, arg2, neststruct%delp_bc, &
3702 & neststruct%nestbctype)
3703 arg1 = split_timestep_bc + 1
3704 arg2 =
REAL(n_split*flagstruct%k_split)
3705 CALL nested_grid_bc_apply_intt(pt, 0, 0, npx, npy, npz, bd, arg1&
3706 & , arg2, neststruct%pt_bc, neststruct%&
3710 IF (hydrostatic)
THEN 3711 CALL geopk(ptop, pe, peln, delp, pkc, gz, phis, pt, q_con, pkz, &
3712 & npz, akap, .false., gridstruct%nested, .true., npx, npy, &
3713 & flagstruct%a2b_ord, bd)
3716 CALL update_dz_d(nord_v, damp_vt, flagstruct%hord_tm, is, ie, js&
3717 & , je, npz, ng, npx, npy, gridstruct%area, gridstruct%&
3718 & rarea, dp_ref, zs, zh, crx, cry, xfx, yfx, delz, ws, &
3719 & rdt, gridstruct, bd, flagstructp%hord_tm_pert)
3721 IF (flagstruct%fv_debug)
THEN 3722 IF (.NOT.flagstruct%hydrostatic)
CALL prt_mxm(
'delz updated', &
3723 & delz, is, ie, js, je, &
3725 & gridstruct%area_64, &
3728 IF (idiag%id_ws .GT. 0 .AND. last_step) used =
send_data(idiag%&
3732 arg10 = beta .LT. -0.1
3733 CALL riem_solver3(flagstruct%m_split, dt, is, ie, js, je, npz, &
3734 & ng, isd, ied, jsd, jed, akap, cappa, cp, ptop, zs, &
3735 & q_con, w, delz, pt, delp, zh, pe, pkc, pk3, pk, peln&
3736 & , ws, flagstruct%scale_z, flagstruct%p_fac, &
3737 & flagstruct%a_imp, flagstruct%use_logp, remap_step, &
3741 IF (gridstruct%square_domain)
THEN 3744 & ehalo=2, shalo=2, nhalo=2)
3752 IF (remap_step)
CALL pe_halo(is, ie, js, je, isd, ied, jsd, jed&
3753 & , npz, ptop, pe, delp)
3754 IF (flagstruct%use_logp)
THEN 3755 CALL pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, &
3758 CALL pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, &
3761 IF (gridstruct%nested)
THEN 3762 arg1 = split_timestep_bc + 1.
3763 arg2 =
REAL(n_split*flagstruct%k_split)
3764 CALL nested_grid_bc_apply_intt(delz, 0, 0, npx, npy, npz, bd, &
3765 & arg1, arg2, neststruct%delz_bc, &
3766 & neststruct%nestbctype)
3768 CALL nest_halo_nh(ptop, grav, akap, cp, delp, delz, pt, phis, &
3769 & pkc, gz, pk3, npx, npy, npz, gridstruct%nested, &
3770 & .true., .true., .true., bd)
3773 CALL complete_group_halo_update(i_pack(4), domain)
3779 gz(i, j, k) = zh(i, j, k)*grav
3783 IF (gridstruct%square_domain)
THEN 3785 CALL complete_group_halo_update(i_pack(5), domain)
3789 IF (remap_step .AND. hydrostatic)
THEN 3794 pk(i, j, k) = pkc(i, j, k)
3803 IF (hydrostatic)
THEN 3804 IF (beta .GT. 0.)
THEN 3806 & gridstruct, bd, npx, npy, npz, ptop, beta_d, &
3807 & flagstruct%a2b_ord)
3809 CALL one_grad_p(u, v, pkc, gz, divg2, delp, dt, ng, gridstruct&
3810 & , bd, npx, npy, npz, ptop, hydrostatic, flagstruct%&
3811 & a2b_ord, flagstruct%d_ext)
3813 ELSE IF (beta .GT. 0.)
THEN 3814 CALL split_p_grad(u, v, pkc, gz, du, dv, delp, pk3, beta_d, dt, &
3815 & ng, gridstruct, bd, npx, npy, npz, flagstruct%&
3817 ELSE IF (beta .LT. -0.1)
THEN 3818 CALL one_grad_p(u, v, pkc, gz, divg2, delp, dt, ng, gridstruct, &
3819 & bd, npx, npy, npz, ptop, hydrostatic, flagstruct%&
3820 & a2b_ord, flagstruct%d_ext)
3822 CALL nh_p_grad(u, v, pkc, gz, delp, pk3, dt, ng, gridstruct, bd&
3823 & , npx, npy, npz, flagstruct%use_logp)
3828 IF (flagstruct%breed_vortex_inline)
THEN 3829 IF (.NOT.hydrostatic)
THEN 3835 pkz(i, j, k) = exp(k1k*log(rdg*delp(i, j, k)/delz(i, j, &
3842 & pkz, delp, u, v, pt, q, flagstruct%nwat, zvir, &
3843 & gridstruct, ks, domain, bd, hydrostatic)
3847 IF (it .EQ. n_split .AND. gridstruct%grid_type .LT. 4 .AND. (.NOT.&
3848 & gridstruct%nested))
THEN 3851 & nbuffer, gridtype=dgrid_ne)
3855 u(i, je+1, k) = nbuffer(i-is+1, k)
3858 v(ie+1, j, k) = ebuffer(j-js+1, k)
3863 & , domain, gridtype=&
3866 IF (gridstruct%nested) neststruct%nest_timestep = neststruct%&
3868 IF (hydrostatic .AND. last_step)
THEN 3869 IF (flagstruct%use_old_omega)
THEN 3874 omga(i, j, k) = (pe(i, k+1, j)-pem(i, k+1, j))*rdt
3881 CALL adv_pe(ua, va, pem, omga, gridstruct, bd, npx, npy, npz, &
3888 om2d(i, k) = omga(i, j, k)
3893 om2d(i, k) = om2d(i, k-1) + omga(i, j, k)
3898 omga(i, j, k) = om2d(i, k)
3903 IF (idiag%id_ws .GT. 0 .AND. hydrostatic)
THEN 3907 ws(i, j) = delz(i, j, npz)/delp(i, j, npz)*omga(i, j, npz)
3913 IF (gridstruct%nested)
THEN 3914 IF (.NOT.hydrostatic)
THEN 3915 arg1 = split_timestep_bc + 1
3916 arg2 =
REAL(n_split*flagstruct%k_split)
3917 CALL nested_grid_bc_apply_intt(w, 0, 0, npx, npy, npz, bd, &
3918 & arg1, arg2, neststruct%w_bc, &
3919 & neststruct%nestbctype)
3921 arg1 = split_timestep_bc + 1
3922 arg2 =
REAL(n_split*flagstruct%k_split)
3923 CALL nested_grid_bc_apply_intt(u, 0, 1, npx, npy, npz, bd, arg1&
3924 & , arg2, neststruct%u_bc, neststruct%&
3926 arg1 = split_timestep_bc + 1
3927 arg2 =
REAL(n_split*flagstruct%k_split)
3928 CALL nested_grid_bc_apply_intt(v, 1, 0, npx, npy, npz, bd, arg1&
3929 & , arg2, neststruct%v_bc, neststruct%&
3936 IF (nq .GT. 0 .AND. (.NOT.flagstruct%inline_q))
THEN 3943 IF (flagstruct%fv_debug)
THEN 3944 IF (is_master())
WRITE(*, *)
'End of n_split loop' 3946 IF (n_con .NE. 0 .AND. flagstruct%d_con .GT. 1.e-5)
THEN 3947 IF (3 .GT. flagstruct%nord + 1)
THEN 3948 nf_ke = flagstruct%nord + 1
3953 CALL del2_cubed(heat_source, arg11, gridstruct, domain, npx, npy, &
3956 IF (hydrostatic)
THEN 3967 pt(i, j, k) = pt(i, j, k) + heat_source(i, j, k)/(
cp_air&
3968 & *delp(i, j, k)*pkz(i, j, k))
3972 dtmp = heat_source(i, j, k)/(
cp_air*delp(i, j, k))
3973 IF (bdt .GE. 0.)
THEN 3978 x1 = abs0*flagstruct%delt_max
3979 IF (dtmp .GE. 0.)
THEN 3984 IF (x1 .GT. y1)
THEN 3989 pt(i, j, k) = pt(i, j, k) + sign(min1, dtmp)/pkz(i, j, k&
4000 IF (bdt*flagstruct%delt_max .GE. 0.)
THEN 4001 delt = bdt*flagstruct%delt_max
4003 delt = -(bdt*flagstruct%delt_max)
4010 pkz(i, j, k) = exp(k1k*log(rdg*delp(i, j, k)/delz(i, j, k)&
4012 dtmp = heat_source(i, j, k)/(cv_air*delp(i, j, k))
4013 IF (dtmp .GE. 0.)
THEN 4018 IF (delt .GT. y2)
THEN 4023 pt(i, j, k) = pt(i, j, k) + sign(min2, dtmp)/pkz(i, j, k)
4050 SUBROUTINE pk3_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop&
4051 & , akap, pk3, delp)
4053 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4054 REAL,
INTENT(IN) :: ptop, akap
4055 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4056 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4058 REAL :: pei(isd:ied)
4059 REAL :: pej(jsd:jed)
4076 pei(is-2) = pei(is-2) + delp(is-2, j, k)
4078 pei(is-1) = pei(is-1) + delp(is-1, j, k)
4080 pk3(is-2, j, k+1) = exp(akap*log(pei(is-2)))
4082 pk3(is-1, j, k+1) = exp(akap*log(pei(is-1)))
4090 pei(ie+1) = pei(ie+1) + delp(ie+1, j, k)
4092 pei(ie+2) = pei(ie+2) + delp(ie+2, j, k)
4094 pk3(ie+1, j, k+1) = exp(akap*log(pei(ie+1)))
4096 pk3(ie+2, j, k+1) = exp(akap*log(pei(ie+2)))
4108 pej(js-2) = pej(js-2) + delp(i, js-2, k)
4110 pej(js-1) = pej(js-1) + delp(i, js-1, k)
4112 pk3(i, js-2, k+1) = exp(akap*log(pej(js-2)))
4114 pk3(i, js-1, k+1) = exp(akap*log(pej(js-1)))
4122 pej(je+1) = pej(je+1) + delp(i, je+1, k)
4124 pej(je+2) = pej(je+2) + delp(i, je+2, k)
4126 pk3(i, je+1, k+1) = exp(akap*log(pej(je+1)))
4128 pk3(i, je+2, k+1) = exp(akap*log(pej(je+2)))
4154 SUBROUTINE pk3_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop&
4155 & , akap, pk3, pk3_ad, delp, delp_ad)
4157 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4158 REAL,
INTENT(IN) :: ptop, akap
4159 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4160 REAL,
DIMENSION(isd:ied, jsd:jed, npz) :: delp_ad
4161 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4162 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3_ad
4163 REAL :: pei(isd:ied)
4164 REAL :: pei_ad(isd:ied)
4165 REAL :: pej(jsd:jed)
4166 REAL :: pej_ad(jsd:jed)
4180 pej_ad(je+2) = pej_ad(je+2) + akap*exp(akap*log(pej(je+2)))*&
4181 & pk3_ad(i, je+2, k+1)/pej(je+2)
4182 pk3_ad(i, je+2, k+1) = 0.0
4184 pej_ad(je+1) = pej_ad(je+1) + akap*exp(akap*log(pej(je+1)))*&
4185 & pk3_ad(i, je+1, k+1)/pej(je+1)
4186 pk3_ad(i, je+1, k+1) = 0.0
4188 delp_ad(i, je+2, k) = delp_ad(i, je+2, k) + pej_ad(je+2)
4190 delp_ad(i, je+1, k) = delp_ad(i, je+1, k) + pej_ad(je+1)
4198 pej_ad(js-1) = pej_ad(js-1) + akap*exp(akap*log(pej(js-1)))*&
4199 & pk3_ad(i, js-1, k+1)/pej(js-1)
4200 pk3_ad(i, js-1, k+1) = 0.0
4202 pej_ad(js-2) = pej_ad(js-2) + akap*exp(akap*log(pej(js-2)))*&
4203 & pk3_ad(i, js-2, k+1)/pej(js-2)
4204 pk3_ad(i, js-2, k+1) = 0.0
4206 delp_ad(i, js-1, k) = delp_ad(i, js-1, k) + pej_ad(js-1)
4208 delp_ad(i, js-2, k) = delp_ad(i, js-2, k) + pej_ad(js-2)
4219 pei_ad(ie+2) = pei_ad(ie+2) + akap*exp(akap*log(pei(ie+2)))*&
4220 & pk3_ad(ie+2, j, k+1)/pei(ie+2)
4221 pk3_ad(ie+2, j, k+1) = 0.0
4223 pei_ad(ie+1) = pei_ad(ie+1) + akap*exp(akap*log(pei(ie+1)))*&
4224 & pk3_ad(ie+1, j, k+1)/pei(ie+1)
4225 pk3_ad(ie+1, j, k+1) = 0.0
4227 delp_ad(ie+2, j, k) = delp_ad(ie+2, j, k) + pei_ad(ie+2)
4229 delp_ad(ie+1, j, k) = delp_ad(ie+1, j, k) + pei_ad(ie+1)
4237 pei_ad(is-1) = pei_ad(is-1) + akap*exp(akap*log(pei(is-1)))*&
4238 & pk3_ad(is-1, j, k+1)/pei(is-1)
4239 pk3_ad(is-1, j, k+1) = 0.0
4241 pei_ad(is-2) = pei_ad(is-2) + akap*exp(akap*log(pei(is-2)))*&
4242 & pk3_ad(is-2, j, k+1)/pei(is-2)
4243 pk3_ad(is-2, j, k+1) = 0.0
4245 delp_ad(is-1, j, k) = delp_ad(is-1, j, k) + pei_ad(is-1)
4247 delp_ad(is-2, j, k) = delp_ad(is-2, j, k) + pei_ad(is-2)
4255 SUBROUTINE pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, &
4258 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4259 REAL,
INTENT(IN) :: ptop, akap
4260 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4261 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4263 REAL :: pei(isd:ied)
4264 REAL :: pej(jsd:jed)
4274 pei(is-2) = pei(is-2) + delp(is-2, j, k)
4275 pei(is-1) = pei(is-1) + delp(is-1, j, k)
4276 pk3(is-2, j, k+1) = exp(akap*log(pei(is-2)))
4277 pk3(is-1, j, k+1) = exp(akap*log(pei(is-1)))
4282 pei(ie+1) = pei(ie+1) + delp(ie+1, j, k)
4283 pei(ie+2) = pei(ie+2) + delp(ie+2, j, k)
4284 pk3(ie+1, j, k+1) = exp(akap*log(pei(ie+1)))
4285 pk3(ie+2, j, k+1) = exp(akap*log(pei(ie+2)))
4294 pej(js-2) = pej(js-2) + delp(i, js-2, k)
4295 pej(js-1) = pej(js-1) + delp(i, js-1, k)
4296 pk3(i, js-2, k+1) = exp(akap*log(pej(js-2)))
4297 pk3(i, js-1, k+1) = exp(akap*log(pej(js-1)))
4302 pej(je+1) = pej(je+1) + delp(i, je+1, k)
4303 pej(je+2) = pej(je+2) + delp(i, je+2, k)
4304 pk3(i, je+1, k+1) = exp(akap*log(pej(je+1)))
4305 pk3(i, je+2, k+1) = exp(akap*log(pej(je+2)))
4329 SUBROUTINE pln_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop&
4332 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4333 REAL,
INTENT(IN) :: ptop
4334 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4335 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4351 pet = pet + delp(i, j, k)
4353 pk3(i, j, k+1) = log(pet)
4361 pet = pet + delp(i, j, k)
4363 pk3(i, j, k+1) = log(pet)
4375 pet = pet + delp(i, j, k)
4377 pk3(i, j, k+1) = log(pet)
4385 pet = pet + delp(i, j, k)
4387 pk3(i, j, k+1) = log(pet)
4413 SUBROUTINE pln_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop&
4414 & , pk3, pk3_ad, delp, delp_ad)
4416 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4417 REAL,
INTENT(IN) :: ptop
4418 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4419 REAL,
DIMENSION(isd:ied, jsd:jed, npz) :: delp_ad
4420 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4421 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3_ad
4435 pet_ad = pet_ad + pk3_ad(i, j, k+1)/pet
4436 pk3_ad(i, j, k+1) = 0.0
4438 delp_ad(i, j, k) = delp_ad(i, j, k) + pet_ad
4446 pet_ad = pet_ad + pk3_ad(i, j, k+1)/pet
4447 pk3_ad(i, j, k+1) = 0.0
4449 delp_ad(i, j, k) = delp_ad(i, j, k) + pet_ad
4459 pet_ad = pet_ad + pk3_ad(i, j, k+1)/pet
4460 pk3_ad(i, j, k+1) = 0.0
4462 delp_ad(i, j, k) = delp_ad(i, j, k) + pet_ad
4470 pet_ad = pet_ad + pk3_ad(i, j, k+1)/pet
4471 pk3_ad(i, j, k+1) = 0.0
4473 delp_ad(i, j, k) = delp_ad(i, j, k) + pet_ad
4479 SUBROUTINE pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3&
4482 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4483 REAL,
INTENT(IN) :: ptop
4484 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4485 REAL,
DIMENSION(isd:ied, jsd:jed, npz+1),
INTENT(INOUT) :: pk3
4496 pet = pet + delp(i, j, k)
4497 pk3(i, j, k+1) = log(pet)
4503 pet = pet + delp(i, j, k)
4504 pk3(i, j, k+1) = log(pet)
4514 pet = pet + delp(i, j, k)
4515 pk3(i, j, k+1) = log(pet)
4521 pet = pet + delp(i, j, k)
4522 pk3(i, j, k+1) = log(pet)
4547 SUBROUTINE pe_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, &
4550 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4551 REAL,
INTENT(IN) :: ptop
4552 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4553 REAL,
DIMENSION(is-1:ie+1, npz+1, js-1:je+1),
INTENT(INOUT) :: pe
4559 pe(is-1, 1, j) = ptop
4561 pe(ie+1, 1, j) = ptop
4564 pe(is-1, k+1, j) = pe(is-1, k, j) + delp(is-1, j, k)
4566 pe(ie+1, k+1, j) = pe(ie+1, k, j) + delp(ie+1, j, k)
4572 pe(i, 1, js-1) = ptop
4574 pe(i, 1, je+1) = ptop
4577 pe(i, k+1, js-1) = pe(i, k, js-1) + delp(i, js-1, k)
4579 pe(i, k+1, je+1) = pe(i, k, je+1) + delp(i, je+1, k)
4603 SUBROUTINE pe_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, &
4604 & pe, pe_ad, delp, delp_ad)
4606 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4607 REAL,
INTENT(IN) :: ptop
4608 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4609 REAL,
DIMENSION(isd:ied, jsd:jed, npz) :: delp_ad
4610 REAL,
DIMENSION(is-1:ie+1, npz+1, js-1:je+1),
INTENT(INOUT) :: pe
4611 REAL,
DIMENSION(is-1:ie+1, npz+1, js-1:je+1),
INTENT(INOUT) :: pe_ad
4616 pe_ad(i, k, je+1) = pe_ad(i, k, je+1) + pe_ad(i, k+1, je+1)
4617 delp_ad(i, je+1, k) = delp_ad(i, je+1, k) + pe_ad(i, k+1, je+1)
4618 pe_ad(i, k+1, je+1) = 0.0
4620 pe_ad(i, k, js-1) = pe_ad(i, k, js-1) + pe_ad(i, k+1, js-1)
4621 delp_ad(i, js-1, k) = delp_ad(i, js-1, k) + pe_ad(i, k+1, js-1)
4622 pe_ad(i, k+1, js-1) = 0.0
4625 pe_ad(i, 1, je+1) = 0.0
4627 pe_ad(i, 1, js-1) = 0.0
4632 pe_ad(ie+1, k, j) = pe_ad(ie+1, k, j) + pe_ad(ie+1, k+1, j)
4633 delp_ad(ie+1, j, k) = delp_ad(ie+1, j, k) + pe_ad(ie+1, k+1, j)
4634 pe_ad(ie+1, k+1, j) = 0.0
4636 pe_ad(is-1, k, j) = pe_ad(is-1, k, j) + pe_ad(is-1, k+1, j)
4637 delp_ad(is-1, j, k) = delp_ad(is-1, j, k) + pe_ad(is-1, k+1, j)
4638 pe_ad(is-1, k+1, j) = 0.0
4641 pe_ad(ie+1, 1, j) = 0.0
4643 pe_ad(is-1, 1, j) = 0.0
4646 SUBROUTINE pe_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, &
4649 INTEGER,
INTENT(IN) :: is, ie, js, je, isd, ied, jsd, jed, npz
4650 REAL,
INTENT(IN) :: ptop
4651 REAL,
DIMENSION(isd:ied, jsd:jed, npz),
INTENT(IN) :: delp
4652 REAL,
DIMENSION(is-1:ie+1, npz+1, js-1:je+1),
INTENT(INOUT) :: pe
4657 pe(is-1, 1, j) = ptop
4658 pe(ie+1, 1, j) = ptop
4660 pe(is-1, k+1, j) = pe(is-1, k, j) + delp(is-1, j, k)
4661 pe(ie+1, k+1, j) = pe(ie+1, k, j) + delp(ie+1, j, k)
4666 pe(i, 1, js-1) = ptop
4667 pe(i, 1, je+1) = ptop
4669 pe(i, k+1, js-1) = pe(i, k, js-1) + delp(i, js-1, k)
4670 pe(i, k+1, je+1) = pe(i, k, je+1) + delp(i, je+1, k)
4694 SUBROUTINE adv_pe_fwd(ua, va, pem, om, gridstruct, bd, npx, npy, npz, &
4697 INTEGER,
INTENT(IN) :: npx, npy, npz, ng
4698 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
4700 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: ua&
4703 REAL,
INTENT(IN) :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
4704 REAL,
INTENT(INOUT) :: om(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
4705 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
4707 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: up, vp
4708 REAL :: v3(3, bd%is:bd%ie, bd%js:bd%je)
4709 REAL :: pin(bd%isd:bd%ied, bd%jsd:bd%jed)
4710 REAL :: pb(bd%isd:bd%ied, bd%jsd:bd%jed)
4711 REAL :: grad(3, bd%is:bd%ie, bd%js:bd%je)
4712 REAL :: pdx(3, bd%is:bd%ie, bd%js:bd%je+1)
4713 REAL :: pdy(3, bd%is:bd%ie+1, bd%js:bd%je)
4714 INTEGER :: i, j, k, n
4715 INTEGER :: is, ie, js, je
4737 IF (k .EQ. npz)
THEN 4740 up(i, j) = ua(i, j, npz)
4741 vp(i, j) = va(i, j, npz)
4748 up(i, j) = 0.5*(ua(i, j, k)+ua(i, j, k+1))
4749 vp(i, j) = 0.5*(va(i, j, k)+va(i, j, k+1))
4759 v3(n, i, j) = up(i, j)*gridstruct%ec1(n, i, j) + vp(i, j)*&
4760 & gridstruct%ec2(n, i, j)
4766 pin(i, j) = pem(i, k+1, j)
4770 CALL a2b_ord2_fwd(pin, pb, gridstruct, npx, npy, is, ie, js, je, &
4775 pdx(n, i, j) = (pb(i, j)+pb(i+1, j))*gridstruct%dx(i, j)*&
4776 & gridstruct%en1(n, i, j)
4783 pdy(n, i, j) = (pb(i, j)+pb(i, j+1))*gridstruct%dy(i, j)*&
4784 & gridstruct%en2(n, i, j)
4793 grad(n, i, j) = pdx(n, i, j+1) - pdx(n, i, j) - pdy(n, i, j)&
4802 om(i, j, k) = om(i, j, k) + 0.5*gridstruct%rarea(i, j)*(v3(1, &
4803 & i, j)*grad(1, i, j)+v3(2, i, j)*grad(2, i, j)+v3(3, i, j)*&
4835 SUBROUTINE adv_pe_bwd(ua, ua_ad, va, va_ad, pem, pem_ad, om, om_ad, &
4836 & gridstruct, bd, npx, npy, npz, ng)
4838 INTEGER,
INTENT(IN) :: npx, npy, npz, ng
4839 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
4840 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: ua&
4842 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz) :: ua_ad, va_ad
4843 REAL,
INTENT(IN) :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
4844 REAL :: pem_ad(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
4845 REAL,
INTENT(INOUT) :: om(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
4846 REAL,
INTENT(INOUT) :: om_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
4847 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
4848 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: up, vp
4849 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: up_ad, vp_ad
4850 REAL :: v3(3, bd%is:bd%ie, bd%js:bd%je)
4851 REAL :: v3_ad(3, bd%is:bd%ie, bd%js:bd%je)
4852 REAL :: pin(bd%isd:bd%ied, bd%jsd:bd%jed)
4853 REAL :: pin_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
4854 REAL :: pb(bd%isd:bd%ied, bd%jsd:bd%jed)
4855 REAL :: pb_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
4856 REAL :: grad(3, bd%is:bd%ie, bd%js:bd%je)
4857 REAL :: grad_ad(3, bd%is:bd%ie, bd%js:bd%je)
4858 REAL :: pdx(3, bd%is:bd%ie, bd%js:bd%je+1)
4859 REAL :: pdx_ad(3, bd%is:bd%ie, bd%js:bd%je+1)
4860 REAL :: pdy(3, bd%is:bd%ie+1, bd%js:bd%je)
4861 REAL :: pdy_ad(3, bd%is:bd%ie+1, bd%js:bd%je)
4862 INTEGER :: i, j, k, n
4863 INTEGER :: is, ie, js, je
4884 CALL poprealarray(v3, 3*(bd%ie-bd%is+1)*(bd%je-bd%js+1))
4885 CALL poprealarray(grad, 3*(bd%ie-bd%is+1)*(bd%je-bd%js+1))
4901 temp_ad1 = gridstruct%rarea(i, j)*0.5*om_ad(i, j, k)
4902 v3_ad(1, i, j) = v3_ad(1, i, j) + grad(1, i, j)*temp_ad1
4903 grad_ad(1, i, j) = grad_ad(1, i, j) + v3(1, i, j)*temp_ad1
4904 v3_ad(2, i, j) = v3_ad(2, i, j) + grad(2, i, j)*temp_ad1
4905 grad_ad(2, i, j) = grad_ad(2, i, j) + v3(2, i, j)*temp_ad1
4906 v3_ad(3, i, j) = v3_ad(3, i, j) + grad(3, i, j)*temp_ad1
4907 grad_ad(3, i, j) = grad_ad(3, i, j) + v3(3, i, j)*temp_ad1
4914 pdx_ad(n, i, j+1) = pdx_ad(n, i, j+1) + grad_ad(n, i, j)
4915 pdx_ad(n, i, j) = pdx_ad(n, i, j) - grad_ad(n, i, j)
4916 pdy_ad(n, i+1, j) = pdy_ad(n, i+1, j) + grad_ad(n, i, j)
4917 pdy_ad(n, i, j) = pdy_ad(n, i, j) - grad_ad(n, i, j)
4918 grad_ad(n, i, j) = 0.0
4925 temp_ad0 = gridstruct%dy(i, j)*gridstruct%en2(n, i, j)*&
4927 pb_ad(i, j) = pb_ad(i, j) + temp_ad0
4928 pb_ad(i, j+1) = pb_ad(i, j+1) + temp_ad0
4929 pdy_ad(n, i, j) = 0.0
4936 temp_ad = gridstruct%dx(i, j)*gridstruct%en1(n, i, j)*pdx_ad&
4938 pb_ad(i, j) = pb_ad(i, j) + temp_ad
4939 pb_ad(i+1, j) = pb_ad(i+1, j) + temp_ad
4940 pdx_ad(n, i, j) = 0.0
4944 CALL a2b_ord2_bwd(pin, pin_ad, pb, pb_ad, gridstruct, npx, npy, is&
4948 pem_ad(i, k+1, j) = pem_ad(i, k+1, j) + pin_ad(i, j)
4956 up_ad(i, j) = up_ad(i, j) + gridstruct%ec1(n, i, j)*v3_ad(n&
4958 vp_ad(i, j) = vp_ad(i, j) + gridstruct%ec2(n, i, j)*v3_ad(n&
4960 v3_ad(n, i, j) = 0.0
4965 IF (branch .EQ. 0)
THEN 4968 va_ad(i, j, k) = va_ad(i, j, k) + 0.5*vp_ad(i, j)
4969 va_ad(i, j, k+1) = va_ad(i, j, k+1) + 0.5*vp_ad(i, j)
4971 ua_ad(i, j, k) = ua_ad(i, j, k) + 0.5*up_ad(i, j)
4972 ua_ad(i, j, k+1) = ua_ad(i, j, k+1) + 0.5*up_ad(i, j)
4979 va_ad(i, j, npz) = va_ad(i, j, npz) + vp_ad(i, j)
4981 ua_ad(i, j, npz) = ua_ad(i, j, npz) + up_ad(i, j)
4988 SUBROUTINE adv_pe(ua, va, pem, om, gridstruct, bd, npx, npy, npz, ng)
4990 INTEGER,
INTENT(IN) :: npx, npy, npz, ng
4991 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
4993 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: ua&
4996 REAL,
INTENT(IN) :: pem(bd%is-1:bd%ie+1, npz+1, bd%js-1:bd%je+1)
4997 REAL,
INTENT(INOUT) :: om(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
4998 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
5000 REAL,
DIMENSION(bd%is:bd%ie, bd%js:bd%je) :: up, vp
5001 REAL :: v3(3, bd%is:bd%ie, bd%js:bd%je)
5002 REAL :: pin(bd%isd:bd%ied, bd%jsd:bd%jed)
5003 REAL :: pb(bd%isd:bd%ied, bd%jsd:bd%jed)
5004 REAL :: grad(3, bd%is:bd%ie, bd%js:bd%je)
5005 REAL :: pdx(3, bd%is:bd%ie, bd%js:bd%je+1)
5006 REAL :: pdy(3, bd%is:bd%ie+1, bd%js:bd%je)
5007 INTEGER :: i, j, k, n
5008 INTEGER :: is, ie, js, je
5016 IF (k .EQ. npz)
THEN 5019 up(i, j) = ua(i, j, npz)
5020 vp(i, j) = va(i, j, npz)
5026 up(i, j) = 0.5*(ua(i, j, k)+ua(i, j, k+1))
5027 vp(i, j) = 0.5*(va(i, j, k)+va(i, j, k+1))
5035 v3(n, i, j) = up(i, j)*gridstruct%ec1(n, i, j) + vp(i, j)*&
5036 & gridstruct%ec2(n, i, j)
5042 pin(i, j) = pem(i, k+1, j)
5046 CALL a2b_ord2(pin, pb, gridstruct, npx, npy, is, ie, js, je, ng)
5050 pdx(n, i, j) = (pb(i, j)+pb(i+1, j))*gridstruct%dx(i, j)*&
5051 & gridstruct%en1(n, i, j)
5058 pdy(n, i, j) = (pb(i, j)+pb(i, j+1))*gridstruct%dy(i, j)*&
5059 & gridstruct%en2(n, i, j)
5067 grad(n, i, j) = pdx(n, i, j+1) - pdx(n, i, j) - pdy(n, i, j)&
5075 om(i, j, k) = om(i, j, k) + 0.5*gridstruct%rarea(i, j)*(v3(1, &
5076 & i, j)*grad(1, i, j)+v3(2, i, j)*grad(2, i, j)+v3(3, i, j)*&
5102 SUBROUTINE p_grad_c_fwd(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, &
5103 & rdyc, hydrostatic)
5105 INTEGER,
INTENT(IN) :: npz
5106 REAL,
INTENT(IN) :: dt2
5107 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5108 REAL,
DIMENSION(bd%isd:, bd%jsd:, :),
INTENT(IN) :: delpc
5111 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(IN) :: &
5113 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5114 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5115 REAL,
INTENT(IN) :: rdxc(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5116 REAL,
INTENT(IN) :: rdyc(bd%isd:bd%ied, bd%jsd:bd%jed)
5117 LOGICAL,
INTENT(IN) :: hydrostatic
5119 REAL :: wk(bd%is-1:bd%ie+1, bd%js-1:bd%je+1)
5121 INTEGER :: is, ie, js, je
5136 IF (hydrostatic)
THEN 5140 wk(i, j) = pkc(i, j, k+1) - pkc(i, j, k)
5148 wk(i, j) = delpc(i, j, k)
5155 uc(i, j, k) = uc(i, j, k) + dt2*rdxc(i, j)/(wk(i-1, j)+wk(i, j&
5156 & ))*((gz(i-1, j, k+1)-gz(i, j, k))*(pkc(i, j, k+1)-pkc(i-1, j&
5157 & , k))+(gz(i-1, j, k)-gz(i, j, k+1))*(pkc(i-1, j, k+1)-pkc(i&
5163 vc(i, j, k) = vc(i, j, k) + dt2*rdyc(i, j)/(wk(i, j-1)+wk(i, j&
5164 & ))*((gz(i, j-1, k+1)-gz(i, j, k))*(pkc(i, j, k+1)-pkc(i, j-1&
5165 & , k))+(gz(i, j-1, k)-gz(i, j, k+1))*(pkc(i, j-1, k+1)-pkc(i&
5196 SUBROUTINE p_grad_c_bwd(dt2, npz, delpc, delpc_ad, pkc, pkc_ad, gz, &
5197 & gz_ad, uc, uc_ad, vc, vc_ad, bd, rdxc, rdyc, hydrostatic)
5199 INTEGER,
INTENT(IN) :: npz
5200 REAL,
INTENT(IN) :: dt2
5201 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5202 REAL,
DIMENSION(bd%isd:, bd%jsd:, :),
INTENT(IN) :: delpc
5203 REAL,
DIMENSION(bd%isd:, bd%jsd:, :) :: delpc_ad
5204 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(IN) :: &
5206 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1) :: pkc_ad, &
5208 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5209 REAL,
INTENT(INOUT) :: uc_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5210 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5211 REAL,
INTENT(INOUT) :: vc_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5212 REAL,
INTENT(IN) :: rdxc(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5213 REAL,
INTENT(IN) :: rdyc(bd%isd:bd%ied, bd%jsd:bd%jed)
5214 LOGICAL,
INTENT(IN) :: hydrostatic
5215 REAL :: wk(bd%is-1:bd%ie+1, bd%js-1:bd%je+1)
5216 REAL :: wk_ad(bd%is-1:bd%ie+1, bd%js-1:bd%je+1)
5218 INTEGER :: is, ie, js, je
5251 temp4 = wk(i, j-1) + wk(i, j)
5252 temp8 = pkc(i, j-1, k+1) - pkc(i, j, k)
5253 temp7 = gz(i, j-1, k) - gz(i, j, k+1)
5254 temp6 = pkc(i, j, k+1) - pkc(i, j-1, k)
5255 temp5 = gz(i, j-1, k+1) - gz(i, j, k)
5256 temp_ad1 = dt2*rdyc(i, j)*vc_ad(i, j, k)/temp4
5257 temp_ad2 = -((temp5*temp6+temp7*temp8)*temp_ad1/temp4)
5258 gz_ad(i, j-1, k+1) = gz_ad(i, j-1, k+1) + temp6*temp_ad1
5259 gz_ad(i, j, k) = gz_ad(i, j, k) - temp6*temp_ad1
5260 pkc_ad(i, j, k+1) = pkc_ad(i, j, k+1) + temp5*temp_ad1
5261 pkc_ad(i, j-1, k) = pkc_ad(i, j-1, k) - temp5*temp_ad1
5262 gz_ad(i, j-1, k) = gz_ad(i, j-1, k) + temp8*temp_ad1
5263 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) - temp8*temp_ad1
5264 pkc_ad(i, j-1, k+1) = pkc_ad(i, j-1, k+1) + temp7*temp_ad1
5265 pkc_ad(i, j, k) = pkc_ad(i, j, k) - temp7*temp_ad1
5266 wk_ad(i, j-1) = wk_ad(i, j-1) + temp_ad2
5267 wk_ad(i, j) = wk_ad(i, j) + temp_ad2
5272 temp = wk(i-1, j) + wk(i, j)
5273 temp3 = pkc(i-1, j, k+1) - pkc(i, j, k)
5274 temp2 = gz(i-1, j, k) - gz(i, j, k+1)
5275 temp1 = pkc(i, j, k+1) - pkc(i-1, j, k)
5276 temp0 = gz(i-1, j, k+1) - gz(i, j, k)
5277 temp_ad = dt2*rdxc(i, j)*uc_ad(i, j, k)/temp
5278 temp_ad0 = -((temp0*temp1+temp2*temp3)*temp_ad/temp)
5279 gz_ad(i-1, j, k+1) = gz_ad(i-1, j, k+1) + temp1*temp_ad
5280 gz_ad(i, j, k) = gz_ad(i, j, k) - temp1*temp_ad
5281 pkc_ad(i, j, k+1) = pkc_ad(i, j, k+1) + temp0*temp_ad
5282 pkc_ad(i-1, j, k) = pkc_ad(i-1, j, k) - temp0*temp_ad
5283 gz_ad(i-1, j, k) = gz_ad(i-1, j, k) + temp3*temp_ad
5284 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) - temp3*temp_ad
5285 pkc_ad(i-1, j, k+1) = pkc_ad(i-1, j, k+1) + temp2*temp_ad
5286 pkc_ad(i, j, k) = pkc_ad(i, j, k) - temp2*temp_ad
5287 wk_ad(i-1, j) = wk_ad(i-1, j) + temp_ad0
5288 wk_ad(i, j) = wk_ad(i, j) + temp_ad0
5292 IF (branch .EQ. 0)
THEN 5296 delpc_ad(i, j, k) = delpc_ad(i, j, k) + wk_ad(i, j)
5304 pkc_ad(i, j, k+1) = pkc_ad(i, j, k+1) + wk_ad(i, j)
5305 pkc_ad(i, j, k) = pkc_ad(i, j, k) - wk_ad(i, j)
5312 SUBROUTINE p_grad_c(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, rdyc, &
5315 INTEGER,
INTENT(IN) :: npz
5316 REAL,
INTENT(IN) :: dt2
5317 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5318 REAL,
DIMENSION(bd%isd:, bd%jsd:, :),
INTENT(IN) :: delpc
5321 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(IN) :: &
5323 REAL,
INTENT(INOUT) :: uc(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5324 REAL,
INTENT(INOUT) :: vc(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5325 REAL,
INTENT(IN) :: rdxc(bd%isd:bd%ied+1, bd%jsd:bd%jed+1)
5326 REAL,
INTENT(IN) :: rdyc(bd%isd:bd%ied, bd%jsd:bd%jed)
5327 LOGICAL,
INTENT(IN) :: hydrostatic
5329 REAL :: wk(bd%is-1:bd%ie+1, bd%js-1:bd%je+1)
5331 INTEGER :: is, ie, js, je
5339 IF (hydrostatic)
THEN 5342 wk(i, j) = pkc(i, j, k+1) - pkc(i, j, k)
5348 wk(i, j) = delpc(i, j, k)
5354 uc(i, j, k) = uc(i, j, k) + dt2*rdxc(i, j)/(wk(i-1, j)+wk(i, j&
5355 & ))*((gz(i-1, j, k+1)-gz(i, j, k))*(pkc(i, j, k+1)-pkc(i-1, j&
5356 & , k))+(gz(i-1, j, k)-gz(i, j, k+1))*(pkc(i-1, j, k+1)-pkc(i&
5362 vc(i, j, k) = vc(i, j, k) + dt2*rdyc(i, j)/(wk(i, j-1)+wk(i, j&
5363 & ))*((gz(i, j-1, k+1)-gz(i, j, k))*(pkc(i, j, k+1)-pkc(i, j-1&
5364 & , k))+(gz(i, j-1, k)-gz(i, j, k+1))*(pkc(i, j-1, k+1)-pkc(i&
5390 SUBROUTINE nh_p_grad_fwd(u, v, pp, gz, delp, pk, dt, ng, gridstruct, &
5391 & bd, npx, npy, npz, use_logp)
5394 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
5395 REAL,
INTENT(IN) :: dt
5396 LOGICAL,
INTENT(IN) :: use_logp
5397 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5398 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
5400 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5402 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5404 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5405 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5406 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5407 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
5409 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
5410 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
5411 REAL :: du1, dv1, top_value
5413 INTEGER :: is, ie, js, je
5414 INTEGER :: isd, ied, jsd, jed
5450 pk(i, j, 1) = top_value
5457 CALL a2b_ord4_fwd(pp(isd:ied, jsd:jed, k), wk1, gridstruct, &
5458 & npx, npy, is, ie, js, je, ng, .true.)
5459 CALL a2b_ord4_fwd(pk(isd:ied, jsd:jed, k), wk1, gridstruct, &
5460 & npx, npy, is, ie, js, je, ng, .true.)
5465 CALL a2b_ord4_fwd(gz(isd:ied, jsd:jed, k), wk1, gridstruct, npx&
5466 & , npy, is, ie, js, je, ng, .true.)
5472 CALL a2b_ord4_fwd(delp(isd:ied, jsd:jed, k), wk1, gridstruct, &
5473 & npx, npy, is, ie, js, je, ng)
5477 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
5484 du1 = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*&
5485 & (pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*&
5486 & (pk(i, j, k+1)-pk(i+1, j, k)))
5489 u(i, j, k) = (u(i, j, k)+du1+dt/(wk1(i, j)+wk1(i+1, j))*((gz(i&
5490 & , j, k+1)-gz(i+1, j, k))*(pp(i+1, j, k+1)-pp(i, j, k))+(gz(i&
5491 & , j, k)-gz(i+1, j, k+1))*(pp(i, j, k+1)-pp(i+1, j, k))))*&
5492 & gridstruct%rdx(i, j)
5498 dv1 = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*&
5499 & (pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*&
5500 & (pk(i, j, k+1)-pk(i, j+1, k)))
5503 v(i, j, k) = (v(i, j, k)+dv1+dt/(wk1(i, j)+wk1(i, j+1))*((gz(i&
5504 & , j, k+1)-gz(i, j+1, k))*(pp(i, j+1, k+1)-pp(i, j, k))+(gz(i&
5505 & , j, k)-gz(i, j+1, k+1))*(pp(i, j, k+1)-pp(i, j+1, k))))*&
5506 & gridstruct%rdy(i, j)
5518 CALL pushrealarray(wk1, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
5541 SUBROUTINE nh_p_grad_bwd(u, u_ad, v, v_ad, pp, pp_ad, gz, gz_ad, delp&
5542 & , delp_ad, pk, pk_ad, dt, ng, gridstruct, bd, npx, npy, npz, &
5546 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
5547 REAL,
INTENT(IN) :: dt
5548 LOGICAL,
INTENT(IN) :: use_logp
5549 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5550 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
5551 REAL,
INTENT(INOUT) :: delp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
5552 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5553 REAL,
INTENT(INOUT) :: pp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5554 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5555 REAL,
INTENT(INOUT) :: pk_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5556 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5557 REAL,
INTENT(INOUT) :: gz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5558 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5559 REAL,
INTENT(INOUT) :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5560 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5561 REAL,
INTENT(INOUT) :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5562 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
5563 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
5564 REAL :: wk1_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
5565 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
5566 REAL :: wk_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
5567 REAL :: du1, dv1, top_value
5568 REAL :: du1_ad, dv1_ad
5570 INTEGER :: is, ie, js, je
5571 INTEGER :: isd, ied, jsd, jed
5620 CALL poprealarray(wk1, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
5635 temp14 = wk1(i, j) + wk1(i, j+1)
5636 temp18 = pp(i, j, k+1) - pp(i, j+1, k)
5637 temp17 = gz(i, j, k) - gz(i, j+1, k+1)
5638 temp16 = pp(i, j+1, k+1) - pp(i, j, k)
5639 temp15 = gz(i, j, k+1) - gz(i, j+1, k)
5640 temp_ad4 = gridstruct%rdy(i, j)*v_ad(i, j, k)
5641 temp_ad5 = dt*temp_ad4/temp14
5642 temp_ad6 = -((temp15*temp16+temp17*temp18)*temp_ad5/temp14)
5644 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp16*temp_ad5
5645 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp16*temp_ad5
5646 pp_ad(i, j+1, k+1) = pp_ad(i, j+1, k+1) + temp15*temp_ad5
5647 pp_ad(i, j, k) = pp_ad(i, j, k) - temp15*temp_ad5
5648 gz_ad(i, j, k) = gz_ad(i, j, k) + temp18*temp_ad5
5649 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp18*temp_ad5
5650 pp_ad(i, j, k+1) = pp_ad(i, j, k+1) + temp17*temp_ad5
5651 pp_ad(i, j+1, k) = pp_ad(i, j+1, k) - temp17*temp_ad5
5652 wk1_ad(i, j) = wk1_ad(i, j) + temp_ad6
5653 wk1_ad(i, j+1) = wk1_ad(i, j+1) + temp_ad6
5654 v_ad(i, j, k) = temp_ad4
5655 temp9 = wk(i, j) + wk(i, j+1)
5656 temp13 = pk(i, j, k+1) - pk(i, j+1, k)
5657 temp12 = gz(i, j, k) - gz(i, j+1, k+1)
5658 temp11 = pk(i, j+1, k+1) - pk(i, j, k)
5659 temp10 = gz(i, j, k+1) - gz(i, j+1, k)
5660 temp_ad7 = dt*dv1_ad/temp9
5661 temp_ad8 = -((temp10*temp11+temp12*temp13)*temp_ad7/temp9)
5662 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp11*temp_ad7
5663 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp11*temp_ad7
5664 pk_ad(i, j+1, k+1) = pk_ad(i, j+1, k+1) + temp10*temp_ad7
5665 pk_ad(i, j, k) = pk_ad(i, j, k) - temp10*temp_ad7
5666 gz_ad(i, j, k) = gz_ad(i, j, k) + temp13*temp_ad7
5667 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp13*temp_ad7
5668 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp12*temp_ad7
5669 pk_ad(i, j+1, k) = pk_ad(i, j+1, k) - temp12*temp_ad7
5670 wk_ad(i, j) = wk_ad(i, j) + temp_ad8
5671 wk_ad(i, j+1) = wk_ad(i, j+1) + temp_ad8
5677 temp4 = wk1(i, j) + wk1(i+1, j)
5678 temp8 = pp(i, j, k+1) - pp(i+1, j, k)
5679 temp7 = gz(i, j, k) - gz(i+1, j, k+1)
5680 temp6 = pp(i+1, j, k+1) - pp(i, j, k)
5681 temp5 = gz(i, j, k+1) - gz(i+1, j, k)
5682 temp_ad = gridstruct%rdx(i, j)*u_ad(i, j, k)
5683 temp_ad0 = dt*temp_ad/temp4
5684 temp_ad1 = -((temp5*temp6+temp7*temp8)*temp_ad0/temp4)
5686 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp6*temp_ad0
5687 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp6*temp_ad0
5688 pp_ad(i+1, j, k+1) = pp_ad(i+1, j, k+1) + temp5*temp_ad0
5689 pp_ad(i, j, k) = pp_ad(i, j, k) - temp5*temp_ad0
5690 gz_ad(i, j, k) = gz_ad(i, j, k) + temp8*temp_ad0
5691 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp8*temp_ad0
5692 pp_ad(i, j, k+1) = pp_ad(i, j, k+1) + temp7*temp_ad0
5693 pp_ad(i+1, j, k) = pp_ad(i+1, j, k) - temp7*temp_ad0
5694 wk1_ad(i, j) = wk1_ad(i, j) + temp_ad1
5695 wk1_ad(i+1, j) = wk1_ad(i+1, j) + temp_ad1
5696 u_ad(i, j, k) = temp_ad
5697 temp = wk(i, j) + wk(i+1, j)
5698 temp3 = pk(i, j, k+1) - pk(i+1, j, k)
5699 temp2 = gz(i, j, k) - gz(i+1, j, k+1)
5700 temp1 = pk(i+1, j, k+1) - pk(i, j, k)
5701 temp0 = gz(i, j, k+1) - gz(i+1, j, k)
5702 temp_ad2 = dt*du1_ad/temp
5703 temp_ad3 = -((temp0*temp1+temp2*temp3)*temp_ad2/temp)
5704 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp1*temp_ad2
5705 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp1*temp_ad2
5706 pk_ad(i+1, j, k+1) = pk_ad(i+1, j, k+1) + temp0*temp_ad2
5707 pk_ad(i, j, k) = pk_ad(i, j, k) - temp0*temp_ad2
5708 gz_ad(i, j, k) = gz_ad(i, j, k) + temp3*temp_ad2
5709 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp3*temp_ad2
5710 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp2*temp_ad2
5711 pk_ad(i+1, j, k) = pk_ad(i+1, j, k) - temp2*temp_ad2
5712 wk_ad(i, j) = wk_ad(i, j) + temp_ad3
5713 wk_ad(i+1, j) = wk_ad(i+1, j) + temp_ad3
5719 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + wk_ad(i, j)
5720 pk_ad(i, j, k) = pk_ad(i, j, k) - wk_ad(i, j)
5724 CALL a2b_ord4_bwd(delp(isd:ied, jsd:jed, k), delp_ad(isd:ied, &
5725 & jsd:jed, k), wk1, wk1_ad, gridstruct, npx, npy, is&
5729 CALL a2b_ord4_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd:&
5730 & jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, ie&
5731 & , js, je, ng, .true.)
5733 IF (branch .EQ. 0)
THEN 5734 CALL a2b_ord4_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd&
5735 & :jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, &
5736 & ie, js, je, ng, .true.)
5737 CALL a2b_ord4_bwd(pp(isd:ied, jsd:jed, k), pp_ad(isd:ied, jsd&
5738 & :jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, &
5739 & ie, js, je, ng, .true.)
5745 pk_ad(i, j, 1) = 0.0
5747 pp_ad(i, j, 1) = 0.0
5751 SUBROUTINE nh_p_grad(u, v, pp, gz, delp, pk, dt, ng, gridstruct, bd, &
5752 & npx, npy, npz, use_logp)
5755 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
5756 REAL,
INTENT(IN) :: dt
5757 LOGICAL,
INTENT(IN) :: use_logp
5758 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5759 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
5761 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5763 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5765 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5766 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5767 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5768 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
5770 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
5771 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
5772 REAL :: du1, dv1, top_value
5774 INTEGER :: is, ie, js, je
5775 INTEGER :: isd, ied, jsd, jed
5794 pk(i, j, 1) = top_value
5801 CALL a2b_ord4(pp(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
5802 & npy, is, ie, js, je, ng, .true.)
5803 CALL a2b_ord4(pk(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
5804 & npy, is, ie, js, je, ng, .true.)
5806 CALL a2b_ord4(gz(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
5807 & npy, is, ie, js, je, ng, .true.)
5813 CALL a2b_ord4(delp(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
5814 & npy, is, ie, js, je, ng)
5817 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
5824 du1 = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*&
5825 & (pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*&
5826 & (pk(i, j, k+1)-pk(i+1, j, k)))
5828 u(i, j, k) = (u(i, j, k)+du1+dt/(wk1(i, j)+wk1(i+1, j))*((gz(i&
5829 & , j, k+1)-gz(i+1, j, k))*(pp(i+1, j, k+1)-pp(i, j, k))+(gz(i&
5830 & , j, k)-gz(i+1, j, k+1))*(pp(i, j, k+1)-pp(i+1, j, k))))*&
5831 & gridstruct%rdx(i, j)
5837 dv1 = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*&
5838 & (pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*&
5839 & (pk(i, j, k+1)-pk(i, j+1, k)))
5841 v(i, j, k) = (v(i, j, k)+dv1+dt/(wk1(i, j)+wk1(i, j+1))*((gz(i&
5842 & , j, k+1)-gz(i, j+1, k))*(pp(i, j+1, k+1)-pp(i, j, k))+(gz(i&
5843 & , j, k)-gz(i, j+1, k+1))*(pp(i, j, k+1)-pp(i, j+1, k))))*&
5844 & gridstruct%rdy(i, j)
5869 SUBROUTINE split_p_grad_fwd(u, v, pp, gz, du, dv, delp, pk, beta, dt, &
5870 & ng, gridstruct, bd, npx, npy, npz, use_logp)
5873 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
5874 REAL,
INTENT(IN) :: beta, dt
5875 LOGICAL,
INTENT(IN) :: use_logp
5876 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
5877 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
5879 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5881 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5883 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
5884 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5885 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5886 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
5887 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
5888 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
5890 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
5891 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
5892 REAL :: alpha, top_value
5894 INTEGER :: is, ie, js, je
5895 INTEGER :: isd, ied, jsd, jed
5930 pk(i, j, 1) = top_value
5937 CALL a2b_ord4_fwd(pp(isd:ied, jsd:jed, k), wk1, gridstruct, &
5938 & npx, npy, is, ie, js, je, ng, .true.)
5939 CALL a2b_ord4_fwd(pk(isd:ied, jsd:jed, k), wk1, gridstruct, &
5940 & npx, npy, is, ie, js, je, ng, .true.)
5945 CALL a2b_ord4_fwd(gz(isd:ied, jsd:jed, k), wk1, gridstruct, npx&
5946 & , npy, is, ie, js, je, ng, .true.)
5952 CALL a2b_ord4_fwd(delp(isd:ied, jsd:jed, k), wk1, gridstruct, &
5953 & npx, npy, is, ie, js, je, ng)
5957 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
5963 u(i, j, k) = u(i, j, k) + beta*du(i, j, k)
5967 du(i, j, k) = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1&
5968 & , j, k))*(pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, &
5969 & j, k+1))*(pk(i, j, k+1)-pk(i+1, j, k)))
5972 u(i, j, k) = (u(i, j, k)+alpha*du(i, j, k)+dt/(wk1(i, j)+wk1(i&
5973 & +1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*(pp(i+1, j, k+1)-pp(i&
5974 & , j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*(pp(i, j, k+1)-pp(i+1&
5975 & , j, k))))*gridstruct%rdx(i, j)
5981 v(i, j, k) = v(i, j, k) + beta*dv(i, j, k)
5984 dv(i, j, k) = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j&
5985 & +1, k))*(pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1&
5986 & , k+1))*(pk(i, j, k+1)-pk(i, j+1, k)))
5989 v(i, j, k) = (v(i, j, k)+alpha*dv(i, j, k)+dt/(wk1(i, j)+wk1(i&
5990 & , j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*(pp(i, j+1, k+1)-pp(i&
5991 & , j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*(pp(i, j, k+1)-pp(i, &
5992 & j+1, k))))*gridstruct%rdy(i, j)
6004 CALL pushrealarray(wk1, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
6029 & , du_ad, dv, dv_ad, delp, delp_ad, pk, pk_ad, beta, dt, ng, &
6030 & gridstruct, bd, npx, npy, npz, use_logp)
6033 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
6034 REAL,
INTENT(IN) :: beta, dt
6035 LOGICAL,
INTENT(IN) :: use_logp
6036 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6037 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6038 REAL,
INTENT(INOUT) :: delp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6039 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6040 REAL,
INTENT(INOUT) :: pp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6041 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6042 REAL,
INTENT(INOUT) :: pk_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6043 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6044 REAL,
INTENT(INOUT) :: gz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6045 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6046 REAL,
INTENT(INOUT) :: du_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6047 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6048 REAL,
INTENT(INOUT) :: dv_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6049 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6050 REAL,
INTENT(INOUT) :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6051 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6052 REAL,
INTENT(INOUT) :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6053 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6054 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
6055 REAL :: wk1_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
6056 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
6057 REAL :: wk_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
6058 REAL :: alpha, top_value
6060 INTEGER :: is, ie, js, je
6061 INTEGER :: isd, ied, jsd, jed
6110 CALL poprealarray(wk1, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
6124 temp14 = wk1(i, j) + wk1(i, j+1)
6125 temp18 = pp(i, j, k+1) - pp(i, j+1, k)
6126 temp17 = gz(i, j, k) - gz(i, j+1, k+1)
6127 temp16 = pp(i, j+1, k+1) - pp(i, j, k)
6128 temp15 = gz(i, j, k+1) - gz(i, j+1, k)
6129 temp_ad4 = gridstruct%rdy(i, j)*v_ad(i, j, k)
6130 temp_ad5 = dt*temp_ad4/temp14
6131 temp_ad6 = -((temp15*temp16+temp17*temp18)*temp_ad5/temp14)
6132 dv_ad(i, j, k) = dv_ad(i, j, k) + alpha*temp_ad4
6133 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp16*temp_ad5
6134 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp16*temp_ad5
6135 pp_ad(i, j+1, k+1) = pp_ad(i, j+1, k+1) + temp15*temp_ad5
6136 pp_ad(i, j, k) = pp_ad(i, j, k) - temp15*temp_ad5
6137 gz_ad(i, j, k) = gz_ad(i, j, k) + temp18*temp_ad5
6138 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp18*temp_ad5
6139 pp_ad(i, j, k+1) = pp_ad(i, j, k+1) + temp17*temp_ad5
6140 pp_ad(i, j+1, k) = pp_ad(i, j+1, k) - temp17*temp_ad5
6141 wk1_ad(i, j) = wk1_ad(i, j) + temp_ad6
6142 wk1_ad(i, j+1) = wk1_ad(i, j+1) + temp_ad6
6143 v_ad(i, j, k) = temp_ad4
6144 temp9 = wk(i, j) + wk(i, j+1)
6145 temp13 = pk(i, j, k+1) - pk(i, j+1, k)
6146 temp12 = gz(i, j, k) - gz(i, j+1, k+1)
6147 temp11 = pk(i, j+1, k+1) - pk(i, j, k)
6148 temp10 = gz(i, j, k+1) - gz(i, j+1, k)
6149 temp_ad7 = dt*dv_ad(i, j, k)/temp9
6150 temp_ad8 = -((temp10*temp11+temp12*temp13)*temp_ad7/temp9)
6151 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp11*temp_ad7
6152 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp11*temp_ad7
6153 pk_ad(i, j+1, k+1) = pk_ad(i, j+1, k+1) + temp10*temp_ad7
6154 pk_ad(i, j, k) = pk_ad(i, j, k) - temp10*temp_ad7
6155 gz_ad(i, j, k) = gz_ad(i, j, k) + temp13*temp_ad7
6156 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp13*temp_ad7
6157 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp12*temp_ad7
6158 pk_ad(i, j+1, k) = pk_ad(i, j+1, k) - temp12*temp_ad7
6159 wk_ad(i, j) = wk_ad(i, j) + temp_ad8
6160 wk_ad(i, j+1) = wk_ad(i, j+1) + temp_ad8
6161 dv_ad(i, j, k) = beta*v_ad(i, j, k)
6167 temp4 = wk1(i, j) + wk1(i+1, j)
6168 temp8 = pp(i, j, k+1) - pp(i+1, j, k)
6169 temp7 = gz(i, j, k) - gz(i+1, j, k+1)
6170 temp6 = pp(i+1, j, k+1) - pp(i, j, k)
6171 temp5 = gz(i, j, k+1) - gz(i+1, j, k)
6172 temp_ad = gridstruct%rdx(i, j)*u_ad(i, j, k)
6173 temp_ad0 = dt*temp_ad/temp4
6174 temp_ad1 = -((temp5*temp6+temp7*temp8)*temp_ad0/temp4)
6175 du_ad(i, j, k) = du_ad(i, j, k) + alpha*temp_ad
6176 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp6*temp_ad0
6177 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp6*temp_ad0
6178 pp_ad(i+1, j, k+1) = pp_ad(i+1, j, k+1) + temp5*temp_ad0
6179 pp_ad(i, j, k) = pp_ad(i, j, k) - temp5*temp_ad0
6180 gz_ad(i, j, k) = gz_ad(i, j, k) + temp8*temp_ad0
6181 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp8*temp_ad0
6182 pp_ad(i, j, k+1) = pp_ad(i, j, k+1) + temp7*temp_ad0
6183 pp_ad(i+1, j, k) = pp_ad(i+1, j, k) - temp7*temp_ad0
6184 wk1_ad(i, j) = wk1_ad(i, j) + temp_ad1
6185 wk1_ad(i+1, j) = wk1_ad(i+1, j) + temp_ad1
6186 u_ad(i, j, k) = temp_ad
6187 temp = wk(i, j) + wk(i+1, j)
6188 temp3 = pk(i, j, k+1) - pk(i+1, j, k)
6189 temp2 = gz(i, j, k) - gz(i+1, j, k+1)
6190 temp1 = pk(i+1, j, k+1) - pk(i, j, k)
6191 temp0 = gz(i, j, k+1) - gz(i+1, j, k)
6192 temp_ad2 = dt*du_ad(i, j, k)/temp
6193 temp_ad3 = -((temp0*temp1+temp2*temp3)*temp_ad2/temp)
6194 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp1*temp_ad2
6195 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp1*temp_ad2
6196 pk_ad(i+1, j, k+1) = pk_ad(i+1, j, k+1) + temp0*temp_ad2
6197 pk_ad(i, j, k) = pk_ad(i, j, k) - temp0*temp_ad2
6198 gz_ad(i, j, k) = gz_ad(i, j, k) + temp3*temp_ad2
6199 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp3*temp_ad2
6200 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp2*temp_ad2
6201 pk_ad(i+1, j, k) = pk_ad(i+1, j, k) - temp2*temp_ad2
6202 wk_ad(i, j) = wk_ad(i, j) + temp_ad3
6203 wk_ad(i+1, j) = wk_ad(i+1, j) + temp_ad3
6204 du_ad(i, j, k) = beta*u_ad(i, j, k)
6211 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + wk_ad(i, j)
6212 pk_ad(i, j, k) = pk_ad(i, j, k) - wk_ad(i, j)
6216 CALL a2b_ord4_bwd(delp(isd:ied, jsd:jed, k), delp_ad(isd:ied, &
6217 & jsd:jed, k), wk1, wk1_ad, gridstruct, npx, npy, is&
6221 CALL a2b_ord4_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd:&
6222 & jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, ie&
6223 & , js, je, ng, .true.)
6225 IF (branch .EQ. 0)
THEN 6226 CALL a2b_ord4_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd&
6227 & :jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, &
6228 & ie, js, je, ng, .true.)
6229 CALL a2b_ord4_bwd(pp(isd:ied, jsd:jed, k), pp_ad(isd:ied, jsd&
6230 & :jed, k), wk1, wk1_ad, gridstruct, npx, npy, is, &
6231 & ie, js, je, ng, .true.)
6237 pk_ad(i, j, 1) = 0.0
6239 pp_ad(i, j, 1) = 0.0
6243 SUBROUTINE split_p_grad(u, v, pp, gz, du, dv, delp, pk, beta, dt, ng, &
6244 & gridstruct, bd, npx, npy, npz, use_logp)
6247 INTEGER,
INTENT(IN) :: ng, npx, npy, npz
6248 REAL,
INTENT(IN) :: beta, dt
6249 LOGICAL,
INTENT(IN) :: use_logp
6250 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6251 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6253 REAL,
INTENT(INOUT) :: pp(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6255 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6257 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6258 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6259 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6260 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6261 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6262 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6264 REAL :: wk1(bd%isd:bd%ied, bd%jsd:bd%jed)
6265 REAL :: wk(bd%is:bd%ie+1, bd%js:bd%je+1)
6266 REAL :: alpha, top_value
6268 INTEGER :: is, ie, js, je
6269 INTEGER :: isd, ied, jsd, jed
6288 pk(i, j, 1) = top_value
6295 CALL a2b_ord4(pp(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
6296 & npy, is, ie, js, je, ng, .true.)
6297 CALL a2b_ord4(pk(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
6298 & npy, is, ie, js, je, ng, .true.)
6300 CALL a2b_ord4(gz(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
6301 & npy, is, ie, js, je, ng, .true.)
6307 CALL a2b_ord4(delp(isd:ied, jsd:jed, k), wk1, gridstruct, npx, &
6308 & npy, is, ie, js, je, ng)
6311 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
6316 u(i, j, k) = u(i, j, k) + beta*du(i, j, k)
6320 du(i, j, k) = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1&
6321 & , j, k))*(pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, &
6322 & j, k+1))*(pk(i, j, k+1)-pk(i+1, j, k)))
6325 u(i, j, k) = (u(i, j, k)+alpha*du(i, j, k)+dt/(wk1(i, j)+wk1(i&
6326 & +1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*(pp(i+1, j, k+1)-pp(i&
6327 & , j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*(pp(i, j, k+1)-pp(i+1&
6328 & , j, k))))*gridstruct%rdx(i, j)
6333 v(i, j, k) = v(i, j, k) + beta*dv(i, j, k)
6336 dv(i, j, k) = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j&
6337 & +1, k))*(pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1&
6338 & , k+1))*(pk(i, j, k+1)-pk(i, j+1, k)))
6341 v(i, j, k) = (v(i, j, k)+alpha*dv(i, j, k)+dt/(wk1(i, j)+wk1(i&
6342 & , j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*(pp(i, j+1, k+1)-pp(i&
6343 & , j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*(pp(i, j, k+1)-pp(i, &
6344 & j+1, k))))*gridstruct%rdy(i, j)
6370 & gridstruct, bd, npx, npy, npz, ptop, hydrostatic, a2b_ord, d_ext)
6373 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
6374 REAL,
INTENT(IN) :: dt, ptop, d_ext
6375 LOGICAL,
INTENT(IN) :: hydrostatic
6376 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6377 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
6378 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6379 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6380 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6381 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6382 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6383 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6385 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: wk
6386 REAL :: wk1(bd%is:bd%ie+1, bd%js:bd%je+1)
6387 REAL :: wk2(bd%is:bd%ie, bd%js:bd%je+1)
6390 INTEGER :: is, ie, js, je
6391 INTEGER :: isd, ied, jsd, jed
6414 IF (hydrostatic)
THEN 6425 pk(i, j, 1) = top_value
6431 IF (a2b_ord .EQ. 4)
THEN 6432 CALL a2b_ord4_fwd(pk(isd:ied, jsd:jed, k), wk, gridstruct, &
6433 & npx, npy, is, ie, js, je, ng, .true.)
6436 CALL a2b_ord2_fwd(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6437 & npy, is, ie, js, je, ng, .true.)
6444 IF (a2b_ord .EQ. 4)
THEN 6445 CALL a2b_ord4_fwd(gz(isd:ied, jsd:jed, k), wk, gridstruct, &
6446 & npx, npy, is, ie, js, je, ng, .true.)
6449 CALL a2b_ord2_fwd(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6450 & npy, is, ie, js, je, ng, .true.)
6454 IF (d_ext .GT. 0.)
THEN 6458 wk2(i, j) = divg2(i, j) - divg2(i+1, j)
6464 wk1(i, j) = divg2(i, j) - divg2(i, j+1)
6484 IF (hydrostatic)
THEN 6488 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
6492 ELSE IF (a2b_ord .EQ. 4)
THEN 6493 CALL a2b_ord4_fwd(delp(isd:ied, jsd:jed, k), wk, gridstruct, &
6494 & npx, npy, is, ie, js, je, ng)
6497 CALL a2b_ord2_fwd(delp(isd:ied, jsd:jed, k), wk, gridstruct, npx&
6498 & , npy, is, ie, js, je, ng)
6504 u(i, j, k) = gridstruct%rdx(i, j)*(wk2(i, j)+u(i, j, k)+dt/(wk&
6505 & (i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*(pk(i+1, j&
6506 & , k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*(pk(i, j, &
6507 & k+1)-pk(i+1, j, k))))
6513 v(i, j, k) = gridstruct%rdy(i, j)*(wk1(i, j)+v(i, j, k)+dt/(wk&
6514 & (i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*(pk(i, j+1&
6515 & , k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*(pk(i, j, &
6516 & k+1)-pk(i, j+1, k))))
6550 SUBROUTINE one_grad_p_bwd(u, u_ad, v, v_ad, pk, pk_ad, gz, gz_ad, &
6551 & divg2, divg2_ad, delp, delp_ad, dt, ng, gridstruct, bd, npx, npy, &
6552 & npz, ptop, hydrostatic, a2b_ord, d_ext)
6555 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
6556 REAL,
INTENT(IN) :: dt, ptop, d_ext
6557 LOGICAL,
INTENT(IN) :: hydrostatic
6558 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6559 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
6560 REAL :: divg2_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
6561 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6562 REAL,
INTENT(INOUT) :: pk_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6563 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6564 REAL,
INTENT(INOUT) :: gz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6565 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6566 REAL,
INTENT(INOUT) :: delp_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6567 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6568 REAL,
INTENT(INOUT) :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6569 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6570 REAL,
INTENT(INOUT) :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6571 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6572 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: wk
6573 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: wk_ad
6574 REAL :: wk1(bd%is:bd%ie+1, bd%js:bd%je+1)
6575 REAL :: wk1_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
6576 REAL :: wk2(bd%is:bd%ie, bd%js:bd%je+1)
6577 REAL :: wk2_ad(bd%is:bd%ie, bd%js:bd%je+1)
6580 INTEGER :: is, ie, js, je
6581 INTEGER :: isd, ied, jsd, jed
6621 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
6630 temp4 = wk(i, j) + wk(i, j+1)
6631 temp8 = pk(i, j, k+1) - pk(i, j+1, k)
6632 temp7 = gz(i, j, k) - gz(i, j+1, k+1)
6633 temp6 = pk(i, j+1, k+1) - pk(i, j, k)
6634 temp5 = gz(i, j, k+1) - gz(i, j+1, k)
6635 temp_ad2 = gridstruct%rdy(i, j)*v_ad(i, j, k)
6636 temp_ad3 = dt*temp_ad2/temp4
6637 temp_ad4 = -((temp5*temp6+temp7*temp8)*temp_ad3/temp4)
6638 wk1_ad(i, j) = wk1_ad(i, j) + temp_ad2
6639 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp6*temp_ad3
6640 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp6*temp_ad3
6641 pk_ad(i, j+1, k+1) = pk_ad(i, j+1, k+1) + temp5*temp_ad3
6642 pk_ad(i, j, k) = pk_ad(i, j, k) - temp5*temp_ad3
6643 gz_ad(i, j, k) = gz_ad(i, j, k) + temp8*temp_ad3
6644 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp8*temp_ad3
6645 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp7*temp_ad3
6646 pk_ad(i, j+1, k) = pk_ad(i, j+1, k) - temp7*temp_ad3
6647 wk_ad(i, j) = wk_ad(i, j) + temp_ad4
6648 wk_ad(i, j+1) = wk_ad(i, j+1) + temp_ad4
6649 v_ad(i, j, k) = temp_ad2
6655 temp = wk(i, j) + wk(i+1, j)
6656 temp3 = pk(i, j, k+1) - pk(i+1, j, k)
6657 temp2 = gz(i, j, k) - gz(i+1, j, k+1)
6658 temp1 = pk(i+1, j, k+1) - pk(i, j, k)
6659 temp0 = gz(i, j, k+1) - gz(i+1, j, k)
6660 temp_ad = gridstruct%rdx(i, j)*u_ad(i, j, k)
6661 temp_ad0 = dt*temp_ad/temp
6662 temp_ad1 = -((temp0*temp1+temp2*temp3)*temp_ad0/temp)
6663 wk2_ad(i, j) = wk2_ad(i, j) + temp_ad
6664 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp1*temp_ad0
6665 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp1*temp_ad0
6666 pk_ad(i+1, j, k+1) = pk_ad(i+1, j, k+1) + temp0*temp_ad0
6667 pk_ad(i, j, k) = pk_ad(i, j, k) - temp0*temp_ad0
6668 gz_ad(i, j, k) = gz_ad(i, j, k) + temp3*temp_ad0
6669 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp3*temp_ad0
6670 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp2*temp_ad0
6671 pk_ad(i+1, j, k) = pk_ad(i+1, j, k) - temp2*temp_ad0
6672 wk_ad(i, j) = wk_ad(i, j) + temp_ad1
6673 wk_ad(i+1, j) = wk_ad(i+1, j) + temp_ad1
6674 u_ad(i, j, k) = temp_ad
6678 IF (branch .EQ. 0)
THEN 6679 CALL a2b_ord2_bwd(delp(isd:ied, jsd:jed, k), delp_ad(isd:ied, &
6680 & jsd:jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie&
6682 ELSE IF (branch .EQ. 1)
THEN 6683 CALL a2b_ord4_bwd(delp(isd:ied, jsd:jed, k), delp_ad(isd:ied&
6684 & , jsd:jed, k), wk, wk_ad, gridstruct, npx, npy, &
6685 & is, ie, js, je, ng)
6690 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + wk_ad(i, j)
6691 pk_ad(i, j, k) = pk_ad(i, j, k) - wk_ad(i, j)
6698 IF (branch .NE. 0)
THEN 6701 divg2_ad(i, j) = divg2_ad(i, j) + wk1_ad(i, j)
6702 divg2_ad(i, j+1) = divg2_ad(i, j+1) - wk1_ad(i, j)
6708 divg2_ad(i, j) = divg2_ad(i, j) + wk2_ad(i, j)
6709 divg2_ad(i+1, j) = divg2_ad(i+1, j) - wk2_ad(i, j)
6716 IF (branch .EQ. 0)
THEN 6717 CALL a2b_ord2_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd:&
6718 & jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie, js&
6721 CALL a2b_ord4_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd&
6722 & :jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie&
6723 & , js, je, ng, .true.)
6728 IF (branch .EQ. 0)
THEN 6729 CALL a2b_ord2_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd:&
6730 & jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie, js&
6733 CALL a2b_ord4_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd&
6734 & :jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie&
6735 & , js, je, ng, .true.)
6741 pk_ad(i, j, 1) = 0.0
6745 SUBROUTINE one_grad_p(u, v, pk, gz, divg2, delp, dt, ng, gridstruct, &
6746 & bd, npx, npy, npz, ptop, hydrostatic, a2b_ord, d_ext)
6749 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
6750 REAL,
INTENT(IN) :: dt, ptop, d_ext
6751 LOGICAL,
INTENT(IN) :: hydrostatic
6752 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6753 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
6754 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6755 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6756 REAL,
INTENT(INOUT) :: delp(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
6757 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6758 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6759 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6761 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed) :: wk
6762 REAL :: wk1(bd%is:bd%ie+1, bd%js:bd%je+1)
6763 REAL :: wk2(bd%is:bd%ie, bd%js:bd%je+1)
6766 INTEGER :: is, ie, js, je
6767 INTEGER :: isd, ied, jsd, jed
6776 IF (hydrostatic)
THEN 6786 pk(i, j, 1) = top_value
6792 IF (a2b_ord .EQ. 4)
THEN 6793 CALL a2b_ord4(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6794 & npy, is, ie, js, je, ng, .true.)
6796 CALL a2b_ord2(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, npy&
6797 & , is, ie, js, je, ng, .true.)
6803 IF (a2b_ord .EQ. 4)
THEN 6804 CALL a2b_ord4(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6805 & npy, is, ie, js, je, ng, .true.)
6807 CALL a2b_ord2(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, npy&
6808 & , is, ie, js, je, ng, .true.)
6811 IF (d_ext .GT. 0.)
THEN 6815 wk2(i, j) = divg2(i, j) - divg2(i+1, j)
6821 wk1(i, j) = divg2(i, j) - divg2(i, j+1)
6839 IF (hydrostatic)
THEN 6842 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
6845 ELSE IF (a2b_ord .EQ. 4)
THEN 6846 CALL a2b_ord4(delp(isd:ied, jsd:jed, k), wk, gridstruct, npx&
6847 & , npy, is, ie, js, je, ng)
6849 CALL a2b_ord2(delp(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6850 & npy, is, ie, js, je, ng)
6854 u(i, j, k) = gridstruct%rdx(i, j)*(wk2(i, j)+u(i, j, k)+dt/(wk&
6855 & (i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1, j, k))*(pk(i+1, j&
6856 & , k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, j, k+1))*(pk(i, j, &
6857 & k+1)-pk(i+1, j, k))))
6862 v(i, j, k) = gridstruct%rdy(i, j)*(wk1(i, j)+v(i, j, k)+dt/(wk&
6863 & (i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j+1, k))*(pk(i, j+1&
6864 & , k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1, k+1))*(pk(i, j, &
6865 & k+1)-pk(i, j+1, k))))
6891 & gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
6894 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
6895 REAL,
INTENT(IN) :: dt, ptop, beta
6896 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
6897 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
6898 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6899 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
6900 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6901 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6902 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
6903 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
6904 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
6906 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
6907 REAL :: top_value, alpha
6909 INTEGER :: is, ie, js, je
6910 INTEGER :: isd, ied, jsd, jed
6939 pk(i, j, 1) = top_value
6945 IF (a2b_ord .EQ. 4)
THEN 6946 CALL a2b_ord4_fwd(pk(isd:ied, jsd:jed, k), wk, gridstruct, &
6947 & npx, npy, is, ie, js, je, ng, .true.)
6950 CALL a2b_ord2_fwd(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6951 & npy, is, ie, js, je, ng, .true.)
6958 IF (a2b_ord .EQ. 4)
THEN 6959 CALL a2b_ord4_fwd(gz(isd:ied, jsd:jed, k), wk, gridstruct, &
6960 & npx, npy, is, ie, js, je, ng, .true.)
6963 CALL a2b_ord2_fwd(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
6964 & npy, is, ie, js, je, ng, .true.)
6975 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
6981 u(i, j, k) = u(i, j, k) + beta*du(i, j, k)
6982 du(i, j, k) = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1&
6983 & , j, k))*(pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, &
6984 & j, k+1))*(pk(i, j, k+1)-pk(i+1, j, k)))
6985 u(i, j, k) = (u(i, j, k)+divg2(i, j)-divg2(i+1, j)+alpha*du(i&
6986 & , j, k))*gridstruct%rdx(i, j)
6992 v(i, j, k) = v(i, j, k) + beta*dv(i, j, k)
6993 dv(i, j, k) = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j&
6994 & +1, k))*(pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1&
6995 & , k+1))*(pk(i, j, k+1)-pk(i, j+1, k)))
6996 v(i, j, k) = (v(i, j, k)+divg2(i, j)-divg2(i, j+1)+alpha*dv(i&
6997 & , j, k))*gridstruct%rdy(i, j)
7033 & pk_ad, gz, gz_ad, du, du_ad, dv, dv_ad, dt, ng, gridstruct, bd, npx&
7034 & , npy, npz, ptop, beta, a2b_ord)
7037 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
7038 REAL,
INTENT(IN) :: dt, ptop, beta
7039 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7040 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
7041 REAL :: divg2_ad(bd%is:bd%ie+1, bd%js:bd%je+1)
7042 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7043 REAL,
INTENT(INOUT) :: pk_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7044 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7045 REAL,
INTENT(INOUT) :: gz_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7046 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7047 REAL,
INTENT(INOUT) :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7048 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7049 REAL,
INTENT(INOUT) :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7050 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7051 REAL,
INTENT(INOUT) :: du_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7052 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7053 REAL,
INTENT(INOUT) :: dv_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7054 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
7055 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
7056 REAL :: wk_ad(bd%isd:bd%ied, bd%jsd:bd%jed)
7057 REAL :: top_value, alpha
7059 INTEGER :: is, ie, js, je
7060 INTEGER :: isd, ied, jsd, jed
7100 CALL poprealarray(wk, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1))
7106 temp_ad2 = gridstruct%rdy(i, j)*v_ad(i, j, k)
7107 divg2_ad(i, j) = divg2_ad(i, j) + temp_ad2
7108 dv_ad(i, j, k) = dv_ad(i, j, k) + alpha*temp_ad2
7109 divg2_ad(i, j+1) = divg2_ad(i, j+1) - temp_ad2
7110 v_ad(i, j, k) = temp_ad2
7111 temp4 = wk(i, j) + wk(i, j+1)
7112 temp8 = pk(i, j, k+1) - pk(i, j+1, k)
7113 temp7 = gz(i, j, k) - gz(i, j+1, k+1)
7114 temp6 = pk(i, j+1, k+1) - pk(i, j, k)
7115 temp5 = gz(i, j, k+1) - gz(i, j+1, k)
7116 temp_ad3 = dt*dv_ad(i, j, k)/temp4
7117 temp_ad4 = -((temp5*temp6+temp7*temp8)*temp_ad3/temp4)
7118 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp6*temp_ad3
7119 gz_ad(i, j+1, k) = gz_ad(i, j+1, k) - temp6*temp_ad3
7120 pk_ad(i, j+1, k+1) = pk_ad(i, j+1, k+1) + temp5*temp_ad3
7121 pk_ad(i, j, k) = pk_ad(i, j, k) - temp5*temp_ad3
7122 gz_ad(i, j, k) = gz_ad(i, j, k) + temp8*temp_ad3
7123 gz_ad(i, j+1, k+1) = gz_ad(i, j+1, k+1) - temp8*temp_ad3
7124 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp7*temp_ad3
7125 pk_ad(i, j+1, k) = pk_ad(i, j+1, k) - temp7*temp_ad3
7126 wk_ad(i, j) = wk_ad(i, j) + temp_ad4
7127 wk_ad(i, j+1) = wk_ad(i, j+1) + temp_ad4
7128 dv_ad(i, j, k) = beta*v_ad(i, j, k)
7134 temp_ad = gridstruct%rdx(i, j)*u_ad(i, j, k)
7135 divg2_ad(i, j) = divg2_ad(i, j) + temp_ad
7136 du_ad(i, j, k) = du_ad(i, j, k) + alpha*temp_ad
7137 divg2_ad(i+1, j) = divg2_ad(i+1, j) - temp_ad
7138 u_ad(i, j, k) = temp_ad
7139 temp = wk(i, j) + wk(i+1, j)
7140 temp3 = pk(i, j, k+1) - pk(i+1, j, k)
7141 temp2 = gz(i, j, k) - gz(i+1, j, k+1)
7142 temp1 = pk(i+1, j, k+1) - pk(i, j, k)
7143 temp0 = gz(i, j, k+1) - gz(i+1, j, k)
7144 temp_ad0 = dt*du_ad(i, j, k)/temp
7145 temp_ad1 = -((temp0*temp1+temp2*temp3)*temp_ad0/temp)
7146 gz_ad(i, j, k+1) = gz_ad(i, j, k+1) + temp1*temp_ad0
7147 gz_ad(i+1, j, k) = gz_ad(i+1, j, k) - temp1*temp_ad0
7148 pk_ad(i+1, j, k+1) = pk_ad(i+1, j, k+1) + temp0*temp_ad0
7149 pk_ad(i, j, k) = pk_ad(i, j, k) - temp0*temp_ad0
7150 gz_ad(i, j, k) = gz_ad(i, j, k) + temp3*temp_ad0
7151 gz_ad(i+1, j, k+1) = gz_ad(i+1, j, k+1) - temp3*temp_ad0
7152 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp2*temp_ad0
7153 pk_ad(i+1, j, k) = pk_ad(i+1, j, k) - temp2*temp_ad0
7154 wk_ad(i, j) = wk_ad(i, j) + temp_ad1
7155 wk_ad(i+1, j) = wk_ad(i+1, j) + temp_ad1
7156 du_ad(i, j, k) = beta*u_ad(i, j, k)
7163 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + wk_ad(i, j)
7164 pk_ad(i, j, k) = pk_ad(i, j, k) - wk_ad(i, j)
7171 IF (branch .EQ. 0)
THEN 7172 CALL a2b_ord2_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd:&
7173 & jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie, js&
7176 CALL a2b_ord4_bwd(gz(isd:ied, jsd:jed, k), gz_ad(isd:ied, jsd&
7177 & :jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie&
7178 & , js, je, ng, .true.)
7183 IF (branch .EQ. 0)
THEN 7184 CALL a2b_ord2_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd:&
7185 & jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie, js&
7188 CALL a2b_ord4_bwd(pk(isd:ied, jsd:jed, k), pk_ad(isd:ied, jsd&
7189 & :jed, k), wk, wk_ad, gridstruct, npx, npy, is, ie&
7190 & , js, je, ng, .true.)
7196 pk_ad(i, j, 1) = 0.0
7201 & gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
7204 INTEGER,
INTENT(IN) :: ng, npx, npy, npz, a2b_ord
7205 REAL,
INTENT(IN) :: dt, ptop, beta
7206 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7207 REAL,
INTENT(IN) :: divg2(bd%is:bd%ie+1, bd%js:bd%je+1)
7208 REAL,
INTENT(INOUT) :: pk(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7209 REAL,
INTENT(INOUT) :: gz(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1)
7210 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7211 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7212 REAL,
INTENT(INOUT) :: du(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
7213 REAL,
INTENT(INOUT) :: dv(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
7214 TYPE(FV_GRID_TYPE),
INTENT(INOUT),
TARGET :: gridstruct
7216 REAL :: wk(bd%isd:bd%ied, bd%jsd:bd%jed)
7217 REAL :: top_value, alpha
7219 INTEGER :: is, ie, js, je
7220 INTEGER :: isd, ied, jsd, jed
7235 pk(i, j, 1) = top_value
7241 IF (a2b_ord .EQ. 4)
THEN 7242 CALL a2b_ord4(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
7243 & npy, is, ie, js, je, ng, .true.)
7245 CALL a2b_ord2(pk(isd:ied, jsd:jed, k), wk, gridstruct, npx, npy&
7246 & , is, ie, js, je, ng, .true.)
7252 IF (a2b_ord .EQ. 4)
THEN 7253 CALL a2b_ord4(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, &
7254 & npy, is, ie, js, je, ng, .true.)
7256 CALL a2b_ord2(gz(isd:ied, jsd:jed, k), wk, gridstruct, npx, npy&
7257 & , is, ie, js, je, ng, .true.)
7266 wk(i, j) = pk(i, j, k+1) - pk(i, j, k)
7271 u(i, j, k) = u(i, j, k) + beta*du(i, j, k)
7272 du(i, j, k) = dt/(wk(i, j)+wk(i+1, j))*((gz(i, j, k+1)-gz(i+1&
7273 & , j, k))*(pk(i+1, j, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i+1, &
7274 & j, k+1))*(pk(i, j, k+1)-pk(i+1, j, k)))
7275 u(i, j, k) = (u(i, j, k)+divg2(i, j)-divg2(i+1, j)+alpha*du(i&
7276 & , j, k))*gridstruct%rdx(i, j)
7281 v(i, j, k) = v(i, j, k) + beta*dv(i, j, k)
7282 dv(i, j, k) = dt/(wk(i, j)+wk(i, j+1))*((gz(i, j, k+1)-gz(i, j&
7283 & +1, k))*(pk(i, j+1, k+1)-pk(i, j, k))+(gz(i, j, k)-gz(i, j+1&
7284 & , k+1))*(pk(i, j, k+1)-pk(i, j+1, k)))
7285 v(i, j, k) = (v(i, j, k)+divg2(i, j)-divg2(i, j+1)+alpha*dv(i&
7286 & , j, k))*gridstruct%rdy(i, j)
7311 SUBROUTINE mix_dp_fwd(hydrostatic, w, delp, pt, km, ak, bk, cg, &
7315 INTEGER,
INTENT(IN) :: km
7316 REAL,
INTENT(IN) :: ak(km+1), bk(km+1)
7317 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7318 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7320 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7322 LOGICAL,
INTENT(IN) :: hydrostatic, cg, fv_debug
7325 INTEGER :: i, j, k, ip
7326 INTEGER :: ifirst, ilast
7327 INTEGER :: jfirst, jlast
7328 INTEGER :: is, ie, js, je
7329 INTEGER :: isd, ied, jsd, jed
7370 dpmin = 0.01*(ak(k+1)-ak(k)+(bk(k+1)-bk(k))*1.e5)
7372 IF (delp(i, j, k) .LT. dpmin)
THEN 7376 dp = dpmin - delp(i, j, k)
7378 pt(i, j, k) = (pt(i, j, k)*delp(i, j, k)+pt(i, j, k+1)*dp)/&
7380 IF (.NOT.hydrostatic)
THEN 7382 w(i, j, k) = (w(i, j, k)*delp(i, j, k)+w(i, j, k+1)*dp)/&
7389 delp(i, j, k) = dpmin
7391 delp(i, j, k+1) = delp(i, j, k+1) - dp
7401 dpmin = 0.01*(ak(km+1)-ak(km)+(bk(km+1)-bk(km))*1.e5)
7403 IF (delp(i, j, km) .LT. dpmin)
THEN 7407 dp = dpmin - delp(i, j, km)
7409 pt(i, j, km) = (pt(i, j, km)*delp(i, j, km)+pt(i, j, km-1)*dp)&
7411 IF (.NOT.hydrostatic)
THEN 7413 w(i, j, km) = (w(i, j, km)*delp(i, j, km)+w(i, j, km-1)*dp)/&
7420 delp(i, j, km) = dpmin
7422 delp(i, j, km-1) = delp(i, j, km-1) - dp
7429 IF (fv_debug .AND. ip .NE. 0)
THEN 7432 WRITE(*, *)
'Warning: Mix_dp', res, j, ip
7463 SUBROUTINE mix_dp_bwd(hydrostatic, w, w_ad, delp, delp_ad, pt, pt_ad, &
7464 & km, ak, bk, cg, fv_debug, bd)
7467 INTEGER,
INTENT(IN) :: km
7468 REAL,
INTENT(IN) :: ak(km+1), bk(km+1)
7469 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7470 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7472 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7474 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7476 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7478 LOGICAL,
INTENT(IN) :: hydrostatic, cg, fv_debug
7481 INTEGER :: i, j, k, ip
7482 INTEGER :: ifirst, ilast
7483 INTEGER :: jfirst, jlast
7484 INTEGER :: is, ie, js, je
7485 INTEGER :: isd, ied, jsd, jed
7513 DO j=jlast,jfirst,-1
7515 dpmin = 0.01*(ak(km+1)-ak(km)+(bk(km+1)-bk(km))*1.e5)
7516 DO i=ilast,ifirst,-1
7518 IF (branch .NE. 0)
THEN 7520 dp_ad = -delp_ad(i, j, km-1)
7522 delp_ad(i, j, km) = 0.0
7524 IF (branch .EQ. 0)
THEN 7526 temp_ad2 = w_ad(i, j, km)/dpmin
7527 delp_ad(i, j, km) = delp_ad(i, j, km) + w(i, j, km)*temp_ad2
7528 w_ad(i, j, km-1) = w_ad(i, j, km-1) + dp*temp_ad2
7529 dp_ad = dp_ad + w(i, j, km-1)*temp_ad2
7530 w_ad(i, j, km) = delp(i, j, km)*temp_ad2
7533 temp_ad1 = pt_ad(i, j, km)/dpmin
7534 pt_ad(i, j, km-1) = pt_ad(i, j, km-1) + dp*temp_ad1
7535 dp_ad = dp_ad + pt(i, j, km-1)*temp_ad1
7536 delp_ad(i, j, km) = delp_ad(i, j, km) + pt(i, j, km)*temp_ad1 &
7538 pt_ad(i, j, km) = delp(i, j, km)*temp_ad1
7544 DO i=ilast,ifirst,-1
7546 IF (branch .NE. 0)
THEN 7548 dp_ad = -delp_ad(i, j, k+1)
7550 delp_ad(i, j, k) = 0.0
7552 IF (branch .EQ. 0)
THEN 7554 temp_ad0 = w_ad(i, j, k)/dpmin
7555 delp_ad(i, j, k) = delp_ad(i, j, k) + w(i, j, k)*temp_ad0
7556 w_ad(i, j, k+1) = w_ad(i, j, k+1) + dp*temp_ad0
7557 dp_ad = dp_ad + w(i, j, k+1)*temp_ad0
7558 w_ad(i, j, k) = delp(i, j, k)*temp_ad0
7561 temp_ad = pt_ad(i, j, k)/dpmin
7562 pt_ad(i, j, k+1) = pt_ad(i, j, k+1) + dp*temp_ad
7563 dp_ad = dp_ad + pt(i, j, k+1)*temp_ad
7564 delp_ad(i, j, k) = delp_ad(i, j, k) + pt(i, j, k)*temp_ad - &
7566 pt_ad(i, j, k) = delp(i, j, k)*temp_ad
7574 SUBROUTINE mix_dp(hydrostatic, w, delp, pt, km, ak, bk, cg, fv_debug, &
7578 INTEGER,
INTENT(IN) :: km
7579 REAL,
INTENT(IN) :: ak(km+1), bk(km+1)
7580 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7581 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7583 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(INOUT) :: &
7585 LOGICAL,
INTENT(IN) :: hydrostatic, cg, fv_debug
7588 INTEGER :: i, j, k, ip
7589 INTEGER :: ifirst, ilast
7590 INTEGER :: jfirst, jlast
7591 INTEGER :: is, ie, js, je
7592 INTEGER :: isd, ied, jsd, jed
7618 dpmin = 0.01*(ak(k+1)-ak(k)+(bk(k+1)-bk(k))*1.e5)
7620 IF (delp(i, j, k) .LT. dpmin)
THEN 7623 dp = dpmin - delp(i, j, k)
7624 pt(i, j, k) = (pt(i, j, k)*delp(i, j, k)+pt(i, j, k+1)*dp)/&
7626 IF (.NOT.hydrostatic) w(i, j, k) = (w(i, j, k)*delp(i, j, k)&
7627 & +w(i, j, k+1)*dp)/dpmin
7628 delp(i, j, k) = dpmin
7629 delp(i, j, k+1) = delp(i, j, k+1) - dp
7635 dpmin = 0.01*(ak(km+1)-ak(km)+(bk(km+1)-bk(km))*1.e5)
7637 IF (delp(i, j, km) .LT. dpmin)
THEN 7640 dp = dpmin - delp(i, j, km)
7641 pt(i, j, km) = (pt(i, j, km)*delp(i, j, km)+pt(i, j, km-1)*dp)&
7643 IF (.NOT.hydrostatic) w(i, j, km) = (w(i, j, km)*delp(i, j, km&
7644 & )+w(i, j, km-1)*dp)/dpmin
7645 delp(i, j, km) = dpmin
7646 delp(i, j, km-1) = delp(i, j, km-1) - dp
7650 IF (fv_debug .AND. ip .NE. 0)
WRITE(*, *)
'Warning: Mix_dp', &
7674 SUBROUTINE geopk_fwd(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz&
7675 & , km, akap, cg, nested, computehalo, npx, npy, a2b_ord, bd)
7677 INTEGER,
INTENT(IN) :: km, npx, npy, a2b_ord
7678 REAL,
INTENT(IN) :: akap, ptop
7679 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7680 REAL,
INTENT(IN) :: hs(bd%isd:bd%ied, bd%jsd:bd%jed)
7681 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: pt&
7683 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: &
7685 LOGICAL,
INTENT(IN) :: cg, nested, computehalo
7687 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km+1) :: gz, pk
7688 REAL :: pe(bd%is-1:bd%ie+1, km+1, bd%js-1:bd%je+1)
7690 REAL :: peln(bd%is:bd%ie, km+1, bd%js:bd%je)
7691 REAL :: pkz(bd%is:bd%ie, bd%js:bd%je, km)
7695 REAL :: peg(bd%isd:bd%ied, km+1)
7696 REAL :: pkg(bd%isd:bd%ied, km+1)
7697 REAL(kind=8) :: p1d(bd%isd:bd%ied)
7698 REAL(kind=8) :: g1d(bd%isd:bd%ied)
7699 REAL :: logp(bd%isd:bd%ied)
7701 INTEGER :: ifirst, ilast
7702 INTEGER :: jfirst, jlast
7703 INTEGER :: is, ie, js, je
7704 INTEGER :: isd, ied, jsd, jed
7747 IF ((.NOT.cg .AND. a2b_ord .EQ. 4) .OR. (nested .AND. (.NOT.cg))) &
7760 IF (nested .AND. computehalo)
THEN 7761 IF (is .EQ. 1) ifirst = isd
7762 IF (ie .EQ. npx - 1) ilast = ied
7763 IF (js .EQ. 1) jfirst = jsd
7764 IF (je .EQ. npy - 1)
THEN 7784 gz(i, j, km+1) = hs(i, j)
7786 IF (j .GE. js .AND. j .LE. je)
THEN 7789 peln(i, 1, j) =
peln1 7795 IF (j .GT. js - 2 .AND. j .LT. je + 2)
THEN 7796 IF (ifirst .LT. is - 1)
THEN 7801 IF (ilast .GT. ie + 1)
THEN 7821 p1d(i) = p1d(i) + delp(i, j, k-1)
7823 logp(i) = log(p1d(i))
7825 pk(i, j, k) = exp(akap*logp(i))
7827 IF (j .GT. js - 2 .AND. j .LT. je + 2)
THEN 7828 IF (ifirst .LT. is - 1)
THEN 7833 IF (ilast .GT. ie + 1)
THEN 7841 pe(i, k, j) = p1d(i)
7845 IF (j .GE. js .AND. j .LE. je)
THEN 7848 peln(i, k, j) = logp(i)
7861 g1d(i) = g1d(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k&
7864 gz(i, j, k) = g1d(i)
7867 IF (.NOT.cg .AND. j .GE. js .AND. j .LE. je)
THEN 7871 pkz(i, j, k) = (pk(i, j, k+1)-pk(i, j, k))/(akap*(peln(i, k+&
7872 & 1, j)-peln(i, k, j)))
7909 SUBROUTINE geopk_bwd(ptop, pe, pe_ad, peln, peln_ad, delp, delp_ad, pk&
7910 & , pk_ad, gz, gz_ad, hs, pt, pt_ad, q_con, pkz, pkz_ad, km, akap, cg&
7911 & , nested, computehalo, npx, npy, a2b_ord, bd)
7913 INTEGER,
INTENT(IN) :: km, npx, npy, a2b_ord
7914 REAL,
INTENT(IN) :: akap, ptop
7915 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
7916 REAL,
INTENT(IN) :: hs(bd%isd:bd%ied, bd%jsd:bd%jed)
7917 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: pt&
7919 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km) :: pt_ad, delp_ad
7920 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: &
7922 LOGICAL,
INTENT(IN) :: cg, nested, computehalo
7923 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km+1) :: gz, pk
7924 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km+1) :: gz_ad, pk_ad
7925 REAL :: pe(bd%is-1:bd%ie+1, km+1, bd%js-1:bd%je+1)
7926 REAL :: pe_ad(bd%is-1:bd%ie+1, km+1, bd%js-1:bd%je+1)
7927 REAL :: peln(bd%is:bd%ie, km+1, bd%js:bd%je)
7928 REAL :: peln_ad(bd%is:bd%ie, km+1, bd%js:bd%je)
7929 REAL :: pkz(bd%is:bd%ie, bd%js:bd%je, km)
7930 REAL :: pkz_ad(bd%is:bd%ie, bd%js:bd%je, km)
7931 REAL :: peg(bd%isd:bd%ied, km+1)
7932 REAL :: pkg(bd%isd:bd%ied, km+1)
7933 REAL(kind=8) :: p1d(bd%isd:bd%ied)
7934 REAL(kind=8) :: p1d_ad(bd%isd:bd%ied)
7935 REAL(kind=8) :: g1d(bd%isd:bd%ied)
7936 REAL(kind=8) :: g1d_ad(bd%isd:bd%ied)
7937 REAL :: logp(bd%isd:bd%ied)
7938 REAL :: logp_ad(bd%isd:bd%ied)
7940 INTEGER :: ifirst, ilast
7941 INTEGER :: jfirst, jlast
7942 INTEGER :: is, ie, js, je
7943 INTEGER :: isd, ied, jsd, jed
7999 DO j=jlast,jfirst,-1
8001 IF (branch .EQ. 0)
THEN 8005 temp = akap*(peln(i, k+1, j)-peln(i, k, j))
8006 temp_ad0 = pkz_ad(i, j, k)/temp
8007 temp_ad1 = -((pk(i, j, k+1)-pk(i, j, k))*akap*temp_ad0/temp)
8008 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp_ad0
8009 pk_ad(i, j, k) = pk_ad(i, j, k) - temp_ad0
8010 peln_ad(i, k+1, j) = peln_ad(i, k+1, j) + temp_ad1
8011 peln_ad(i, k, j) = peln_ad(i, k, j) - temp_ad1
8012 pkz_ad(i, j, k) = 0.0
8017 DO i=ilast,ifirst,-1
8019 g1d_ad(i) = g1d_ad(i) + gz_ad(i, j, k)
8020 gz_ad(i, j, k) = 0.0
8021 temp_ad =
cp_air*pt(i, j, k)*g1d_ad(i)
8022 pt_ad(i, j, k) = pt_ad(i, j, k) +
cp_air*(pk(i, j, k+1)-pk(i, &
8024 pk_ad(i, j, k+1) = pk_ad(i, j, k+1) + temp_ad
8025 pk_ad(i, j, k) = pk_ad(i, j, k) - temp_ad
8030 IF (branch .NE. 0)
THEN 8031 IF (branch .NE. 1)
THEN 8034 logp_ad(i) = logp_ad(i) + peln_ad(i, k, j)
8035 peln_ad(i, k, j) = 0.0
8040 DO i=ad_to0,ad_from0,-1
8042 p1d_ad(i) = p1d_ad(i) + pe_ad(i, k, j)
8043 pe_ad(i, k, j) = 0.0
8046 DO i=ilast,ifirst,-1
8048 logp_ad(i) = logp_ad(i) + exp(akap*logp(i))*akap*pk_ad(i, j, k&
8050 pk_ad(i, j, k) = 0.0
8052 p1d_ad(i) = p1d_ad(i) + logp_ad(i)/p1d(i)
8055 delp_ad(i, j, k-1) = delp_ad(i, j, k-1) + p1d_ad(i)
8059 IF (branch .NE. 0)
THEN 8062 DO i=ad_to,ad_from,-1
8064 pe_ad(i, 1, j) = 0.0
8068 IF (branch .EQ. 0)
THEN 8071 peln_ad(i, 1, j) = 0.0
8074 DO i=ilast,ifirst,-1
8076 gz_ad(i, j, km+1) = 0.0
8079 pk_ad(i, j, 1) = 0.0
8086 SUBROUTINE geopk(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz, km&
8087 & , akap, cg, nested, computehalo, npx, npy, a2b_ord, bd)
8089 INTEGER,
INTENT(IN) :: km, npx, npy, a2b_ord
8090 REAL,
INTENT(IN) :: akap, ptop
8091 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
8092 REAL,
INTENT(IN) :: hs(bd%isd:bd%ied, bd%jsd:bd%jed)
8093 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: pt&
8095 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km),
INTENT(IN) :: &
8097 LOGICAL,
INTENT(IN) :: cg, nested, computehalo
8099 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, km+1),
INTENT(OUT) :: &
8101 REAL,
INTENT(OUT) :: pe(bd%is-1:bd%ie+1, km+1, bd%js-1:bd%je+1)
8103 REAL,
INTENT(OUT) :: peln(bd%is:bd%ie, km+1, bd%js:bd%je)
8104 REAL,
INTENT(OUT) :: pkz(bd%is:bd%ie, bd%js:bd%je, km)
8108 REAL :: peg(bd%isd:bd%ied, km+1)
8109 REAL :: pkg(bd%isd:bd%ied, km+1)
8110 REAL(kind=8) :: p1d(bd%isd:bd%ied)
8111 REAL(kind=8) :: g1d(bd%isd:bd%ied)
8112 REAL :: logp(bd%isd:bd%ied)
8114 INTEGER :: ifirst, ilast
8115 INTEGER :: jfirst, jlast
8116 INTEGER :: is, ie, js, je
8117 INTEGER :: isd, ied, jsd, jed
8134 IF ((.NOT.cg .AND. a2b_ord .EQ. 4) .OR. (nested .AND. (.NOT.cg))) &
8147 IF (nested .AND. computehalo)
THEN 8148 IF (is .EQ. 1) ifirst = isd
8149 IF (ie .EQ. npx - 1) ilast = ied
8150 IF (js .EQ. 1) jfirst = jsd
8151 IF (je .EQ. npy - 1) jlast = jed
8161 gz(i, j, km+1) = hs(i, j)
8163 IF (j .GE. js .AND. j .LE. je)
THEN 8165 peln(i, 1, j) =
peln1 8168 IF (j .GT. js - 2 .AND. j .LT. je + 2)
THEN 8169 IF (ifirst .LT. is - 1)
THEN 8174 IF (ilast .GT. ie + 1)
THEN 8186 p1d(i) = p1d(i) + delp(i, j, k-1)
8187 logp(i) = log(p1d(i))
8188 pk(i, j, k) = exp(akap*logp(i))
8190 IF (j .GT. js - 2 .AND. j .LT. je + 2)
THEN 8191 IF (ifirst .LT. is - 1)
THEN 8196 IF (ilast .GT. ie + 1)
THEN 8202 pe(i, k, j) = p1d(i)
8204 IF (j .GE. js .AND. j .LE. je)
THEN 8206 peln(i, k, j) = logp(i)
8214 g1d(i) = g1d(i) +
cp_air*pt(i, j, k)*(pk(i, j, k+1)-pk(i, j, k&
8216 gz(i, j, k) = g1d(i)
8219 IF (.NOT.cg .AND. j .GE. js .AND. j .LE. je)
THEN 8222 pkz(i, j, k) = (pk(i, j, k+1)-pk(i, j, k))/(akap*(peln(i, k+&
8223 & 1, j)-peln(i, k, j)))
8228 END SUBROUTINE geopk 8249 SUBROUTINE del2_cubed_fwd(q, cd, gridstruct, domain, npx, npy, km, &
8255 INTEGER,
INTENT(IN) :: npx, npy, km, nmax
8257 REAL(kind=r_grid),
INTENT(IN) :: cd
8258 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
8259 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km)
8260 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
8261 TYPE(DOMAIN2D),
INTENT(INOUT) :: domain
8262 REAL,
PARAMETER :: r3=1./3.
8263 REAL :: fx(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy(bd%isd:bd%ied, bd%jsd&
8265 REAL :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
8266 INTEGER :: i, j, k, n, nt, ntimes
8267 INTEGER :: is, ie, js, je
8268 INTEGER :: isd, ied, jsd, jed
8323 IF (3 .GT. nmax)
THEN 8328 CALL pushrealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*km)
8337 IF (gridstruct%sw_corner)
THEN 8338 q(1, 1, k) = (q(1, 1, k)+q(0, 1, k)+q(1, 0, k))*r3
8339 q(0, 1, k) = q(1, 1, k)
8340 q(1, 0, k) = q(1, 1, k)
8345 IF (gridstruct%se_corner)
THEN 8346 tmp0 = (q(ie, 1, k)+q(npx, 1, k)+q(ie, 0, k))*r3
8350 q(ie, 0, k) = q(ie, 1, k)
8355 IF (gridstruct%ne_corner)
THEN 8356 tmp3 = (q(ie, je, k)+q(npx, je, k)+q(ie, npy, k))*r3
8359 q(npx, je, k) = tmp2
8361 q(ie, npy, k) = tmp1
8366 IF (gridstruct%nw_corner)
THEN 8367 tmp5 = (q(1, je, k)+q(0, je, k)+q(1, npy, k))*r3
8369 q(0, je, k) = q(1, je, k)
8377 CALL copy_corners(q(isd:ied, jsd:jed, k), npx, npy, 1, &
8378 & gridstruct%nested, bd, gridstruct%sw_corner, &
8379 & gridstruct%se_corner, gridstruct%nw_corner, &
8380 & gridstruct%ne_corner)
8388 DO i=ad_from,ie+1+nt
8389 fx(i, j) = gridstruct%del6_v(i, j)*(q(i-1, j, k)-q(i, j, k))
8397 CALL copy_corners(q(isd:ied, jsd:jed, k), npx, npy, 2, &
8398 & gridstruct%nested, bd, gridstruct%sw_corner, &
8399 & gridstruct%se_corner, gridstruct%nw_corner, &
8400 & gridstruct%ne_corner)
8406 DO j=ad_from2,je+1+nt
8409 fy(i, j) = gridstruct%del6_u(i, j)*(q(i, j-1, k)-q(i, j, k))
8420 q(i, j, k) = q(i, j, k) + cd*gridstruct%rarea(i, j)*(fx(i, j&
8421 & )-fx(i+1, j)+fy(i, j)-fy(i, j+1))
8458 SUBROUTINE del2_cubed_bwd(q, q_ad, cd, gridstruct, domain, npx, npy, &
8461 INTEGER,
INTENT(IN) :: npx, npy, km, nmax
8462 REAL(kind=r_grid),
INTENT(IN) :: cd
8464 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km)
8465 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, km)
8467 TYPE(
domain2d),
INTENT(INOUT) :: domain
8468 REAL,
PARAMETER :: r3=1./3.
8469 REAL :: fx(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy(bd%isd:bd%ied, bd%jsd&
8471 REAL :: fx_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy_ad(bd%isd:bd%ied, &
8473 REAL :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
8474 INTEGER :: i, j, k, n, nt, ntimes
8475 INTEGER :: is, ie, js, je
8476 INTEGER :: isd, ied, jsd, jed
8546 DO j=ad_to4,ad_from4,-1
8549 DO i=ad_to3,ad_from3,-1
8550 temp_ad5 = cd*gridstruct%rarea(i, j)*q_ad(i, j, k)
8551 fx_ad(i, j) = fx_ad(i, j) + temp_ad5
8552 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad5
8553 fy_ad(i, j) = fy_ad(i, j) + temp_ad5
8554 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad5
8559 DO j=ad_to2,ad_from2,-1
8562 DO i=ad_to1,ad_from1,-1
8563 temp_ad4 = gridstruct%del6_u(i, j)*fy_ad(i, j)
8564 q_ad(i, j-1, k) = q_ad(i, j-1, k) + temp_ad4
8565 q_ad(i, j, k) = q_ad(i, j, k) - temp_ad4
8571 & , q_ad(isd:ied, jsd:jed, k), &
8572 & npx, npy, 2, gridstruct%&
8573 & nested, bd, gridstruct%&
8574 & sw_corner, gridstruct%&
8575 & se_corner, gridstruct%&
8576 & nw_corner, gridstruct%&
8580 DO j=ad_to0,ad_from0,-1
8583 DO i=ad_to,ad_from,-1
8584 temp_ad3 = gridstruct%del6_v(i, j)*fx_ad(i, j)
8585 q_ad(i-1, j, k) = q_ad(i-1, j, k) + temp_ad3
8586 q_ad(i, j, k) = q_ad(i, j, k) - temp_ad3
8592 & , q_ad(isd:ied, jsd:jed, k), &
8593 & npx, npy, 1, gridstruct%&
8594 & nested, bd, gridstruct%&
8595 & sw_corner, gridstruct%&
8596 & se_corner, gridstruct%&
8597 & nw_corner, gridstruct%&
8600 IF (branch .EQ. 0)
THEN 8601 tmp_ad4 = q_ad(1, npy, k)
8602 q_ad(1, npy, k) = 0.0
8603 q_ad(1, je, k) = q_ad(1, je, k) + q_ad(0, je, k) + tmp_ad4
8604 q_ad(0, je, k) = 0.0
8605 tmp_ad5 = q_ad(1, je, k)
8606 temp_ad2 = r3*tmp_ad5
8607 q_ad(1, je, k) = temp_ad2
8608 q_ad(0, je, k) = q_ad(0, je, k) + temp_ad2
8609 q_ad(1, npy, k) = q_ad(1, npy, k) + temp_ad2
8612 IF (branch .EQ. 0)
THEN 8613 tmp_ad1 = q_ad(ie, npy, k)
8614 q_ad(ie, npy, k) = 0.0
8615 q_ad(ie, je, k) = q_ad(ie, je, k) + tmp_ad1
8616 tmp_ad2 = q_ad(npx, je, k)
8617 q_ad(npx, je, k) = 0.0
8618 q_ad(ie, je, k) = q_ad(ie, je, k) + tmp_ad2
8619 tmp_ad3 = q_ad(ie, je, k)
8620 temp_ad1 = r3*tmp_ad3
8621 q_ad(ie, je, k) = temp_ad1
8622 q_ad(npx, je, k) = q_ad(npx, je, k) + temp_ad1
8623 q_ad(ie, npy, k) = q_ad(ie, npy, k) + temp_ad1
8626 IF (branch .EQ. 0)
THEN 8627 q_ad(ie, 1, k) = q_ad(ie, 1, k) + q_ad(ie, 0, k)
8628 q_ad(ie, 0, k) = 0.0
8629 tmp_ad = q_ad(npx, 1, k)
8630 q_ad(npx, 1, k) = 0.0
8631 q_ad(ie, 1, k) = q_ad(ie, 1, k) + tmp_ad
8632 tmp_ad0 = q_ad(ie, 1, k)
8633 temp_ad0 = r3*tmp_ad0
8634 q_ad(ie, 1, k) = temp_ad0
8635 q_ad(npx, 1, k) = q_ad(npx, 1, k) + temp_ad0
8636 q_ad(ie, 0, k) = q_ad(ie, 0, k) + temp_ad0
8639 IF (branch .EQ. 0)
THEN 8640 q_ad(1, 1, k) = q_ad(1, 1, k) + q_ad(1, 0, k)
8642 q_ad(1, 1, k) = q_ad(1, 1, k) + q_ad(0, 1, k)
8644 temp_ad = r3*q_ad(1, 1, k)
8645 q_ad(0, 1, k) = q_ad(0, 1, k) + temp_ad
8646 q_ad(1, 0, k) = q_ad(1, 0, k) + temp_ad
8647 q_ad(1, 1, k) = temp_ad
8651 CALL poprealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*km)
8654 SUBROUTINE del2_cubed(q, cd, gridstruct, domain, npx, npy, km, nmax, &
8660 INTEGER,
INTENT(IN) :: npx, npy, km, nmax
8662 REAL(kind=r_grid),
INTENT(IN) :: cd
8664 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, km)
8666 TYPE(
domain2d),
INTENT(INOUT) :: domain
8667 REAL,
PARAMETER :: r3=1./3.
8668 REAL :: fx(bd%isd:bd%ied+1, bd%jsd:bd%jed), fy(bd%isd:bd%ied, bd%jsd&
8670 REAL :: q2(bd%isd:bd%ied, bd%jsd:bd%jed)
8671 INTEGER :: i, j, k, n, nt, ntimes
8672 INTEGER :: is, ie, js, je
8673 INTEGER :: isd, ied, jsd, jed
8687 IF (3 .GT. nmax)
THEN 8702 IF (gridstruct%sw_corner)
THEN 8703 q(1, 1, k) = (q(1, 1, k)+q(0, 1, k)+q(1, 0, k))*r3
8704 q(0, 1, k) = q(1, 1, k)
8705 q(1, 0, k) = q(1, 1, k)
8707 IF (gridstruct%se_corner)
THEN 8708 q(ie, 1, k) = (q(ie, 1, k)+q(npx, 1, k)+q(ie, 0, k))*r3
8709 q(npx, 1, k) = q(ie, 1, k)
8710 q(ie, 0, k) = q(ie, 1, k)
8712 IF (gridstruct%ne_corner)
THEN 8713 q(ie, je, k) = (q(ie, je, k)+q(npx, je, k)+q(ie, npy, k))*r3
8714 q(npx, je, k) = q(ie, je, k)
8715 q(ie, npy, k) = q(ie, je, k)
8717 IF (gridstruct%nw_corner)
THEN 8718 q(1, je, k) = (q(1, je, k)+q(0, je, k)+q(1, npy, k))*r3
8719 q(0, je, k) = q(1, je, k)
8720 q(1, npy, k) = q(1, je, k)
8722 IF (nt .GT. 0)
CALL copy_corners(q(isd:ied, jsd:jed, k), npx, &
8723 & npy, 1, gridstruct%nested, bd, &
8724 & gridstruct%sw_corner, gridstruct%&
8725 & se_corner, gridstruct%nw_corner, &
8726 & gridstruct%ne_corner)
8729 fx(i, j) = gridstruct%del6_v(i, j)*(q(i-1, j, k)-q(i, j, k))
8732 IF (nt .GT. 0)
CALL copy_corners(q(isd:ied, jsd:jed, k), npx, &
8733 & npy, 2, gridstruct%nested, bd, &
8734 & gridstruct%sw_corner, gridstruct%&
8735 & se_corner, gridstruct%nw_corner, &
8736 & gridstruct%ne_corner)
8739 fy(i, j) = gridstruct%del6_u(i, j)*(q(i, j-1, k)-q(i, j, k))
8744 q(i, j, k) = q(i, j, k) + cd*gridstruct%rarea(i, j)*(fx(i, j&
8745 & )-fx(i+1, j)+fy(i, j)-fy(i, j+1))
8751 SUBROUTINE init_ijk_mem(i1, i2, j1, j2, km, array, var)
8753 INTEGER,
INTENT(IN) :: i1, i2, j1, j2, km
8754 REAL,
INTENT(INOUT) :: array(i1:i2, j1:j2, km)
8755 REAL,
INTENT(IN) :: var
8761 array(i, j, k) = var
8766 SUBROUTINE rayleigh_fast(dt, npx, npy, npz, pfull, tau, u, v, w, ptop&
8767 & , hydrostatic, rf_cutoff, bd)
8770 REAL,
INTENT(IN) :: dt
8772 REAL,
INTENT(IN) :: tau
8773 REAL,
INTENT(IN) :: ptop, rf_cutoff
8774 INTEGER,
INTENT(IN) :: npx, npy, npz
8775 REAL,
DIMENSION(npz),
INTENT(IN) :: pfull
8776 LOGICAL,
INTENT(IN) :: hydrostatic
8779 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, npz)
8781 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, npz)
8783 REAL,
INTENT(INOUT) :: w(bd%isd:, bd%jsd:, :)
8785 REAL(kind=r_grid) :: rff(npz)
8786 REAL,
PARAMETER :: sday=86400.
8789 INTEGER :: is, ie, js, je
8790 INTEGER :: isd, ied, jsd, jed
8806 IF (is_master())
WRITE(6, *) &
8807 &
'Fast Rayleigh friction E-folding time (days):' 8809 IF (pfull(k) .LT. rf_cutoff)
THEN 8810 rff(k) = dt/tau0*sin(0.5*
pi*log(rf_cutoff/pfull(k))/log(&
8811 & rf_cutoff/ptop))**2
8815 rff(k) = 1.d0/(1.0d0+rff(k))
8825 IF (pfull(k) .LT. rf_cutoff)
THEN 8828 u(i, j, k) = rf(k)*u(i, j, k)
8833 v(i, j, k) = rf(k)*v(i, j, k)
8836 IF (.NOT.hydrostatic)
THEN 8839 w(i, j, k) = rf(k)*w(i, j, k)
8847
subroutine, public nested_grid_bc_apply_intt(var_nest, istag, jstag, npx, npy, npz, bd, step, split, bc, bctype)
real, parameter, public radius
Radius of the Earth [m].
subroutine one_grad_p_fwd(u, v, pk, gz, divg2, delp, dt, ng, gridstruct, bd, npx, npy, npz, ptop, hydrostatic, a2b_ord, d_ext)
subroutine, public a2b_ord2_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine p_grad_c_fwd(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, rdyc, hydrostatic)
subroutine grad1_p_update_bwd(divg2, divg2_ad, u, u_ad, v, v_ad, pk, pk_ad, gz, gz_ad, du, du_ad, dv, dv_ad, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
subroutine geopk_fwd(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz, km, akap, cg, nested, computehalo, npx, npy, a2b_ord, bd)
subroutine grad1_p_update(divg2, u, v, pk, gz, du, dv, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
subroutine geopk(ptop, pe, peln, delp, pk, gz, hs, pt, q_con, pkz, km, akap, cg, nested, computehalo, npx, npy, a2b_ord, bd)
subroutine mix_dp_fwd(hydrostatic, w, delp, pt, km, ak, bk, cg, fv_debug, bd)
subroutine, public a2b_ord4(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine, public del2_cubed(q, cd, gridstruct, domain, npx, npy, km, nmax, bd)
subroutine, public case9_forcing1(phis, time_since_start)
subroutine, public del2_cubed_bwd(q, q_ad, cd, gridstruct, domain, npx, npy, km, nmax, bd)
subroutine, public a2b_ord2_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
subroutine grad1_p_update_fwd(divg2, u, v, pk, gz, du, dv, dt, ng, gridstruct, bd, npx, npy, npz, ptop, beta, a2b_ord)
subroutine p_grad_c_bwd(dt2, npz, delpc, delpc_ad, pkc, pkc_ad, gz, gz_ad, uc, uc_ad, vc, vc_ad, bd, rdxc, rdyc, hydrostatic)
subroutine, public c_sw_fwd(delpc, delp, ptc, pt, u, v, w, uc, vc, ua, va, wc, ut, vt, divg_d, nord, dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
integer, parameter, public corner
subroutine, public case9_forcing2(phis)
subroutine, public nested_grid_bc_apply_intt_adm(var_nest, var_nest_ad, istag, jstag, npx, npy, npz, bd, step, split, bc, bctype)
subroutine adv_pe_bwd(ua, ua_ad, va, va_ad, pem, pem_ad, om, om_ad, gridstruct, bd, npx, npy, npz, ng)
subroutine, public pushcontrol(ctype, field)
subroutine, public copy_corners(q, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine pln_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3, delp)
subroutine pe_halo_fwd(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 split_p_grad_bwd(u, u_ad, v, v_ad, pp, pp_ad, gz, gz_ad, du, du_ad, dv, dv_ad, delp, delp_ad, pk, pk_ad, beta, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine mix_dp(hydrostatic, w, delp, pt, km, ak, bk, cg, fv_debug, bd)
subroutine adv_pe(ua, va, pem, om, gridstruct, bd, npx, npy, npz, ng)
subroutine, public dyn_core_bwd(npx, npy, npz, ng, sphum, nq, bdt, n_split, zvir, cp, akap, cappa, grav, hydrostatic, u, u_ad, v, v_ad, w, w_ad, delz, delz_ad, pt, pt_ad, q, q_ad, delp, delp_ad, pe, pe_ad, pk, pk_ad, phis, ws, ws_ad, omga, omga_ad, ptop, pfull, ua, ua_ad, va, va_ad, uc, uc_ad, vc, vc_ad, mfx, mfx_ad, mfy, mfy_ad, cx, cx_ad, cy, cy_ad, pkz, pkz_ad, peln, peln_ad, q_con, ak, bk, dpx, dpx_ad, ks, gridstruct, flagstruct, flagstructp, neststruct, idiag, bd, domain, init_step, i_pack, end_step, gz, gz_ad, pkc, pkc_ad, ptc, ptc_ad, crx, crx_ad, xfx, xfx_ad, cry, cry_ad, yfx, yfx_ad, divgd, divgd_ad, delpc, delpc_ad, ut, ut_ad, vt, vt_ad, zh, zh_ad, pk3, pk3_ad, du, du_ad, dv, dv_ad, time_total)
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)
subroutine pe_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, delp)
subroutine pk3_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap, pk3, pk3_ad, delp, delp_ad)
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 pln_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3, pk3_ad, delp, delp_ad)
subroutine, public c_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, wc, wc_ad, ut, ut_ad, vt, vt_ad, divg_d, divg_d_ad, nord, dt2, hydrostatic, dord4, bd, gridstruct, flagstruct)
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)
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)
subroutine, public a2b_ord4_bwd(qin, qin_ad, qout, qout_ad, gridstruct, npx, npy, is, ie, js, je, ng, replace)
real, parameter, public pi
Ratio of circle circumference to diameter [N/A].
subroutine, public riem_solver3_fwd(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)
subroutine timing_on(blk_name)
subroutine mix_dp_bwd(hydrostatic, w, w_ad, delp, delp_ad, pt, pt_ad, km, ak, bk, cg, fv_debug, bd)
subroutine nh_p_grad_bwd(u, u_ad, v, v_ad, pp, pp_ad, gz, gz_ad, delp, delp_ad, pk, pk_ad, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine pk3_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap, pk3, delp)
subroutine, public init_ijk_mem(i1, i2, j1, j2, km, array, var)
subroutine, public riem_solver3_bwd(ms, dt, is, ie, js, je, km, ng, isd, ied, jsd, jed, akap, cappa, cp, ptop, zs, q_con, w, w_ad, delz, delz_ad, pt, pt_ad, delp, delp_ad, zh, zh_ad, pe, pe_ad, ppe, ppe_ad, pk3, pk3_ad, pk, pk_ad, peln, peln_ad, ws, ws_ad, scale_m, p_fac, a_imp, use_logp, last_call, fp_out)
integer, parameter, public r_grid
logical, public do_adiabatic_init
subroutine nh_p_grad(u, v, pp, gz, delp, pk, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine split_p_grad_fwd(u, v, pp, gz, du, dv, delp, pk, beta, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine, public complete_group_halo_update(group, groupp, domain)
subroutine rayleigh_fast(dt, npx, npy, npz, pfull, tau, u, v, w, ptop, hydrostatic, rf_cutoff, bd)
subroutine p_grad_c(dt2, npz, delpc, pkc, gz, uc, vc, bd, rdxc, rdyc, hydrostatic)
subroutine, public dyn_core_fwd(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, flagstructp, neststruct, idiag, bd, domain, init_step, i_pack, end_step, gz, pkc, ptc, crx, xfx, cry, yfx, divgd, delpc, ut, vt, zh, pk3, du, dv, time_total)
subroutine, public d_sw_bwd(delpc, delpc_ad, delp, delp_ad, ptc, ptc_ad, pt, pt_ad, u, u_ad, v, v_ad, w, w_ad, uc, uc_ad, vc, vc_ad, ua, ua_ad, va, va_ad, divg_d, divg_d_ad, xflux, xflux_ad, yflux, yflux_ad, cx, cx_ad, cy, cy_ad, crx_adv, crx_adv_ad, cry_adv, cry_adv_ad, xfx_adv, xfx_adv_ad, yfx_adv, yfx_adv_ad, q_con, z_rat, z_rat_ad, kgb, heat_source, heat_source_ad, dpx, dpx_ad, zvir, sphum, nq, q, q_ad, 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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
subroutine geopk_bwd(ptop, pe, pe_ad, peln, peln_ad, delp, delp_ad, pk, pk_ad, gz, gz_ad, hs, pt, pt_ad, q_con, pkz, pkz_ad, km, akap, cg, nested, computehalo, npx, npy, a2b_ord, bd)
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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
real(kind=r_grid), parameter cnst_0p20
subroutine, public d_sw_fwd(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, hord_tr_pert, hord_mt_pert, hord_vt_pert, hord_tm_pert, hord_dp_pert, split_damp, nord_pert, nord_v_pert, nord_w_pert, nord_t_pert, dddmp_pert, d2_bg_pert, d4_bg_pert, damp_v_pert, damp_w_pert, damp_t_pert)
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_adm(q, q_ad, npx, npy, dir, nested, bd, sw_corner, se_corner, nw_corner, ne_corner)
subroutine split_p_grad(u, v, pp, gz, du, dv, delp, pk, beta, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine, public prt_maxmin(qname, q, is, ie, js, je, n_g, km, fac)
integer, public test_case
subroutine adv_pe_fwd(ua, va, pem, om, gridstruct, bd, npx, npy, npz, ng)
subroutine, public extrapolation_bc(q, istag, jstag, npx, npy, bd, pd_in, debug_in)
subroutine nh_p_grad_fwd(u, v, pp, gz, delp, pk, dt, ng, gridstruct, bd, npx, npy, npz, use_logp)
subroutine one_grad_p_bwd(u, u_ad, v, v_ad, pk, pk_ad, gz, gz_ad, divg2, divg2_ad, delp, delp_ad, dt, ng, gridstruct, bd, npx, npy, npz, ptop, hydrostatic, a2b_ord, d_ext)
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 del2_cubed_fwd(q, cd, gridstruct, domain, npx, npy, km, nmax, bd)
subroutine, public popcontrol(ctype, field)
type(time_type), public fv_time
subroutine pln_halo_fwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pk3, delp)
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, flagstructp, neststruct, idiag, bd, domain, init_step, i_pack, end_step, gz, pkc, ptc, crx, xfx, cry, yfx, divgd, delpc, ut, vt, zh, pk3, du, dv, time_total)
subroutine pe_halo_bwd(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, pe, pe_ad, delp, delp_ad)
subroutine timing_off(blk_name)
subroutine pk3_halo(is, ie, js, je, isd, ied, jsd, jed, npz, ptop, akap, pk3, delp)
subroutine, public a2b_ord4_fwd(qin, qout, gridstruct, npx, npy, is, ie, js, je, ng, replace)