From e8f869e044d964dedf191cbd819cb786e941b11c Mon Sep 17 00:00:00 2001 From: Walter Hannah Date: Fri, 13 Dec 2024 09:28:35 -0800 Subject: [PATCH 1/6] add namelist vars for disabling P3 subgrid cldfrac "disabling" might be misleading because these flags "maximize" cloud fraction by setting them to 1 everywhere --- .../eamxx/cime_config/namelist_defaults_scream.xml | 4 ++++ components/eamxx/src/physics/p3/eamxx_p3_run.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 9fa076d47dd2..5af337f1afac 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -223,6 +223,10 @@ be lost if SCREAM_HACK_XML is not enabled. 0.304 1.0 true + + false + false + false diff --git a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp index 3de8184319af..22d83fdcb9b9 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp @@ -15,6 +15,20 @@ void P3Microphysics::run_impl (const double dt) ); // Kokkos::parallel_for(p3_main_local_vals) Kokkos::fence(); + // allow namelist flags to override sub-grid cloud fraction (set it to 1 everywhere) + if (m_params.get("fix_cld_frac_l", false)) { + auto& cld_frac_l = p3_preproc.cld_frac_l; + Kokkos::deep_copy(cld_frac_l,1.0); + } + if (m_params.get("fix_cld_frac_r", false)) { + auto& cld_frac_r = p3_preproc.cld_frac_r; + Kokkos::deep_copy(cld_frac_r,1.0); + } + if (m_params.get("fix_cld_frac_i", false)) { + auto& cld_frac_i = p3_preproc.cld_frac_i; + Kokkos::deep_copy(cld_frac_i,1.0); + } + // Update the variables in the p3 input structures with local values. infrastructure.dt = dt; From 8503556202f48070a21f0c9625cfe11d24d36c1e Mon Sep 17 00:00:00 2001 From: Walter Hannah Date: Fri, 13 Dec 2024 09:56:19 -0800 Subject: [PATCH 2/6] make P3 cld frac flags more verbose --- components/eamxx/cime_config/namelist_defaults_scream.xml | 6 +++--- components/eamxx/src/physics/p3/eamxx_p3_run.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 5af337f1afac..bff0c21f0c21 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -224,9 +224,9 @@ be lost if SCREAM_HACK_XML is not enabled. 1.0 true - false - false - false + false + false + false diff --git a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp index 22d83fdcb9b9..1e3218d7e4a3 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp @@ -16,15 +16,15 @@ void P3Microphysics::run_impl (const double dt) Kokkos::fence(); // allow namelist flags to override sub-grid cloud fraction (set it to 1 everywhere) - if (m_params.get("fix_cld_frac_l", false)) { + if (m_params.get("set_cld_frac_l_to_one", false)) { auto& cld_frac_l = p3_preproc.cld_frac_l; Kokkos::deep_copy(cld_frac_l,1.0); } - if (m_params.get("fix_cld_frac_r", false)) { + if (m_params.get("set_cld_frac_r_to_one", false)) { auto& cld_frac_r = p3_preproc.cld_frac_r; Kokkos::deep_copy(cld_frac_r,1.0); } - if (m_params.get("fix_cld_frac_i", false)) { + if (m_params.get("set_cld_frac_i_to_one", false)) { auto& cld_frac_i = p3_preproc.cld_frac_i; Kokkos::deep_copy(cld_frac_i,1.0); } From 19ea8c782119e6f33ab75d7bf18c47ff12f046f7 Mon Sep 17 00:00:00 2001 From: Walter Hannah Date: Fri, 13 Dec 2024 10:40:01 -0800 Subject: [PATCH 3/6] add type and doc for namelist flags --- components/eamxx/cime_config/namelist_defaults_scream.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index bff0c21f0c21..03c1631c4b6d 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -224,9 +224,9 @@ be lost if SCREAM_HACK_XML is not enabled. 1.0 true - false - false - false + false + false + false From dd0afd90a3bbd9b36332d9bc701f7759833ce81b Mon Sep 17 00:00:00 2001 From: Walter Hannah Date: Tue, 17 Dec 2024 12:57:14 -0800 Subject: [PATCH 4/6] refactor p3 cloud fraction flags --- .../physics/p3/eamxx_p3_process_interface.cpp | 9 +++- .../physics/p3/eamxx_p3_process_interface.hpp | 43 ++++++++++++------- 2 files changed, 36 insertions(+), 16 deletions(-) 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 f6771d6bf171..9736d7ae5980 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp @@ -275,9 +275,16 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */) auto cld_frac_l = m_buffer.cld_frac_l; auto cld_frac_i = m_buffer.cld_frac_i; auto dz = m_buffer.dz; + auto set_cld_frac_l_to_one = m_params.get("set_cld_frac_l_to_one", false); + auto set_cld_frac_i_to_one = m_params.get("set_cld_frac_i_to_one", false); + auto set_cld_frac_r_to_one = m_params.get("set_cld_frac_r_to_one", false); // -- Set values for the pre-amble structure - p3_preproc.set_variables(m_num_cols,nk_pack,pmid,pmid_dry,pseudo_density,pseudo_density_dry, + p3_preproc.set_variables(m_num_cols,nk_pack, + set_cld_frac_l_to_one, + set_cld_frac_i_to_one, + set_cld_frac_r_to_one, + 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); 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 7aedd97b5a82..d8016d9e4c36 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp @@ -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) = m_set_cld_frac_l_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld); + cld_frac_i(icol,ipack) = m_set_cld_frac_i_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld); + cld_frac_r(icol,ipack) = m_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;iveccld_frac_r(icol,ipack)[ivec] ? - cld_frac_t(icol,ipack_m1)[ivec_m1] : - cld_frac_r(icol,ipack)[ivec]; + if ( !m_set_cld_frac_r_to_one ) { + for (int ivec=0;iveccld_frac_r(icol,ipack)[ivec] ? + cld_frac_t(icol,ipack_m1)[ivec_m1] : + cld_frac_r(icol,ipack)[ivec]; + } } } // @@ -129,6 +132,7 @@ class P3Microphysics : public AtmosphereProcess } // operator // Local variables int m_ncol, m_npack; + bool m_set_cld_frac_l_to_one, m_set_cld_frac_i_to_one, m_set_cld_frac_r_to_one; Real mincld = 0.0001; // TODO: These should be stored somewhere as more universal constants. Or maybe in the P3 class hpp view_2d_const pmid; view_2d_const pmid_dry; @@ -154,6 +158,9 @@ class P3Microphysics : public AtmosphereProcess view_2d dz; // Assigning local variables void set_variables(const int ncol, const int npack, + const bool set_cld_frac_l_to_one, + const bool set_cld_frac_i_to_one, + const bool set_cld_frac_r_to_one, const view_2d_const& pmid_, const view_2d_const& pmid_dry_, const view_2d_const& pseudo_density_, const view_2d_const& pseudo_density_dry_, const view_2d& T_atm_, @@ -166,6 +173,9 @@ class P3Microphysics : public AtmosphereProcess { m_ncol = ncol; m_npack = npack; + m_set_cld_frac_l_to_one = set_cld_frac_l_to_one; + m_set_cld_frac_i_to_one = set_cld_frac_i_to_one; + m_set_cld_frac_r_to_one = set_cld_frac_r_to_one; // IN pmid = pmid_; pmid_dry = pmid_dry_; @@ -262,6 +272,9 @@ class P3Microphysics : public AtmosphereProcess } // operator // Local variables int m_ncol, m_npack; + bool m_set_cld_frac_l_to_one; + bool m_set_cld_frac_i_to_one; + bool m_set_cld_frac_r_to_one; double m_dt; view_2d T_atm; view_2d_const pmid; From 94fa6d5832a26039013b7667c5193d572527cbd5 Mon Sep 17 00:00:00 2001 From: Walter Hannah Date: Tue, 17 Dec 2024 14:15:48 -0800 Subject: [PATCH 5/6] remove old method --- components/eamxx/src/physics/p3/eamxx_p3_run.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp index 1e3218d7e4a3..3de8184319af 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_run.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_run.cpp @@ -15,20 +15,6 @@ void P3Microphysics::run_impl (const double dt) ); // Kokkos::parallel_for(p3_main_local_vals) Kokkos::fence(); - // allow namelist flags to override sub-grid cloud fraction (set it to 1 everywhere) - if (m_params.get("set_cld_frac_l_to_one", false)) { - auto& cld_frac_l = p3_preproc.cld_frac_l; - Kokkos::deep_copy(cld_frac_l,1.0); - } - if (m_params.get("set_cld_frac_r_to_one", false)) { - auto& cld_frac_r = p3_preproc.cld_frac_r; - Kokkos::deep_copy(cld_frac_r,1.0); - } - if (m_params.get("set_cld_frac_i_to_one", false)) { - auto& cld_frac_i = p3_preproc.cld_frac_i; - Kokkos::deep_copy(cld_frac_i,1.0); - } - // Update the variables in the p3 input structures with local values. infrastructure.dt = dt; From e5e8caf7e3eeea1df1b251f529d6f9a3a7d820f4 Mon Sep 17 00:00:00 2001 From: mahf708 Date: Thu, 19 Dec 2024 10:07:16 -0800 Subject: [PATCH 6/6] EAMxx: move cld_frac overrides to P3Runtime --- .../physics/p3/eamxx_p3_process_interface.cpp | 11 ++------- .../physics/p3/eamxx_p3_process_interface.hpp | 24 +++++++------------ .../eamxx/src/physics/p3/p3_functions.hpp | 6 +++++ 3 files changed, 17 insertions(+), 24 deletions(-) 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 9736d7ae5980..1ea5cbe0f05b 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp @@ -275,19 +275,12 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */) auto cld_frac_l = m_buffer.cld_frac_l; auto cld_frac_i = m_buffer.cld_frac_i; auto dz = m_buffer.dz; - auto set_cld_frac_l_to_one = m_params.get("set_cld_frac_l_to_one", false); - auto set_cld_frac_i_to_one = m_params.get("set_cld_frac_i_to_one", false); - auto set_cld_frac_r_to_one = m_params.get("set_cld_frac_r_to_one", false); // -- Set values for the pre-amble structure - p3_preproc.set_variables(m_num_cols,nk_pack, - set_cld_frac_l_to_one, - set_cld_frac_i_to_one, - set_cld_frac_r_to_one, - pmid,pmid_dry,pseudo_density,pseudo_density_dry, + 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; 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 d8016d9e4c36..839458c91c30 100644 --- a/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp +++ b/components/eamxx/src/physics/p3/eamxx_p3_process_interface.hpp @@ -106,12 +106,12 @@ class P3Microphysics : public AtmosphereProcess // Cloud fraction // Set minimum cloud fraction - avoids division by zero // Alternatively set fraction to 1 everywhere to disable subgrid effects - cld_frac_l(icol,ipack) = m_set_cld_frac_l_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld); - cld_frac_i(icol,ipack) = m_set_cld_frac_i_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld); - cld_frac_r(icol,ipack) = m_set_cld_frac_r_to_one ? 1 : ekat::max(cld_frac_t_pack,mincld); + 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. - if ( !m_set_cld_frac_r_to_one ) { + if ( !runtime_opts.set_cld_frac_r_to_one ) { for (int ivec=0;ivec("max_total_ni", max_total_ni); @@ -153,6 +156,9 @@ struct Functions deposition_nucleation_exponent = params.get("deposition_nucleation_exponent", deposition_nucleation_exponent); ice_sedimentation_factor = params.get("ice_sedimentation_factor", ice_sedimentation_factor); do_ice_production = params.get("do_ice_production", do_ice_production); + set_cld_frac_l_to_one = params.get("set_cld_frac_l_to_one", set_cld_frac_l_to_one); + set_cld_frac_i_to_one = params.get("set_cld_frac_i_to_one", set_cld_frac_i_to_one); + set_cld_frac_r_to_one = params.get("set_cld_frac_r_to_one", set_cld_frac_r_to_one); } };