Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAMxx: Add namelist vars for disabling P3 subgrid cldfrac #6849

Merged
merged 6 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/eamxx/cime_config/namelist_defaults_scream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ be lost if SCREAM_HACK_XML is not enabled.
<deposition_nucleation_exponent type="real" doc="Deposition nucleation exponent factor">0.304</deposition_nucleation_exponent>
<ice_sedimentation_factor type="real" doc="Ice sedimentation fall speed factor">1.0</ice_sedimentation_factor>
<do_ice_production type="logical" doc="Flag to turn on ice production processes (loss processes unaffected)">true</do_ice_production>
<!-- flags to override subgrid coud fraction by setting them to 1 everywhere if true -->
<set_cld_frac_l_to_one type="logical" doc="set P3 input liquid cloud fraction to 1 everywhere">false</set_cld_frac_l_to_one>
<set_cld_frac_r_to_one type="logical" doc="set P3 input rain cloud fraction to 1 everywhere" >false</set_cld_frac_r_to_one>
<set_cld_frac_i_to_one type="logical" doc="set P3 input ice cloud fraction to 1 everywhere" >false</set_cld_frac_i_to_one>
</p3>

<!-- SHOC macrophysics -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */)
p3_preproc.set_variables(m_num_cols,nk_pack,pmid,pmid_dry,pseudo_density,pseudo_density_dry,
T_atm,cld_frac_t,
qv, qc, nc, qr, nr, qi, qm, ni, bm, qv_prev,
inv_exner, th_atm, cld_frac_l, cld_frac_i, cld_frac_r, dz);
inv_exner, th_atm, cld_frac_l, cld_frac_i, cld_frac_r, dz, runtime_options);
// --Prognostic State Variables:
prog_state.qc = p3_preproc.qc;
prog_state.nc = p3_preproc.nc;
Expand Down
39 changes: 23 additions & 16 deletions components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,26 @@ class P3Microphysics : public AtmosphereProcess
th_atm(icol,ipack) = PF::calculate_theta_from_T(T_atm_pack,pmid_pack);
// Cloud fraction
// Set minimum cloud fraction - avoids division by zero
cld_frac_l(icol,ipack) = ekat::max(cld_frac_t_pack,mincld);
cld_frac_i(icol,ipack) = ekat::max(cld_frac_t_pack,mincld);
cld_frac_r(icol,ipack) = ekat::max(cld_frac_t_pack,mincld);
// Alternatively set fraction to 1 everywhere to disable subgrid effects
cld_frac_l(icol,ipack) = runtime_opts.set_cld_frac_l_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld);
cld_frac_i(icol,ipack) = runtime_opts.set_cld_frac_i_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld);
cld_frac_r(icol,ipack) = runtime_opts.set_cld_frac_r_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld);

