From 943ca3b61ec4f7298b0e90c5ecf30ab81ba80d32 Mon Sep 17 00:00:00 2001 From: tcclevenger Date: Fri, 30 Aug 2024 10:15:33 -0600 Subject: [PATCH 1/3] view alloc fixes for P3 small kernels --- .../src/physics/p3/disp/p3_main_impl_disp.cpp | 185 ++++++++++-------- .../physics/p3/eamxx_p3_process_interface.cpp | 124 +++++++++--- .../physics/p3/eamxx_p3_process_interface.hpp | 24 ++- .../eamxx/src/physics/p3/eamxx_p3_run.cpp | 6 +- .../src/physics/p3/impl/p3_main_impl.hpp | 30 +-- .../eamxx/src/physics/p3/p3_functions.hpp | 43 ++++ .../eamxx/src/physics/p3/p3_functions_f90.cpp | 37 +++- 7 files changed, 322 insertions(+), 127 deletions(-) diff --git a/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp index d20350b0788..0f125b7ae96 100644 --- a/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp @@ -32,16 +32,16 @@ ::p3_main_init_disp( const uview_2d& qv_supersat_i, const uview_2d& qtend_ignore, const uview_2d& ntend_ignore, const uview_2d& mu_c, const uview_2d& lamc, const uview_2d& rho_qi, const uview_2d& qv2qi_depos_tend, const uview_2d& precip_total_tend, const uview_2d& nevapr, const uview_2d& precip_liq_flux, const uview_2d& precip_ice_flux) -{ +{ using ExeSpace = typename KT::ExeSpace; const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(nj, nk_pack); Kokkos::parallel_for("p3_main_init", policy, KOKKOS_LAMBDA(const MemberType& team) { - - const Int i = team.league_rank(); - precip_liq_surf(i) = 0; - precip_ice_surf(i) = 0; + + const Int i = team.league_rank(); + precip_liq_surf(i) = 0; + precip_ice_surf(i) = 0; Kokkos::parallel_for( Kokkos::TeamVectorRange(team, nk_pack), [&] (Int k) { @@ -107,6 +107,7 @@ ::p3_main_internal_disp( const P3Infrastructure& infrastructure, const P3HistoryOnly& history_only, const P3LookupTables& lookup_tables, + const P3Temporaries& temporaries, const WorkspaceManager& workspace_mgr, Int nj, Int nk, @@ -131,87 +132,99 @@ ::p3_main_internal_disp( view_1d nucleationPossible("nucleationPossible", nj); view_1d hydrometeorsPresent("hydrometeorsPresent", nj); - // - // Create temporary variables needed for p3 - // - view_2d - mu_r("mu_r", nj, nk_pack), // shape parameter of rain - T_atm("T_atm", nj, nk_pack), // temperature at the beginning of the microphysics step [K] - - // 2D size distribution and fallspeed parameters - lamr("lamr", nj, nk_pack), logn0r("logn0r", nj, nk_pack), nu("nu", nj, nk_pack), - cdist("cdist", nj, nk_pack), cdist1("cdist1", nj, nk_pack), cdistr("cdistr", nj, nk_pack), - - // Variables needed for in-cloud calculations - // Inverse cloud fractions (1/cld) - inv_cld_frac_i("inv_cld_frac_i", nj, nk_pack), inv_cld_frac_l("inv_cld_frac_l", nj, nk_pack), inv_cld_frac_r("inv_cld_frac_r", nj, nk_pack), - // In cloud mass-mixing ratios - qc_incld("qc_incld", nj, nk_pack), qr_incld("qr_incld", nj, nk_pack), qi_incld("qi_incld", nj, nk_pack), qm_incld("qm_incld", nj, nk_pack), - // In cloud number concentrations - nc_incld("nc_incld", nj, nk_pack), nr_incld("nr_incld", nj, nk_pack), ni_incld("ni_incld", nj, nk_pack), bm_incld("bm_incld", nj, nk_pack), - - // Other - inv_dz("inv_dz", nj, nk_pack), inv_rho("inv_rho", nj, nk_pack), ze_ice("ze_ice", nj, nk_pack), ze_rain("ze_rain", nj, nk_pack), - prec("prec", nj, nk_pack), rho("rho", nj, nk_pack), rhofacr("rhofacr", nj, nk_pack), rhofaci("rhofaci", nj, nk_pack), - acn("acn", nj, nk_pack), qv_sat_l("qv_sat", nj, nk_pack), qv_sat_i("qv_sat_i", nj, nk_pack), sup("sup", nj, nk_pack), - qv_supersat_i("qv_supersat", nj, nk_pack), tmparr2("tmparr2", nj, nk_pack), exner("exner", nj, nk_pack), - diag_equiv_reflectivity("diag_equiv_ref", nj, nk_pack), diag_vm_qi("diag_vm_qi", nj, nk_pack), diag_diam_qi("diag_diam_qi", nj, nk_pack), - pratot("pratot", nj, nk_pack), prctot("prctot", nj, nk_pack), - - // p3_tend_out, may not need these - qtend_ignore("qtend_ignore", nj, nk_pack), ntend_ignore("ntend_ignore", nj, nk_pack), - - // Variables still used in F90 but removed from C++ interface - mu_c("mu_c", nj, nk_pack), lamc("lamc", nj, nk_pack), - qr_evap_tend("qr_evap_tend", nj, nk_pack), - - // cloud sedimentation - v_qc("v_qc", nj, nk_pack), v_nc("v_nc", nj, nk_pack), flux_qx("flux_qx", nj, nk_pack), flux_nx("flux_nx", nj, nk_pack), - - // ice sedimentation - v_qit("v_qit", nj, nk_pack), v_nit("v_nit", nj, nk_pack), flux_nit("flux_nit", nj, nk_pack), flux_bir("flux_bir", nj, nk_pack), - flux_qir("flux_qir", nj, nk_pack), flux_qit("flux_qit", nj, nk_pack), - - // rain sedimentation - v_qr("v_qr", nj, nk_pack), v_nr("v_nr", nj, nk_pack); - // Get views of all inputs - auto pres = diagnostic_inputs.pres; - auto dz = diagnostic_inputs.dz; - auto nc_nuceat_tend = diagnostic_inputs.nc_nuceat_tend; - auto nccn_prescribed = diagnostic_inputs.nccn; - auto ni_activated = diagnostic_inputs.ni_activated; - auto inv_qc_relvar = diagnostic_inputs.inv_qc_relvar; - auto dpres = diagnostic_inputs.dpres; - auto inv_exner = diagnostic_inputs.inv_exner; - auto cld_frac_i = diagnostic_inputs.cld_frac_i; - auto cld_frac_l = diagnostic_inputs.cld_frac_l; - auto cld_frac_r = diagnostic_inputs.cld_frac_r; - auto col_location = infrastructure.col_location; - auto qc = prognostic_state.qc; - auto nc = prognostic_state.nc; - auto qr = prognostic_state.qr; - auto nr = prognostic_state.nr; - auto qi = prognostic_state.qi; - auto qm = prognostic_state.qm; - auto ni = prognostic_state.ni; - auto bm = prognostic_state.bm; - auto qv = prognostic_state.qv; - auto th = prognostic_state.th; - auto diag_eff_radius_qc = diagnostic_outputs.diag_eff_radius_qc; - auto diag_eff_radius_qi = diagnostic_outputs.diag_eff_radius_qi; - auto diag_eff_radius_qr = diagnostic_outputs.diag_eff_radius_qr; - auto qv2qi_depos_tend = diagnostic_outputs.qv2qi_depos_tend; - auto rho_qi = diagnostic_outputs.rho_qi; - auto precip_liq_flux = diagnostic_outputs.precip_liq_flux; - auto precip_ice_flux = diagnostic_outputs.precip_ice_flux; - auto precip_total_tend = diagnostic_outputs.precip_total_tend; - auto nevapr = diagnostic_outputs.nevapr; - auto qv_prev = diagnostic_inputs.qv_prev; - auto t_prev = diagnostic_inputs.t_prev; - auto liq_ice_exchange = history_only.liq_ice_exchange; - auto vap_liq_exchange = history_only.vap_liq_exchange; - auto vap_ice_exchange = history_only.vap_ice_exchange; + auto pres = diagnostic_inputs.pres; + auto dz = diagnostic_inputs.dz; + auto nc_nuceat_tend = diagnostic_inputs.nc_nuceat_tend; + auto nccn_prescribed = diagnostic_inputs.nccn; + auto ni_activated = diagnostic_inputs.ni_activated; + auto inv_qc_relvar = diagnostic_inputs.inv_qc_relvar; + auto dpres = diagnostic_inputs.dpres; + auto inv_exner = diagnostic_inputs.inv_exner; + auto cld_frac_i = diagnostic_inputs.cld_frac_i; + auto cld_frac_l = diagnostic_inputs.cld_frac_l; + auto cld_frac_r = diagnostic_inputs.cld_frac_r; + auto col_location = infrastructure.col_location; + auto qc = prognostic_state.qc; + auto nc = prognostic_state.nc; + auto qr = prognostic_state.qr; + auto nr = prognostic_state.nr; + auto qi = prognostic_state.qi; + auto qm = prognostic_state.qm; + auto ni = prognostic_state.ni; + auto bm = prognostic_state.bm; + auto qv = prognostic_state.qv; + auto th = prognostic_state.th; + auto diag_eff_radius_qc = diagnostic_outputs.diag_eff_radius_qc; + auto diag_eff_radius_qi = diagnostic_outputs.diag_eff_radius_qi; + auto diag_eff_radius_qr = diagnostic_outputs.diag_eff_radius_qr; + auto qv2qi_depos_tend = diagnostic_outputs.qv2qi_depos_tend; + auto rho_qi = diagnostic_outputs.rho_qi; + auto precip_liq_flux = diagnostic_outputs.precip_liq_flux; + auto precip_ice_flux = diagnostic_outputs.precip_ice_flux; + auto precip_total_tend = diagnostic_outputs.precip_total_tend; + auto nevapr = diagnostic_outputs.nevapr; + auto qv_prev = diagnostic_inputs.qv_prev; + auto t_prev = diagnostic_inputs.t_prev; + auto liq_ice_exchange = history_only.liq_ice_exchange; + auto vap_liq_exchange = history_only.vap_liq_exchange; + auto vap_ice_exchange = history_only.vap_ice_exchange; + auto mu_r = temporaries.mu_r; + auto T_atm = temporaries.T_atm; + auto lamr = temporaries.lamr; + auto logn0r = temporaries.logn0r; + auto nu = temporaries.nu; + auto cdist = temporaries.cdist; + auto cdist1 = temporaries.cdist1; + auto cdistr = temporaries.cdistr; + auto inv_cld_frac_i = temporaries.inv_cld_frac_i; + auto inv_cld_frac_l = temporaries.inv_cld_frac_l; + auto inv_cld_frac_r = temporaries.inv_cld_frac_r; + auto qc_incld = temporaries.qc_incld; + auto qr_incld = temporaries.qr_incld; + auto qi_incld = temporaries.qi_incld; + auto qm_incld = temporaries.qm_incld; + auto nc_incld = temporaries.nc_incld; + auto nr_incld = temporaries.nr_incld; + auto ni_incld = temporaries.ni_incld; + auto bm_incld = temporaries.bm_incld; + auto inv_dz = temporaries.inv_dz; + auto inv_rho = temporaries.inv_rho; + auto ze_ice = temporaries.ze_ice; + auto ze_rain = temporaries.ze_rain; + auto prec = temporaries.prec; + auto rho = temporaries.rho; + auto rhofacr = temporaries.rhofacr; + auto rhofaci = temporaries.rhofaci; + auto acn = temporaries.acn; + auto qv_sat_l = temporaries.qv_sat_l; + auto qv_sat_i = temporaries.qv_sat_i; + auto sup = temporaries.sup; + auto qv_supersat_i = temporaries.qv_supersat_i; + auto tmparr2 = temporaries.tmparr2; + auto exner = temporaries.exner; + auto diag_equiv_reflectivity = temporaries.diag_equiv_reflectivity; + auto diag_vm_qi = temporaries.diag_vm_qi; + auto diag_diam_qi = temporaries.diag_diam_qi; + auto pratot = temporaries.pratot; + auto prctot = temporaries.prctot; + auto qtend_ignore = temporaries.qtend_ignore; + auto ntend_ignore = temporaries.ntend_ignore; + auto mu_c = temporaries.mu_c; + auto lamc = temporaries.lamc; + auto qr_evap_tend = temporaries.qr_evap_tend; + auto v_qc = temporaries.v_qc; + auto v_nc = temporaries.v_nc; + auto flux_qx = temporaries.flux_qx; + auto flux_nx = temporaries.flux_nx; + auto v_qit = temporaries.v_qit; + auto v_nit = temporaries.v_nit; + auto flux_nit = temporaries.flux_nit; + auto flux_bir = temporaries.flux_bir; + auto flux_qir = temporaries.flux_qir; + auto flux_qit = temporaries.flux_qit; + auto v_qr = temporaries.v_qr; + auto v_nr = temporaries.v_nr; // we do not want to measure init stuff auto start = std::chrono::steady_clock::now(); @@ -242,7 +255,7 @@ ::p3_main_internal_disp( p3_main_part2_disp( nj, nk, runtime_options.max_total_ni, infrastructure.predictNc, infrastructure.prescribedCCN, infrastructure.dt, inv_dt, - lookup_tables.dnu_table_vals, lookup_tables.ice_table_vals, lookup_tables.collect_table_vals, + lookup_tables.dnu_table_vals, lookup_tables.ice_table_vals, lookup_tables.collect_table_vals, lookup_tables.revap_table_vals, pres, dpres, dz, nc_nuceat_tend, inv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, inv_cld_frac_r, ni_activated, inv_qc_relvar, cld_frac_i, cld_frac_l, cld_frac_r, qv_prev, t_prev, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, diff --git a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp index acaecd7eef7..c414d7093f6 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp @@ -152,10 +152,14 @@ void P3Microphysics::init_buffers(const ATMBufferManager &buffer_manager) Real* mem = reinterpret_cast(buffer_manager.get_memory()); // 1d scalar views - m_buffer.precip_liq_surf_flux = decltype(m_buffer.precip_liq_surf_flux)(mem, m_num_cols); - mem += m_buffer.precip_liq_surf_flux.size(); - m_buffer.precip_ice_surf_flux = decltype(m_buffer.precip_ice_surf_flux)(mem, m_num_cols); - mem += m_buffer.precip_ice_surf_flux.size(); + using scalar_1d_view_t = decltype(m_buffer.precip_liq_surf_flux); + scalar_1d_view_t* _1d_scalar_view_ptrs[Buffer::num_1d_scalar] = { + &m_buffer.precip_liq_surf_flux, &m_buffer.precip_ice_surf_flux + }; + for (int i=0; isize(); + } // 2d scalar views m_buffer.col_location = decltype(m_buffer.col_location)(mem, m_num_cols, 3); @@ -167,26 +171,38 @@ void P3Microphysics::init_buffers(const ATMBufferManager &buffer_manager) const Int nk_pack = ekat::npack(m_num_levs); const Int nk_pack_p1 = ekat::npack(m_num_levs+1); - m_buffer.inv_exner = decltype(m_buffer.inv_exner)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.inv_exner.size(); - m_buffer.th_atm = decltype(m_buffer.th_atm)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.th_atm.size(); - m_buffer.cld_frac_l = decltype(m_buffer.cld_frac_l)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.cld_frac_l.size(); - m_buffer.cld_frac_i = decltype(m_buffer.cld_frac_i)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.cld_frac_i.size(); - m_buffer.dz = decltype(m_buffer.dz)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.dz.size(); - m_buffer.qv2qi_depos_tend = decltype(m_buffer.qv2qi_depos_tend)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.qv2qi_depos_tend.size(); - m_buffer.rho_qi = decltype(m_buffer.rho_qi)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.rho_qi.size(); - m_buffer.precip_liq_flux = decltype(m_buffer.precip_liq_flux)(s_mem, m_num_cols, nk_pack_p1); - s_mem += m_buffer.precip_liq_flux.size(); - m_buffer.precip_ice_flux = decltype(m_buffer.precip_ice_flux)(s_mem, m_num_cols, nk_pack_p1); - s_mem += m_buffer.precip_ice_flux.size(); - m_buffer.unused = decltype(m_buffer.unused)(s_mem, m_num_cols, nk_pack); - s_mem += m_buffer.unused.size(); + using spack_2d_view_t = decltype(m_buffer.inv_exner); + spack_2d_view_t* _2d_spack_mid_view_ptrs[Buffer::num_2d_vector] = { + &m_buffer.inv_exner, &m_buffer.th_atm, &m_buffer.cld_frac_l, &m_buffer.cld_frac_i, + &m_buffer.dz, &m_buffer.qv2qi_depos_tend, &m_buffer.rho_qi, &m_buffer.unused +#ifdef SCREAM_P3_SMALL_KERNELS + , &m_buffer.mu_r, &m_buffer.T_atm, &m_buffer.lamr, &m_buffer.logn0r, &m_buffer.nu, + &m_buffer.cdist, &m_buffer.cdist1, &m_buffer.cdistr, &m_buffer.inv_cld_frac_i, + &m_buffer.inv_cld_frac_l, &m_buffer.inv_cld_frac_r, &m_buffer.qc_incld, &m_buffer.qr_incld, + &m_buffer.qi_incld, &m_buffer.qm_incld, &m_buffer.nc_incld, &m_buffer.nr_incld, + &m_buffer.ni_incld, &m_buffer.bm_incld, &m_buffer.inv_dz, &m_buffer.inv_rho, &m_buffer.ze_ice, + &m_buffer.ze_rain, &m_buffer.prec, &m_buffer.rho, &m_buffer.rhofacr, &m_buffer.rhofaci, + &m_buffer.acn, &m_buffer.qv_sat_l, &m_buffer.qv_sat_i, &m_buffer.sup, &m_buffer.qv_supersat_i, + &m_buffer.tmparr2, &m_buffer.exner, &m_buffer.diag_equiv_reflectivity, &m_buffer.diag_vm_qi, + &m_buffer.diag_diam_qi, &m_buffer.pratot, &m_buffer.prctot, &m_buffer.qtend_ignore, + &m_buffer.ntend_ignore, &m_buffer.mu_c, &m_buffer.lamc, &m_buffer.qr_evap_tend, &m_buffer.v_qc, + &m_buffer.v_nc, &m_buffer.flux_qx, &m_buffer.flux_nx, &m_buffer.v_qit, &m_buffer.v_nit, + &m_buffer.flux_nit, &m_buffer.flux_bir, &m_buffer.flux_qir, &m_buffer.flux_qit, &m_buffer.v_qr, + &m_buffer.v_nr +#endif + }; + for (int i=0; isize(); + } + + spack_2d_view_t* _2d_spack_int_view_ptrs[Buffer::num_2dp1_vector] = { + &m_buffer.precip_liq_flux, &m_buffer.precip_ice_flux + }; + for (int i=0; isize(); + } // WSM data m_buffer.wsm_data = s_mem; @@ -324,6 +340,66 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */) history_only.liq_ice_exchange = get_field_out("micro_liq_ice_exchange").get_view(); history_only.vap_liq_exchange = get_field_out("micro_vap_liq_exchange").get_view(); history_only.vap_ice_exchange = get_field_out("micro_vap_ice_exchange").get_view(); +#ifdef SCREAM_P3_SMALL_KERNELS + // Temporaries + temporaries.mu_r = m_buffer.mu_r; + temporaries.T_atm = m_buffer.T_atm; + temporaries.lamr = m_buffer.lamr; + temporaries.logn0r = m_buffer.logn0r; + temporaries.nu = m_buffer.nu; + temporaries.cdist = m_buffer.cdist; + temporaries.cdist1 = m_buffer.cdist1; + temporaries.cdistr = m_buffer.cdistr; + temporaries.inv_cld_frac_i = m_buffer.inv_cld_frac_i; + temporaries.inv_cld_frac_l = m_buffer.inv_cld_frac_l; + temporaries.inv_cld_frac_r = m_buffer.inv_cld_frac_r; + temporaries.qc_incld = m_buffer.qc_incld; + temporaries.qr_incld = m_buffer.qr_incld; + temporaries.qi_incld = m_buffer.qi_incld; + temporaries.qm_incld = m_buffer.qm_incld; + temporaries.nc_incld = m_buffer.nc_incld; + temporaries.nr_incld = m_buffer.nr_incld; + temporaries.ni_incld = m_buffer.ni_incld; + temporaries.bm_incld = m_buffer.bm_incld; + temporaries.inv_dz = m_buffer.inv_dz; + temporaries.inv_rho = m_buffer.inv_rho; + temporaries.ze_ice = m_buffer.ze_ice; + temporaries.ze_rain = m_buffer.ze_rain; + temporaries.prec = m_buffer.prec; + temporaries.rho = m_buffer.rho; + temporaries.rhofacr = m_buffer.rhofacr; + temporaries.rhofaci = m_buffer.rhofaci; + temporaries.acn = m_buffer.acn; + temporaries.qv_sat_l = m_buffer.qv_sat_l; + temporaries.qv_sat_i = m_buffer.qv_sat_i; + temporaries.sup = m_buffer.sup; + temporaries.qv_supersat_i = m_buffer.qv_supersat_i; + temporaries.tmparr2 = m_buffer.tmparr2; + temporaries.exner = m_buffer.exner; + temporaries.diag_equiv_reflectivity = m_buffer.diag_equiv_reflectivity; + temporaries.diag_vm_qi = m_buffer.diag_vm_qi; + temporaries.diag_diam_qi = m_buffer.diag_diam_qi; + temporaries.pratot = m_buffer.pratot; + temporaries.prctot = m_buffer.prctot; + temporaries.qtend_ignore = m_buffer.qtend_ignore; + temporaries.ntend_ignore = m_buffer.ntend_ignore; + temporaries.mu_c = m_buffer.mu_c; + temporaries.lamc = m_buffer.lamc; + temporaries.qr_evap_tend = m_buffer.qr_evap_tend; + temporaries.v_qc = m_buffer.v_qc; + temporaries.v_nc = m_buffer.v_nc; + temporaries.flux_qx = m_buffer.flux_qx; + temporaries.flux_nx = m_buffer.flux_nx; + temporaries.v_qit = m_buffer.v_qit; + temporaries.v_nit = m_buffer.v_nit; + temporaries.flux_nit = m_buffer.flux_nit; + temporaries.flux_bir = m_buffer.flux_bir; + temporaries.flux_qir = m_buffer.flux_qir; + temporaries.flux_qit = m_buffer.flux_qit; + temporaries.v_qr = m_buffer.v_qr; + temporaries.v_nr = m_buffer.v_nr; +#endif + // -- Set values for the post-amble structure p3_postproc.set_variables(m_num_cols,nk_pack, prog_state.th,pmid,pmid_dry,T_atm,t_prev, diff --git a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp index 47d543ded02..32e3b76d1a0 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp @@ -158,7 +158,7 @@ class P3Microphysics : public AtmosphereProcess // Assigning local variables void set_variables(const int ncol, const int npack, const view_2d_const& pmid_, const view_2d_const& pmid_dry_, - const view_2d_const& pseudo_density_, + const view_2d_const& pseudo_density_, const view_2d_const& pseudo_density_dry_, const view_2d& T_atm_, const view_2d_const& cld_frac_t_, const view_2d& qv_, const view_2d& qc_, const view_2d& nc_, const view_2d& qr_, const view_2d& nr_, const view_2d& qi_, @@ -361,7 +361,11 @@ class P3Microphysics : public AtmosphereProcess // 1d view scalar, size (ncol) static constexpr int num_1d_scalar = 2; //no 2d vars now, but keeping 1d struct for future expansion // 2d view packed, size (ncol, nlev_packs) +#ifdef SCREAM_P3_SMALL_KERNELS + static constexpr int num_2d_vector = 64; +#else static constexpr int num_2d_vector = 8; +#endif static constexpr int num_2dp1_vector = 2; uview_1d precip_liq_surf_flux; @@ -377,6 +381,21 @@ class P3Microphysics : public AtmosphereProcess uview_2d precip_ice_flux; //nlev+1 uview_2d unused; +#ifdef SCREAM_P3_SMALL_KERNELS + uview_2d + mu_r, T_atm, lamr, logn0r, nu, cdist, cdist1, cdistr, + inv_cld_frac_i, inv_cld_frac_l, inv_cld_frac_r, + qc_incld, qr_incld, qi_incld, qm_incld, + nc_incld, nr_incld, ni_incld, bm_incld, + inv_dz, inv_rho, ze_ice, ze_rain, prec, rho, rhofacr, + rhofaci, acn, qv_sat_l, qv_sat_i, sup, qv_supersat_i, + tmparr2, exner, diag_equiv_reflectivity, diag_vm_qi, + diag_diam_qi, pratot, prctot, qtend_ignore, ntend_ignore, + mu_c, lamc, qr_evap_tend, v_qc, v_nc, flux_qx, flux_nx, + v_qit, v_nit, flux_nit, flux_bir, flux_qir, flux_qit, + v_qr, v_nr; +#endif + suview_2d col_location; Spack* wsm_data; @@ -410,6 +429,9 @@ class P3Microphysics : public AtmosphereProcess P3F::P3DiagnosticOutputs diag_outputs; P3F::P3HistoryOnly history_only; P3F::P3LookupTables lookup_tables; +#ifdef SCREAM_P3_SMALL_KERNELS + P3F::P3Temporaries temporaries; +#endif P3F::P3Infrastructure infrastructure; P3F::P3Runtime runtime_options; p3_preamble p3_preproc; diff --git a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp index 9ccfdaf2022..cdb156d71f6 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp @@ -29,7 +29,11 @@ void P3Microphysics::run_impl (const double dt) get_field_out("micro_vap_ice_exchange").deep_copy(0.0); P3F::p3_main(runtime_options, prog_state, diag_inputs, diag_outputs, infrastructure, - history_only, lookup_tables, workspace_mgr, m_num_cols, m_num_levs, m_p3constants); + history_only, lookup_tables, +#ifdef SCREAM_P3_SMALL_KERNELS + temporaries, +#endif + workspace_mgr, m_num_cols, m_num_levs, m_p3constants); // Conduct the post-processing of the p3_main output. Kokkos::parallel_for( diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp index c98a37d0557..270042c9998 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp @@ -162,10 +162,10 @@ ::p3_main_internal( &inv_dz, &inv_rho, &ze_ice, &ze_rain, &prec, &rho, &rhofacr, &rhofaci, &acn, &qv_sat_l, &qv_sat_i, &sup, &qv_supersat_i, &tmparr1, &exner, &diag_equiv_reflectivity, &diag_vm_qi, &diag_diam_qi, - &pratot, &prctot, &qtend_ignore, &ntend_ignore, + &pratot, &prctot, &qtend_ignore, &ntend_ignore, &mu_c, &lamc, &qr_evap_tend }); - + // Get single-column subviews of all inputs, shouldn't need any i-indexing // after this. const auto opres = ekat::subview(diagnostic_inputs.pres, i); @@ -344,22 +344,15 @@ ::p3_main( const P3Infrastructure& infrastructure, const P3HistoryOnly& history_only, const P3LookupTables& lookup_tables, +#ifdef SCREAM_P3_SMALL_KERNELS + const P3Temporaries& temporaries, +#endif const WorkspaceManager& workspace_mgr, Int nj, Int nk, const physics::P3_Constants & p3constants) { -#ifndef SCREAM_P3_SMALL_KERNELS - return p3_main_internal(runtime_options, - prognostic_state, - diagnostic_inputs, - diagnostic_outputs, - infrastructure, - history_only, - lookup_tables, - workspace_mgr, - nj, nk, p3constants); -#else +#ifdef SCREAM_P3_SMALL_KERNELS return p3_main_internal_disp(runtime_options, prognostic_state, diagnostic_inputs, @@ -367,8 +360,19 @@ ::p3_main( infrastructure, history_only, lookup_tables, + temporaries, workspace_mgr, nj, nk, p3constants); +#else + return p3_main_internal(runtime_options, + prognostic_state, + diagnostic_inputs, + diagnostic_outputs, + infrastructure, + history_only, + lookup_tables, + workspace_mgr, + nj, nk, p3constants); #endif } } // namespace p3 diff --git a/components/eamxx/src/physics/p3/p3_functions.hpp b/components/eamxx/src/physics/p3/p3_functions.hpp index 3a5218f5c00..791538d67dc 100644 --- a/components/eamxx/src/physics/p3/p3_functions.hpp +++ b/components/eamxx/src/physics/p3/p3_functions.hpp @@ -246,6 +246,45 @@ struct Functions view_dnu_table dnu_table_vals; }; +#ifdef SCREAM_P3_SMALL_KERNELS + struct P3Temporaries { + P3Temporaries() = default; + // shape parameter of rain + view_2d mu_r; + // temperature at the beginning of the microphysics step [K] + view_2d T_atm; + // 2D size distribution and fallspeed parameters + view_2d lamr, logn0r, nu; + view_2d cdist, cdist1, cdistr; + // Variables needed for in-cloud calculations + // Inverse cloud fractions (1/cld) + view_2d inv_cld_frac_i, inv_cld_frac_l, inv_cld_frac_r; + // In cloud mass-mixing ratios + view_2d qc_incld, qr_incld, qi_incld, qm_incld; + // In cloud number concentrations + view_2d nc_incld, nr_incld, ni_incld, bm_incld; + // Other + view_2d inv_dz, inv_rho, ze_ice, ze_rain; + view_2d prec, rho, rhofacr, rhofaci; + view_2d acn, qv_sat_l, qv_sat_i, sup; + view_2d qv_supersat_i, tmparr2, exner; + view_2d diag_equiv_reflectivity, diag_vm_qi, diag_diam_qi; + view_2d pratot, prctot; + // p3_tend_out, may not need these + view_2d qtend_ignore, ntend_ignore; + // Variables still used in F90 but removed from C++ interface + view_2d mu_c, lamc; + view_2d qr_evap_tend; + // cloud sedimentation + view_2d v_qc, v_nc, flux_qx, flux_nx; + // ice sedimentation + view_2d v_qit, v_nit, flux_nit, flux_bir; + view_2d flux_qir, flux_qit; + // rain sedimentation + view_2d v_qr, v_nr; + }; +#endif + // -- Table3 -- struct Table3 { @@ -1301,6 +1340,9 @@ struct Functions const P3Infrastructure& infrastructure, const P3HistoryOnly& history_only, const P3LookupTables& lookup_tables, +#ifdef SCREAM_P3_SMALL_KERNELS + const P3Temporaries& temporaries, +#endif const WorkspaceManager& workspace_mgr, Int nj, // number of columns Int nk, // number of vertical cells per column @@ -1328,6 +1370,7 @@ struct Functions const P3Infrastructure& infrastructure, const P3HistoryOnly& history_only, const P3LookupTables& lookup_tables, + const P3Temporaries& temporaries, const WorkspaceManager& workspace_mgr, Int nj, // number of columns Int nk, // number of vertical cells per column diff --git a/components/eamxx/src/physics/p3/p3_functions_f90.cpp b/components/eamxx/src/physics/p3/p3_functions_f90.cpp index eff3102f0e4..b8f6e826fc1 100644 --- a/components/eamxx/src/physics/p3/p3_functions_f90.cpp +++ b/components/eamxx/src/physics/p3/p3_functions_f90.cpp @@ -2054,6 +2054,36 @@ Int p3_main_f( P3F::P3HistoryOnly history_only{liq_ice_exchange_d, vap_liq_exchange_d, vap_ice_exchange_d}; + const Int nk_pack = ekat::npack(nk); +#ifdef SCREAM_P3_SMALL_KERNELS + view_2d + mu_r("mu_r", nj, nk_pack), T_atm("T_atm", nj, nk_pack), lamr("lamr", nj, nk_pack), logn0r("logn0r", nj, nk_pack), nu("nu", nj, nk_pack), + cdist("cdist", nj, nk_pack), cdist1("cdist1", nj, nk_pack), cdistr("cdistr", nj, nk_pack), inv_cld_frac_i("inv_cld_frac_i", nj, nk_pack), + inv_cld_frac_l("inv_cld_frac_l", nj, nk_pack), inv_cld_frac_r("inv_cld_frac_r", nj, nk_pack), qc_incld("qc_incld", nj, nk_pack), + qr_incld("qr_incld", nj, nk_pack), qi_incld("qi_incld", nj, nk_pack), qm_incld("qm_incld", nj, nk_pack), nc_incld("nc_incld", nj, nk_pack), + nr_incld("nr_incld", nj, nk_pack), ni_incld("ni_incld", nj, nk_pack), bm_incld("bm_incld", nj, nk_pack), inv_dz("inv_dz", nj, nk_pack), + inv_rho("inv_rho", nj, nk_pack), ze_ice("ze_ice", nj, nk_pack), ze_rain("ze_rain", nj, nk_pack), prec("prec", nj, nk_pack), + rho("rho", nj, nk_pack), rhofacr("rhofacr", nj, nk_pack), rhofaci("rhofaci", nj, nk_pack), acn("acn", nj, nk_pack), qv_sat_l("qv_sat", nj, nk_pack), + qv_sat_i("qv_sat_i", nj, nk_pack), sup("sup", nj, nk_pack), qv_supersat_i("qv_supersat", nj, nk_pack), tmparr2("tmparr2", nj, nk_pack), + exner("exner", nj, nk_pack), diag_equiv_reflectivity("diag_equiv_ref", nj, nk_pack), diag_vm_qi("diag_vm_qi", nj, nk_pack), + diag_diam_qi("diag_diam_qi", nj, nk_pack), pratot("pratot", nj, nk_pack), prctot("prctot", nj, nk_pack), qtend_ignore("qtend_ignore", nj, nk_pack), + ntend_ignore("ntend_ignore", nj, nk_pack), mu_c("mu_c", nj, nk_pack), lamc("lamc", nj, nk_pack), qr_evap_tend("qr_evap_tend", nj, nk_pack), + v_qc("v_qc", nj, nk_pack), v_nc("v_nc", nj, nk_pack), flux_qx("flux_qx", nj, nk_pack), flux_nx("flux_nx", nj, nk_pack), v_qit("v_qit", nj, nk_pack), + v_nit("v_nit", nj, nk_pack), flux_nit("flux_nit", nj, nk_pack), flux_bir("flux_bir", nj, nk_pack), flux_qir("flux_qir", nj, nk_pack), + flux_qit("flux_qit", nj, nk_pack), v_qr("v_qr", nj, nk_pack), v_nr("v_nr", nj, nk_pack); + + P3F::P3Temporaries temporaries{ + mu_r, T_atm, lamr, logn0r, nu, cdist, cdist1, cdistr, inv_cld_frac_i, + inv_cld_frac_l, inv_cld_frac_r, qc_incld, qr_incld, qi_incld, qm_incld, + nc_incld, nr_incld, ni_incld, bm_incld, inv_dz, inv_rho, ze_ice, ze_rain, + prec, rho, rhofacr, rhofaci, acn, qv_sat_l, qv_sat_i, sup, qv_supersat_i, + tmparr2, exner, diag_equiv_reflectivity, diag_vm_qi, diag_diam_qi, + pratot, prctot, qtend_ignore, ntend_ignore, mu_c, lamc, qr_evap_tend, + v_qc, v_nc, flux_qx, flux_nx, v_qit, v_nit, flux_nit, flux_bir, flux_qir, + flux_qit, v_qr, v_nr + }; +#endif + // load tables view_1d_table mu_r_table_vals; view_2d_table vn_table_vals, vm_table_vals, revap_table_vals; @@ -2068,12 +2098,15 @@ Int p3_main_f( P3F::P3Runtime runtime_options{740.0e3}; // Create local workspace - const Int nk_pack = ekat::npack(nk); const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(nj, nk_pack); ekat::WorkspaceManager workspace_mgr(nk_pack, 52, policy); auto elapsed_microsec = P3F::p3_main(runtime_options, prog_state, diag_inputs, diag_outputs, infrastructure, - history_only, lookup_tables, workspace_mgr, nj, nk, physics::P3_Constants()); + history_only, lookup_tables, +#ifdef SCREAM_P3_SMALL_KERNELS + temporaries, +#endif + workspace_mgr, nj, nk, physics::P3_Constants()); Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const Int& i) { precip_liq_surf_temp_d(0, i / Spack::n)[i % Spack::n] = precip_liq_surf_d(i); From 9438a980a0caebe562568beccb9b1c4b614a390f Mon Sep 17 00:00:00 2001 From: tcclevenger Date: Tue, 3 Sep 2024 10:54:25 -0600 Subject: [PATCH 2/3] Remove latent_heat_* in/out variables Replace with constant scalars --- .../eamxx/src/physics/p3/CMakeLists.txt | 13 +- .../physics/p3/disp/p3_ice_sed_impl_disp.cpp | 7 +- .../src/physics/p3/disp/p3_main_impl_disp.cpp | 13 +- .../p3/disp/p3_main_impl_part1_disp.cpp | 11 +- .../p3/disp/p3_main_impl_part2_disp.cpp | 25 +- .../p3/disp/p3_main_impl_part3_disp.cpp | 10 +- .../src/physics/p3/eti/p3_get_latent_heat.cpp | 14 - .../p3/impl/p3_evaporate_rain_impl.hpp | 8 +- .../p3/impl/p3_get_latent_heat_impl.hpp | 24 -- .../p3_get_time_space_phys_variables_impl.hpp | 12 +- .../p3/impl/p3_ice_cldliq_wet_growth_impl.hpp | 8 +- .../physics/p3/impl/p3_ice_melting_impl.hpp | 8 +- .../src/physics/p3/impl/p3_ice_sed_impl.hpp | 6 +- .../p3_ice_supersat_conservation_impl.hpp | 7 +- .../src/physics/p3/impl/p3_main_impl.hpp | 17 +- .../physics/p3/impl/p3_main_impl_part1.hpp | 13 +- .../physics/p3/impl/p3_main_impl_part2.hpp | 35 +- .../physics/p3/impl/p3_main_impl_part3.hpp | 10 +- .../p3_prevent_liq_supersaturation_impl.hpp | 20 +- .../p3/impl/p3_update_prognostics_impl.hpp | 15 +- .../eamxx/src/physics/p3/p3_functions.hpp | 39 +-- .../eamxx/src/physics/p3/p3_functions_f90.cpp | 309 ++++++++---------- .../eamxx/src/physics/p3/p3_functions_f90.hpp | 10 +- .../eamxx/src/physics/p3/tests/CMakeLists.txt | 1 - .../p3/tests/p3_evaporate_rain_unit_tests.cpp | 52 +-- .../tests/p3_get_latent_heat_unit_tests.cpp | 17 +- .../p3_ice_cldliq_wet_growth_unit_tests.cpp | 47 +-- .../p3/tests/p3_ice_melting_unit_tests.cpp | 46 +-- .../p3/tests/p3_ice_sed_unit_tests.cpp | 10 +- .../p3_ice_supersat_conservation_tests.cpp | 12 +- .../physics/p3/tests/p3_main_unit_tests.cpp | 48 ++- .../p3_prevent_liq_supersaturation_tests.cpp | 29 +- .../src/physics/p3/tests/p3_unit_tests.cpp | 125 ++++--- 33 files changed, 477 insertions(+), 544 deletions(-) delete mode 100644 components/eamxx/src/physics/p3/eti/p3_get_latent_heat.cpp delete mode 100644 components/eamxx/src/physics/p3/impl/p3_get_latent_heat_impl.hpp diff --git a/components/eamxx/src/physics/p3/CMakeLists.txt b/components/eamxx/src/physics/p3/CMakeLists.txt index fc0293cb35d..a1dfc946267 100644 --- a/components/eamxx/src/physics/p3/CMakeLists.txt +++ b/components/eamxx/src/physics/p3/CMakeLists.txt @@ -45,7 +45,6 @@ if (NOT EAMXX_ENABLE_GPU OR Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE OR Kokkos eti/p3_ice_relaxation_timescale.cpp eti/p3_ice_nucleation.cpp eti/p3_ice_cldliq_wet_growth.cpp - eti/p3_get_latent_heat.cpp eti/p3_check_values.cpp eti/p3_incloud_mixingratios.cpp eti/p3_subgrid_variance_scaling.cpp @@ -63,13 +62,13 @@ endif() # List of dispatch source files if monolithic kernels are off set(P3_SK_SRCS - disp/p3_check_values_impl_disp.cpp - disp/p3_ice_sed_impl_disp.cpp - disp/p3_main_impl_part1_disp.cpp + disp/p3_check_values_impl_disp.cpp + disp/p3_ice_sed_impl_disp.cpp + disp/p3_main_impl_part1_disp.cpp disp/p3_main_impl_part3_disp.cpp - disp/p3_cloud_sed_impl_disp.cpp - disp/p3_main_impl_disp.cpp - disp/p3_main_impl_part2_disp.cpp + disp/p3_cloud_sed_impl_disp.cpp + disp/p3_main_impl_disp.cpp + disp/p3_main_impl_part2_disp.cpp disp/p3_rain_sed_impl_disp.cpp ) diff --git a/components/eamxx/src/physics/p3/disp/p3_ice_sed_impl_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_ice_sed_impl_disp.cpp index 0d2aad5247d..f1e84750c25 100644 --- a/components/eamxx/src/physics/p3/disp/p3_ice_sed_impl_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_ice_sed_impl_disp.cpp @@ -46,8 +46,8 @@ ::ice_sedimentation_disp( // Ice sedimentation: (adaptive substepping) ice_sedimentation( - ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(rhofaci, i), ekat::subview(cld_frac_i, i), - ekat::subview(inv_dz, i), team, workspace, nk, ktop, kbot, kdir, dt, inv_dt, + ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(rhofaci, i), ekat::subview(cld_frac_i, i), + ekat::subview(inv_dz, i), team, workspace, nk, ktop, kbot, kdir, dt, inv_dt, ekat::subview(qi, i), ekat::subview(qi_incld, i), ekat::subview(ni, i), ekat::subview(ni_incld, i), ekat::subview(qm, i), ekat::subview(qm_incld, i), ekat::subview(bm, i), ekat::subview(bm_incld, i), ekat::subview(qi_tend, i), ekat::subview(ni_tend, i), ice_table_vals, precip_ice_surf(i), p3constants); @@ -60,7 +60,6 @@ void Functions ::homogeneous_freezing_disp( const uview_2d& T_atm, const uview_2d& inv_exner, - const uview_2d& latent_heat_fusion, const Int& nj, const Int& nk, const Int& ktop, const Int& kbot, const Int& kdir, const uview_2d& qc, const uview_2d& nc, @@ -89,7 +88,7 @@ ::homogeneous_freezing_disp( // homogeneous freezing of cloud and rain homogeneous_freezing( - ekat::subview(T_atm, i), ekat::subview(inv_exner, i), ekat::subview(latent_heat_fusion, i), team, nk, ktop, kbot, kdir, + ekat::subview(T_atm, i), ekat::subview(inv_exner, i), team, nk, ktop, kbot, kdir, ekat::subview(qc, i), ekat::subview(nc, i), ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), ekat::subview(th_atm, i)); diff --git a/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp index 0f125b7ae96..b79b4f6d072 100644 --- a/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp @@ -115,10 +115,6 @@ ::p3_main_internal_disp( { using ExeSpace = typename KT::ExeSpace; - view_2d latent_heat_sublim("latent_heat_sublim", nj, nk), latent_heat_vapor("latent_heat_vapor", nj, nk), latent_heat_fusion("latent_heat_fusion", nj, nk); - - get_latent_heat(nj, nk, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion); - const Int nk_pack = ekat::npack(nk); // load constants into local vars @@ -244,7 +240,7 @@ ::p3_main_internal_disp( p3_main_part1_disp( nj, nk, infrastructure.predictNc, infrastructure.prescribedCCN, infrastructure.dt, pres, dpres, dz, nc_nuceat_tend, nccn_prescribed, inv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, - inv_cld_frac_r, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion, + inv_cld_frac_r, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, qv, th, qc, nc, qr, nr, qi, ni, qm, bm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, @@ -259,8 +255,7 @@ ::p3_main_internal_disp( lookup_tables.revap_table_vals, pres, dpres, dz, nc_nuceat_tend, inv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, inv_cld_frac_r, ni_activated, inv_qc_relvar, cld_frac_i, cld_frac_l, cld_frac_r, qv_prev, t_prev, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, - qv, th, qc, nc, qr, nr, qi, ni, qm, bm, latent_heat_vapor, - latent_heat_sublim, latent_heat_fusion, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, + qv, th, qc, nc, qr, nr, qi, ni, qm, bm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, ni_incld, bm_incld, mu_c, nu, lamc, cdist, cdist1, cdistr, mu_r, lamr, logn0r, qv2qi_depos_tend, precip_total_tend, nevapr, qr_evap_tend, vap_liq_exchange, vap_ice_exchange, liq_ice_exchange, @@ -301,7 +296,7 @@ ::p3_main_internal_disp( // homogeneous freezing f cloud and rain homogeneous_freezing_disp( - T_atm, inv_exner, latent_heat_fusion, nj, nk, ktop, kbot, kdir, qc, nc, qr, nr, qi, + T_atm, inv_exner, nj, nk, ktop, kbot, kdir, qc, nc, qr, nr, qi, ni, qm, bm, th, nucleationPossible, hydrometeorsPresent); // @@ -311,7 +306,7 @@ ::p3_main_internal_disp( p3_main_part3_disp( nj, nk_pack, runtime_options.max_total_ni, lookup_tables.dnu_table_vals, lookup_tables.ice_table_vals, inv_exner, cld_frac_l, cld_frac_r, cld_frac_i, rho, inv_rho, rhofaci, qv, th, qc, nc, qr, nr, qi, ni, - qm, bm, latent_heat_vapor, latent_heat_sublim, mu_c, nu, lamc, mu_r, lamr, + qm, bm, mu_c, nu, lamc, mu_r, lamr, vap_liq_exchange, ze_rain, ze_ice, diag_vm_qi, diag_eff_radius_qi, diag_diam_qi, rho_qi, diag_equiv_reflectivity, diag_eff_radius_qc, diag_eff_radius_qr, nucleationPossible, hydrometeorsPresent, p3constants); diff --git a/components/eamxx/src/physics/p3/disp/p3_main_impl_part1_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_main_impl_part1_disp.cpp index 3dae805255b..28db7a6348d 100644 --- a/components/eamxx/src/physics/p3/disp/p3_main_impl_part1_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_main_impl_part1_disp.cpp @@ -31,9 +31,6 @@ ::p3_main_part1_disp( const uview_2d& inv_cld_frac_l, const uview_2d& inv_cld_frac_i, const uview_2d& inv_cld_frac_r, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, - const uview_2d& latent_heat_fusion, const uview_2d& T_atm, const uview_2d& rho, const uview_2d& inv_rho, @@ -73,17 +70,17 @@ ::p3_main_part1_disp( policy, KOKKOS_LAMBDA(const MemberType& team) { const Int i = team.league_rank(); - + p3_main_part1( team, nk, predictNc, prescribedCCN, dt, ekat::subview(pres, i), ekat::subview(dpres, i), ekat::subview(dz, i), ekat::subview(nc_nuceat_tend, i), ekat::subview(nccn_prescribed, i), ekat::subview(inv_exner, i), ekat::subview(exner, i), ekat::subview(inv_cld_frac_l, i), - ekat::subview(inv_cld_frac_i, i), ekat::subview(inv_cld_frac_r, i), ekat::subview(latent_heat_vapor, i), ekat::subview(latent_heat_sublim, i), - ekat::subview(latent_heat_fusion, i), ekat::subview(T_atm, i), ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(qv_sat_l, i), + ekat::subview(inv_cld_frac_i, i), ekat::subview(inv_cld_frac_r, i), + ekat::subview(T_atm, i), ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(qv_sat_l, i), ekat::subview(qv_sat_i, i), ekat::subview(qv_supersat_i, i), ekat::subview(rhofacr, i), ekat::subview(rhofaci, i), ekat::subview(acn, i), ekat::subview(qv, i), ekat::subview(th_atm, i), ekat::subview(qc, i), ekat::subview(nc, i), ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), ekat::subview(qc_incld, i), ekat::subview(qr_incld, i), ekat::subview(qi_incld, i), - ekat::subview(qm_incld, i), ekat::subview(nc_incld, i), ekat::subview(nr_incld, i), ekat::subview(ni_incld, i), ekat::subview(bm_incld, i), + ekat::subview(qm_incld, i), ekat::subview(nc_incld, i), ekat::subview(nr_incld, i), ekat::subview(ni_incld, i), ekat::subview(bm_incld, i), nucleationPossible(i), hydrometeorsPresent(i), p3constants); }); diff --git a/components/eamxx/src/physics/p3/disp/p3_main_impl_part2_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_main_impl_part2_disp.cpp index 2b619d54bf3..5aa32bf817f 100644 --- a/components/eamxx/src/physics/p3/disp/p3_main_impl_part2_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_main_impl_part2_disp.cpp @@ -59,9 +59,6 @@ ::p3_main_part2_disp( const uview_2d& ni, const uview_2d& qm, const uview_2d& bm, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, - const uview_2d& latent_heat_fusion, const uview_2d& qc_incld, const uview_2d& qr_incld, const uview_2d& qi_incld, @@ -104,25 +101,25 @@ ::p3_main_part2_disp( const Int i = team.league_rank(); if (!(nucleationPossible(i) || hydrometeorsPresent(i))) { - return; + return; } // ------------------------------------------------------------------------------------------ // main k-loop (for processes): p3_main_part2( team, nk_pack, max_total_ni, predictNc, do_prescribed_CCN, dt, inv_dt, - dnu_table_vals, ice_table_vals, collect_table_vals, revap_table_vals, + dnu_table_vals, ice_table_vals, collect_table_vals, revap_table_vals, ekat::subview(pres, i), ekat::subview(dpres, i), ekat::subview(dz, i), ekat::subview(nc_nuceat_tend, i), ekat::subview(inv_exner, i), - ekat::subview(exner, i), ekat::subview(inv_cld_frac_l, i), ekat::subview(inv_cld_frac_i, i), ekat::subview(inv_cld_frac_r, i), - ekat::subview(ni_activated, i), ekat::subview(inv_qc_relvar, i), ekat::subview(cld_frac_i, i), ekat::subview(cld_frac_l, i), - ekat::subview(cld_frac_r, i), ekat::subview(qv_prev, i), ekat::subview(t_prev, i), ekat::subview(T_atm, i), ekat::subview(rho, i), - ekat::subview(inv_rho, i), ekat::subview(qv_sat_l, i), ekat::subview(qv_sat_i, i), ekat::subview(qv_supersat_i, i), ekat::subview(rhofacr, i), - ekat::subview(rhofaci, i), ekat::subview(acn, i), ekat::subview(qv, i), ekat::subview(th_atm, i), ekat::subview(qc, i), ekat::subview(nc, i), - ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), - ekat::subview(latent_heat_vapor, i), ekat::subview(latent_heat_sublim, i), ekat::subview(latent_heat_fusion, i), ekat::subview(qc_incld, i), - ekat::subview(qr_incld, i), ekat::subview(qi_incld, i), ekat::subview(qm_incld, i), ekat::subview(nc_incld, i), ekat::subview(nr_incld, i), + ekat::subview(exner, i), ekat::subview(inv_cld_frac_l, i), ekat::subview(inv_cld_frac_i, i), ekat::subview(inv_cld_frac_r, i), + ekat::subview(ni_activated, i), ekat::subview(inv_qc_relvar, i), ekat::subview(cld_frac_i, i), ekat::subview(cld_frac_l, i), + ekat::subview(cld_frac_r, i), ekat::subview(qv_prev, i), ekat::subview(t_prev, i), ekat::subview(T_atm, i), ekat::subview(rho, i), + ekat::subview(inv_rho, i), ekat::subview(qv_sat_l, i), ekat::subview(qv_sat_i, i), ekat::subview(qv_supersat_i, i), ekat::subview(rhofacr, i), + ekat::subview(rhofaci, i), ekat::subview(acn, i), ekat::subview(qv, i), ekat::subview(th_atm, i), ekat::subview(qc, i), ekat::subview(nc, i), + ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), + ekat::subview(qc_incld, i), + ekat::subview(qr_incld, i), ekat::subview(qi_incld, i), ekat::subview(qm_incld, i), ekat::subview(nc_incld, i), ekat::subview(nr_incld, i), ekat::subview(ni_incld, i), ekat::subview(bm_incld, i), ekat::subview(mu_c, i), ekat::subview(nu, i), ekat::subview(lamc, i), ekat::subview(cdist, i), - ekat::subview(cdist1, i), ekat::subview(cdistr, i), ekat::subview(mu_r, i), ekat::subview(lamr, i), ekat::subview(logn0r, i), + ekat::subview(cdist1, i), ekat::subview(cdistr, i), ekat::subview(mu_r, i), ekat::subview(lamr, i), ekat::subview(logn0r, i), ekat::subview(qv2qi_depos_tend, i), ekat::subview(precip_total_tend, i), ekat::subview(nevapr, i), ekat::subview(qr_evap_tend, i), ekat::subview(vap_liq_exchange, i), ekat::subview(vap_ice_exchange, i), ekat::subview(liq_ice_exchange, i), ekat::subview(pratot, i), ekat::subview(prctot, i), hydrometeorsPresent(i), nk, p3constants); diff --git a/components/eamxx/src/physics/p3/disp/p3_main_impl_part3_disp.cpp b/components/eamxx/src/physics/p3/disp/p3_main_impl_part3_disp.cpp index 6d591a7e932..fd41fb5f0fe 100644 --- a/components/eamxx/src/physics/p3/disp/p3_main_impl_part3_disp.cpp +++ b/components/eamxx/src/physics/p3/disp/p3_main_impl_part3_disp.cpp @@ -38,8 +38,6 @@ ::p3_main_part3_disp( const uview_2d& ni, const uview_2d& qm, const uview_2d& bm, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, const uview_2d& mu_c, const uview_2d& nu, const uview_2d& lamc, @@ -77,11 +75,11 @@ ::p3_main_part3_disp( // p3_main_part3( team, nk_pack, max_total_ni, dnu_table_vals, ice_table_vals, ekat::subview(inv_exner, i), ekat::subview(cld_frac_l, i), ekat::subview(cld_frac_r, i), - ekat::subview(cld_frac_i, i), ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(rhofaci, i), ekat::subview(qv, i), - ekat::subview(th_atm, i), ekat::subview(qc, i), ekat::subview(nc, i), ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), - ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), ekat::subview(latent_heat_vapor, i), ekat::subview(latent_heat_sublim, i), + ekat::subview(cld_frac_i, i), ekat::subview(rho, i), ekat::subview(inv_rho, i), ekat::subview(rhofaci, i), ekat::subview(qv, i), + ekat::subview(th_atm, i), ekat::subview(qc, i), ekat::subview(nc, i), ekat::subview(qr, i), ekat::subview(nr, i), ekat::subview(qi, i), + ekat::subview(ni, i), ekat::subview(qm, i), ekat::subview(bm, i), ekat::subview(mu_c, i), ekat::subview(nu, i), ekat::subview(lamc, i), ekat::subview(mu_r, i), ekat::subview(lamr, i), - ekat::subview(vap_liq_exchange, i), ekat::subview(ze_rain, i), ekat::subview(ze_ice, i), ekat::subview(diag_vm_qi, i), ekat::subview(diag_eff_radius_qi, i), + ekat::subview(vap_liq_exchange, i), ekat::subview(ze_rain, i), ekat::subview(ze_ice, i), ekat::subview(diag_vm_qi, i), ekat::subview(diag_eff_radius_qi, i), ekat::subview(diag_diam_qi, i), ekat::subview(rho_qi, i), ekat::subview(diag_equiv_reflectivity, i), ekat::subview(diag_eff_radius_qc, i), ekat::subview(diag_eff_radius_qr, i), p3constants); diff --git a/components/eamxx/src/physics/p3/eti/p3_get_latent_heat.cpp b/components/eamxx/src/physics/p3/eti/p3_get_latent_heat.cpp deleted file mode 100644 index 87e41c93458..00000000000 --- a/components/eamxx/src/physics/p3/eti/p3_get_latent_heat.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "p3_get_latent_heat_impl.hpp" - -namespace scream { -namespace p3 { - -/* - * Explicit instantiation for doing conservation functions on Reals using the - * default device. - */ - -template struct Functions; - -} // namespace p3 -} // namespace scream diff --git a/components/eamxx/src/physics/p3/impl/p3_evaporate_rain_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_evaporate_rain_impl.hpp index 5455bfaa4c1..5560fcfe912 100644 --- a/components/eamxx/src/physics/p3/impl/p3_evaporate_rain_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_evaporate_rain_impl.hpp @@ -69,7 +69,7 @@ ::evaporate_rain( const Spack& cld_frac_l, const Spack& cld_frac_r, const Spack& qv, const Spack& qv_prev, const Spack& qv_sat_l, const Spack& qv_sat_i, const Spack& ab, const Spack& abi, const Spack& epsr, const Spack& epsi_tot, const Spack& t_atm, const Spack& t_atm_prev, - const Spack& latent_heat_sublim, const Spack& dqsdt, const Scalar& dt, + const Spack& dqsdt, const Scalar& dt, Spack& qr2qv_evap_tend, Spack& nr_evap_tend, const Smask& context) { @@ -92,6 +92,8 @@ ::evaporate_rain( constexpr Scalar QSMALL = C::QSMALL; constexpr Scalar Tmelt = C::Tmelt; constexpr Scalar inv_cp = 1/C::Cpair; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; //Compute absolute supersaturation. //Ignore the difference between clear-sky and cell-ave qv and T @@ -133,9 +135,9 @@ ::evaporate_rain( const Smask not_freezing = !is_freezing && context; Spack eps_eff, A_c; if (is_freezing.any()){ - eps_eff.set(is_freezing,epsr + epsi_tot*(1 + latent_heat_sublim*inv_cp*dqsdt)/abi); + eps_eff.set(is_freezing,epsr + epsi_tot*(1 + (latvap+latice)*inv_cp*dqsdt)/abi); A_c.set(is_freezing,(qv - qv_prev)*inv_dt - dqsdt*(t_atm-t_atm_prev)*inv_dt - - (qv_sat_l - qv_sat_i)*(1 + latent_heat_sublim*inv_cp*dqsdt)/abi*epsi_tot ); + - (qv_sat_l - qv_sat_i)*(1 + (latvap+latice)*inv_cp*dqsdt)/abi*epsi_tot ); } if (not_freezing.any()){ eps_eff.set(not_freezing,epsr); diff --git a/components/eamxx/src/physics/p3/impl/p3_get_latent_heat_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_get_latent_heat_impl.hpp deleted file mode 100644 index 439a1e2c84d..00000000000 --- a/components/eamxx/src/physics/p3/impl/p3_get_latent_heat_impl.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef P3_GET_LATENT_HEAT_IMPL_HPP -#define P3_GET_LATENT_HEAT_IMPL_HPP - -#include "p3_functions.hpp" // for ETI only but harmless for GPU - -namespace scream { -namespace p3 { - -template -void Functions -::get_latent_heat(const Int& nj, const Int& nk, view_2d& v, view_2d& s, view_2d& f) -{ - constexpr Scalar latvap = C::LatVap; - constexpr Scalar latice = C::LatIce; - - Kokkos::deep_copy(v, latvap); - Kokkos::deep_copy(s, latvap + latice); - Kokkos::deep_copy(f, latice); -} - -} // namespace p3 -} // namespace scream - -#endif // P3_GET_LATENT_HEAT_IMPL_HPP diff --git a/components/eamxx/src/physics/p3/impl/p3_get_time_space_phys_variables_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_get_time_space_phys_variables_impl.hpp index f46c4aaebb5..ea42d7995ba 100644 --- a/components/eamxx/src/physics/p3/impl/p3_get_time_space_phys_variables_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_get_time_space_phys_variables_impl.hpp @@ -11,7 +11,7 @@ template KOKKOS_FUNCTION void Functions ::get_time_space_phys_variables( - const Spack& T_atm, const Spack& pres, const Spack& rho, const Spack& latent_heat_vapor, const Spack& latent_heat_sublim, + const Spack& T_atm, const Spack& pres, const Spack& rho, const Spack& qv_sat_l, const Spack& qv_sat_i, Spack& mu, Spack& dv, Spack& sc, Spack& dqsdt, Spack& dqsidt, Spack& ab, Spack& abi, Spack& kap, Spack& eii, const Smask& context) @@ -23,15 +23,17 @@ ::get_time_space_phys_variables( constexpr Scalar RV = C::RV; constexpr Scalar INV_CP = C::INV_CP; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; constexpr Scalar tval1 = 253.15; constexpr Scalar tval2 = 273.15; constexpr Scalar dtval = 20; //this is tval2-tval1, but specifying here as int to be BFB with F90. const auto dum = 1/(RV*square(T_atm)); - dqsdt.set(context, latent_heat_vapor*qv_sat_l*dum); - dqsidt.set(context, latent_heat_sublim*qv_sat_i*dum); - ab.set(context, 1+dqsdt*latent_heat_vapor*INV_CP); - abi.set(context, 1+dqsidt*latent_heat_sublim*INV_CP); + dqsdt.set(context, latvap*qv_sat_l*dum); + dqsidt.set(context, (latvap+latice)*qv_sat_i*dum); + ab.set(context, 1+dqsdt*latvap*INV_CP); + abi.set(context, 1+dqsidt*(latvap+latice)*INV_CP); kap.set(context, sp(1.414e+3)*mu); //very simple temperature dependent aggregation efficiency diff --git a/components/eamxx/src/physics/p3/impl/p3_ice_cldliq_wet_growth_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_ice_cldliq_wet_growth_impl.hpp index cd8d9ce7ef0..319d10f64ef 100644 --- a/components/eamxx/src/physics/p3/impl/p3_ice_cldliq_wet_growth_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_ice_cldliq_wet_growth_impl.hpp @@ -13,7 +13,7 @@ KOKKOS_FUNCTION void Functions ::ice_cldliq_wet_growth( const Spack& rho, const Spack& temp, const Spack& pres, const Spack& rhofaci, const Spack& table_val_qi2qr_melting, - const Spack& table_val_qi2qr_vent_melt, const Spack& latent_heat_vapor, const Spack& latent_heat_fusion, const Spack& dv, + const Spack& table_val_qi2qr_vent_melt, const Spack& dv, const Spack& kap, const Spack& mu, const Spack& sc, const Spack& qv, const Spack& qc_incld, const Spack& qi_incld, const Spack& ni_incld, const Spack& qr_incld, Smask& log_wetgrowth, Spack& qr2qi_collect_tend, Spack& qc2qi_collect_tend, Spack& qc_growth_rate, Spack& nr_ice_shed_tend, Spack& qc2qr_ice_shed_tend, const Smask& context) @@ -26,6 +26,8 @@ ::ice_cldliq_wet_growth( constexpr Scalar zero = C::ZERO; constexpr Scalar one = C::ONE; constexpr Scalar cpw = C::CpLiq; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; const auto t_is_negative = temp < tmelt; const auto qi_incld_ge_small = qi_incld >= qsmall; @@ -46,8 +48,8 @@ ::ice_cldliq_wet_growth( qc_growth_rate.set(any_if, ((table_val_qi2qr_melting+table_val_qi2qr_vent_melt*cbrt(sc)*sqrt(rhofaci*rho/mu))* - twopi*(rho*latent_heat_vapor*dv*(qsat0-qv)-(temp-tmelt)*kap)/ - (latent_heat_fusion+cpw*(temp-tmelt)))*ni_incld); + twopi*(rho*latvap*dv*(qsat0-qv)-(temp-tmelt)*kap)/ + (latice+cpw*(temp-tmelt)))*ni_incld); qc_growth_rate.set(any_if, max(qc_growth_rate, zero)); diff --git a/components/eamxx/src/physics/p3/impl/p3_ice_melting_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_ice_melting_impl.hpp index dc6c8d16256..a4b86806ad0 100644 --- a/components/eamxx/src/physics/p3/impl/p3_ice_melting_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_ice_melting_impl.hpp @@ -13,7 +13,7 @@ KOKKOS_FUNCTION void Functions ::ice_melting( const Spack& rho, const Spack& T_atm, const Spack& pres, const Spack& rhofaci, - const Spack& table_val_qi2qr_melting, const Spack& table_val_qi2qr_vent_melt, const Spack& latent_heat_vapor, const Spack& latent_heat_fusion, + const Spack& table_val_qi2qr_melting, const Spack& table_val_qi2qr_vent_melt, const Spack& dv, const Spack& sc, const Spack& mu, const Spack& kap, const Spack& qv, const Spack& qi_incld, const Spack& ni_incld, Spack& qi2qr_melt_tend, Spack& ni2nr_melt_tend, const Smask& context) @@ -29,6 +29,8 @@ ::ice_melting( const auto Pi = C::Pi; const auto QSMALL = C::QSMALL; const auto Tmelt = C::Tmelt; + const auto latvap = C::LatVap; + const auto latice = C::LatIce; //Find cells above freezing AND which have ice const auto has_melt_qi = (qi_incld >= QSMALL ) && (T_atm > Tmelt) && context; @@ -38,8 +40,8 @@ ::ice_melting( const auto qsat0 = physics::qv_sat_dry(Spack(Tmelt), pres, false, context, physics::MurphyKoop, "p3::ice_melting"); //"false" here means NOT saturation w/ respect to ice. qi2qr_melt_tend.set(has_melt_qi, ( (table_val_qi2qr_melting+table_val_qi2qr_vent_melt*cbrt(sc)*sqrt(rhofaci*rho/mu)) - *((T_atm-Tmelt)*kap-rho*latent_heat_vapor*dv*(qsat0-qv)) - * 2 * Pi /latent_heat_fusion)*ni_incld ); + *((T_atm-Tmelt)*kap-rho*latvap*dv*(qsat0-qv)) + * 2 * Pi /latice)*ni_incld ); //make sure qi2qr_melt_tend is always negative qi2qr_melt_tend = max(qi2qr_melt_tend, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_ice_sed_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_ice_sed_impl.hpp index 29232c69e68..1273d7bbc20 100644 --- a/components/eamxx/src/physics/p3/impl/p3_ice_sed_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_ice_sed_impl.hpp @@ -210,7 +210,6 @@ void Functions ::homogeneous_freezing( const uview_1d& T_atm, const uview_1d& inv_exner, - const uview_1d& latent_heat_fusion, const MemberType& team, const Int& nk, const Int& ktop, const Int& kbot, const Int& kdir, const uview_1d& qc, @@ -228,6 +227,7 @@ ::homogeneous_freezing( constexpr Scalar T_homogfrz = C::T_homogfrz; constexpr Scalar inv_rho_rimeMax = C::INV_RHO_RIMEMAX; constexpr Scalar inv_cp = C::INV_CP; + constexpr Scalar latice = C::LatIce; const Int kmin_scalar = ( kdir == 1 ? kbot : ktop); const Int kmax_scalar = ( kdir == 1 ? ktop : kbot); @@ -254,13 +254,13 @@ ::homogeneous_freezing( qi(pk).set(qc_ge_small, qi(pk) + Qc_nuc); bm(pk).set(qc_ge_small, bm(pk) + Qc_nuc*inv_rho_rimeMax); ni(pk).set(qc_ge_small, ni(pk) + Nc_nuc); - th_atm(pk).set (qc_ge_small, th_atm(pk) + inv_exner(pk)*Qc_nuc*latent_heat_fusion(pk)*inv_cp); + th_atm(pk).set (qc_ge_small, th_atm(pk) + inv_exner(pk)*Qc_nuc*latice*inv_cp); qm(pk).set(qr_ge_small, qm(pk) + Qr_nuc); qi(pk).set(qr_ge_small, qi(pk) + Qr_nuc); bm(pk).set(qr_ge_small, bm(pk) + Qr_nuc*inv_rho_rimeMax); ni(pk).set(qr_ge_small, ni(pk) + Nr_nuc); - th_atm(pk).set (qr_ge_small, th_atm(pk) + inv_exner(pk)*Qr_nuc*latent_heat_fusion(pk)*inv_cp); + th_atm(pk).set (qr_ge_small, th_atm(pk) + inv_exner(pk)*Qr_nuc*latice*inv_cp); qc(pk).set(qc_ge_small, 0); nc(pk).set(qc_ge_small, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_ice_supersat_conservation_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_ice_supersat_conservation_impl.hpp index 1bed57bad63..091aa20f58d 100644 --- a/components/eamxx/src/physics/p3/impl/p3_ice_supersat_conservation_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_ice_supersat_conservation_impl.hpp @@ -13,11 +13,14 @@ namespace p3 { template KOKKOS_FUNCTION -void Functions::ice_supersat_conservation(Spack& qv2qi_vapdep_tend, Spack& qv2qi_nucleat_tend, const Spack& cld_frac_i, const Spack& qv, const Spack& qv_sat_i, const Spack& latent_heat_sublim, const Spack& t_atm, const Real& dt, const Spack& qi2qv_sublim_tend, const Spack& qr2qv_evap_tend, const Smask& context) +void Functions::ice_supersat_conservation(Spack& qv2qi_vapdep_tend, Spack& qv2qi_nucleat_tend, const Spack& cld_frac_i, const Spack& qv, const Spack& qv_sat_i, const Spack& t_atm, const Real& dt, const Spack& qi2qv_sublim_tend, const Spack& qr2qv_evap_tend, const Smask& context) { constexpr Scalar qsmall = C::QSMALL; constexpr Scalar cp = C::CP; constexpr Scalar rv = C::RH2O; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; + constexpr Scalar latsublim2 = (latvap+latice)*(latvap+latice); const auto qv_sink = qv2qi_vapdep_tend + qv2qi_nucleat_tend; // in [kg/kg] cell-avg values @@ -25,7 +28,7 @@ void Functions::ice_supersat_conservation(Spack& qv2qi_vapdep_tend, Spack& if (mask.any()) { // --- Available water vapor for deposition/nucleation auto qv_avail = (qv + (qi2qv_sublim_tend+qr2qv_evap_tend)*dt - qv_sat_i) / - (1 + square(latent_heat_sublim)*qv_sat_i / (cp*rv*square(t_atm)) ) / dt; + (1 + latsublim2*qv_sat_i / (cp*rv*square(t_atm)) ) / dt; // --- Only excess water vapor can be limited qv_avail = max(qv_avail, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp index 270042c9998..a36a7936404 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp @@ -88,10 +88,6 @@ ::p3_main_internal( { using ExeSpace = typename KT::ExeSpace; - view_2d latent_heat_sublim("latent_heat_sublim", nj, nk), latent_heat_vapor("latent_heat_vapor", nj, nk), latent_heat_fusion("latent_heat_fusion", nj, nk); - - get_latent_heat(nj, nk, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion); - const Int nk_pack = ekat::npack(nk); const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(nj, nk_pack); @@ -202,9 +198,6 @@ ::p3_main_internal( const auto oliq_ice_exchange = ekat::subview(history_only.liq_ice_exchange, i); const auto ovap_liq_exchange = ekat::subview(history_only.vap_liq_exchange, i); const auto ovap_ice_exchange = ekat::subview(history_only.vap_ice_exchange, i); - const auto olatent_heat_vapor = ekat::subview(latent_heat_vapor, i); - const auto olatent_heat_sublim = ekat::subview(latent_heat_sublim, i); - const auto olatent_heat_fusion = ekat::subview(latent_heat_fusion, i); const auto oqv_prev = ekat::subview(diagnostic_inputs.qv_prev, i); const auto ot_prev = ekat::subview(diagnostic_inputs.t_prev, i); @@ -232,7 +225,7 @@ ::p3_main_internal( p3_main_part1( team, nk, infrastructure.predictNc, infrastructure.prescribedCCN, infrastructure.dt, opres, odpres, odz, onc_nuceat_tend, onccn_prescribed, oinv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, - inv_cld_frac_r, olatent_heat_vapor, olatent_heat_sublim, olatent_heat_fusion, + inv_cld_frac_r, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, oqv, oth, oqc, onc, oqr, onr, oqi, oni, oqm, obm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, @@ -251,8 +244,8 @@ ::p3_main_internal( lookup_tables.dnu_table_vals, lookup_tables.ice_table_vals, lookup_tables.collect_table_vals, lookup_tables.revap_table_vals, opres, odpres, odz, onc_nuceat_tend, oinv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, inv_cld_frac_r, oni_activated, oinv_qc_relvar, ocld_frac_i, ocld_frac_l, ocld_frac_r, oqv_prev, ot_prev, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, - oqv, oth, oqc, onc, oqr, onr, oqi, oni, oqm, obm, olatent_heat_vapor, - olatent_heat_sublim, olatent_heat_fusion, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, + oqv, oth, oqc, onc, oqr, onr, oqi, oni, oqm, obm, + qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, ni_incld, bm_incld, mu_c, nu, lamc, cdist, cdist1, cdistr, mu_r, lamr, logn0r, oqv2qi_depos_tend, oprecip_total_tend, onevapr, qr_evap_tend, ovap_liq_exchange, ovap_ice_exchange, oliq_ice_exchange, @@ -295,7 +288,7 @@ ::p3_main_internal( // homogeneous freezing of cloud and rain homogeneous_freezing( - T_atm, oinv_exner, olatent_heat_fusion, team, nk, ktop, kbot, kdir, oqc, onc, oqr, onr, oqi, + T_atm, oinv_exner, team, nk, ktop, kbot, kdir, oqc, onc, oqr, onr, oqi, oni, oqm, obm, oth); // @@ -305,7 +298,7 @@ ::p3_main_internal( p3_main_part3( team, nk_pack, runtime_options.max_total_ni, lookup_tables.dnu_table_vals, lookup_tables.ice_table_vals, oinv_exner, ocld_frac_l, ocld_frac_r, ocld_frac_i, rho, inv_rho, rhofaci, oqv, oth, oqc, onc, oqr, onr, oqi, oni, - oqm, obm, olatent_heat_vapor, olatent_heat_sublim, mu_c, nu, lamc, mu_r, lamr, + oqm, obm, mu_c, nu, lamc, mu_r, lamr, ovap_liq_exchange, ze_rain, ze_ice, diag_vm_qi, odiag_eff_radius_qi, diag_diam_qi, orho_qi, diag_equiv_reflectivity, odiag_eff_radius_qc, odiag_eff_radius_qr, p3constants); diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl_part1.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl_part1.hpp index 439b0544adf..6771a48d4c6 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl_part1.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl_part1.hpp @@ -34,9 +34,6 @@ ::p3_main_part1( const uview_1d& inv_cld_frac_l, const uview_1d& inv_cld_frac_i, const uview_1d& inv_cld_frac_r, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, - const uview_1d& latent_heat_fusion, const uview_1d& T_atm, const uview_1d& rho, const uview_1d& inv_rho, @@ -80,6 +77,8 @@ ::p3_main_part1( constexpr Scalar T_zerodegc = C::T_zerodegc; constexpr Scalar qsmall = C::QSMALL; constexpr Scalar inv_cp = C::INV_CP; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; const Scalar p3_spa_to_nc = p3constants.p3_spa_to_nc; @@ -124,7 +123,7 @@ ::p3_main_part1( auto drymass = qc(k) < qsmall; auto not_drymass = !drymass && range_mask; qv(k).set(drymass, qv(k) + qc(k)); - th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qc(k) * latent_heat_vapor(k) * inv_cp); + th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qc(k) * latvap * inv_cp); qc(k).set(drymass, 0); nc(k).set(drymass, 0); if ( not_drymass.any() ) { @@ -147,7 +146,7 @@ ::p3_main_part1( drymass = qr(k) < qsmall; not_drymass = !drymass && range_mask; qv(k).set(drymass, qv(k) + qr(k)); - th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qr(k) * latent_heat_vapor(k) * inv_cp); + th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qr(k) * latvap * inv_cp); qr(k).set(drymass, 0); nr(k).set(drymass, 0); if ( not_drymass.any() ) { @@ -157,7 +156,7 @@ ::p3_main_part1( drymass = (qi(k) < qsmall || (qi(k) < 1.e-8 && qv_supersat_i(k) < -0.1)); not_drymass = !drymass && range_mask; qv(k).set(drymass, qv(k) + qi(k)); - th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qi(k) * latent_heat_sublim(k) * inv_cp); + th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qi(k) * (latvap+latice) * inv_cp); qi(k).set(drymass, 0); ni(k).set(drymass, 0); qm(k).set(drymass, 0); @@ -168,7 +167,7 @@ ::p3_main_part1( drymass = (qi(k) >= qsmall && qi(k) < 1.e-8 && T_atm(k) >= T_zerodegc); qr(k).set(drymass, qr(k) + qi(k)); - th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qi(k) * latent_heat_fusion(k) * inv_cp); + th_atm(k).set(drymass, th_atm(k) - inv_exner(k) * qi(k) * latice * inv_cp); qi(k).set(drymass, 0); ni(k).set(drymass, 0); qm(k).set(drymass, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl_part2.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl_part2.hpp index c32fb7202eb..d19dc579b7e 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl_part2.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl_part2.hpp @@ -65,9 +65,6 @@ ::p3_main_part2( const uview_1d& ni, const uview_1d& qm, const uview_1d& bm, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, - const uview_1d& latent_heat_fusion, const uview_1d& qc_incld, const uview_1d& qr_incld, const uview_1d& qi_incld, @@ -104,6 +101,8 @@ ::p3_main_part2( constexpr Scalar f2r = C::f2r; constexpr Scalar nmltratio = C::nmltratio; constexpr Scalar inv_cp = C::INV_CP; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; team.team_barrier(); hydrometeorsPresent = false; @@ -115,12 +114,12 @@ ::p3_main_part2( //compute mask to identify padded values in packs, which shouldn't be used in calculations const auto range_pack = ekat::range(k*Spack::n); const auto range_mask = range_pack < nk; - + // if relatively dry and no hydrometeors at this level, skip to end of k-loop (i.e. skip this level) const auto skip_all = ( !range_mask || (qc(k)= qsmall && not_skip_all; qv(k).set(qc_small, qv(k) + qc(k)); - th_atm(k).set(qc_small, th_atm(k) - inv_exner(k) * qc(k) * latent_heat_vapor(k) * inv_cp); + th_atm(k).set(qc_small, th_atm(k) - inv_exner(k) * qc(k) * latvap * inv_cp); qc(k).set(qc_small, 0); nc(k).set(qc_small, 0); @@ -464,7 +463,7 @@ ::p3_main_part2( } qv(k).set(qr_small, qv(k) + qr(k)); - th_atm(k).set(qr_small, th_atm(k) - inv_exner(k) * qr(k) * latent_heat_vapor(k) * inv_cp); + th_atm(k).set(qr_small, th_atm(k) - inv_exner(k) * qr(k) * latvap * inv_cp); qr(k).set(qr_small, 0); nr(k).set(qr_small, 0); @@ -473,7 +472,7 @@ ::p3_main_part2( } qv(k).set(qi_small, qv(k) + qi(k)); - th_atm(k).set(qi_small, th_atm(k) - inv_exner(k) * qi(k) * latent_heat_sublim(k) * inv_cp); + th_atm(k).set(qi_small, th_atm(k) - inv_exner(k) * qi(k) * (latvap+latice) * inv_cp); qi(k).set(qi_small, 0); ni(k).set(qi_small, 0); qm(k).set(qi_small, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl_part3.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl_part3.hpp index 441bcb9feb9..febb00ef4d3 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl_part3.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl_part3.hpp @@ -41,8 +41,6 @@ ::p3_main_part3( const uview_1d& ni, const uview_1d& qm, const uview_1d& bm, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, const uview_1d& mu_c, const uview_1d& nu, const uview_1d& lamc, @@ -63,6 +61,8 @@ ::p3_main_part3( constexpr Scalar qsmall = C::QSMALL; constexpr Scalar inv_cp = C::INV_CP; constexpr Scalar nsmall = C::NSMALL; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; Kokkos::parallel_for( Kokkos::TeamVectorRange(team, nk_pack), [&] (Int k) { @@ -93,7 +93,7 @@ ::p3_main_part3( } if (qc_small.any()) { qv(k) .set(qc_small, qv(k)+qc(k)); - th_atm(k) .set(qc_small, th_atm(k)-inv_exner(k)*qc(k)*latent_heat_vapor(k)*inv_cp); + th_atm(k) .set(qc_small, th_atm(k)-inv_exner(k)*qc(k)*latvap*inv_cp); vap_liq_exchange(k) .set(qc_small, vap_liq_exchange(k) - qc(k)); qc(k) .set(qc_small, 0); nc(k) .set(qc_small, 0); @@ -123,7 +123,7 @@ ::p3_main_part3( if (qr_small.any()) { qv(k) .set(qr_small, qv(k) + qr(k)); - th_atm(k) .set(qr_small, th_atm(k) - inv_exner(k)*qr(k)*latent_heat_vapor(k)*inv_cp); + th_atm(k) .set(qr_small, th_atm(k) - inv_exner(k)*qr(k)*latvap*inv_cp); vap_liq_exchange(k).set(qr_small, vap_liq_exchange(k) - qr(k)); qr(k) .set(qr_small, 0); nr(k) .set(qr_small, 0); @@ -185,7 +185,7 @@ ::p3_main_part3( ze_ice(k).set(qi_gt_small, ze_ice(k)*cld_frac_i(k)); qv(k).set(qi_small, qv(k) + qi(k)); - th_atm(k).set(qi_small, th_atm(k) - inv_exner(k)*qi(k)*latent_heat_sublim(k)*inv_cp); + th_atm(k).set(qi_small, th_atm(k) - inv_exner(k)*qi(k)*(latvap+latice)*inv_cp); qi(k).set(qi_small, 0); ni(k).set(qi_small, 0); qm(k).set(qi_small, 0); diff --git a/components/eamxx/src/physics/p3/impl/p3_prevent_liq_supersaturation_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_prevent_liq_supersaturation_impl.hpp index a9f265d8dcd..10f728f1a07 100644 --- a/components/eamxx/src/physics/p3/impl/p3_prevent_liq_supersaturation_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_prevent_liq_supersaturation_impl.hpp @@ -14,7 +14,7 @@ namespace p3 { template KOKKOS_FUNCTION -void Functions::prevent_liq_supersaturation(const Spack& pres, const Spack& t_atm, const Spack& qv, const Spack& latent_heat_vapor, const Spack& latent_heat_sublim, const Scalar& dt, const Spack& qv2qi_vapdep_tend, const Spack& qinuc, Spack& qi2qv_sublim_tend, Spack& qr2qv_evap_tend, const Smask& context) +void Functions::prevent_liq_supersaturation(const Spack& pres, const Spack& t_atm, const Spack& qv, const Scalar& dt, const Spack& qv2qi_vapdep_tend, const Spack& qinuc, Spack& qi2qv_sublim_tend, Spack& qr2qv_evap_tend, const Smask& context) // Note: context masks cells which are just padding for packs or which don't have any condensate worth // performing calculations on. { @@ -23,6 +23,8 @@ void Functions::prevent_liq_supersaturation(const Spack& pres, const Spack& constexpr Scalar inv_cp = C::INV_CP; constexpr Scalar rv = C::RV; constexpr Scalar qsmall = C::QSMALL; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; Spack qv_sinks, qv_sources, qv_endstep, T_endstep, A, frac; @@ -37,8 +39,8 @@ void Functions::prevent_liq_supersaturation(const Spack& pres, const Spack& //Actual qv and T after microphys step qv_endstep.set(has_sources,qv - qv_sinks*dt + qv_sources*dt); - T_endstep.set(has_sources,t_atm + ( (qv_sinks-qi2qv_sublim_tend)*latent_heat_sublim*inv_cp - - qr2qv_evap_tend*latent_heat_vapor*inv_cp )*dt); + T_endstep.set(has_sources,t_atm + ( (qv_sinks-qi2qv_sublim_tend)*(latvap+latice)*inv_cp + - qr2qv_evap_tend*latvap*inv_cp )*dt); //qv we would have at end of step if we were saturated with respect to liquid const auto qsl = physics::qv_sat_dry(T_endstep,pres,false,has_sources,physics::MurphyKoop,"p3::prevent_liq_supersaturation"); //"false" means NOT sat w/ respect to ice @@ -46,18 +48,18 @@ void Functions::prevent_liq_supersaturation(const Spack& pres, const Spack& //The balance we seek is: // qv-qv_sinks*dt+qv_sources*frac*dt=qsl+dqsl_dT*(T correction due to conservation) // where the T correction for conservation is: - // dt*[latent_heat_sublim/cp*(qi2qv_sublim_tend-frac*qi2qv_sublim_tend) - // +latent_heat_vapor/cp*(qr2qv_evap_tend -frac*qr2qv_evap_tend)] - // =(1-frac)*dt/cp*(latent_heat_sublim*qi2qv_sublim_tend + latent_heat_vap*qr2qv_evap_tend). + // dt*[(latvap+latice)/cp*(qi2qv_sublim_tend-frac*qi2qv_sublim_tend) + // +latvap/cp*(qr2qv_evap_tend -frac*qr2qv_evap_tend)] + // =(1-frac)*dt/cp*((latvap+latice)*qi2qv_sublim_tend + latvap*qr2qv_evap_tend). // Note T correction is positive because frac *reduces* evaporative cooling. Note as well that // dqsl_dt comes from linearization of qsl around the end-of-step T computed before temperature // correction. dqsl_dt should be computed with respect to *liquid* even though frac also adjusts // sublimation because we want to be saturated with respect to liquid at the end of the step. - // dqsl_dt=Latent_heat_vapor*qsl/rv*T^2 following Clausius Clapeyron. Combining and solving for + // dqsl_dt=latvap*qsl/rv*T^2 following Clausius Clapeyron. Combining and solving for // frac yields: - A.set(has_sources,latent_heat_vapor*qsl*dt*inv_cp/(rv*T_endstep*T_endstep) - * (latent_heat_sublim*qi2qv_sublim_tend + latent_heat_vapor*qr2qv_evap_tend) ); + A.set(has_sources,latvap*qsl*dt*inv_cp/(rv*T_endstep*T_endstep) + * ((latvap+latice)*qi2qv_sublim_tend + latvap*qr2qv_evap_tend) ); frac.set(has_sources, (qsl-qv+qv_sinks*dt + A)/(qv_sources*dt + A) ); diff --git a/components/eamxx/src/physics/p3/impl/p3_update_prognostics_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_update_prognostics_impl.hpp index 3f8bcab2cd5..86feaa04f49 100644 --- a/components/eamxx/src/physics/p3/impl/p3_update_prognostics_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_update_prognostics_impl.hpp @@ -15,7 +15,7 @@ ::update_prognostic_ice( const Spack& qr2qi_immers_freeze_tend, const Spack& nr2ni_immers_freeze_tend, const Spack& nr_ice_shed_tend, const Spack& qi2qr_melt_tend, const Spack& ni2nr_melt_tend, const Spack& qi2qv_sublim_tend, const Spack& qv2qi_vapdep_tend, const Spack& qv2qi_nucleat_tend, const Spack& ni_nucleat_tend, const Spack& ni_selfcollect_tend, const Spack& ni_sublim_tend, const Spack& qc2qi_berg_tend, - const Spack& inv_exner, const Spack& latent_heat_sublim, const Spack& latent_heat_fusion, const bool do_predict_nc, + const Spack& inv_exner, const bool do_predict_nc, const Smask& log_wetgrowth, const Scalar dt, const Scalar& nmltratio, const Spack& rho_qm_cloud, Spack& th_atm, Spack& qv, Spack& qi, Spack& ni, Spack& qm, Spack& bm, Spack& qc, Spack& nc, Spack& qr, Spack& nr, @@ -23,6 +23,8 @@ ::update_prognostic_ice( { constexpr Scalar QSMALL = C::QSMALL; constexpr Scalar INV_RHO_RIMEMAX = C::INV_RHO_RIMEMAX; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; qc.set(context, qc + (-qc2qi_hetero_freeze_tend-qc2qi_collect_tend-qc2qr_ice_shed_tend-qc2qi_berg_tend)*dt); if ( do_predict_nc ){ @@ -76,9 +78,9 @@ ::update_prognostic_ice( qv.set(context, qv + (-qv2qi_vapdep_tend+qi2qv_sublim_tend-qv2qi_nucleat_tend)*dt); constexpr Scalar INV_CP = C::INV_CP; - th_atm.set(context, th_atm + inv_exner * ((qv2qi_vapdep_tend - qi2qv_sublim_tend + qv2qi_nucleat_tend) * latent_heat_sublim * INV_CP + - (qr2qi_collect_tend + qc2qi_collect_tend + qc2qi_hetero_freeze_tend + qr2qi_immers_freeze_tend - - qi2qr_melt_tend + qc2qi_berg_tend) * latent_heat_fusion * INV_CP) * dt); + th_atm.set(context, th_atm + inv_exner * ((qv2qi_vapdep_tend - qi2qv_sublim_tend + qv2qi_nucleat_tend) * (latvap+latice) * INV_CP + + (qr2qi_collect_tend + qc2qi_collect_tend + qc2qi_hetero_freeze_tend + qr2qi_immers_freeze_tend - + qi2qr_melt_tend + qc2qi_berg_tend) * latice * INV_CP) * dt); } template @@ -88,13 +90,14 @@ ::update_prognostic_liquid( const Spack& qc2qr_accret_tend, const Spack& nc_accret_tend, const Spack& qc2qr_autoconv_tend,const Spack& nc2nr_autoconv_tend, const Spack& ncautr, const Spack& nc_selfcollect_tend, const Spack& qr2qv_evap_tend, const Spack& nr_evap_tend, const Spack& nr_selfcollect_tend, - const bool do_predict_nc, const bool do_prescribed_CCN, const Spack& inv_rho, const Spack& inv_exner, const Spack& latent_heat_vapor, + const bool do_predict_nc, const bool do_prescribed_CCN, const Spack& inv_rho, const Spack& inv_exner, const Scalar dt, Spack& th_atm, Spack& qv, Spack& qc, Spack& nc, Spack& qr, Spack& nr, const Smask& context) { constexpr Scalar NCCNST = C::NCCNST; constexpr int IPARAM = C::IPARAM; constexpr Scalar INV_CP = C::INV_CP; + constexpr Scalar latvap = C::LatVap; qc.set(context, qc + (-qc2qr_accret_tend-qc2qr_autoconv_tend)*dt); qr.set(context, qr + (qc2qr_accret_tend+qc2qr_autoconv_tend-qr2qv_evap_tend)*dt); @@ -115,7 +118,7 @@ ::update_prognostic_liquid( qv.set(context, qv + qr2qv_evap_tend *dt); - th_atm.set(context, th_atm + inv_exner*(-qr2qv_evap_tend * latent_heat_vapor * INV_CP) * dt); + th_atm.set(context, th_atm + inv_exner*(-qr2qv_evap_tend * latvap * INV_CP) * dt); } } // namespace p3 diff --git a/components/eamxx/src/physics/p3/p3_functions.hpp b/components/eamxx/src/physics/p3/p3_functions.hpp index 791538d67dc..81a49268800 100644 --- a/components/eamxx/src/physics/p3/p3_functions.hpp +++ b/components/eamxx/src/physics/p3/p3_functions.hpp @@ -588,7 +588,6 @@ struct Functions static void homogeneous_freezing( const uview_1d& T_atm, const uview_1d& inv_exner, - const uview_1d& latent_heat_fusion, const MemberType& team, const Int& nk, const Int& ktop, const Int& kbot, const Int& kdir, const uview_1d& qc, @@ -605,7 +604,6 @@ struct Functions static void homogeneous_freezing_disp( const uview_2d& T_atm, const uview_2d& inv_exner, - const uview_2d& latent_heat_fusion, const Int& nj, const Int& nk, const Int& ktop, const Int& kbot, const Int& kdir, const uview_2d& qc, const uview_2d& nc, @@ -767,8 +765,8 @@ struct Functions const Spack& qr2qi_collect_tend, const Spack& nr_collect_tend, const Spack& qr2qi_immers_freeze_tend, const Spack& nr2ni_immers_freeze_tend, const Spack& nr_ice_shed_tend, const Spack& qi2qr_melt_tend, const Spack& ni2nr_melt_tend, const Spack& qi2qv_sublim_tend, const Spack& qv2qi_vapdep_tend, const Spack& qv2qi_nucleat_tend, const Spack& ni_nucleat_tend, const Spack& ni_selfcollect_tend, - const Spack& ni_sublim_tend, const Spack& qc2qi_berg_tend, const Spack& inv_exner, const Spack& latent_heat_sublim, - const Spack& latent_heat_fusion, const bool do_predict_nc, const Smask& log_wetgrowth, const Scalar dt, + const Spack& ni_sublim_tend, const Spack& qc2qi_berg_tend, const Spack& inv_exner, + const bool do_predict_nc, const Smask& log_wetgrowth, const Scalar dt, const Scalar& nmltratio, const Spack& rho_qm_cloud, Spack& th_atm, Spack& qv, Spack& qi, Spack& ni, Spack& qm, Spack& bm, Spack& qc, Spack& nc, Spack& qr, Spack& nr, const Smask& context = Smask(true)); @@ -776,7 +774,6 @@ struct Functions // TODO (comments) KOKKOS_FUNCTION static void get_time_space_phys_variables(const Spack& T_atm, const Spack& pres, const Spack& rho, - const Spack& latent_heat_vapor, const Spack& latent_heat_sublim, const Spack& qv_sat_l, const Spack& qv_sat_i, Spack& mu, Spack& dv, Spack& sc, Spack& dqsdt, Spack& dqsidt, Spack& ab, Spack& abi, Spack& kap, Spack& eii, @@ -835,14 +832,14 @@ struct Functions const Spack& cld_frac_l, const Spack& cld_frac_r, const Spack& qv, const Spack& qv_prev, const Spack& qv_sat_l, const Spack& qv_sat_i, const Spack& ab, const Spack& abi, const Spack& epsr, const Spack & epsi_tot, const Spack& t, const Spack& t_prev, - const Spack& latent_heat_sublim, const Spack& dqsdt, const Scalar& dt, + const Spack& dqsdt, const Scalar& dt, Spack& qr2qv_evap_tend, Spack& nr_evap_tend, const Smask& context = Smask(true)); //get number and mass tendencies due to melting ice KOKKOS_FUNCTION static void ice_melting(const Spack& rho, const Spack& T_atm, const Spack& pres, const Spack& rhofaci, - const Spack& table_val_qi2qr_melting, const Spack& table_val_qi2qr_vent_melt, const Spack& latent_heat_vapor, const Spack& latent_heat_fusion, + const Spack& table_val_qi2qr_melting, const Spack& table_val_qi2qr_vent_melt, const Spack& dv, const Spack& sc, const Spack& mu, const Spack& kap, const Spack& qv, const Spack& qi_incld, const Spack& ni_incld, Spack& qi2qr_melt_tend, Spack& ni2nr_melt_tend, const Smask& context = Smask(true)); @@ -852,7 +849,7 @@ struct Functions static void update_prognostic_liquid(const Spack& qc2qr_accret_tend, const Spack& nc_accret_tend, const Spack& qc2qr_autoconv_tend,const Spack& nc2nr_autoconv_tend, const Spack& ncautr, const Spack& nc_selfcollect_tend, const Spack& qr2qv_evap_tend, const Spack& nr_evap_tend, const Spack& nr_selfcollect_tend, - const bool do_predict_nc, const bool do_prescribed_CCN, const Spack& inv_rho, const Spack& inv_exner, const Spack& latent_heat_vapor, + const bool do_predict_nc, const bool do_prescribed_CCN, const Spack& inv_rho, const Spack& inv_exner, const Scalar dt, Spack& th_atm, Spack& qv, Spack& qc, Spack& nc, Spack& qr, Spack& nr, const Smask& context = Smask(true)); @@ -893,15 +890,12 @@ struct Functions KOKKOS_FUNCTION static void ice_cldliq_wet_growth(const Spack& rho, const Spack& temp, const Spack& pres, const Spack& rhofaci, const Spack& table_val_qi2qr_melting, - const Spack& table_val_qi2qr_vent_melt, const Spack& latent_heat_vapor, const Spack& latent_heat_fusion, const Spack& dv, + const Spack& table_val_qi2qr_vent_melt, const Spack& dv, const Spack& kap, const Spack& mu, const Spack& sc, const Spack& qv, const Spack& qc_incld, const Spack& qi_incld, const Spack& ni_incld, const Spack& qr_incld, Smask& log_wetgrowth, Spack& qr2qi_collect_tend, Spack& qc2qi_collect_tend, Spack& qc_growth_rate, Spack& nr_ice_shed_tend, Spack& qc2qr_ice_shed_tend, const Smask& context = Smask(true)); - // Note: not a kernel function - static void get_latent_heat(const Int& nj, const Int& nk, view_2d& v, view_2d& s, view_2d& f); - KOKKOS_FUNCTION static void check_values(const uview_1d& qv, const uview_1d& temp, const Int& ktop, const Int& kbot, const Int& timestepcount, const bool& force_abort, const Int& source_ind, const MemberType& team, @@ -993,9 +987,6 @@ struct Functions const uview_1d& inv_cld_frac_l, const uview_1d& inv_cld_frac_i, const uview_1d& inv_cld_frac_r, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, - const uview_1d& latent_heat_fusion, const uview_1d& T_atm, const uview_1d& rho, const uview_1d& inv_rho, @@ -1044,9 +1035,6 @@ struct Functions const uview_2d& inv_cld_frac_l, const uview_2d& inv_cld_frac_i, const uview_2d& inv_cld_frac_r, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, - const uview_2d& latent_heat_fusion, const uview_2d& T_atm, const uview_2d& rho, const uview_2d& inv_rho, @@ -1127,9 +1115,6 @@ struct Functions const uview_1d& ni, const uview_1d& qm, const uview_1d& bm, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, - const uview_1d& latent_heat_fusion, const uview_1d& qc_incld, const uview_1d& qr_incld, const uview_1d& qi_incld, @@ -1208,9 +1193,6 @@ struct Functions const uview_2d& ni, const uview_2d& qm, const uview_2d& bm, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, - const uview_2d& latent_heat_fusion, const uview_2d& qc_incld, const uview_2d& qr_incld, const uview_2d& qi_incld, @@ -1266,8 +1248,6 @@ struct Functions const uview_1d& ni, const uview_1d& qm, const uview_1d& bm, - const uview_1d& latent_heat_vapor, - const uview_1d& latent_heat_sublim, const uview_1d& mu_c, const uview_1d& nu, const uview_1d& lamc, @@ -1309,8 +1289,6 @@ struct Functions const uview_2d& ni, const uview_2d& qm, const uview_2d& bm, - const uview_2d& latent_heat_vapor, - const uview_2d& latent_heat_sublim, const uview_2d& mu_c, const uview_2d& nu, const uview_2d& lamc, @@ -1378,7 +1356,7 @@ struct Functions #endif KOKKOS_FUNCTION - static void ice_supersat_conservation(Spack& qidep, Spack& qinuc, const Spack& cld_frac_i, const Spack& qv, const Spack& qv_sat_i, const Spack& latent_heat_sublim, const Spack& t_atm, const Real& dt, const Spack& qi2qv_sublim_tend, const Spack& qr2qv_evap_tend, const Smask& context = Smask(true)); + static void ice_supersat_conservation(Spack& qidep, Spack& qinuc, const Spack& cld_frac_i, const Spack& qv, const Spack& qv_sat_i, const Spack& t_atm, const Real& dt, const Spack& qi2qv_sublim_tend, const Spack& qr2qv_evap_tend, const Smask& context = Smask(true)); KOKKOS_FUNCTION static void nc_conservation(const Spack& nc, const Spack& nc_selfcollect_tend, const Real& dt, Spack& nc_collect_tend, Spack& nc2ni_immers_freeze_tend, Spack& nc_accret_tend, Spack& nc2nr_autoconv_tend, const Smask& context = Smask(true)); @@ -1390,7 +1368,7 @@ struct Functions static void ni_conservation(const Spack& ni, const Spack& ni_nucleat_tend, const Spack& nr2ni_immers_freeze_tend, const Spack& nc2ni_immers_freeze_tend, const Real& dt, Spack& ni2nr_melt_tend, Spack& ni_sublim_tend, Spack& ni_selfcollect_tend, const Smask& context = Smask(true)); KOKKOS_FUNCTION - static void prevent_liq_supersaturation(const Spack& pres, const Spack& t_atm, const Spack& qv, const Spack& latent_heat_vapor, const Spack& latent_heat_sublim, const Scalar& dt, const Spack& qidep, const Spack& qinuc, Spack& qi2qv_sublim_tend, Spack& qr2qv_evap_tend, const Smask& context = Smask(true) ); + static void prevent_liq_supersaturation(const Spack& pres, const Spack& t_atm, const Spack& qv, const Scalar& dt, const Spack& qidep, const Spack& qinuc, Spack& qi2qv_sublim_tend, Spack& qr2qv_evap_tend, const Smask& context = Smask(true) ); }; // struct Functions template @@ -1438,7 +1416,6 @@ void init_tables_from_f90_c(Real* vn_table_vals_data, Real* vm_table_vals_data, # include "p3_ice_melting_impl.hpp" # include "p3_calc_liq_relaxation_timescale_impl.hpp" # include "p3_ice_cldliq_wet_growth_impl.hpp" -# include "p3_get_latent_heat_impl.hpp" # include "p3_check_values_impl.hpp" # include "p3_incloud_mixingratios_impl.hpp" # include "p3_subgrid_variance_scaling_impl.hpp" diff --git a/components/eamxx/src/physics/p3/p3_functions_f90.cpp b/components/eamxx/src/physics/p3/p3_functions_f90.cpp index b8f6e826fc1..40d82d4f652 100644 --- a/components/eamxx/src/physics/p3/p3_functions_f90.cpp +++ b/components/eamxx/src/physics/p3/p3_functions_f90.cpp @@ -1417,7 +1417,7 @@ void rain_sedimentation_f( void homogeneous_freezing_f( Int kts, Int kte, Int ktop, Int kbot, Int kdir, - Real* T_atm, Real* inv_exner, Real* latent_heat_fusion, + Real* T_atm, Real* inv_exner, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* th_atm) { using P3F = Functions; @@ -1440,31 +1440,31 @@ void homogeneous_freezing_f( const Int nk_pack = ekat::npack(nk); // Set up views - std::vector temp_d(HomogeneousFreezingData::NUM_ARRAYS); + std::vector temp_d(HomogeneousFreezingData::NUM_ARRAYS-1); - ekat::host_to_device({T_atm, inv_exner, latent_heat_fusion, qc, nc, qr, nr, qi, ni, qm, bm, th_atm}, + ekat::host_to_device({T_atm, inv_exner, qc, nc, qr, nr, qi, ni, qm, bm, th_atm}, nk, temp_d); + int current_index = 0; view_1d - t_d (temp_d[0]), - inv_exner_d (temp_d[1]), - latent_heat_fusion_d (temp_d[2]), - qc_d (temp_d[3]), - nc_d (temp_d[4]), - qr_d (temp_d[5]), - nr_d (temp_d[6]), - qi_d (temp_d[7]), - ni_d (temp_d[8]), - qm_d (temp_d[9]), - bm_d (temp_d[10]), - th_atm_d (temp_d[11]); + t_d (temp_d[current_index++]), + inv_exner_d (temp_d[current_index++]), + qc_d (temp_d[current_index++]), + nc_d (temp_d[current_index++]), + qr_d (temp_d[current_index++]), + nr_d (temp_d[current_index++]), + qi_d (temp_d[current_index++]), + ni_d (temp_d[current_index++]), + qm_d (temp_d[current_index++]), + bm_d (temp_d[current_index++]), + th_atm_d (temp_d[current_index++]); // Call core function from kernel auto policy = ekat::ExeSpaceUtils::get_default_team_policy(1, nk_pack); Kokkos::parallel_for(policy, KOKKOS_LAMBDA(const MemberType& team) { P3F::homogeneous_freezing( - t_d, inv_exner_d, latent_heat_fusion_d, + t_d, inv_exner_d, team, nk, ktop, kbot, kdir, qc_d, nc_d, qr_d, nr_d, qi_d, ni_d, qm_d, bm_d, th_atm_d); @@ -1476,37 +1476,6 @@ void homogeneous_freezing_f( ekat::device_to_host({qc, nc, qr, nr, qi, ni, qm, bm, th_atm}, nk, inout_views); } -void get_latent_heat_f(Int its, Int ite, Int kts, Int kte, Real* v, Real* s, Real* f) -{ - using P3F = Functions; - using Spack = typename P3F::Spack; - using view_2d = typename P3F::view_2d; - - EKAT_REQUIRE_MSG(kte >= kts, - "kte must be >= kts, kts=" << kts << " kte=" << kte); - - EKAT_REQUIRE_MSG(ite >= its, - "ite must be >= its, its=" << its << " ite=" << ite); - - kts -= 1; - kte -= 1; - its -= 1; - ite -= 1; - - Int nk = (kte - kts) + 1; - Int nj = (ite - its) + 1; - - // Set up views - view_2d v_d("v_d", nj, nk), - s_d("s_d", nj, nk), - f_d("f_d", nj, nk); - - P3F::get_latent_heat(nj, nk, v_d, s_d, f_d); - - std::vector out_views = {v_d, s_d, f_d}; - ekat::device_to_host({v, s, f}, nj, nk, out_views, true); -} - void check_values_f(Real* qv, Real* temp, Int kstart, Int kend, Int timestepcount, bool force_abort, Int source_ind, Real* col_loc) { @@ -1545,7 +1514,7 @@ void p3_main_part1_f( bool do_predict_nc, bool do_prescribed_CCN, Real dt, Real* pres, Real* dpres, Real* dz, Real* nc_nuceat_tend, Real* nccn_prescribed, Real* inv_exner, Real* exner, Real* inv_cld_frac_l, Real* inv_cld_frac_i, - Real* inv_cld_frac_r, Real* latent_heat_vapor, Real* latent_heat_sublim, Real* latent_heat_fusion, + Real* inv_cld_frac_r, Real* T_atm, Real* rho, Real* inv_rho, Real* qv_sat_l, Real* qv_sat_i, Real* qv_supersat_i, Real* rhofacr, Real* rhofaci, Real* acn, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, Real* ni_incld, Real* bm_incld, @@ -1576,7 +1545,7 @@ void p3_main_part1_f( ekat::host_to_device({pres, dpres, dz, nc_nuceat_tend, inv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, inv_cld_frac_r, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, - acn, qv, th_atm, qc, nc, qr, nr, qi, ni, qm, bm, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion, qc_incld, qr_incld, qi_incld, + acn, qv, th_atm, qc, nc, qr, nr, qi, ni, qm, bm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, ni_incld, bm_incld, nccn_prescribed}, nk, temp_d); @@ -1609,18 +1578,15 @@ void p3_main_part1_f( ni_d (temp_d[25]), qm_d (temp_d[26]), bm_d (temp_d[27]), - latent_heat_vapor_d (temp_d[28]), - latent_heat_sublim_d (temp_d[29]), - latent_heat_fusion_d (temp_d[30]), - qc_incld_d (temp_d[31]), - qr_incld_d (temp_d[32]), - qi_incld_d (temp_d[33]), - qm_incld_d (temp_d[34]), - nc_incld_d (temp_d[35]), - nr_incld_d (temp_d[36]), - ni_incld_d (temp_d[37]), - bm_incld_d (temp_d[38]), - nccn_prescribed_d (temp_d[39]); + qc_incld_d (temp_d[28]), + qr_incld_d (temp_d[29]), + qi_incld_d (temp_d[30]), + qm_incld_d (temp_d[31]), + nc_incld_d (temp_d[32]), + nr_incld_d (temp_d[33]), + ni_incld_d (temp_d[34]), + bm_incld_d (temp_d[35]), + nccn_prescribed_d (temp_d[36]); // Call core function from kernel bview_1d bools_d("bools", 2); @@ -1630,7 +1596,7 @@ void p3_main_part1_f( P3F::p3_main_part1( team, nk, do_predict_nc, do_prescribed_CCN, dt, pres_d, dpres_d, dz_d, nc_nuceat_tend_d, nccn_prescribed_d, inv_exner_d, exner_d, inv_cld_frac_l_d, inv_cld_frac_i_d, - inv_cld_frac_r_d, latent_heat_vapor_d, latent_heat_sublim_d, latent_heat_fusion_d, + inv_cld_frac_r_d, t_d, rho_d, inv_rho_d, qv_sat_l_d, qv_sat_i_d, qv_supersat_i_d, rhofacr_d, rhofaci_d, acn_d, qv_d, th_atm_d, qc_d, nc_d, qr_d, nr_d, qi_d, ni_d, qm_d, bm_d, qc_incld_d, qr_incld_d, qi_incld_d, qm_incld_d, nc_incld_d, nr_incld_d, ni_incld_d, bm_incld_d, @@ -1661,7 +1627,7 @@ void p3_main_part2_f( Real* inv_cld_frac_r, Real* ni_activated, Real* inv_qc_relvar, Real* cld_frac_i, Real* cld_frac_l, Real* cld_frac_r, Real* qv_prev, Real* t_prev, Real* T_atm, Real* rho, Real* inv_rho, Real* qv_sat_l, Real* qv_sat_i, Real* qv_supersat_i, Real* rhofacr, Real* rhofaci, Real* acn, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, - Real* qm, Real* bm, Real* latent_heat_vapor, Real* latent_heat_sublim, Real* latent_heat_fusion, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, + Real* qm, Real* bm, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, Real* ni_incld, Real* bm_incld, Real* mu_c, Real* nu, Real* lamc, Real* cdist, Real* cdist1, Real* cdistr, Real* mu_r, Real* lamr, Real* logn0r, Real* qv2qi_depos_tend, Real* precip_total_tend, Real* nevapr, Real* qr_evap_tend, Real* vap_liq_exchange, Real* vap_ice_exchange, Real* liq_ice_exchange, Real* pratot, Real* prctot, bool* is_hydromet_present) @@ -1688,82 +1654,80 @@ void p3_main_part2_f( const Real max_total_ni = 740.0e3; // Hard-code this value for F90 comparison // Set up views - std::vector temp_d(P3MainPart2Data::NUM_ARRAYS); + std::vector temp_d(P3MainPart2Data::NUM_ARRAYS-3); ekat::host_to_device({pres, dpres, dz, nc_nuceat_tend, inv_exner, exner, inv_cld_frac_l, inv_cld_frac_i, inv_cld_frac_r, ni_activated, inv_qc_relvar, cld_frac_i, cld_frac_l, cld_frac_r, T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, - qv, th_atm, qc, nc, qr, nr, qi, ni, qm, bm, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion, qc_incld, qr_incld, + qv, th_atm, qc, nc, qr, nr, qi, ni, qm, bm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, ni_incld, bm_incld, mu_c, nu, lamc, cdist, cdist1, cdistr, mu_r, lamr, logn0r, qv2qi_depos_tend, precip_total_tend, nevapr, qr_evap_tend, vap_liq_exchange, vap_ice_exchange, liq_ice_exchange, pratot, prctot, qv_prev, t_prev }, nk, temp_d); + int current_index = 0; view_1d - pres_d (temp_d[0]), - dpres_d (temp_d[1]), - dz_d (temp_d[2]), - nc_nuceat_tend_d (temp_d[3]), - inv_exner_d (temp_d[4]), - exner_d (temp_d[5]), - inv_cld_frac_l_d (temp_d[6]), - inv_cld_frac_i_d (temp_d[7]), - inv_cld_frac_r_d (temp_d[8]), - ni_activated_d (temp_d[9]), - inv_qc_relvar_d (temp_d[10]), - cld_frac_i_d (temp_d[11]), - cld_frac_l_d (temp_d[12]), - cld_frac_r_d (temp_d[13]), - t_d (temp_d[14]), - rho_d (temp_d[15]), - inv_rho_d (temp_d[16]), - qv_sat_l_d (temp_d[17]), - qv_sat_i_d (temp_d[18]), - qv_supersat_i_d (temp_d[19]), - rhofacr_d (temp_d[20]), - rhofaci_d (temp_d[21]), - acn_d (temp_d[22]), - qv_d (temp_d[23]), - th_atm_d (temp_d[24]), - qc_d (temp_d[25]), - nc_d (temp_d[26]), - qr_d (temp_d[27]), - nr_d (temp_d[28]), - qi_d (temp_d[29]), - ni_d (temp_d[30]), - qm_d (temp_d[31]), - bm_d (temp_d[32]), - latent_heat_vapor_d (temp_d[33]), - latent_heat_sublim_d(temp_d[34]), - latent_heat_fusion_d(temp_d[35]), - qc_incld_d (temp_d[36]), - qr_incld_d (temp_d[37]), - qi_incld_d (temp_d[38]), - qm_incld_d (temp_d[39]), - nc_incld_d (temp_d[40]), - nr_incld_d (temp_d[41]), - ni_incld_d (temp_d[42]), - bm_incld_d (temp_d[43]), - mu_c_d (temp_d[44]), - nu_d (temp_d[45]), - lamc_d (temp_d[46]), - cdist_d (temp_d[47]), - cdist1_d (temp_d[48]), - cdistr_d (temp_d[49]), - mu_r_d (temp_d[50]), - lamr_d (temp_d[51]), - logn0r_d (temp_d[52]), - qv2qi_depos_tend_d (temp_d[53]), - precip_total_tend_d (temp_d[54]), - nevapr_d (temp_d[55]), - qr_evap_tend_d (temp_d[56]), - vap_liq_exchange_d (temp_d[57]), - vap_ice_exchange_d (temp_d[58]), - liq_ice_exchange_d (temp_d[59]), - pratot_d (temp_d[60]), - prctot_d (temp_d[61]), - qv_prev_d (temp_d[62]), - t_prev_d (temp_d[63]); + pres_d (temp_d[current_index++]), + dpres_d (temp_d[current_index++]), + dz_d (temp_d[current_index++]), + nc_nuceat_tend_d (temp_d[current_index++]), + inv_exner_d (temp_d[current_index++]), + exner_d (temp_d[current_index++]), + inv_cld_frac_l_d (temp_d[current_index++]), + inv_cld_frac_i_d (temp_d[current_index++]), + inv_cld_frac_r_d (temp_d[current_index++]), + ni_activated_d (temp_d[current_index++]), + inv_qc_relvar_d (temp_d[current_index++]), + cld_frac_i_d (temp_d[current_index++]), + cld_frac_l_d (temp_d[current_index++]), + cld_frac_r_d (temp_d[current_index++]), + t_d (temp_d[current_index++]), + rho_d (temp_d[current_index++]), + inv_rho_d (temp_d[current_index++]), + qv_sat_l_d (temp_d[current_index++]), + qv_sat_i_d (temp_d[current_index++]), + qv_supersat_i_d (temp_d[current_index++]), + rhofacr_d (temp_d[current_index++]), + rhofaci_d (temp_d[current_index++]), + acn_d (temp_d[current_index++]), + qv_d (temp_d[current_index++]), + th_atm_d (temp_d[current_index++]), + qc_d (temp_d[current_index++]), + nc_d (temp_d[current_index++]), + qr_d (temp_d[current_index++]), + nr_d (temp_d[current_index++]), + qi_d (temp_d[current_index++]), + ni_d (temp_d[current_index++]), + qm_d (temp_d[current_index++]), + bm_d (temp_d[current_index++]), + qc_incld_d (temp_d[current_index++]), + qr_incld_d (temp_d[current_index++]), + qi_incld_d (temp_d[current_index++]), + qm_incld_d (temp_d[current_index++]), + nc_incld_d (temp_d[current_index++]), + nr_incld_d (temp_d[current_index++]), + ni_incld_d (temp_d[current_index++]), + bm_incld_d (temp_d[current_index++]), + mu_c_d (temp_d[current_index++]), + nu_d (temp_d[current_index++]), + lamc_d (temp_d[current_index++]), + cdist_d (temp_d[current_index++]), + cdist1_d (temp_d[current_index++]), + cdistr_d (temp_d[current_index++]), + mu_r_d (temp_d[current_index++]), + lamr_d (temp_d[current_index++]), + logn0r_d (temp_d[current_index++]), + qv2qi_depos_tend_d (temp_d[current_index++]), + precip_total_tend_d (temp_d[current_index++]), + nevapr_d (temp_d[current_index++]), + qr_evap_tend_d (temp_d[current_index++]), + vap_liq_exchange_d (temp_d[current_index++]), + vap_ice_exchange_d (temp_d[current_index++]), + liq_ice_exchange_d (temp_d[current_index++]), + pratot_d (temp_d[current_index++]), + prctot_d (temp_d[current_index++]), + qv_prev_d (temp_d[current_index++]), + t_prev_d (temp_d[current_index++]); // Call core function from kernel const auto dnu = P3GlobalForFortran::dnu(); @@ -1780,7 +1744,7 @@ void p3_main_part2_f( inv_cld_frac_i_d, inv_cld_frac_r_d, ni_activated_d, inv_qc_relvar_d, cld_frac_i_d, cld_frac_l_d, cld_frac_r_d, qv_prev_d, t_prev_d, t_d, rho_d, inv_rho_d, qv_sat_l_d, qv_sat_i_d, qv_supersat_i_d, rhofacr_d, rhofaci_d, acn_d, qv_d, th_atm_d, qc_d, nc_d, qr_d, nr_d, qi_d, ni_d, qm_d, bm_d, - latent_heat_vapor_d, latent_heat_sublim_d, latent_heat_fusion_d, qc_incld_d, qr_incld_d, qi_incld_d, + qc_incld_d, qr_incld_d, qi_incld_d, qm_incld_d, nc_incld_d, nr_incld_d, ni_incld_d, bm_incld_d, mu_c_d, nu_d, lamc_d, cdist_d, cdist1_d, cdistr_d, mu_r_d, lamr_d, logn0r_d, qv2qi_depos_tend_d, precip_total_tend_d, nevapr_d, qr_evap_tend_d, vap_liq_exchange_d, @@ -1791,7 +1755,7 @@ void p3_main_part2_f( std::vector inout_views = { t_d, rho_d, inv_rho_d, qv_sat_l_d, qv_sat_i_d, qv_supersat_i_d, rhofacr_d, rhofaci_d, acn_d, qv_d, th_atm_d, qc_d, nc_d, qr_d, nr_d, qi_d, ni_d, qm_d, bm_d, - latent_heat_vapor_d, latent_heat_sublim_d, latent_heat_fusion_d, qc_incld_d, qr_incld_d, qi_incld_d, qm_incld_d, + qc_incld_d, qr_incld_d, qi_incld_d, qm_incld_d, nc_incld_d, nr_incld_d, ni_incld_d, bm_incld_d, mu_c_d, nu_d, lamc_d, cdist_d, cdist1_d, cdistr_d, mu_r_d, lamr_d, logn0r_d, qv2qi_depos_tend_d, precip_total_tend_d, nevapr_d, qr_evap_tend_d, vap_liq_exchange_d, vap_ice_exchange_d, @@ -1800,7 +1764,7 @@ void p3_main_part2_f( ekat::device_to_host({ T_atm, rho, inv_rho, qv_sat_l, qv_sat_i, qv_supersat_i, rhofacr, rhofaci, acn, qv, th_atm, qc, nc, - qr, nr, qi, ni, qm, bm, latent_heat_vapor, latent_heat_sublim, latent_heat_fusion, qc_incld, qr_incld, + qr, nr, qi, ni, qm, bm, qc_incld, qr_incld, qi_incld, qm_incld, nc_incld, nr_incld, ni_incld, bm_incld, mu_c, nu, lamc, cdist, cdist1, cdistr, mu_r, lamr, logn0r, qv2qi_depos_tend, precip_total_tend, nevapr, qr_evap_tend, vap_liq_exchange, vap_ice_exchange, liq_ice_exchange, @@ -1818,7 +1782,7 @@ void p3_main_part3_f( Real* inv_exner, Real* cld_frac_l, Real* cld_frac_r, Real* cld_frac_i, Real* rho, Real* inv_rho, Real* rhofaci, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, - Real* bm, Real* latent_heat_vapor, Real* latent_heat_sublim, Real* mu_c, Real* nu, Real* lamc, + Real* bm, Real* mu_c, Real* nu, Real* lamc, Real* mu_r, Real* lamr, Real* vap_liq_exchange, Real* ze_rain, Real* ze_ice, Real* diag_vm_qi, Real* diag_eff_radius_qi, Real* diag_diam_qi, Real* rho_qi, Real* diag_equiv_reflectivity, Real* diag_eff_radius_qc, Real* diag_eff_radius_qr) @@ -1844,50 +1808,49 @@ void p3_main_part3_f( const Real max_total_ni = 740.0e3; // Hard-code this value for F90 comparison // Set up views - std::vector temp_d(P3MainPart3Data::NUM_ARRAYS); + std::vector temp_d(P3MainPart3Data::NUM_ARRAYS-2); ekat::host_to_device({ inv_exner, cld_frac_l, cld_frac_r, cld_frac_i, rho, inv_rho, rhofaci, qv, th_atm, qc, - nc, qr, nr, qi, ni, qm, bm, latent_heat_vapor, latent_heat_sublim, mu_c, nu, lamc, mu_r, + nc, qr, nr, qi, ni, qm, bm, mu_c, nu, lamc, mu_r, lamr, vap_liq_exchange, ze_rain, ze_ice, diag_vm_qi, diag_eff_radius_qi, diag_diam_qi, rho_qi, diag_equiv_reflectivity, diag_eff_radius_qc, diag_eff_radius_qr}, nk, temp_d); + int current_index = 0; view_1d - inv_exner_d (temp_d[0]), - cld_frac_l_d (temp_d[1]), - cld_frac_r_d (temp_d[2]), - cld_frac_i_d (temp_d[3]), - rho_d (temp_d[4]), - inv_rho_d (temp_d[5]), - rhofaci_d (temp_d[6]), - qv_d (temp_d[7]), - th_atm_d (temp_d[8]), - qc_d (temp_d[9]), - nc_d (temp_d[10]), - qr_d (temp_d[11]), - nr_d (temp_d[12]), - qi_d (temp_d[13]), - ni_d (temp_d[14]), - qm_d (temp_d[15]), - bm_d (temp_d[16]), - latent_heat_vapor_d (temp_d[17]), - latent_heat_sublim_d (temp_d[18]), - mu_c_d (temp_d[19]), - nu_d (temp_d[20]), - lamc_d (temp_d[21]), - mu_r_d (temp_d[22]), - lamr_d (temp_d[23]), - vap_liq_exchange_d (temp_d[24]), - ze_rain_d (temp_d[25]), - ze_ice_d (temp_d[26]), - diag_vm_qi_d (temp_d[27]), - diag_eff_radius_qi_d (temp_d[28]), - diag_diam_qi_d (temp_d[29]), - rho_qi_d (temp_d[30]), - diag_equiv_reflectivity_d (temp_d[31]), - diag_eff_radius_qc_d (temp_d[32]), - diag_eff_radius_qr_d (temp_d[33]); + inv_exner_d (temp_d[current_index++]), + cld_frac_l_d (temp_d[current_index++]), + cld_frac_r_d (temp_d[current_index++]), + cld_frac_i_d (temp_d[current_index++]), + rho_d (temp_d[current_index++]), + inv_rho_d (temp_d[current_index++]), + rhofaci_d (temp_d[current_index++]), + qv_d (temp_d[current_index++]), + th_atm_d (temp_d[current_index++]), + qc_d (temp_d[current_index++]), + nc_d (temp_d[current_index++]), + qr_d (temp_d[current_index++]), + nr_d (temp_d[current_index++]), + qi_d (temp_d[current_index++]), + ni_d (temp_d[current_index++]), + qm_d (temp_d[current_index++]), + bm_d (temp_d[current_index++]), + mu_c_d (temp_d[current_index++]), + nu_d (temp_d[current_index++]), + lamc_d (temp_d[current_index++]), + mu_r_d (temp_d[current_index++]), + lamr_d (temp_d[current_index++]), + vap_liq_exchange_d (temp_d[current_index++]), + ze_rain_d (temp_d[current_index++]), + ze_ice_d (temp_d[current_index++]), + diag_vm_qi_d (temp_d[current_index++]), + diag_eff_radius_qi_d (temp_d[current_index++]), + diag_diam_qi_d (temp_d[current_index++]), + rho_qi_d (temp_d[current_index++]), + diag_equiv_reflectivity_d (temp_d[current_index++]), + diag_eff_radius_qc_d (temp_d[current_index++]), + diag_eff_radius_qr_d (temp_d[current_index++]); // Call core function from kernel const auto dnu = P3GlobalForFortran::dnu(); @@ -1898,8 +1861,8 @@ void p3_main_part3_f( P3F::p3_main_part3(team, nk_pack, max_total_ni, dnu, ice_table_vals, inv_exner_d, cld_frac_l_d, cld_frac_r_d, cld_frac_i_d, rho_d, inv_rho_d, rhofaci_d, qv_d, th_atm_d, qc_d, nc_d, qr_d, nr_d, - qi_d, ni_d, qm_d, bm_d, latent_heat_vapor_d, - latent_heat_sublim_d, mu_c_d, nu_d, lamc_d, mu_r_d, lamr_d, + qi_d, ni_d, qm_d, bm_d, + mu_c_d, nu_d, lamc_d, mu_r_d, lamr_d, vap_liq_exchange_d, ze_rain_d, ze_ice_d, diag_vm_qi_d, diag_eff_radius_qi_d, diag_diam_qi_d, rho_qi_d, diag_equiv_reflectivity_d, diag_eff_radius_qc_d, diag_eff_radius_qr_d, physics::P3_Constants()); @@ -1908,14 +1871,14 @@ void p3_main_part3_f( // Sync back to host std::vector inout_views = { rho_d, inv_rho_d, rhofaci_d, qv_d, th_atm_d, qc_d, nc_d, qr_d, nr_d, qi_d, - ni_d, qm_d, bm_d, latent_heat_vapor_d, latent_heat_sublim_d, mu_c_d, nu_d, lamc_d, mu_r_d, + ni_d, qm_d, bm_d, mu_c_d, nu_d, lamc_d, mu_r_d, lamr_d, vap_liq_exchange_d, ze_rain_d, ze_ice_d, diag_vm_qi_d, diag_eff_radius_qi_d, diag_diam_qi_d, rho_qi_d, diag_equiv_reflectivity_d, diag_eff_radius_qc_d, diag_eff_radius_qr_d }; ekat::device_to_host({ rho, inv_rho, rhofaci, qv, th_atm, qc, nc, qr, nr, qi, ni, qm, bm, - latent_heat_vapor, latent_heat_sublim, mu_c, nu, lamc, mu_r, lamr, vap_liq_exchange, ze_rain, ze_ice, + mu_c, nu, lamc, mu_r, lamr, vap_liq_exchange, ze_rain, ze_ice, diag_vm_qi, diag_eff_radius_qi, diag_diam_qi, rho_qi, diag_equiv_reflectivity, diag_eff_radius_qc, diag_eff_radius_qr }, diff --git a/components/eamxx/src/physics/p3/p3_functions_f90.hpp b/components/eamxx/src/physics/p3/p3_functions_f90.hpp index 926c9ab4701..d1c29d3de0d 100644 --- a/components/eamxx/src/physics/p3/p3_functions_f90.hpp +++ b/components/eamxx/src/physics/p3/p3_functions_f90.hpp @@ -908,11 +908,9 @@ void rain_sedimentation_f( void homogeneous_freezing_f( Int kts, Int kte, Int ktop, Int kbot, Int kdir, - Real* T_atm, Real* inv_exner, Real* latent_heat_fusion, + Real* T_atm, Real* inv_exner, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* th_atm); -void get_latent_heat_f(Int its, Int ite, Int kts, Int kte, Real* v, Real* s, Real* f); - void check_values_f(Real* Qv, Real* temp, Int kstart, Int kend, Int timestepcount, bool force_abort, Int source_ind, Real* col_loc); @@ -921,7 +919,7 @@ void p3_main_part1_f( bool do_predict_nc, bool do_prescribed_CCN, Real dt, Real* pres, Real* dpres, Real* dz, Real* nc_nuceat_tend, Real* nccn_prescribed, Real* inv_exner, Real* exner, Real* inv_cld_frac_l, Real* inv_cld_frac_i, - Real* inv_cld_frac_r, Real* latent_heat_vapor, Real* latent_heat_sublim, Real* latent_heat_fusion, + Real* inv_cld_frac_r, Real* T_atm, Real* rho, Real* inv_rho, Real* qv_sat_l, Real* qv_sat_i, Real* qv_supersat_i, Real* rhofacr, Real* rhofaci, Real* acn, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, Real* ni_incld, Real* bm_incld, @@ -931,7 +929,7 @@ void p3_main_part2_f( Int kts, Int kte, Int kbot, Int ktop, Int kdir, bool do_predict_nc, bool do_prescribed_CCN, Real dt, Real inv_dt, Real* pres, Real* dpres, Real* dz, Real* nc_nuceat_tend, Real* inv_exner, Real* exner, Real* inv_cld_frac_l, Real* inv_cld_frac_i, Real* inv_cld_frac_r, Real* ni_activated, Real* inv_qc_relvar, Real* cld_frac_i, Real* cld_frac_l, Real* cld_frac_r, Real* qv_prev, Real* t_prev, Real* T_atm, Real* rho, Real* inv_rho, Real* qv_sat_l, Real* qv_sat_i, Real* qv_supersat_i, Real* rhofacr, Real* rhofaci, Real* acn, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, - Real* qm, Real* bm, Real* latent_heat_vapor, Real* latent_heat_sublim, Real* latent_heat_fusion, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, + Real* qm, Real* bm, Real* qc_incld, Real* qr_incld, Real* qi_incld, Real* qm_incld, Real* nc_incld, Real* nr_incld, Real* ni_incld, Real* bm_incld, Real* mu_c, Real* nu, Real* lamc, Real* cdist, Real* cdist1, Real* cdistr, Real* mu_r, Real* lamr, Real* logn0r, Real* qv2qi_depos_tend, Real* precip_total_tend, Real* nevapr, Real* qr_evap_tend, Real* vap_liq_exchange, Real* vap_ice_exchange, Real* liq_ice_exchange, Real* pratot, Real* prctot, bool* is_hydromet_present); @@ -939,7 +937,7 @@ void p3_main_part2_f( void p3_main_part3_f( Int kts, Int kte, Int kbot, Int ktop, Int kdir, Real* inv_exner, Real* cld_frac_l, Real* cld_frac_r, Real* cld_frac_i, - Real* rho, Real* inv_rho, Real* rhofaci, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* latent_heat_vapor, Real* latent_heat_sublim, + Real* rho, Real* inv_rho, Real* rhofaci, Real* qv, Real* th_atm, Real* qc, Real* nc, Real* qr, Real* nr, Real* qi, Real* ni, Real* qm, Real* bm, Real* mu_c, Real* nu, Real* lamc, Real* mu_r, Real* lamr, Real* vap_liq_exchange, Real* ze_rain, Real* ze_ice, Real* diag_vm_qi, Real* diag_eff_radius_qi, Real* diag_diam_qi, Real* rho_qi, Real* diag_equiv_reflectivity, Real* diag_eff_radius_qc, Real* diag_eff_radius_qr); diff --git a/components/eamxx/src/physics/p3/tests/CMakeLists.txt b/components/eamxx/src/physics/p3/tests/CMakeLists.txt index 912c7cedac6..217c2945e48 100644 --- a/components/eamxx/src/physics/p3/tests/CMakeLists.txt +++ b/components/eamxx/src/physics/p3/tests/CMakeLists.txt @@ -26,7 +26,6 @@ set(P3_TESTS_SRCS p3_ice_melting_unit_tests.cpp p3_evaporate_rain_unit_tests.cpp p3_ice_cldliq_wet_growth_unit_tests.cpp - p3_get_latent_heat_unit_tests.cpp p3_subgrid_variance_scaling_unit_tests.cpp p3_check_values_unit_tests.cpp p3_incloud_mixingratios_unit_tests.cpp diff --git a/components/eamxx/src/physics/p3/tests/p3_evaporate_rain_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_evaporate_rain_unit_tests.cpp index 24cc3a84818..f8398135a19 100644 --- a/components/eamxx/src/physics/p3/tests/p3_evaporate_rain_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_evaporate_rain_unit_tests.cpp @@ -82,7 +82,6 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip Spack epsi_tot(1./60.); Spack t(287); Spack t_prev(285); - Spack latent_heat_sublim(3.34e5); Spack dqsdt(1e-3); Scalar dt=60; Spack qrtend; @@ -92,7 +91,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip constexpr Scalar QSMALL = C::QSMALL; Functions::evaporate_rain(Spack(QSMALL/2),qc_incld,nr_incld,qi_incld, //qr_incld->QSMALL/2 cld_frac_l,cld_frac_r,qv,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qrtend,nrtend); REQUIRE( std::abs(qrtend[0])<1e-8 ); REQUIRE( std::abs(nrtend[0])<1e-8 ); @@ -101,7 +100,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip Spack qr_tiny=Spack(5e-13); Functions::evaporate_rain(qr_tiny,qc_incld,nr_incld,qi_incld, //qr_incld->_tiny cld_frac_l,cld_frac_r,qv,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qrtend,nrtend); REQUIRE( std::abs(qrtend[0] - qr_tiny[0]/dt *(cld_frac_r[0]-cld_frac_l[0])/cld_frac_r[0])<1e-8 ); @@ -111,7 +110,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip //if no rainy areas outside cloud, don't evap Functions::evaporate_rain(qr_incld,qc_incld,nr_incld,qi_incld, cld_frac_r,cld_frac_r,qv,qv_prev,qv_sat_l,qv_sat_i, //cld_frac_l->_r - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qrtend,nrtend); REQUIRE( std::abs(qrtend[0])<1e-8 ); REQUIRE( std::abs(nrtend[0])<1e-8 ); @@ -120,7 +119,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip Functions::evaporate_rain(qr_incld,qc_incld,nr_incld,qi_incld, //set qv->qv_sat_l*2 in next line to ensure supersaturated. cld_frac_l,cld_frac_r,qv_sat_l*2,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qrtend,nrtend); REQUIRE( std::abs(qrtend[0])<1e-8 ); REQUIRE( std::abs(nrtend[0])<1e-8 ); @@ -129,7 +128,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip Functions::evaporate_rain(qr_incld,qc_incld,nr_incld,qi_incld, //qv -> qv*0.1 to encourage lots of rain evap cld_frac_l,cld_frac_r,qv*0.1,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qrtend,nrtend); REQUIRE( qrtend[0] <= qr_incld[0]/dt); REQUIRE( nrtend[0] <= nr_incld[0]/dt); //keep end-of-step nr positive. Should always be true. @@ -137,6 +136,8 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip }; //end run_property static void run_bfb(){ + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; //fortran generated data is input to the following //This subroutine has 20 args, only 18 are supplied here for invoking it as last 2 are intent-outs @@ -152,23 +153,23 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip //rows 9-16: random junk but ensured cld_frac_r>cld_frac_l and subsaturated. EvapRainData espd[max_pack_size] = { //qr_incld, qc_incld, nr_incld, qi_incld, cld_frac_l, cld_frac_r, qv, qv_prev, qv_sat_l, qv_sat_i, ab, abi, epsr, epsi_tot, t, t_prev, lat_ht_sublim, dqsdt, dt - {4.634940e-03,1.215335e-03,6.073270e+07,3.594486e-04,6.134229e-01,9.134229e-01,2.747871e-03,1.911238e-03,5.913313e-03,1.057645e-03,1.782748e+00,1.571392e+00,3.868229e+02,2.248689e+02,3.101180e+02,1.395063e+02,3.335413e+05,5.494606e-03,6.000000e+02}, - {6.175320e-13,4.432407e-03,8.029967e+07,1.905151e-03,2.190099e-01,7.031070e-01,4.172977e-05,7.315360e-03,7.280063e-03,1.378543e-03,1.461443e+00,1.507382e+00,8.452377e+02,1.971876e+02,2.389249e+02,1.497752e+02,3.578466e+05,5.107905e-03,6.000000e+02}, - {4.519798e-03,7.348916e-03,7.420725e+07,2.220971e-03,1.882608e-01,2.934182e-01,4.957590e-03,2.550256e-03,3.136926e-03,4.498115e-03,1.433526e+00,1.207516e+00,9.716844e+02,5.602546e+01,1.389465e+02,1.075863e+02,3.570404e+05,6.771428e-03,6.000000e+02}, - {7.169182e-03,6.657331e-03,9.807967e+07,7.981196e-03,2.914473e-01,6.375719e-01,2.420032e-03,1.223012e-03,7.685516e-03,5.207024e-03,1.644865e+00,1.433872e+00,3.825069e+02,6.550300e+02,1.833466e+02,1.741918e+02,3.295800e+05,3.792982e-03,6.000000e+02}, - {1.103118e-03,9.158125e-03,3.136196e+07,4.286154e-03,2.699078e-01,4.668103e-01,9.645460e-03,6.379119e-03,8.283285e-03,3.342400e-03,1.546698e+00,1.417916e+00,9.289270e+02,9.844129e+02,2.543202e+02,1.932996e+02,3.327786e+05,2.693119e-03,6.000000e+02}, - {4.308000e-03,8.168535e-03,7.439969e+07,5.131497e-03,6.851225e-01,3.298025e-01,4.331812e-03,2.814373e-03,3.592807e-03,1.527499e-03,1.856943e+00,1.003269e+00,9.165690e+02,9.379921e+02,2.163204e+02,3.165814e+02,3.874371e+05,6.801393e-03,6.000000e+02}, - {0.000000e-00,3.318968e-03,4.664041e+07,8.737282e-03,2.585907e-01,6.297295e-02,8.747418e-03,2.710437e-03,2.164895e-03,9.455725e-03,1.241506e+00,1.561393e+00,2.492674e+02,6.546182e+02,2.228772e+02,2.147968e+02,3.590381e+05,5.903261e-03,6.000000e+02}, - {7.677170e-03,6.069057e-05,6.404241e+07,3.094233e-03,3.755403e-01,5.026876e-01,4.723817e-03,1.204228e-03,6.156526e-03,8.194797e-03,1.361509e+00,1.772751e+00,6.420537e+01,4.043364e+02,2.833110e+02,3.314521e+02,3.427004e+05,2.996696e-03,6.000000e+02}, - - {9.999294e-03,3.138400e-03,2.355097e+07,9.897893e-03,7.667177e-01,9.739270e-01,4.221430e-03,3.570130e-03,8.370033e-03,9.527208e-03,1.597218e+00,1.111438e+00,7.832357e+02,8.364566e+02,2.854867e+02,2.340771e+02,3.198709e+05,7.235757e-03,6.000000e+02}, - {8.841793e-03,3.530456e-03,9.618284e+07,9.311658e-03,3.458590e-01,6.978258e-01,1.279864e-03,4.652008e-03,1.869728e-03,8.931663e-03,1.712564e+00,1.223882e+00,9.692403e+02,2.358558e+02,3.204043e+02,1.827677e+02,3.220502e+05,7.646405e-03,6.000000e+02}, - {1.425612e-03,6.653411e-04,2.843806e+07,1.922560e-03,9.100262e-01,0.996264e-01,8.973183e-04,9.857420e-03,6.221419e-03,8.133433e-03,1.815337e+00,1.885506e+00,5.508742e+02,1.612139e+02,2.798523e+02,2.631136e+02,3.045141e+05,4.148666e-03,6.000000e+02}, - {4.125177e-04,4.056163e-03,2.716439e+07,6.484214e-03,1.658752e-01,2.859102e-01,5.724081e-03,6.282997e-03,7.313187e-03,6.049825e-03,1.140910e+00,1.145941e+00,7.490652e+02,5.011633e+02,1.986541e+02,2.745566e+02,3.371001e+05,6.784784e-03,6.000000e+02}, - {5.010628e-03,2.863789e-04,8.953841e+07,3.953058e-03,1.135952e-01,9.718675e-01,1.846157e-03,5.743094e-03,2.842649e-03,8.155366e-03,1.227867e+00,1.894249e+00,1.161776e+02,3.578576e+02,1.240083e+02,1.639791e+02,3.167181e+05,4.497257e-03,6.000000e+02}, - {9.487866e-03,6.584660e-03,6.149682e+06,9.413342e-03,4.757261e-01,6.503885e-01,1.078922e-03,3.489665e-03,3.059596e-03,9.285703e-03,1.192620e+00,1.967205e+00,5.085628e+02,3.741816e+01,1.196252e+02,2.904002e+02,3.637035e+05,2.566077e-03,6.000000e+02}, - {3.241928e-03,7.024929e-03,2.212493e+07,8.600485e-03,3.963690e-01,4.834201e-01,3.736511e-03,5.724475e-03,4.790239e-03,2.766218e-03,1.151150e+00,1.150516e+00,2.089426e+02,8.666450e+02,1.898220e+02,2.862496e+02,3.056143e+05,7.039800e-03,6.000000e+02}, - {4.617594e-03,3.157739e-03,5.569465e+07,8.221076e-03,7.918279e-01,9.995014e-01,1.338309e-04,1.319707e-03,2.896082e-03,4.359171e-03,1.007827e+00,1.812954e+00,5.332209e+02,2.973599e+02,3.271466e+02,2.622351e+02,3.821569e+05,1.407429e-03,6.000000e+02} + {4.634940e-03,1.215335e-03,6.073270e+07,3.594486e-04,6.134229e-01,9.134229e-01,2.747871e-03,1.911238e-03,5.913313e-03,1.057645e-03,1.782748e+00,1.571392e+00,3.868229e+02,2.248689e+02,3.101180e+02,1.395063e+02,latvap+latice,5.494606e-03,6.000000e+02}, + {6.175320e-13,4.432407e-03,8.029967e+07,1.905151e-03,2.190099e-01,7.031070e-01,4.172977e-05,7.315360e-03,7.280063e-03,1.378543e-03,1.461443e+00,1.507382e+00,8.452377e+02,1.971876e+02,2.389249e+02,1.497752e+02,latvap+latice,5.107905e-03,6.000000e+02}, + {4.519798e-03,7.348916e-03,7.420725e+07,2.220971e-03,1.882608e-01,2.934182e-01,4.957590e-03,2.550256e-03,3.136926e-03,4.498115e-03,1.433526e+00,1.207516e+00,9.716844e+02,5.602546e+01,1.389465e+02,1.075863e+02,latvap+latice,6.771428e-03,6.000000e+02}, + {7.169182e-03,6.657331e-03,9.807967e+07,7.981196e-03,2.914473e-01,6.375719e-01,2.420032e-03,1.223012e-03,7.685516e-03,5.207024e-03,1.644865e+00,1.433872e+00,3.825069e+02,6.550300e+02,1.833466e+02,1.741918e+02,latvap+latice,3.792982e-03,6.000000e+02}, + {1.103118e-03,9.158125e-03,3.136196e+07,4.286154e-03,2.699078e-01,4.668103e-01,9.645460e-03,6.379119e-03,8.283285e-03,3.342400e-03,1.546698e+00,1.417916e+00,9.289270e+02,9.844129e+02,2.543202e+02,1.932996e+02,latvap+latice,2.693119e-03,6.000000e+02}, + {4.308000e-03,8.168535e-03,7.439969e+07,5.131497e-03,6.851225e-01,3.298025e-01,4.331812e-03,2.814373e-03,3.592807e-03,1.527499e-03,1.856943e+00,1.003269e+00,9.165690e+02,9.379921e+02,2.163204e+02,3.165814e+02,latvap+latice,6.801393e-03,6.000000e+02}, + {0.000000e-00,3.318968e-03,4.664041e+07,8.737282e-03,2.585907e-01,6.297295e-02,8.747418e-03,2.710437e-03,2.164895e-03,9.455725e-03,1.241506e+00,1.561393e+00,2.492674e+02,6.546182e+02,2.228772e+02,2.147968e+02,latvap+latice,5.903261e-03,6.000000e+02}, + {7.677170e-03,6.069057e-05,6.404241e+07,3.094233e-03,3.755403e-01,5.026876e-01,4.723817e-03,1.204228e-03,6.156526e-03,8.194797e-03,1.361509e+00,1.772751e+00,6.420537e+01,4.043364e+02,2.833110e+02,3.314521e+02,latvap+latice,2.996696e-03,6.000000e+02}, + + {9.999294e-03,3.138400e-03,2.355097e+07,9.897893e-03,7.667177e-01,9.739270e-01,4.221430e-03,3.570130e-03,8.370033e-03,9.527208e-03,1.597218e+00,1.111438e+00,7.832357e+02,8.364566e+02,2.854867e+02,2.340771e+02,latvap+latice,7.235757e-03,6.000000e+02}, + {8.841793e-03,3.530456e-03,9.618284e+07,9.311658e-03,3.458590e-01,6.978258e-01,1.279864e-03,4.652008e-03,1.869728e-03,8.931663e-03,1.712564e+00,1.223882e+00,9.692403e+02,2.358558e+02,3.204043e+02,1.827677e+02,latvap+latice,7.646405e-03,6.000000e+02}, + {1.425612e-03,6.653411e-04,2.843806e+07,1.922560e-03,9.100262e-01,0.996264e-01,8.973183e-04,9.857420e-03,6.221419e-03,8.133433e-03,1.815337e+00,1.885506e+00,5.508742e+02,1.612139e+02,2.798523e+02,2.631136e+02,latvap+latice,4.148666e-03,6.000000e+02}, + {4.125177e-04,4.056163e-03,2.716439e+07,6.484214e-03,1.658752e-01,2.859102e-01,5.724081e-03,6.282997e-03,7.313187e-03,6.049825e-03,1.140910e+00,1.145941e+00,7.490652e+02,5.011633e+02,1.986541e+02,2.745566e+02,latvap+latice,6.784784e-03,6.000000e+02}, + {5.010628e-03,2.863789e-04,8.953841e+07,3.953058e-03,1.135952e-01,9.718675e-01,1.846157e-03,5.743094e-03,2.842649e-03,8.155366e-03,1.227867e+00,1.894249e+00,1.161776e+02,3.578576e+02,1.240083e+02,1.639791e+02,latvap+latice,4.497257e-03,6.000000e+02}, + {9.487866e-03,6.584660e-03,6.149682e+06,9.413342e-03,4.757261e-01,6.503885e-01,1.078922e-03,3.489665e-03,3.059596e-03,9.285703e-03,1.192620e+00,1.967205e+00,5.085628e+02,3.741816e+01,1.196252e+02,2.904002e+02,latvap+latice,2.566077e-03,6.000000e+02}, + {3.241928e-03,7.024929e-03,2.212493e+07,8.600485e-03,3.963690e-01,4.834201e-01,3.736511e-03,5.724475e-03,4.790239e-03,2.766218e-03,1.151150e+00,1.150516e+00,2.089426e+02,8.666450e+02,1.898220e+02,2.862496e+02,latvap+latice,7.039800e-03,6.000000e+02}, + {4.617594e-03,3.157739e-03,5.569465e+07,8.221076e-03,7.918279e-01,9.995014e-01,1.338309e-04,1.319707e-03,2.896082e-03,4.359171e-03,1.007827e+00,1.812954e+00,5.332209e+02,2.973599e+02,3.271466e+02,2.622351e+02,latvap+latice,1.407429e-03,6.000000e+02} }; // Sync to device @@ -191,7 +192,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip // Init pack inputs Spack qr_incld,qc_incld,nr_incld,qi_incld, cld_frac_l,cld_frac_r,qv,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt; + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt; Scalar dt; @@ -215,7 +216,6 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip epsi_tot[s] = espd_device(vs).epsi_tot; t[s] = espd_device(vs).t; t_prev[s] = espd_device(vs).t_prev; - latent_heat_sublim[s]=espd_device(vs).latent_heat_sublim; dqsdt[s]=espd_device(vs).dqsdt; dt=espd_device(vs).dt; //qr2qv_evap_tend[s] = espd_device(vs).qr2qv_evap_tend; //PMC shouldn't have to init output vars. @@ -224,7 +224,7 @@ struct UnitWrap::UnitTest::TestEvapSublPrecip Functions::evaporate_rain(qr_incld,qc_incld,nr_incld,qi_incld, cld_frac_l,cld_frac_r,qv,qv_prev,qv_sat_l,qv_sat_i, - ab,abi,epsr,epsi_tot,t,t_prev,latent_heat_sublim,dqsdt,dt, + ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt, qr2qv_evap_tend,nr_evap_tend); // Copy results back into views diff --git a/components/eamxx/src/physics/p3/tests/p3_get_latent_heat_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_get_latent_heat_unit_tests.cpp index 3ce02ced459..5d7b4de4ea7 100644 --- a/components/eamxx/src/physics/p3/tests/p3_get_latent_heat_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_get_latent_heat_unit_tests.cpp @@ -24,12 +24,12 @@ struct UnitWrap::UnitTest::TestLatentHeat { static void run_latent_heat_bfb() { + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; + LatentHeatData latent_fortran[] = { // its, ite, kts, kte LatentHeatData(1, 7, 1, 10), - LatentHeatData(1, 7, 1, 10), - LatentHeatData(1, 7, 1, 10), - LatentHeatData(1, 7, 1, 10), }; static constexpr Int num_runs = sizeof(latent_fortran) / sizeof(LatentHeatData); @@ -45,16 +45,11 @@ struct UnitWrap::UnitTest::TestLatentHeat { LatentHeatData& h = latent_fortran[i]; get_latent_heat(h); - LatentHeatData& d = latent_cxx[i]; - get_latent_heat_f(d.its, d.ite, d.kts, d.kte, d.v, d.s, d.f); - if (SCREAM_BFB_TESTING) { - REQUIRE(h.total(h.v) == d.total(d.v)); - for (Int j = 0; j < h.total(h.v); ++j) { - REQUIRE(d.v[j] == h.v[j]); - REQUIRE(d.s[j] == h.s[j]); - REQUIRE(d.f[j] == h.f[j]); + REQUIRE(h.v[j] == latvap); + REQUIRE(h.s[j] == (latvap+latice)); + REQUIRE(h.f[j] == latice); } } } diff --git a/components/eamxx/src/physics/p3/tests/p3_ice_cldliq_wet_growth_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_ice_cldliq_wet_growth_unit_tests.cpp index 78f7ab986c6..caf6638d5cd 100644 --- a/components/eamxx/src/physics/p3/tests/p3_ice_cldliq_wet_growth_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_ice_cldliq_wet_growth_unit_tests.cpp @@ -25,27 +25,30 @@ struct UnitWrap::UnitTest::TestIceCldliqWetGrowth { { using KTH = KokkosTypes; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; + IceWetGrowthData self[max_pack_size] = { // rho,temp,pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,latent_heat_vapor,latent_heat_fusion,dv,kap,mu,sc,qv,qc_incld,qi_incld,ni_incld,qr_incld,log_wetgrowth,qr2qi_collect_tend,qc2qi_collect_tend,qc_growth_rate,nr_ice_shed_tend,qc2qr_ice_shed_tend - {4.056000E-03, 1.023000E+02, 1.201000E+02, 9.002000E-04, 8.215000E-04, 8.852000E-01, 0.174000E+00, 1.221000E-14, 5.100000E-03, 9.558000E-04, 1.213000E-03, 9.653000E-04, 1.023000E-01, 4.098000E-02, 2.098000E-02, 9.952000E+03, 1.023000E-05, false, 1.241456E-04, 9.021345E-02, 1.043000E-01, 1.921000E-02, 0.242000E-02}, - {6.852000E-02, 1.120000E+02, 2.450000E+02, 9.321000E-04, 9.124000E-04, 8.852000E-01, 0.374000E+00, 1.221000E-13, 4.100000E-03, 9.558000E-04, 2.560000E-03, 1.764000E-03, 2.346000E-01, 5.632000E-02, 3.024000E-02, 9.952000E+03, 2.093000E-05, false, 2.341678E-04, 1.092432E-02, 2.903000E-01, 2.125000E-02, 0.342000E-02}, - {8.852000E-02, 1.210000E+02, 3.420000E+02, 9.623000E-04, 9.432000E-04, 8.900000E-01, 0.123000E+00, 1.221000E-12, 3.100000E-03, 9.558000E-04, 3.211000E-03, 3.421000E-03, 3.421000E-01, 6.542000E-02, 4.567000E-02, 9.952000E+03, 3.091000E-05, false, 3.215234E-04, 2.098987E-02, 3.450000E-01, 3.490000E-02, 0.932000E-02}, - {1.902000E-01, 1.326000E+02, 4.321000E+02, 9.982000E-04, 9.623000E-04, 9.900000E-01, 0.123000E+00, 1.221000E-11, 2.100000E-03, 9.558000E-04, 4.121000E-03, 4.569000E-03, 4.673000E-01, 7.902000E-02, 5.321000E-02, 9.952000E+03, 4.521000E-05, false, 4.675567E-04, 3.214982E-02, 4.290000E-01, 4.590000E-02, 1.025000E-01}, - - {2.201000E-01, 1.456000E+02, 5.670000E+02, 1.234000E-03, 9.723000E-04, 0.100000E+01, 0.174000E+00, 1.221000E-10, 1.100000E-03, 2.550008E-05, 4.980000E-03, 5.621000E-03, 5.420000E-01, 8.021000E-02, 6.902000E-02, 9.952000E+04, 5.678000E-05, false, 5.389236E-04, 4.125969E-02, 5.098000E-01, 5.921000E-02, 2.031000E-01}, - {3.502000E-01, 1.780009E+02, 6.832000E+02, 1.562000E-03, 1.024000E-03, 0.100000E+01, 0.374000E+00, 1.221000E-09, 8.100000E-04, 2.558000E-05, 5.643000E-03, 7.367000E-03, 6.782000E-01, 9.253000E-02, 8.045000E-02, 9.952000E+04, 6.902000E-05, false, 6.432654E-04, 5.389457E-02, 6.723000E-01, 6.093000E-02, 4.098000E-01}, - {4.852000E-01, 2.100009E+02, 7.090000E+02, 2.101000E-03, 1.235000E-03, 0.100000E+01, 0.123000E+00, 1.221000E-08, 4.100000E-04, 2.558000E-05, 7.892000E-03, 9.087000E-03, 8.213000E-01, 1.256000E-01, 9.134000E-02, 9.952000E+04, 8.367000E-05, false, 7.210983E-04, 6.476985E-02, 8.902000E-01, 8.345000E-02, 8.023000E-01}, - {5.852000E-01, 2.310000E+02, 9.215000E+02, 2.312000E-03, 1.456000E-03, 0.100000E+01, 0.123000E+00, 1.221000E-07, 2.100000E-04, 2.558000E-05, 9.321000E-03, 1.245000E-02, 1.067000E-00, 2.347000E-01, 1.092000E-01, 9.952000E+04, 9.098000E-05, false, 8.543367E-04, 8.213186E-02, 9.021000E-01, 9.321000E-02, 9.098000E-01}, - - {6.852000E-01, 2.563000E+02, 1.089000E+03, 3.601000E-03, 1.864000E-03, 0.950000E+00, 0.150000E+00, 1.221000E-06, 9.952000E-05, 4.596000E-05, 1.453000E-02, 2.543000E-02, 2.345000E-00, 3.578000E-01, 2.873000E-01, 1.734000E+04, 1.023000E-04, false, 9.021215E-04, 9.023367E-02, 1.023000E-00, 1.056000E-01, 1.256000E-00}, - {7.852000E-01, 2.789000E+02, 3.754000E+03, 3.891000E-03, 2.093000E-03, 0.950000E+00, 0.374000E+00, 1.221000E-05, 4.952000E-05, 4.596000E-05, 2.789000E-02, 4.367000E-02, 3.890000E-00, 4.980000E-01, 3.468000E-01, 1.734000E+04, 2.146000E-04, false, 1.043468E-05, 1.094854E-02, 2.012000E-00, 2.893000E-01, 2.903000E-00}, - {8.852000E-01, 3.123000E+02, 8.902000E+03, 4.872000E-03, 2.345000E-03, 0.950000E+00, 0.123000E+00, 1.221000E-04, 1.952000E-05, 4.596000E-05, 4.256000E-02, 6.324000E-02, 4.120000E-00, 6.321000E-01, 4.890000E-01, 1.734000E+04, 4.321000E-04, false, 2.341763E-05, 2.126247E-03, 3.120000E-00, 3.456000E-01, 3.912000E-00}, - {9.852000E-01, 4.981000E+02, 1.092000E+04, 5.210000E-03, 3.210000E-03, 0.950000E+00, 0.123000E+00, 1.221000E-03, 9.952000E-06, 4.596000E-05, 6.821000E-02, 8.789000E-02, 5.320000E-00, 7.982000E-01, 6.921000E-01, 1.734000E+04, 5.821000E-04, false, 3.901479E-05, 3.874763E-03, 5.902000E-00, 5.092000E-01, 4.821000E-00}, - - {1.002000E+01, 1.234000E+03, 2.125000E+04, 6.012000E-03, 5.902000E-03, 1.069000E+00, 0.174000E+00, 1.221000E-02, 6.952000E-06, 6.596000E-05, 8.472000E-02, 1.543000E-01, 6.012000E-00, 8.902000E-01, 9.210000E-01, 1.734000E+04, 6.921000E-04, false, 4.521923E-05, 4.592698E-03, 6.091000E-00, 6.743000E-01, 5.602000E-00}, - {1.152000E+01, 2.120000E+03, 4.568000E+04, 6.342000E-03, 9.210000E-03, 1.069000E+00, 0.374000E+00, 1.221000E-02, 3.952000E-06, 6.596000E-05, 1.098000E-01, 3.456000E-01, 7.241000E-00, 9.102000E-01, 1.002000E-00, 1.734000E+04, 7.901000E-04, false, 5.236542E-05, 5.678873E-03, 7.231000E-00, 8.321000E-01, 6.092000E-00}, - {1.252000E+01, 3.145000E+03, 8.213000E+04, 9.290000E-03, 1.034000E-02, 1.069000E+00, 0.123000E+00, 1.221000E-02, 1.952000E-06, 6.596000E-05, 2.340006E-01, 5.632000E-01, 8.452000E-00, 1.003000E-01, 2.145000E-00, 1.734000E+04, 9.212000E-04, false, 6.732276E-05, 7.321873E-03, 8.234000E-00, 9.023000E-01, 7.201000E-00}, - {1.352000E+01, 4.742000E+03, 1.014000E+05, 1.234000E-02, 1.456000E-02, 1.069000E+00, 0.123000E+00, 1.221000E-02, 9.952000E-07, 6.596000E-05, 4.123000E-01, 6.128000E-01, 9.076000E-00, 2.831000E-01, 3.902000E-00, 1.734000E+04, 1.023000E-03, false, 7.902887E-05, 9.032908E-03, 9.021000E-00, 1.092000E-01, 8.096000E-00} + {4.056000E-03, 1.023000E+02, 1.201000E+02, 9.002000E-04, 8.215000E-04, 8.852000E-01, latvap, latice, 5.100000E-03, 9.558000E-04, 1.213000E-03, 9.653000E-04, 1.023000E-01, 4.098000E-02, 2.098000E-02, 9.952000E+03, 1.023000E-05, false, 1.241456E-04, 9.021345E-02, 1.043000E-01, 1.921000E-02, 0.242000E-02}, + {6.852000E-02, 1.120000E+02, 2.450000E+02, 9.321000E-04, 9.124000E-04, 8.852000E-01, latvap, latice, 4.100000E-03, 9.558000E-04, 2.560000E-03, 1.764000E-03, 2.346000E-01, 5.632000E-02, 3.024000E-02, 9.952000E+03, 2.093000E-05, false, 2.341678E-04, 1.092432E-02, 2.903000E-01, 2.125000E-02, 0.342000E-02}, + {8.852000E-02, 1.210000E+02, 3.420000E+02, 9.623000E-04, 9.432000E-04, 8.900000E-01, latvap, latice, 3.100000E-03, 9.558000E-04, 3.211000E-03, 3.421000E-03, 3.421000E-01, 6.542000E-02, 4.567000E-02, 9.952000E+03, 3.091000E-05, false, 3.215234E-04, 2.098987E-02, 3.450000E-01, 3.490000E-02, 0.932000E-02}, + {1.902000E-01, 1.326000E+02, 4.321000E+02, 9.982000E-04, 9.623000E-04, 9.900000E-01, latvap, latice, 2.100000E-03, 9.558000E-04, 4.121000E-03, 4.569000E-03, 4.673000E-01, 7.902000E-02, 5.321000E-02, 9.952000E+03, 4.521000E-05, false, 4.675567E-04, 3.214982E-02, 4.290000E-01, 4.590000E-02, 1.025000E-01}, + + {2.201000E-01, 1.456000E+02, 5.670000E+02, 1.234000E-03, 9.723000E-04, 0.100000E+01, latvap, latice, 1.100000E-03, 2.550008E-05, 4.980000E-03, 5.621000E-03, 5.420000E-01, 8.021000E-02, 6.902000E-02, 9.952000E+04, 5.678000E-05, false, 5.389236E-04, 4.125969E-02, 5.098000E-01, 5.921000E-02, 2.031000E-01}, + {3.502000E-01, 1.780009E+02, 6.832000E+02, 1.562000E-03, 1.024000E-03, 0.100000E+01, latvap, latice, 8.100000E-04, 2.558000E-05, 5.643000E-03, 7.367000E-03, 6.782000E-01, 9.253000E-02, 8.045000E-02, 9.952000E+04, 6.902000E-05, false, 6.432654E-04, 5.389457E-02, 6.723000E-01, 6.093000E-02, 4.098000E-01}, + {4.852000E-01, 2.100009E+02, 7.090000E+02, 2.101000E-03, 1.235000E-03, 0.100000E+01, latvap, latice, 4.100000E-04, 2.558000E-05, 7.892000E-03, 9.087000E-03, 8.213000E-01, 1.256000E-01, 9.134000E-02, 9.952000E+04, 8.367000E-05, false, 7.210983E-04, 6.476985E-02, 8.902000E-01, 8.345000E-02, 8.023000E-01}, + {5.852000E-01, 2.310000E+02, 9.215000E+02, 2.312000E-03, 1.456000E-03, 0.100000E+01, latvap, latice, 2.100000E-04, 2.558000E-05, 9.321000E-03, 1.245000E-02, 1.067000E-00, 2.347000E-01, 1.092000E-01, 9.952000E+04, 9.098000E-05, false, 8.543367E-04, 8.213186E-02, 9.021000E-01, 9.321000E-02, 9.098000E-01}, + + {6.852000E-01, 2.563000E+02, 1.089000E+03, 3.601000E-03, 1.864000E-03, 0.950000E+00, latvap, latice, 9.952000E-05, 4.596000E-05, 1.453000E-02, 2.543000E-02, 2.345000E-00, 3.578000E-01, 2.873000E-01, 1.734000E+04, 1.023000E-04, false, 9.021215E-04, 9.023367E-02, 1.023000E-00, 1.056000E-01, 1.256000E-00}, + {7.852000E-01, 2.789000E+02, 3.754000E+03, 3.891000E-03, 2.093000E-03, 0.950000E+00, latvap, latice, 4.952000E-05, 4.596000E-05, 2.789000E-02, 4.367000E-02, 3.890000E-00, 4.980000E-01, 3.468000E-01, 1.734000E+04, 2.146000E-04, false, 1.043468E-05, 1.094854E-02, 2.012000E-00, 2.893000E-01, 2.903000E-00}, + {8.852000E-01, 3.123000E+02, 8.902000E+03, 4.872000E-03, 2.345000E-03, 0.950000E+00, latvap, latice, 1.952000E-05, 4.596000E-05, 4.256000E-02, 6.324000E-02, 4.120000E-00, 6.321000E-01, 4.890000E-01, 1.734000E+04, 4.321000E-04, false, 2.341763E-05, 2.126247E-03, 3.120000E-00, 3.456000E-01, 3.912000E-00}, + {9.852000E-01, 4.981000E+02, 1.092000E+04, 5.210000E-03, 3.210000E-03, 0.950000E+00, latvap, latice, 9.952000E-06, 4.596000E-05, 6.821000E-02, 8.789000E-02, 5.320000E-00, 7.982000E-01, 6.921000E-01, 1.734000E+04, 5.821000E-04, false, 3.901479E-05, 3.874763E-03, 5.902000E-00, 5.092000E-01, 4.821000E-00}, + + {1.002000E+01, 1.234000E+03, 2.125000E+04, 6.012000E-03, 5.902000E-03, 1.069000E+00, latvap, latice, 6.952000E-06, 6.596000E-05, 8.472000E-02, 1.543000E-01, 6.012000E-00, 8.902000E-01, 9.210000E-01, 1.734000E+04, 6.921000E-04, false, 4.521923E-05, 4.592698E-03, 6.091000E-00, 6.743000E-01, 5.602000E-00}, + {1.152000E+01, 2.120000E+03, 4.568000E+04, 6.342000E-03, 9.210000E-03, 1.069000E+00, latvap, latice, 3.952000E-06, 6.596000E-05, 1.098000E-01, 3.456000E-01, 7.241000E-00, 9.102000E-01, 1.002000E-00, 1.734000E+04, 7.901000E-04, false, 5.236542E-05, 5.678873E-03, 7.231000E-00, 8.321000E-01, 6.092000E-00}, + {1.252000E+01, 3.145000E+03, 8.213000E+04, 9.290000E-03, 1.034000E-02, 1.069000E+00, latvap, latice, 1.952000E-06, 6.596000E-05, 2.340006E-01, 5.632000E-01, 8.452000E-00, 1.003000E-01, 2.145000E-00, 1.734000E+04, 9.212000E-04, false, 6.732276E-05, 7.321873E-03, 8.234000E-00, 9.023000E-01, 7.201000E-00}, + {1.352000E+01, 4.742000E+03, 1.014000E+05, 1.234000E-02, 1.456000E-02, 1.069000E+00, latvap, latice, 9.952000E-07, 6.596000E-05, 4.123000E-01, 6.128000E-01, 9.076000E-00, 2.831000E-01, 3.902000E-00, 1.734000E+04, 1.023000E-03, false, 7.902887E-05, 9.032908E-03, 9.021000E-00, 1.092000E-01, 8.096000E-00} }; // Sync to device @@ -64,7 +67,7 @@ struct UnitWrap::UnitTest::TestIceCldliqWetGrowth { const Int offset = i * Spack::n; // Init pack inputs - Spack rho,temp, pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,latent_heat_vapor,latent_heat_fusion,dv,kap,mu,sc, + Spack rho,temp, pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,dv,kap,mu,sc, qv,qc_incld,qi_incld,ni_incld,qr_incld; Smask log_wetgrowth; @@ -78,8 +81,6 @@ struct UnitWrap::UnitTest::TestIceCldliqWetGrowth { rhofaci[s] = self_device(vs).rhofaci; table_val_qi2qr_melting[s] = self_device(vs).table_val_qi2qr_melting; table_val_qi2qr_vent_melt[s] = self_device(vs).table_val_qi2qr_vent_melt; - latent_heat_vapor[s] = self_device(vs).latent_heat_vapor; - latent_heat_fusion[s] = self_device(vs).latent_heat_fusion; dv[s] = self_device(vs).dv; kap[s] = self_device(vs).kap; mu[s] = self_device(vs).mu; @@ -97,7 +98,7 @@ struct UnitWrap::UnitTest::TestIceCldliqWetGrowth { log_wetgrowth.set(s, self_device(vs).log_wetgrowth); } - Functions::ice_cldliq_wet_growth(rho, temp, pres, rhofaci, table_val_qi2qr_melting, table_val_qi2qr_vent_melt, latent_heat_vapor, latent_heat_fusion, dv, kap, mu, sc, + Functions::ice_cldliq_wet_growth(rho, temp, pres, rhofaci, table_val_qi2qr_melting, table_val_qi2qr_vent_melt, dv, kap, mu, sc, qv, qc_incld, qi_incld, ni_incld, qr_incld, log_wetgrowth, qr2qi_collect_tend, qc2qi_collect_tend, qc_growth_rate, nr_ice_shed_tend, qc2qr_ice_shed_tend); diff --git a/components/eamxx/src/physics/p3/tests/p3_ice_melting_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_ice_melting_unit_tests.cpp index 3e340f68710..28c6582f8a1 100644 --- a/components/eamxx/src/physics/p3/tests/p3_ice_melting_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_ice_melting_unit_tests.cpp @@ -23,29 +23,31 @@ struct UnitWrap::UnitTest::TestP3IceMelting { static void ice_melting_bfb(){ + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; // make array of input data (why not pass actual variables?). Copied 1st 4 rows 4x to fill pack size. IceMeltingData IceMelt[max_pack_size] = { //rho, T_atm, pres, rhofaci, table_val_qi2qr_melting, table_val_qi2qr_vent_melt, latent_heat_vapor, latent_heat_fusion, dv, sc, mu, kap, qv, qi_incld,ni_incld - {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, - {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, - {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, - {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,0.250E+07,0.334E+06,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, - - {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, - {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, - {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, - {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,0.250E+07,0.334E+06,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, - - {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, - {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, - {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, - {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,0.250E+07,0.334E+06,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, - - {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, - {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, - {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,0.250E+07,0.334E+06,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, - {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,0.250E+07,0.334E+06,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05} + {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,latvap,latice,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, + {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,latvap,latice,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, + {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,latvap,latice,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, + {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,latvap,latice,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, + + {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,latvap,latice,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, + {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,latvap,latice,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, + {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,latvap,latice,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, + {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,latvap,latice,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, + + {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,latvap,latice,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, + {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,latvap,latice,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, + {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,latvap,latice,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, + {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,latvap,latice,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05}, + + {0.117E+01,0.299E+03,0.101E+06,0.829E+00,0.122E+01,0.562E-01,latvap,latice,0.263E-04,0.601E+00,0.185E-04,0.261E-01,0.160E-01,0.510E-02, 0.195E-12}, + {0.114E+01,0.296E+03,0.973E+05,0.842E+00,0.122E+01,0.562E-01,latvap,latice,0.268E-04,0.601E+00,0.183E-04,0.259E-01,0.149E-01,0.510E-02, 0.195E-12}, + {0.977E+00,0.287E+03,0.809E+05,0.913E+00,0.122E+01,0.562E-01,latvap,latice,0.306E-04,0.599E+00,0.179E-04,0.253E-01,0.827E-02,0.000E+00, 0.000E+00}, + {0.103E+01,0.289E+03,0.862E+05,0.887E+00,0.636E-03,0.281E-04,latvap,latice,0.291E-04,0.600E+00,0.180E-04,0.254E-01,0.107E-01,0.510E-02, 0.336E+05} }; // Sync to device @@ -65,7 +67,7 @@ static void ice_melting_bfb(){ const Int offset = i * Spack::n; // Init pack inputs - Spack rho,T_atm,pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,latent_heat_vapor,latent_heat_fusion,dv,sc,mu,kap,qv,qi_incld,ni_incld,qi2qr_melt_tend,ni2nr_melt_tend; + Spack rho,T_atm,pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,dv,sc,mu,kap,qv,qi_incld,ni_incld,qi2qr_melt_tend,ni2nr_melt_tend; for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { rho[s] = IceMelt_device(vs).rho; T_atm[s] = IceMelt_device(vs).T_atm; @@ -73,8 +75,6 @@ static void ice_melting_bfb(){ rhofaci[s] = IceMelt_device(vs).rhofaci; table_val_qi2qr_melting[s] = IceMelt_device(vs).table_val_qi2qr_melting; table_val_qi2qr_vent_melt[s] = IceMelt_device(vs).table_val_qi2qr_vent_melt; - latent_heat_vapor[s] = IceMelt_device(vs).latent_heat_vapor; - latent_heat_fusion[s] = IceMelt_device(vs).latent_heat_fusion; dv[s] = IceMelt_device(vs).dv; sc[s] = IceMelt_device(vs).sc; mu[s] = IceMelt_device(vs).mu; @@ -86,7 +86,7 @@ static void ice_melting_bfb(){ ni2nr_melt_tend[s] = IceMelt_device(vs).ni2nr_melt_tend; } - Functions::ice_melting(rho,T_atm,pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,latent_heat_vapor,latent_heat_fusion,dv,sc,mu,kap,qv,qi_incld,ni_incld,qi2qr_melt_tend,ni2nr_melt_tend); + Functions::ice_melting(rho,T_atm,pres,rhofaci,table_val_qi2qr_melting,table_val_qi2qr_vent_melt,dv,sc,mu,kap,qv,qi_incld,ni_incld,qi2qr_melt_tend,ni2nr_melt_tend); // Copy results back into views for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { IceMelt_device(vs).qi2qr_melt_tend = qi2qr_melt_tend[s]; diff --git a/components/eamxx/src/physics/p3/tests/p3_ice_sed_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_ice_sed_unit_tests.cpp index 02167261bf8..93c06a9054d 100644 --- a/components/eamxx/src/physics/p3/tests/p3_ice_sed_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_ice_sed_unit_tests.cpp @@ -187,6 +187,8 @@ static void run_bfb_ice_sed() static void run_bfb_homogeneous_freezing() { + constexpr Scalar latice = C::LatIce; + auto engine = setup_random_test(); HomogeneousFreezingData hfds_fortran[] = { @@ -203,6 +205,12 @@ static void run_bfb_homogeneous_freezing() for (auto& d : hfds_fortran) { const auto qsmall_r = std::make_pair(C::QSMALL/2, C::QSMALL*2); d.randomize(engine, { {d.T_atm, {C::T_homogfrz - 10, C::T_homogfrz + 10}}, {d.qc, qsmall_r}, {d.qr, qsmall_r} }); + + // C++ impl uses constants for latent_heat values. Manually set here + // so F90 can match + for (int k=0; k::TestIceSupersatConservation { static void run_bfb() { + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; + auto engine = setup_random_test(); IceSupersatConservationData f90_data[max_pack_size]; @@ -27,6 +30,10 @@ struct UnitWrap::UnitTest::TestIceSupersatConservation { for (auto& d : f90_data) { d.randomize(engine); d.dt = f90_data[0].dt; // hold this fixed, it is not packed data + + // C++ impl uses constants for latent_heat values. Manually set here + // so F90 can match + d.latent_heat_sublim = latvap+latice; } // Create copies of data for use by cxx and sync it to device. Needs to happen before fortran calls so that @@ -46,10 +53,9 @@ struct UnitWrap::UnitTest::TestIceSupersatConservation { const Int offset = i * Spack::n; // Init pack inputs - Spack cld_frac_i, latent_heat_sublim, qidep, qinuc, qv, qv_sat_i, t_atm, qi2qv_sublim_tend, qr2qv_evap_tend; + Spack cld_frac_i, qidep, qinuc, qv, qv_sat_i, t_atm, qi2qv_sublim_tend, qr2qv_evap_tend; for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { cld_frac_i[s] = cxx_device(vs).cld_frac_i; - latent_heat_sublim[s] = cxx_device(vs).latent_heat_sublim; qidep[s] = cxx_device(vs).qidep; qinuc[s] = cxx_device(vs).qinuc; qv[s] = cxx_device(vs).qv; @@ -59,7 +65,7 @@ struct UnitWrap::UnitTest::TestIceSupersatConservation { qr2qv_evap_tend[s] = cxx_device(vs).qr2qv_evap_tend; } - Functions::ice_supersat_conservation(qidep, qinuc, cld_frac_i, qv, qv_sat_i, latent_heat_sublim, t_atm, cxx_device(offset).dt, qi2qv_sublim_tend, qr2qv_evap_tend); + Functions::ice_supersat_conservation(qidep, qinuc, cld_frac_i, qv, qv_sat_i, t_atm, cxx_device(offset).dt, qi2qv_sublim_tend, qr2qv_evap_tend); // Copy spacks back into cxx_device view for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { diff --git a/components/eamxx/src/physics/p3/tests/p3_main_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_main_unit_tests.cpp index bad0ca7014d..a804bd8756d 100644 --- a/components/eamxx/src/physics/p3/tests/p3_main_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_main_unit_tests.cpp @@ -57,6 +57,8 @@ static void run_bfb_p3_main_part1() constexpr Scalar T_zerodegc = C::T_zerodegc; constexpr Scalar sup_upper = -0.05; constexpr Scalar sup_lower = -0.1; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; P3MainPart1Data isds_fortran[] = { // kts, kte, ktop, kbot, kdir, do_predict_nc, do_prescribed_CCN, dt @@ -74,6 +76,14 @@ static void run_bfb_p3_main_part1() {d.T_atm, {T_zerodegc - 10, T_zerodegc + 10}}, {d.qv_supersat_i, {sup_lower -.05, sup_upper + .05}}, {d.qc, qsmall_r}, {d.qr, qsmall_r}, {d.qi, qsmall_r} }); + + // C++ impl uses constants for latent_heat values. Manually set here + // so F90 can match + for (int k=0; k(); } diff --git a/components/eamxx/src/physics/p3/tests/p3_prevent_liq_supersaturation_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_prevent_liq_supersaturation_tests.cpp index 55501a30aa3..a1b27056281 100644 --- a/components/eamxx/src/physics/p3/tests/p3_prevent_liq_supersaturation_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_prevent_liq_supersaturation_tests.cpp @@ -25,14 +25,14 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { using physics = scream::physics::Functions; constexpr Scalar inv_cp = C::INV_CP; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; //Start with reasonable values //============================ Spack pres(100000); Spack t_atm(270); Spack qv(1.7e-3); - Spack latent_heat_vapor(2.5e6); - Spack latent_heat_sublim(2.838e6); Scalar dt=60; Spack qidep(0); Spack qinuc(0); //dep and nuc only used together, so only fiddle with one @@ -50,8 +50,8 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { Spack qv_sinks=qidep + qinuc; Spack qv_sources=qi2qv_sublim_tend_tmp + qr2qv_evap_tend_tmp; Spack qv_endstep=qv - qv_sinks*dt + qv_sources*dt; - Spack T_endstep=t_atm + ( (qv_sinks-qi2qv_sublim_tend_tmp)*latent_heat_sublim*inv_cp - - qr2qv_evap_tend_tmp*latent_heat_vapor*inv_cp )*dt; + Spack T_endstep=t_atm + ( (qv_sinks-qi2qv_sublim_tend_tmp)*(latvap+latice)*inv_cp + - qr2qv_evap_tend_tmp*latvap*inv_cp )*dt; Spack qsl = physics::qv_sat_dry(T_endstep,pres,false,context); //"false" means NOT sat w/ respect to ice //just require index 0 since all entries are identical @@ -59,7 +59,7 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { REQUIRE(qv_endstep[0]>qsl[0]); // inputs to this test are testing what we want. //Now update sublim and evap tends using prevent_liq_supersaturation - Functions::prevent_liq_supersaturation(pres, t_atm, qv, latent_heat_vapor, latent_heat_sublim, + Functions::prevent_liq_supersaturation(pres, t_atm, qv, dt, qidep, qinuc, qi2qv_sublim_tend_tmp, qr2qv_evap_tend_tmp); //Finally, recompute liquid saturation @@ -67,8 +67,8 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { qv_sinks=qidep + qinuc; qv_sources=qi2qv_sublim_tend_tmp + qr2qv_evap_tend_tmp; qv_endstep=qv - qv_sinks*dt + qv_sources*dt; - T_endstep=t_atm + ( (qv_sinks-qi2qv_sublim_tend_tmp)*latent_heat_sublim*inv_cp - - qr2qv_evap_tend_tmp*latent_heat_vapor*inv_cp )*dt; + T_endstep=t_atm + ( (qv_sinks-qi2qv_sublim_tend_tmp)*(latvap+latice)*inv_cp + - qr2qv_evap_tend_tmp*latvap*inv_cp )*dt; qsl = physics::qv_sat_dry(T_endstep,pres,false,context); //"false" means NOT sat w/ respect to ice //just require index 0 since all entries are identical @@ -80,7 +80,7 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { Spack qi2qv_sublim_tend_tmp2(1e-4); Spack qr2qv_evap_tend_tmp2(1e-4); - Functions::prevent_liq_supersaturation(pres, t_atm, qv_tmp, latent_heat_vapor, latent_heat_sublim, + Functions::prevent_liq_supersaturation(pres, t_atm, qv_tmp, dt, qidep, qinuc, qi2qv_sublim_tend_tmp2, qr2qv_evap_tend_tmp2); //just require index 0 since all entries are identical. REQUIRE( qi2qv_sublim_tend_tmp2[0] ==0 ); @@ -90,6 +90,8 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { static void run_bfb() { + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; auto engine = setup_random_test(); @@ -100,6 +102,11 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { for (auto& d : f90_data) { d.randomize(engine); d.dt = f90_data[0].dt; // Hold this fixed, this is not packed data + + // C++ impl uses constants for latent_heat values. Manually set here + // so F90 can match + d.latent_heat_vapor = latvap; + d.latent_heat_sublim = latvap+latice; } // Create copies of data for use by cxx and sync it to device. Needs to happen before @@ -127,11 +134,9 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { // Init pack inputs Scalar dt; - Spack latent_heat_sublim, latent_heat_vapor, pres, qi2qv_sublim_tend, qidep, qinuc, qr2qv_evap_tend, qv, t_atm; + Spack pres, qi2qv_sublim_tend, qidep, qinuc, qr2qv_evap_tend, qv, t_atm; for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { dt = cxx_device(vs).dt; //dt is scalar but PreventLiqSupersaturationData has diff val for each row. - latent_heat_sublim[s] = cxx_device(vs).latent_heat_sublim; - latent_heat_vapor[s] = cxx_device(vs).latent_heat_vapor; pres[s] = cxx_device(vs).pres; qi2qv_sublim_tend[s] = cxx_device(vs).qi2qv_sublim_tend; qidep[s] = cxx_device(vs).qidep; @@ -141,7 +146,7 @@ struct UnitWrap::UnitTest::TestPreventLiqSupersaturation { t_atm[s] = cxx_device(vs).t_atm; } - Functions::prevent_liq_supersaturation(pres, t_atm, qv, latent_heat_vapor, latent_heat_sublim, dt, qidep, qinuc, qi2qv_sublim_tend, qr2qv_evap_tend); + Functions::prevent_liq_supersaturation(pres, t_atm, qv, dt, qidep, qinuc, qi2qv_sublim_tend, qr2qv_evap_tend); // Copy spacks back into cxx_device view for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { diff --git a/components/eamxx/src/physics/p3/tests/p3_unit_tests.cpp b/components/eamxx/src/physics/p3/tests/p3_unit_tests.cpp index df5b80cdc19..3b994cfdad5 100644 --- a/components/eamxx/src/physics/p3/tests/p3_unit_tests.cpp +++ b/components/eamxx/src/physics/p3/tests/p3_unit_tests.cpp @@ -480,103 +480,105 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticIce constexpr Scalar nmltratio = C::nmltratio; constexpr Scalar dt = 1.8000E+03; constexpr bool do_predict_nc = true; + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; //fortran generated data is input to the following P3UpdatePrognosticIceData pupidc[max_pack_size] = { {4.9078E-19, 1.5312E-09, 4.4387E-09, 3.7961E+06, 1.7737E-04, 0.0000E+00, 3.8085E-08, 5.1281E+04, 1.9251E-15, 3.4778E-04, 3.5801E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.1386E-07, 0.0000E+00, 0.0000E+00, 2.7053E-02, - 0.0000E+00, 1.9209E-10, 1.0686E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 1.9209E-10, 1.0686E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 4.5312E+02, 2.8720E+02, 5.0000E-03, 6.4286E-05, 1.2344E+08, 7.3684E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 6.4286E-05, 1.0000E-02}, {2.1097E-18, 2.7648E-09, 3.8261E-09, 3.7754E+06, 6.8685E-04, 0.0000E+00, 4.1018E-08, 5.1227E+04, 4.8876E-15, 1.3468E-03, 2.8059E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 7.1049E-07, 0.0000E+00, 0.0000E+00, 2.4547E-02, - 0.0000E+00, 2.8615E-10, 1.0741E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 2.8615E-10, 1.0741E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 3.4890E+02, 2.8642E+02, 5.0000E-03, 7.1429E-05, 1.2345E+08, 7.8947E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.1429E-05, 1.0000E-02}, {8.9820E-18, 4.2529E-09, 2.9520E-09, 3.7537E+06, 2.6598E-03, 0.0000E+00, 4.3700E-08, 5.1171E+04, 1.4266E-14, 5.2153E-03, 1.9880E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 9.0244E-07, 0.0000E+00, 0.0000E+00, 2.1083E-02, - 0.0000E+00, 3.7631E-10, 1.0796E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 3.7631E-10, 1.0796E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.8656E+02, 2.8565E+02, 5.0000E-03, 7.8571E-05, 1.2345E+08, 8.4211E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.8571E-05, 1.0000E-02}, {3.7942E-17, 6.0115E-09, 1.8004E-09, 3.7310E+06, 1.0300E-02, 0.0000E+00, 4.6119E-08, 5.1112E+04, 4.4518E-14, 2.0196E-02, 1.1226E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 1.0879E-06, 0.0000E+00, 0.0000E+00, 1.7646E-02, - 0.0000E+00, 4.5891E-10, 1.0853E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 4.5891E-10, 1.0853E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.4570E+02, 2.8489E+02, 5.0000E-03, 8.5714E-05, 1.2345E+08, 8.9474E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 8.5714E-05, 1.0000E-02}, {4.9078E-19, 1.5312E-09, 4.4387E-09, 3.7961E+06, 1.7737E-04, 0.0000E+00, 3.8085E-08, 5.1281E+04, 1.9251E-15, 3.4778E-04, 3.5801E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.1386E-07, 0.0000E+00, 0.0000E+00, 2.7053E-02, - 0.0000E+00, 1.9209E-10, 1.0686E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 1.9209E-10, 1.0686E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 4.5312E+02, 2.8720E+02, 5.0000E-03, 6.4286E-05, 1.2344E+08, 7.3684E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 6.4286E-05, 1.0000E-02}, {2.1097E-18, 2.7648E-09, 3.8261E-09, 3.7754E+06, 6.8685E-04, 0.0000E+00, 4.1018E-08, 5.1227E+04, 4.8876E-15, 1.3468E-03, 2.8059E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 7.1049E-07, 0.0000E+00, 0.0000E+00, 2.4547E-02, - 0.0000E+00, 2.8615E-10, 1.0741E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 2.8615E-10, 1.0741E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 3.4890E+02, 2.8642E+02, 5.0000E-03, 7.1429E-05, 1.2345E+08, 7.8947E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.1429E-05, 1.0000E-02}, {8.9820E-18, 4.2529E-09, 2.9520E-09, 3.7537E+06, 2.6598E-03, 0.0000E+00, 4.3700E-08, 5.1171E+04, 1.4266E-14, 5.2153E-03, 1.9880E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 9.0244E-07, 0.0000E+00, 0.0000E+00, 2.1083E-02, - 0.0000E+00, 3.7631E-10, 1.0796E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 3.7631E-10, 1.0796E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.8656E+02, 2.8565E+02, 5.0000E-03, 7.8571E-05, 1.2345E+08, 8.4211E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.8571E-05, 1.0000E-02}, {3.7942E-17, 6.0115E-09, 1.8004E-09, 3.7310E+06, 1.0300E-02, 0.0000E+00, 4.6119E-08, 5.1112E+04, 4.4518E-14, 2.0196E-02, 1.1226E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 1.0879E-06, 0.0000E+00, 0.0000E+00, 1.7646E-02, - 0.0000E+00, 4.5891E-10, 1.0853E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 4.5891E-10, 1.0853E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.4570E+02, 2.8489E+02, 5.0000E-03, 8.5714E-05, 1.2345E+08, 8.9474E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 8.5714E-05, 1.0000E-02}, {4.9078E-19, 1.5312E-09, 4.4387E-09, 3.7961E+06, 1.7737E-04, 0.0000E+00, 3.8085E-08, 5.1281E+04, 1.9251E-15, 3.4778E-04, 3.5801E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.1386E-07, 0.0000E+00, 0.0000E+00, 2.7053E-02, - 0.0000E+00, 1.9209E-10, 1.0686E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 1.9209E-10, 1.0686E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 4.5312E+02, 2.8720E+02, 5.0000E-03, 6.4286E-05, 1.2344E+08, 7.3684E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 6.4286E-05, 1.0000E-02}, {2.1097E-18, 2.7648E-09, 3.8261E-09, 3.7754E+06, 6.8685E-04, 0.0000E+00, 4.1018E-08, 5.1227E+04, 4.8876E-15, 1.3468E-03, 2.8059E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 7.1049E-07, 0.0000E+00, 0.0000E+00, 2.4547E-02, - 0.0000E+00, 2.8615E-10, 1.0741E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 2.8615E-10, 1.0741E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 3.4890E+02, 2.8642E+02, 5.0000E-03, 7.1429E-05, 1.2345E+08, 7.8947E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.1429E-05, 1.0000E-02}, {8.9820E-18, 4.2529E-09, 2.9520E-09, 3.7537E+06, 2.6598E-03, 0.0000E+00, 4.3700E-08, 5.1171E+04, 1.4266E-14, 5.2153E-03, 1.9880E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 9.0244E-07, 0.0000E+00, 0.0000E+00, 2.1083E-02, - 0.0000E+00, 3.7631E-10, 1.0796E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 3.7631E-10, 1.0796E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.8656E+02, 2.8565E+02, 5.0000E-03, 7.8571E-05, 1.2345E+08, 8.4211E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.8571E-05, 1.0000E-02}, {3.7942E-17, 6.0115E-09, 1.8004E-09, 3.7310E+06, 1.0300E-02, 0.0000E+00, 4.6119E-08, 5.1112E+04, 4.4518E-14, 2.0196E-02, 1.1226E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 1.0879E-06, 0.0000E+00, 0.0000E+00, 1.7646E-02, - 0.0000E+00, 4.5891E-10, 1.0853E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 4.5891E-10, 1.0853E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.4570E+02, 2.8489E+02, 5.0000E-03, 8.5714E-05, 1.2345E+08, 8.9474E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 8.5714E-05, 1.0000E-02}, {4.9078E-19, 1.5312E-09, 4.4387E-09, 3.7961E+06, 1.7737E-04, 0.0000E+00, 3.8085E-08, 5.1281E+04, 1.9251E-15, 3.4778E-04, 3.5801E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.1386E-07, 0.0000E+00, 0.0000E+00, 2.7053E-02, - 0.0000E+00, 1.9209E-10, 1.0686E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 1.9209E-10, 1.0686E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 4.5312E+02, 2.8720E+02, 5.0000E-03, 6.4286E-05, 1.2344E+08, 7.3684E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 6.4286E-05, 1.0000E-02}, {2.1097E-18, 2.7648E-09, 3.8261E-09, 3.7754E+06, 6.8685E-04, 0.0000E+00, 4.1018E-08, 5.1227E+04, 4.8876E-15, 1.3468E-03, 2.8059E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 7.1049E-07, 0.0000E+00, 0.0000E+00, 2.4547E-02, - 0.0000E+00, 2.8615E-10, 1.0741E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 2.8615E-10, 1.0741E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 3.4890E+02, 2.8642E+02, 5.0000E-03, 7.1429E-05, 1.2345E+08, 7.8947E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.1429E-05, 1.0000E-02}, {8.9820E-18, 4.2529E-09, 2.9520E-09, 3.7537E+06, 2.6598E-03, 0.0000E+00, 4.3700E-08, 5.1171E+04, 1.4266E-14, 5.2153E-03, 1.9880E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 9.0244E-07, 0.0000E+00, 0.0000E+00, 2.1083E-02, - 0.0000E+00, 3.7631E-10, 1.0796E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 3.7631E-10, 1.0796E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.8656E+02, 2.8565E+02, 5.0000E-03, 7.8571E-05, 1.2345E+08, 8.4211E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 7.8571E-05, 1.0000E-02}, {3.7942E-17, 6.0115E-09, 1.8004E-09, 3.7310E+06, 1.0300E-02, 0.0000E+00, 4.6119E-08, 5.1112E+04, 4.4518E-14, 2.0196E-02, 1.1226E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 1.0879E-06, 0.0000E+00, 0.0000E+00, 1.7646E-02, - 0.0000E+00, 4.5891E-10, 1.0853E+00, 3.3370E+05, 2.8347E+06, do_predict_nc, true, dt, nmltratio, + 0.0000E+00, 4.5891E-10, 1.0853E+00, latvap+latice, latice, do_predict_nc, true, dt, nmltratio, 2.4570E+02, 2.8489E+02, 5.0000E-03, 8.5714E-05, 1.2345E+08, 8.9474E-06, 1.0000E+06, 1.0000E-04, 1.0000E+06, 8.5714E-05, 1.0000E-02}, }; @@ -599,9 +601,9 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticIce const Int offset = i * Spack::n; // Init pack inputs - Spack qc2qi_hetero_freeze_tend, qc2qi_collect_tend, qc2qr_ice_shed_tend, nc_collect_tend, nc2ni_immers_freeze_tend, ncshdc, qr2qi_collect_tend, nr_collect_tend, - qr2qi_immers_freeze_tend, nr2ni_immers_freeze_tend, nr_ice_shed_tend, qi2qr_melt_tend, ni2nr_melt_tend, qi2qv_sublim_tend, qv2qi_vapdep_tend, qv2qi_nucleat_tend, - ni_nucleat_tend, ni_selfcollect_tend, ni_sublim_tend, qc2qi_berg_tend, inv_exner, latent_heat_fusion, latent_heat_sublim, + Spack qc2qi_hetero_freeze_tend, qc2qi_collect_tend, qc2qr_ice_shed_tend, nc_collect_tend, nc2ni_immers_freeze_tend, ncshdc, qr2qi_collect_tend, nr_collect_tend, + qr2qi_immers_freeze_tend, nr2ni_immers_freeze_tend, nr_ice_shed_tend, qi2qr_melt_tend, ni2nr_melt_tend, qi2qv_sublim_tend, qv2qi_vapdep_tend, qv2qi_nucleat_tend, + ni_nucleat_tend, ni_selfcollect_tend, ni_sublim_tend, qc2qi_berg_tend, inv_exner, rho_qm_cloud, th_atm, qv, qc, nc, qr, nr, qi, ni, qm, bm; Scalar dt; bool do_predict_nc; @@ -633,8 +635,6 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticIce ni_sublim_tend[s] = pupidc_device(vs).ni_sublim_tend; qc2qi_berg_tend[s] = pupidc_device(vs).qc2qi_berg_tend; inv_exner[s] = pupidc_device(vs).inv_exner; - latent_heat_fusion[s] = pupidc_device(vs).latent_heat_fusion; - latent_heat_sublim[s] = pupidc_device(vs).latent_heat_sublim; rho_qm_cloud[s] = pupidc_device(vs).rho_qm_cloud; th_atm[s] = pupidc_device(vs).th_atm; @@ -654,7 +654,7 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticIce Functions::update_prognostic_ice(qc2qi_hetero_freeze_tend, qc2qi_collect_tend, qc2qr_ice_shed_tend, nc_collect_tend, nc2ni_immers_freeze_tend,ncshdc, qr2qi_collect_tend, nr_collect_tend, qr2qi_immers_freeze_tend, nr2ni_immers_freeze_tend, nr_ice_shed_tend, qi2qr_melt_tend, ni2nr_melt_tend, qi2qv_sublim_tend, qv2qi_vapdep_tend, qv2qi_nucleat_tend, ni_nucleat_tend, - ni_selfcollect_tend, ni_sublim_tend, qc2qi_berg_tend, inv_exner, latent_heat_sublim, latent_heat_fusion, + ni_selfcollect_tend, ni_sublim_tend, qc2qi_berg_tend, inv_exner, do_predict_nc, log_wetgrowth, dt, pupidc_device(0).nmltratio, rho_qm_cloud, th_atm, qv, qi, ni, qm, bm, qc, nc, qr, nr); @@ -705,26 +705,28 @@ template struct UnitWrap::UnitTest::TestGetTimeSpacePhysVariables { static void get_time_space_phys_variables_unit_bfb_tests(){ + constexpr Scalar latvap = C::LatVap; + constexpr Scalar latice = C::LatIce; //fortran generated data is input to the following GetTimeSpacePhysVarsData gtspvd[max_pack_size] = { // T_atm, pres, rho, latent_heat_vapor, latent_heat_sublim, qv_sat_l, qv_sat_i - {2.9792E+02, 9.8711E+04, 1.1532E+00, 2.5010E+06, 2.8347E+06, 2.0321E-02, 2.0321E-02}, - {2.9792E+02, 9.8711E+04, 1.1532E+00, 2.5010E+06, 2.8347E+06, 2.0321E-02, 2.0321E-02}, - {2.9583E+02, 9.7322E+04, 1.1449E+00, 2.5010E+06, 2.8347E+06, 1.8120E-02, 1.8120E-02}, - {2.9375E+02, 9.5933E+04, 1.1366E+00, 2.5010E+06, 2.8347E+06, 1.6134E-02, 1.6134E-02}, - {2.8959E+02, 9.3156E+04, 1.1196E+00, 2.5010E+06, 2.8347E+06, 1.2729E-02, 1.2729E-02}, - {2.8750E+02, 9.1767E+04, 1.1109E+00, 2.5010E+06, 2.8347E+06, 1.1279E-02, 1.1279E-02}, - {2.8542E+02, 9.0378E+04, 1.1020E+00, 2.5010E+06, 2.8347E+06, 9.9759E-03, 9.9759E-03}, - {2.8334E+02, 8.8989E+04, 1.0931E+00, 2.5010E+06, 2.8347E+06, 8.8076E-03, 8.8076E-03}, - {2.8125E+02, 8.7600E+04, 1.0840E+00, 2.5010E+06, 2.8347E+06, 7.7615E-03, 7.7615E-03}, - {2.7917E+02, 8.6211E+04, 1.0748E+00, 2.5010E+06, 2.8347E+06, 6.8265E-03, 6.8265E-03}, - {2.7709E+02, 8.4822E+04, 1.0654E+00, 2.5010E+06, 2.8347E+06, 5.9921E-03, 5.9921E-03}, - {2.7501E+02, 8.3433E+04, 1.0559E+00, 2.5010E+06, 2.8347E+06, 5.2488E-03, 5.2488E-03}, - {2.7292E+02, 8.2044E+04, 1.0463E+00, 2.5010E+06, 2.8347E+06, 4.5879E-03, 4.5766E-03}, - {2.7084E+02, 8.0656E+04, 1.0365E+00, 2.5010E+06, 2.8347E+06, 4.0015E-03, 3.9112E-03}, - {2.6876E+02, 7.9267E+04, 1.0265E+00, 2.5010E+06, 2.8347E+06, 3.4821E-03, 3.3349E-03}, - {2.6667E+02, 7.7878E+04, 1.0164E+00, 2.5010E+06, 2.8347E+06, 3.0231E-03, 2.8368E-03}, + {2.9792E+02, 9.8711E+04, 1.1532E+00, latvap, latvap+latice, 2.0321E-02, 2.0321E-02}, + {2.9792E+02, 9.8711E+04, 1.1532E+00, latvap, latvap+latice, 2.0321E-02, 2.0321E-02}, + {2.9583E+02, 9.7322E+04, 1.1449E+00, latvap, latvap+latice, 1.8120E-02, 1.8120E-02}, + {2.9375E+02, 9.5933E+04, 1.1366E+00, latvap, latvap+latice, 1.6134E-02, 1.6134E-02}, + {2.8959E+02, 9.3156E+04, 1.1196E+00, latvap, latvap+latice, 1.2729E-02, 1.2729E-02}, + {2.8750E+02, 9.1767E+04, 1.1109E+00, latvap, latvap+latice, 1.1279E-02, 1.1279E-02}, + {2.8542E+02, 9.0378E+04, 1.1020E+00, latvap, latvap+latice, 9.9759E-03, 9.9759E-03}, + {2.8334E+02, 8.8989E+04, 1.0931E+00, latvap, latvap+latice, 8.8076E-03, 8.8076E-03}, + {2.8125E+02, 8.7600E+04, 1.0840E+00, latvap, latvap+latice, 7.7615E-03, 7.7615E-03}, + {2.7917E+02, 8.6211E+04, 1.0748E+00, latvap, latvap+latice, 6.8265E-03, 6.8265E-03}, + {2.7709E+02, 8.4822E+04, 1.0654E+00, latvap, latvap+latice, 5.9921E-03, 5.9921E-03}, + {2.7501E+02, 8.3433E+04, 1.0559E+00, latvap, latvap+latice, 5.2488E-03, 5.2488E-03}, + {2.7292E+02, 8.2044E+04, 1.0463E+00, latvap, latvap+latice, 4.5879E-03, 4.5766E-03}, + {2.7084E+02, 8.0656E+04, 1.0365E+00, latvap, latvap+latice, 4.0015E-03, 3.9112E-03}, + {2.6876E+02, 7.9267E+04, 1.0265E+00, latvap, latvap+latice, 3.4821E-03, 3.3349E-03}, + {2.6667E+02, 7.7878E+04, 1.0164E+00, latvap, latvap+latice, 3.0231E-03, 2.8368E-03}, }; // Sync to device @@ -745,14 +747,12 @@ struct UnitWrap::UnitTest::TestGetTimeSpacePhysVariables const Int offset = i * Spack::n; // Init pack inputs - Spack T_atm, pres, rho, latent_heat_vapor, latent_heat_sublim, qv_sat_l, qv_sat_i, mu, dv, sc, dqsdt, dqsidt, ab, abi, kap, eii; + Spack T_atm, pres, rho, qv_sat_l, qv_sat_i, mu, dv, sc, dqsdt, dqsidt, ab, abi, kap, eii; for (Int s = 0, vs = offset; s < Spack::n; ++s, ++vs) { T_atm[s] = gtspvd_device(vs).T_atm; pres[s] = gtspvd_device(vs).pres; rho[s] = gtspvd_device(vs).rho; - latent_heat_vapor[s] = gtspvd_device(vs).latent_heat_vapor; - latent_heat_sublim[s] = gtspvd_device(vs).latent_heat_sublim; qv_sat_l[s] = gtspvd_device(vs).qv_sat_l; qv_sat_i[s] = gtspvd_device(vs).qv_sat_i; @@ -767,7 +767,7 @@ struct UnitWrap::UnitTest::TestGetTimeSpacePhysVariables eii[s] = gtspvd_device(vs).eii; } - Functions::get_time_space_phys_variables(T_atm, pres, rho, latent_heat_vapor, latent_heat_sublim, qv_sat_l, qv_sat_i, mu, dv, sc, dqsdt, dqsidt, + Functions::get_time_space_phys_variables(T_atm, pres, rho, qv_sat_l, qv_sat_i, mu, dv, sc, dqsdt, dqsidt, ab, abi, kap, eii); // Copy results back into views @@ -775,8 +775,6 @@ struct UnitWrap::UnitTest::TestGetTimeSpacePhysVariables gtspvd_device(vs).T_atm = T_atm[s]; gtspvd_device(vs).pres = pres[s]; gtspvd_device(vs).rho = rho[s]; - gtspvd_device(vs).latent_heat_vapor = latent_heat_vapor[s]; - gtspvd_device(vs).latent_heat_sublim = latent_heat_sublim[s]; gtspvd_device(vs).qv_sat_l = qv_sat_l[s]; gtspvd_device(vs).qv_sat_i = qv_sat_i[s]; @@ -820,72 +818,73 @@ template struct UnitWrap::UnitTest::TestP3UpdatePrognosticLiq { static void update_prognostic_liquid_unit_bfb_tests(){ + constexpr Scalar latvap = C::LatVap; //fortran generated data is input to the following P3UpdatePrognosticLiqData pupldc[max_pack_size] = { {1.0631E-12, 1.0631E+00, 1.5833E-12, 1.5833E+00, 2.4190E-02, 0.0000E+00, 0.0000E+00, 0.0000E+00, 4.2517E+00, - true , true , 8.6718E-01, 1.0037E+00, 2.5010E+06, 1.8000E+03, 2.9902E+02, 5.0000E-02, 1.0000E-06, 1.0000E+06, 1.0010E-06, + true , true , 8.6718E-01, 1.0037E+00, latvap, 1.8000E+03, 2.9902E+02, 5.0000E-02, 1.0000E-06, 1.0000E+06, 1.0010E-06, 6.3726E+05}, {3.2784E-08, 1.8780E+07, 2.1753E-11, 1.2461E+04, 7.8657E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.8748E+04, - true , true , 9.8387E-01, 1.0741E+00, 2.5010E+06, 1.8000E+03, 2.9033E+02, 3.7211E-03, 5.9050E-05,-6.6723E+09,-5.9050E-05, + true , true , 9.8387E-01, 1.0741E+00, latvap, 1.8000E+03, 2.9033E+02, 3.7211E-03, 5.9050E-05,-6.6723E+09,-5.9050E-05, -8.6159E+07}, {3.2796E-09, 1.8778E+07, 1.8830E-12, 1.0782E+04, 6.8061E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.3698E+04, - true , true , 9.0740E-01, 1.0293E+00, 2.5010E+06, 1.8000E+03, 2.9376E+02, 5.0000E-03, 5.9067E-06,-6.9543E+09, 1.0439E-04, + true , true , 9.0740E-01, 1.0293E+00, latvap, 1.8000E+03, 2.9376E+02, 5.0000E-03, 5.9067E-06,-6.9543E+09, 1.0439E-04, -1.6967E+07}, {6.5634E-09, 1.8778E+07, 3.8238E-12, 1.0940E+04, 6.9061E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.3181E+04, - true , true , 9.1484E-01, 1.0339E+00, 2.5010E+06, 1.8000E+03, 2.9291E+02, 5.0000E-03, 1.1821E-05,-6.9282E+09, 1.0615E-04, + true , true , 9.1484E-01, 1.0339E+00, latvap, 1.8000E+03, 2.9291E+02, 5.0000E-03, 1.1821E-05,-6.9282E+09, 1.0615E-04, -2.8223E+07}, {9.8516E-09, 1.8779E+07, 5.8258E-12, 1.1105E+04, 7.0101E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.2655E+04, - true , true , 9.2251E-01, 1.0386E+00, 2.5010E+06, 1.8000E+03, 2.9206E+02, 5.0000E-03, 1.7743E-05,-6.9009E+09, 1.0790E-04, + true , true , 9.2251E-01, 1.0386E+00, latvap, 1.8000E+03, 2.9206E+02, 5.0000E-03, 1.7743E-05,-6.9009E+09, 1.0790E-04, -3.9628E+07}, {1.3145E-08, 1.8779E+07, 7.8929E-12, 1.1276E+04, 7.1180E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.2122E+04, - true , true , 9.3043E-01, 1.0433E+00, 2.5010E+06, 1.8000E+03, 2.9123E+02, 5.0000E-03, 2.3674E-05,-6.8725E+09, 1.0963E-04, + true , true , 9.3043E-01, 1.0433E+00, latvap, 1.8000E+03, 2.9123E+02, 5.0000E-03, 2.3674E-05,-6.8725E+09, 1.0963E-04, -5.1189E+07}, {1.6443E-08, 1.8779E+07, 1.0029E-11, 1.1454E+04, 7.2303E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.1581E+04, - true , true , 9.3860E-01, 1.0482E+00, 2.5010E+06, 1.8000E+03, 2.9040E+02, 5.0000E-03, 2.9615E-05,-6.8428E+09, 1.1136E-04, + true , true , 9.3860E-01, 1.0482E+00, latvap, 1.8000E+03, 2.9040E+02, 5.0000E-03, 2.9615E-05,-6.8428E+09, 1.1136E-04, -6.2915E+07}, {1.9746E-08, 1.8779E+07, 1.2238E-11, 1.1639E+04, 7.3471E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.1031E+04, - true , true , 9.4705E-01, 1.0531E+00, 2.5010E+06, 1.8000E+03, 2.8958E+02, 5.0000E-03, 3.5565E-05,-6.8117E+09, 1.1308E-04, + true , true , 9.4705E-01, 1.0531E+00, latvap, 1.8000E+03, 2.8958E+02, 5.0000E-03, 3.5565E-05,-6.8117E+09, 1.1308E-04, -7.4813E+07}, {2.3047E-08, 1.8779E+07, 1.4521E-11, 1.1832E+04, 7.4688E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 6.0474E+04, - true , true , 9.5579E-01, 1.0582E+00, 2.5010E+06, 1.8000E+03, 2.8941E+02, 4.7949E-03, 4.1510E-05,-6.7792E+09, 1.4787E-05, + true , true , 9.5579E-01, 1.0582E+00, latvap, 1.8000E+03, 2.8941E+02, 4.7949E-03, 4.1510E-05,-6.7792E+09, 1.4787E-05, -8.2885E+07}, {2.6289E-08, 1.8779E+07, 1.6845E-11, 1.2033E+04, 7.5955E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.9907E+04, - true , true , 9.6483E-01, 1.0634E+00, 2.5010E+06, 1.8000E+03, 2.8972E+02, 4.4341E-03, 4.7350E-05,-6.7452E+09,-4.7350E-05, + true , true , 9.6483E-01, 1.0634E+00, latvap, 1.8000E+03, 2.8972E+02, 4.4341E-03, 4.7350E-05,-6.7452E+09,-4.7350E-05, -8.3634E+07}, {2.9533E-08, 1.8779E+07, 1.9253E-11, 1.2242E+04, 7.7277E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.9332E+04, - true , false , 9.7418E-01, 1.0686E+00, 2.5010E+06, 1.8000E+03, 2.9002E+02, 4.0751E-03, 5.3194E-05,-6.7096E+09,-5.3194E-05, + true , false , 9.7418E-01, 1.0686E+00, latvap, 1.8000E+03, 2.9002E+02, 4.0751E-03, 5.3194E-05,-6.7096E+09,-5.3194E-05, -8.4862E+07}, {3.2784E-08, 1.8780E+07, 2.1753E-11, 1.2461E+04, 7.8657E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.8748E+04, - true , false , 9.8387E-01, 1.0741E+00, 2.5010E+06, 1.8000E+03, 2.9033E+02, 3.7211E-03, 5.9050E-05,-6.6723E+09,-5.9050E-05, + true , false , 9.8387E-01, 1.0741E+00, latvap, 1.8000E+03, 2.9033E+02, 3.7211E-03, 5.9050E-05,-6.6723E+09,-5.9050E-05, -8.6159E+07}, {3.6045E-08, 1.8780E+07, 2.4356E-11, 1.2689E+04, 8.0098E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.8154E+04, - true , false , 9.9391E-01, 1.0796E+00, 2.5010E+06, 1.8000E+03, 2.9063E+02, 3.3756E-03, 6.4925E-05,-6.6333E+09,-6.4925E-05, + true , false , 9.9391E-01, 1.0796E+00, latvap, 1.8000E+03, 2.9063E+02, 3.3756E-03, 6.4925E-05,-6.6333E+09,-6.4925E-05, -8.7530E+07}, {3.9321E-08, 1.8780E+07, 2.7069E-11, 1.2928E+04, 8.1605E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.7552E+04, - true , false , 1.0043E+00, 1.0853E+00, 2.5010E+06, 1.8000E+03, 2.9092E+02, 3.0417E-03, 7.0827E-05,-6.5924E+09,-7.0827E-05, + true , false , 1.0043E+00, 1.0853E+00, latvap, 1.8000E+03, 2.9092E+02, 3.0417E-03, 7.0827E-05,-6.5924E+09,-7.0827E-05, -8.8982E+07}, {4.2614E-08, 1.8780E+07, 2.9903E-11, 1.3178E+04, 8.3182E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.6939E+04, - true , false , 1.0151E+00, 1.0911E+00, 2.5010E+06, 1.8000E+03, 2.9119E+02, 2.7224E-03, 7.6760E-05,-6.5494E+09,-7.6760E-05, + true , false , 1.0151E+00, 1.0911E+00, latvap, 1.8000E+03, 2.9119E+02, 2.7224E-03, 7.6760E-05,-6.5494E+09,-7.6760E-05, -9.0523E+07}, {4.5927E-08, 1.8780E+07, 3.2867E-11, 1.3440E+04, 8.4833E+03, 0.0000E+00, 0.0000E+00, 0.0000E+00, 5.6317E+04, - true , false , 1.0263E+00, 1.0970E+00, 2.5010E+06, 1.8000E+03, 2.9143E+02, 2.4202E-03, 8.2728E-05,-6.5044E+09,-8.2728E-05, + true , false , 1.0263E+00, 1.0970E+00, latvap, 1.8000E+03, 2.9143E+02, 2.4202E-03, 8.2728E-05,-6.5044E+09,-8.2728E-05, -9.0778E+07}, }; @@ -908,7 +907,7 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticLiq // Init pack inputs Spack qc2qr_accret_tend, nc_accret_tend, qc2qr_autoconv_tend, nc2nr_autoconv_tend, ncautr, nc_selfcollect_tend, qr2qv_evap_tend, nr_evap_tend, nr_selfcollect_tend, inv_rho, - inv_exner, latent_heat_vapor, th_atm, qv, qc, nc, qr, nr; + inv_exner, th_atm, qv, qc, nc, qr, nr; bool do_predict_nc, do_prescribed_CCN; Scalar dt; @@ -929,7 +928,6 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticLiq nr_selfcollect_tend[s] = pupldc_device(vs).nr_selfcollect_tend; inv_rho[s] = pupldc_device(vs).inv_rho; inv_exner[s] = pupldc_device(vs).inv_exner; - latent_heat_vapor[s] = pupldc_device(vs).latent_heat_vapor; th_atm[s] = pupldc_device(vs).th_atm; qv[s] = pupldc_device(vs).qv; @@ -941,7 +939,7 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticLiq Functions::update_prognostic_liquid(qc2qr_accret_tend, nc_accret_tend, qc2qr_autoconv_tend, nc2nr_autoconv_tend, ncautr, nc_selfcollect_tend, qr2qv_evap_tend, nr_evap_tend, nr_selfcollect_tend, do_predict_nc, do_prescribed_CCN, inv_rho, inv_exner, - latent_heat_vapor, dt, th_atm, qv, qc, nc, qr, nr); + dt, th_atm, qv, qc, nc, qr, nr); // Copy results back into views pupldc_device(0).dt = dt; @@ -959,7 +957,6 @@ struct UnitWrap::UnitTest::TestP3UpdatePrognosticLiq pupldc_device(vs).nr_selfcollect_tend = nr_selfcollect_tend[s]; pupldc_device(vs).inv_rho = inv_rho[s]; pupldc_device(vs).inv_exner = inv_exner[s]; - pupldc_device(vs).latent_heat_vapor = latent_heat_vapor[s]; pupldc_device(vs).th_atm = th_atm[s]; pupldc_device(vs).qv = qv[s]; From 3a85062a5d11f0353705be47ed8902388dd5d390 Mon Sep 17 00:00:00 2001 From: tcclevenger Date: Tue, 3 Sep 2024 13:14:25 -0600 Subject: [PATCH 3/3] Use kokkos scratch pad for local per-team bools --- .../eamxx/src/physics/p3/impl/p3_main_impl.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp index a36a7936404..964ec21be70 100644 --- a/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp +++ b/components/eamxx/src/physics/p3/impl/p3_main_impl.hpp @@ -87,9 +87,11 @@ ::p3_main_internal( const physics::P3_Constants & p3constants) { using ExeSpace = typename KT::ExeSpace; + using ScratchViewType = Kokkos::View; const Int nk_pack = ekat::npack(nk); - const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(nj, nk_pack); + const auto scratch_size = ScratchViewType::shmem_size(2); + const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(nj, nk_pack).set_scratch_size(0, Kokkos::PerTeam(scratch_size)); // load constants into local vars const Scalar inv_dt = 1 / infrastructure.dt; @@ -98,9 +100,6 @@ ::p3_main_internal( const Int kbot = kdir == -1 ? nk-1 : 0; constexpr bool debug_ABORT = false; - // per-column bools - view_2d bools("bools", nj, 2); - // we do not want to measure init stuff auto start = std::chrono::steady_clock::now(); @@ -201,9 +200,11 @@ ::p3_main_internal( const auto oqv_prev = ekat::subview(diagnostic_inputs.qv_prev, i); const auto ot_prev = ekat::subview(diagnostic_inputs.t_prev, i); - // Need to watch out for race conditions with these shared variables - bool &nucleationPossible = bools(i, 0); - bool &hydrometeorsPresent = bools(i, 1); + // Use Kokkos' scratch pad for allocating 2 bools + // per team to determine early exits + ScratchViewType bools(team.team_scratch(0), 2); + bool &nucleationPossible = bools(0); + bool &hydrometeorsPresent = bools(1); view_1d_ptr_array zero_init = { &mu_r, &lamr, &logn0r, &nu, &cdist, &cdist1, &cdistr,