Skip to content

Commit

Permalink
Merge Pull Request #2887 from E3SM-Project/scream/tcclevenger/extract…
Browse files Browse the repository at this point in the history
…_p3_var_for_mam4xx

Automatically Merged using E3SM Pull Request AutoTester
PR Title: Add P3 vars to FM
PR Author: tcclevenger
PR LABELS: BFB, p3, AT: AUTOMERGE, AT: PRE-TEST INSPECTED
  • Loading branch information
E3SM-Autotester authored Jul 3, 2024
2 parents de7d316 + 82ee85e commit 27b21e2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
6 changes: 4 additions & 2 deletions components/eamxx/src/physics/p3/disp/p3_main_impl_disp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ ::p3_main_internal_disp(
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), precip_total_tend("precip_total_tend", nj, nk_pack),
nevapr("nevapr", nj, nk_pack), qr_evap_tend("qr_evap_tend", nj, nk_pack),
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),
Expand Down Expand Up @@ -205,6 +205,8 @@ ::p3_main_internal_disp(
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;
Expand Down
14 changes: 9 additions & 5 deletions components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ void P3Microphysics::set_grids(const std::shared_ptr<const GridsManager> grids_m
add_field<Updated> ("T_prev_micro_step", scalar3d_layout_mid, K, grid_name, ps);

// Diagnostic Outputs: (all fields are just outputs w.r.t. P3)
add_field<Updated>("precip_liq_surf_mass", scalar2d_layout, kg/m2, grid_name, "ACCUMULATED");
add_field<Updated>("precip_ice_surf_mass", scalar2d_layout, kg/m2, grid_name, "ACCUMULATED");
add_field<Computed>("eff_radius_qc", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Computed>("eff_radius_qi", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Computed>("eff_radius_qr", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Updated>("precip_liq_surf_mass", scalar2d_layout, kg/m2, grid_name, "ACCUMULATED");
add_field<Updated>("precip_ice_surf_mass", scalar2d_layout, kg/m2, grid_name, "ACCUMULATED");
add_field<Computed>("eff_radius_qc", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Computed>("eff_radius_qi", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Computed>("eff_radius_qr", scalar3d_layout_mid, micron, grid_name, ps);
add_field<Computed>("precip_total_tend", scalar3d_layout_mid, kg/(kg*s), grid_name, ps);
add_field<Computed>("nevapr", scalar3d_layout_mid, kg/(kg*s), grid_name, ps);

// History Only: (all fields are just outputs and are really only meant for I/O purposes)
// TODO: These should be averaged over subcycle as well. But there is no simple mechanism
Expand Down Expand Up @@ -307,6 +309,8 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */)
diag_outputs.diag_eff_radius_qc = get_field_out("eff_radius_qc").get_view<Pack**>();
diag_outputs.diag_eff_radius_qi = get_field_out("eff_radius_qi").get_view<Pack**>();
diag_outputs.diag_eff_radius_qr = get_field_out("eff_radius_qr").get_view<Pack**>();
diag_outputs.precip_total_tend = get_field_out("precip_total_tend").get_view<Pack**>();
diag_outputs.nevapr = get_field_out("nevapr").get_view<Pack**>();

diag_outputs.precip_liq_surf = m_buffer.precip_liq_surf_flux;
diag_outputs.precip_ice_surf = m_buffer.precip_ice_surf_flux;
Expand Down
14 changes: 8 additions & 6 deletions components/eamxx/src/physics/p3/impl/p3_main_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ ::p3_main_internal(
qtend_ignore, ntend_ignore,

// Variables still used in F90 but removed from C++ interface
mu_c, lamc, precip_total_tend, nevapr, qr_evap_tend;
mu_c, lamc, qr_evap_tend;

workspace.template take_many_and_reset<46>(
workspace.template take_many_and_reset<44>(
{
"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",
Expand All @@ -153,7 +153,7 @@ ::p3_main_internal(
"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",
"mu_c", "lamc", "precip_total_tend", "nevapr", "qr_evap_tend"
"mu_c", "lamc", "qr_evap_tend"
},
{
&mu_r, &T_atm, &lamr, &logn0r, &nu, &cdist, &cdist1, &cdistr,
Expand All @@ -163,7 +163,7 @@ ::p3_main_internal(
&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,
&mu_c, &lamc, &precip_total_tend, &nevapr, &qr_evap_tend
&mu_c, &lamc, &qr_evap_tend
});

// Get single-column subviews of all inputs, shouldn't need any i-indexing
Expand Down Expand Up @@ -197,6 +197,8 @@ ::p3_main_internal(
const auto orho_qi = ekat::subview(diagnostic_outputs.rho_qi, i);
const auto oprecip_liq_flux = ekat::subview(diagnostic_outputs.precip_liq_flux, i);
const auto oprecip_ice_flux = ekat::subview(diagnostic_outputs.precip_ice_flux, i);
const auto oprecip_total_tend = ekat::subview(diagnostic_outputs.precip_total_tend, i);
const auto onevapr = ekat::subview(diagnostic_outputs.nevapr, i);
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);
Expand All @@ -216,7 +218,7 @@ ::p3_main_internal(
&nc_incld, &nr_incld, &ni_incld, &bm_incld,
&inv_rho, &prec, &rho, &rhofacr, &rhofaci, &acn, &qv_sat_l, &qv_sat_i, &sup, &qv_supersat_i,
&tmparr1, &qtend_ignore, &ntend_ignore,
&mu_c, &lamc, &orho_qi, &oqv2qi_depos_tend, &precip_total_tend, &nevapr, &oprecip_liq_flux, &oprecip_ice_flux
&mu_c, &lamc, &orho_qi, &oqv2qi_depos_tend, &oprecip_total_tend, &onevapr, &oprecip_liq_flux, &oprecip_ice_flux
};

// initialize
Expand Down Expand Up @@ -252,7 +254,7 @@ ::p3_main_internal(
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,
nr_incld, ni_incld, bm_incld, mu_c, nu, lamc, cdist, cdist1, cdistr,
mu_r, lamr, logn0r, oqv2qi_depos_tend, precip_total_tend, nevapr, qr_evap_tend,
mu_r, lamr, logn0r, oqv2qi_depos_tend, oprecip_total_tend, onevapr, qr_evap_tend,
ovap_liq_exchange, ovap_ice_exchange, oliq_ice_exchange,
pratot, prctot, hydrometeorsPresent, nk, p3constants);

Expand Down
4 changes: 4 additions & 0 deletions components/eamxx/src/physics/p3/p3_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ struct Functions
view_2d<Spack> precip_liq_flux;
// Grid-box average ice/snow flux [kg m^-2 s^-1] pverp
view_2d<Spack> precip_ice_flux;
// Total precipitation (rain + snow) [kg/kg/s]
view_2d<Spack> precip_total_tend;
// Evaporation of total precipitation (rain + snow) [kg/kg/s]
view_2d<Spack> nevapr;
};

// This struct stores time stepping and grid-index-related information.
Expand Down
2 changes: 1 addition & 1 deletion components/eamxx/src/physics/p3/p3_functions_f90.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ Int p3_main_f(
inv_exner_d, qv_prev_d, t_prev_d};
P3F::P3DiagnosticOutputs diag_outputs{qv2qi_depos_tend_d, precip_liq_surf_d,
precip_ice_surf_d, diag_eff_radius_qc_d, diag_eff_radius_qi_d, diag_eff_radius_qr_d,
rho_qi_d,precip_liq_flux_d, precip_ice_flux_d};
rho_qi_d,precip_liq_flux_d, precip_ice_flux_d, precip_total_tend_d, nevapr_d};
P3F::P3Infrastructure infrastructure{dt, it, its, ite, kts, kte,
do_predict_nc, do_prescribed_CCN, col_location_d};
P3F::P3HistoryOnly history_only{liq_ice_exchange_d, vap_liq_exchange_d,
Expand Down

0 comments on commit 27b21e2

Please sign in to comment.