// update rain cloud fraction given neighboring levels using max-overlap approach.
for (int ivec=0;ivec<Spack::n;ivec++)
{
// Hard-coded max-overlap cloud fraction calculation. Cycle through the layers from top to bottom and determine if the rain fraction needs to
// be updated to match the cloud fraction in the layer above. It is necessary to calculate the location of the layer directly above this one,
// labeled ipack_m1 and ivec_m1 respectively. Note, the top layer has no layer above it, which is why we have the kstr index in the loop.
Int lev = ipack*Spack::n + ivec; // Determine the level at this pack/vec location.
Int ipack_m1 = (lev - 1) / Spack::n;
Int ivec_m1 = (lev - 1) % Spack::n;
if (lev != 0) { /* Not applicable at the very top layer */
cld_frac_r(icol,ipack)[ivec] = cld_frac_t(icol,ipack_m1)[ivec_m1]>cld_frac_r(icol,ipack)[ivec] ?
cld_frac_t(icol,ipack_m1)[ivec_m1] :
cld_frac_r(icol,ipack)[ivec];
if ( !runtime_opts.set_cld_frac_r_to_one ) {
for (int ivec=0;ivec<Spack::n;ivec++)
{
// Hard-coded max-overlap cloud fraction calculation. Cycle through the layers from top to bottom and determine if the rain fraction needs to
// be updated to match the cloud fraction in the layer above. It is necessary to calculate the location of the layer directly above this one,
// labeled ipack_m1 and ivec_m1 respectively. Note, the top layer has no layer above it, which is why we have the kstr index in the loop.
Int lev = ipack*Spack::n + ivec; // Determine the level at this pack/vec location.
Int ipack_m1 = (lev - 1) / Spack::n;
Int ivec_m1 = (lev - 1) % Spack::n;
if (lev != 0) { /* Not applicable at the very top layer */
cld_frac_r(icol,ipack)[ivec] = cld_frac_t(icol,ipack_m1)[ivec_m1]>cld_frac_r(icol,ipack)[ivec] ?
cld_frac_t(icol,ipack_m1)[ivec_m1] :
cld_frac_r(icol,ipack)[ivec];
}
}
}
//
Expand Down Expand Up @@ -152,6 +155,8 @@ class P3Microphysics : public AtmosphereProcess
view_2d cld_frac_i;
view_2d cld_frac_r;
view_2d dz;
// Add runtime_options as a member variable
P3F::P3Runtime runtime_opts;
// Assigning local variables
void set_variables(const int ncol, const int npack,
const view_2d_const& pmid_, const view_2d_const& pmid_dry_,
Expand All @@ -161,7 +166,8 @@ class P3Microphysics : public AtmosphereProcess
const view_2d& nc_, const view_2d& qr_, const view_2d& nr_, const view_2d& qi_,
const view_2d& qm_, const view_2d& ni_, const view_2d& bm_, const view_2d& qv_prev_,
const view_2d& inv_exner_, const view_2d& th_atm_, const view_2d& cld_frac_l_,
const view_2d& cld_frac_i_, const view_2d& cld_frac_r_, const view_2d& dz_
const view_2d& cld_frac_i_, const view_2d& cld_frac_r_, const view_2d& dz_,
const P3F::P3Runtime& runtime_options
)
{
m_ncol = ncol;
Expand Down Expand Up @@ -190,6 +196,7 @@ class P3Microphysics : public AtmosphereProcess
cld_frac_i = cld_frac_i_;
cld_frac_r = cld_frac_r_;
dz = dz_;
runtime_opts = runtime_options;
} // set_variables
}; // p3_preamble
/* --------------------------------------------------------------------------------------------*/
Expand Down
6 changes: 6 additions & 0 deletions components/eamxx/src/physics/p3/p3_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ struct Functions
Scalar deposition_nucleation_exponent = 0.304;
Scalar ice_sedimentation_factor = 1.0;
bool do_ice_production = true;
bool set_cld_frac_l_to_one = false;
bool set_cld_frac_i_to_one = false;
bool set_cld_frac_r_to_one = false;

void load_runtime_options_from_file(ekat::ParameterList& params) {
max_total_ni = params.get<double>("max_total_ni", max_total_ni);
Expand All @@ -153,6 +156,9 @@ struct Functions
deposition_nucleation_exponent = params.get<double>("deposition_nucleation_exponent", deposition_nucleation_exponent);
ice_sedimentation_factor = params.get<double>("ice_sedimentation_factor", ice_sedimentation_factor);
do_ice_production = params.get<bool>("do_ice_production", do_ice_production);
set_cld_frac_l_to_one = params.get<bool>("set_cld_frac_l_to_one", set_cld_frac_l_to_one);
set_cld_frac_i_to_one = params.get<bool>("set_cld_frac_i_to_one", set_cld_frac_i_to_one);
set_cld_frac_r_to_one = params.get<bool>("set_cld_frac_r_to_one", set_cld_frac_r_to_one);
}

};
Expand Down
Loading