Skip to content

Commit

Permalink
Merge pull request #2 from eagles-project/singhbalwinder/jroverf/dry-dep
Browse files Browse the repository at this point in the history
Implement the MAMDryDep::run_impl() function.
  • Loading branch information
overfelt authored Mar 25, 2024
2 parents 2dd3d73 + 76ca087 commit c2ad201
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 81 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ namespace scream {
// The process responsible for handling MAM4 dry deposition. The AD
// stores exactly ONE instance of this class in its list of subcomponents.
class MAMDryDep final : public scream::AtmosphereProcess {

using KT = ekat::KokkosTypes<DefaultDevice>;

public:
using view_2d = Field::view_dev_t<Real **>;
using view_3d = Field::view_dev_t<Real ***>;
using const_view_2d = Field::view_dev_t<const Real **>;
using const_view_3d = Field::view_dev_t<const Real ***>;
static constexpr int num_aero_modes = mam_coupling::num_aero_modes();
private:
// number of horizontal columns and vertical levels
int ncol_, nlev_;

Expand All @@ -34,7 +38,18 @@ class MAMDryDep final : public scream::AtmosphereProcess {
// physics grid for column information
std::shared_ptr<const AbstractGrid> grid_;

public:
view_3d qtracers_;
view_3d d_qtracers_dt_;
view_3d dgncur_awet_;
view_3d wet_dens_;
view_3d tendencies_;

view_2d aerdepdrycw_;
view_2d aerdepdryis_;

public:
using KT = ekat::KokkosTypes<DefaultDevice>;

// Constructor
MAMDryDep(const ekat::Comm &comm, const ekat::ParameterList &params);

Expand All @@ -43,10 +58,10 @@ class MAMDryDep final : public scream::AtmosphereProcess {
// --------------------------------------------------------------------------

// The type of subcomponent
AtmosphereProcessType type() const { return AtmosphereProcessType::Physics; }
AtmosphereProcessType type() const override { return AtmosphereProcessType::Physics; }

// The name of the subcomponent
std::string name() const { return "mam_dry_deposition"; }
std::string name() const override { return "mam_dry_deposition"; }

// grid
void set_grids(
Expand All @@ -63,7 +78,7 @@ class MAMDryDep final : public scream::AtmosphereProcess {
void run_impl(const double dt) override;

// Finalize
void finalize_impl(){/*Do nothing*/};
void finalize_impl() override {/*Do nothing*/};

// Atmosphere processes often have a pre-processing step that constructs
// required variables from the set of fields stored in the field manager.
Expand Down Expand Up @@ -106,12 +121,21 @@ class MAMDryDep final : public scream::AtmosphereProcess {
mam_coupling::AerosolState wet_aero_pre_, dry_aero_pre_;
}; // MAMAci::Preprocess

struct Parameters {
Real Obukhov_length_ = 0.20723257141035126e+03;
Real surface_friction_velocty_ = 0.39900396673305327;
Real land_fraction_ = 0.1;
Real ice_fraction_ = 0.6;
Real ocean_fraction_ = 0.3;
Real friction_velocity_ = 0.46637129718055864;
Real aerodynamical_resistance_ = 0.91147859222259044e+02;
};
private:
// pre- and postprocessing scratch pads
Preprocess preprocess_;

Parameters parameters_;
}; // MAMDryDep

} // namespace scream

#endif // EAMXX_MAM_DRYDEP_HPP
#endif // EAMXX_MAM_DRYDEP_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void compute_water_content(const mam4::Prognostics &progs, int k,
// extract aerosol tracers for this level into state_q, which is needed
// for computing dry aerosol properties below
// FIXME: we should eliminate this index translation stuff
constexpr int nvars = mam4::water_uptake::nvars;
constexpr int nvars = mam4::aero_model::pcnst;
Real state_q[nvars]; // aerosol tracers for level k
for (int imode = 0; imode < num_modes; ++imode) {
int la, lc; // interstitial and cloudborne indices within state_q
Expand Down
13 changes: 8 additions & 5 deletions components/eamxx/src/physics/mam/mam_coupling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ struct DryAtmosphere {
Real z_surf; // height of bottom of atmosphere [m]
const_view_2d T_mid; // temperature at grid midpoints [K]
const_view_2d p_mid; // total pressure at grid midpoints [Pa]
const_view_2d p_int; // total pressure at layer interfaces [Pa]
view_2d qv; // dry water vapor mixing ratio [kg vapor / kg dry air]
view_2d qc; // dry cloud liquid water mass mixing ratio [kg cloud water/kg dry air]
view_2d nc; // dry cloud liquid water number mixing ratio [# / kg dry air]
Expand Down Expand Up @@ -343,8 +344,9 @@ struct Buffer {
// =======================

// number of local fields stored at column interfaces
static constexpr int num_2d_iface = 1;
static constexpr int num_2d_iface = 2;

uview_2d p_int; // pressure at interfaces
uview_2d z_iface; // height at interfaces

// storage
Expand Down Expand Up @@ -460,6 +462,7 @@ inline size_t init_buffer(const ATMBufferManager &buffer_manager,

// set view pointers for interface fields
uview_2d* view_2d_iface_ptrs[Buffer::num_2d_iface] = {
&buffer.p_int,
&buffer.z_iface
};
for (int i = 0; i < Buffer::num_2d_iface; ++i) {
Expand Down Expand Up @@ -512,6 +515,8 @@ haero::Atmosphere atmosphere_for_column(const DryAtmosphere& dry_atm,
"cldfrac not defined for dry atmosphere state!");
EKAT_KERNEL_ASSERT_MSG(dry_atm.w_updraft.data() != nullptr,
"w_updraft not defined for dry atmosphere state!");
EKAT_KERNEL_ASSERT_MSG(dry_atm.p_int.data() != nullptr,
"p_int not defined for dry atmosphere state!");
return haero::Atmosphere(mam4::nlev,
ekat::subview(dry_atm.T_mid, column_index),
ekat::subview(dry_atm.p_mid, column_index),
Expand All @@ -522,6 +527,7 @@ haero::Atmosphere atmosphere_for_column(const DryAtmosphere& dry_atm,
ekat::subview(dry_atm.ni, column_index),
ekat::subview(dry_atm.z_mid, column_index),
ekat::subview(dry_atm.p_del, column_index),
ekat::subview(dry_atm.p_int, column_index),
ekat::subview(dry_atm.cldfrac, column_index),
ekat::subview(dry_atm.w_updraft, column_index),
dry_atm.pblh(column_index));
Expand Down Expand Up @@ -592,7 +598,6 @@ void compute_vertical_layer_heights(const Team& team,
PF::calculate_z_mid(team, mam4::nlev, z_iface, z_mid);
}


// Given a thread team and wet and dry atmospheres, dispatches threads from the
// team to compute the vertical updraft velocity for the column with the given
// index.
Expand Down Expand Up @@ -720,7 +725,7 @@ void compute_wet_mixing_ratios(const Team& team,
const auto PC = mam4::ModeIndex::PrimaryCarbon; \
const auto NoMode = mam4::ModeIndex::None; \
static const mam4::ModeIndex mode_for_cnst[gas_pcnst()] = { \
NoMode, NoMode, NoMode, NoMode, NoMode, NoMode, /* gases (not aerosols) */ \
NoMode, NoMode, NoMode, NoMode, NoMode, NoMode, /* gases (not aerosols) */ \
Accum, Accum, Accum, Accum, Accum, Accum, Accum, Accum, /* 7 aero species + NMR */ \
Aitken, Aitken, Aitken, Aitken, Aitken, /* 4 aero species + NMR */ \
Coarse, Coarse, Coarse, Coarse, Coarse, Coarse, Coarse, Coarse, /* 7 aero species + NMR */ \
Expand Down Expand Up @@ -817,7 +822,6 @@ void convert_work_arrays_to_vmr(const Real q[gas_pcnst()],
vmr[i] = mam4::conversions::vmr_from_mmr(q[i], mw);
vmrcw[i] = mam4::conversions::vmr_from_mmr(qqcw[i], mw);
} else {
int m = static_cast<int>(mode_index);
if (aero_id != NoAero) { // constituent is an aerosol species
int a = aerosol_index_for_mode(mode_index, aero_id);
const Real mw = mam4::aero_species(a).molecular_weight;
Expand Down Expand Up @@ -850,7 +854,6 @@ void convert_work_arrays_to_mmr(const Real vmr[gas_pcnst()],
q[i] = mam4::conversions::mmr_from_vmr(vmr[i], mw);
qqcw[i] = mam4::conversions::mmr_from_vmr(vmrcw[i], mw);
} else {
int m = static_cast<int>(mode_index);
if (aero_id != NoAero) { // constituent is an aerosol species
int a = aerosol_index_for_mode(mode_index, aero_id);
const Real mw = mam4::aero_species(a).molecular_weight;
Expand Down
4 changes: 2 additions & 2 deletions components/eamxx/src/share/grid/remap/identity_remapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class IdentityRemapper : public AbstractRemapper
return src_layout;
}

void register_field_from_src (const field_type& src) {
void register_field_from_src (const field_type& src) override {
EKAT_REQUIRE_MSG (m_aliasing!=SrcAliasTgt,
"Error! Makes no sense to register from src and ask that src alias tgt.\n");
if (m_aliasing==TgtAliasSrc) {
Expand All @@ -72,7 +72,7 @@ class IdentityRemapper : public AbstractRemapper
AbstractRemapper::register_field_from_src(src);
}
}
void register_field_from_tgt (const field_type& tgt) {
void register_field_from_tgt (const field_type& tgt) override {
EKAT_REQUIRE_MSG (m_aliasing!=TgtAliasSrc,
"Error! Makes no sense to register from tgt and ask that tgt alias src.\n");
if (m_aliasing==SrcAliasTgt) {
Expand Down
2 changes: 2 additions & 0 deletions components/eamxx/tests/uncoupled/mam4/drydep/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ initial_conditions:
ocnfrac: 0.0
fv: 1e-5
ram1: 1e-5
w_updraft: 1e-5
pbl_height: 0.0

# The parameters for I/O control
Scorpio:
Expand Down
2 changes: 1 addition & 1 deletion externals/mam4xx
Submodule mam4xx updated 76 files
+9 −0 .github/pnnl-ci/README.md
+3 −2 .github/pnnl-ci/ci.sh
+1 −1 .github/pnnl-ci/pnnl.gitlab-ci.yml
+42 −38 CMakeLists.txt
+11 −2 src/mam4xx/CMakeLists.txt
+518 −195 src/mam4xx/aer_rad_props.hpp
+51 −0 src/mam4xx/aero_config.hpp.in
+13 −13 src/mam4xx/aero_model.hpp
+97 −93 src/mam4xx/convproc.hpp
+1,033 −6 src/mam4xx/drydep.hpp
+1 −2 src/mam4xx/hetfrz.hpp
+4 −1 src/mam4xx/mam4.hpp
+179 −0 src/mam4xx/mo_sethet.hpp
+152 −0 src/mam4xx/mo_setinv.hpp
+327 −157 src/mam4xx/modal_aer_opt.hpp
+1 −1 src/mam4xx/modal_aero_calcsize.hpp
+22 −16 src/mam4xx/ndrop.hpp
+37 −0 src/mam4xx/spitfire_transport.hpp
+288 −1 src/mam4xx/utils.hpp
+4 −6 src/mam4xx/water_uptake.hpp
+494 −254 src/mam4xx/wet_dep.hpp
+5 −1 src/tests/CMakeLists.txt
+11 −2 src/tests/atmosphere_utils.cpp
+19 −19 src/tests/mam4_convproc_unit_tests.cpp
+101 −0 src/tests/mam4_dry_deposition_unit_tests.cpp
+1 −1 src/tests/mam4_ndrop_unit_tests.cpp
+46 −0 src/tests/mam4_spitfire_transport_unit_tests.cpp
+2 −1 src/validation/CMakeLists.txt
+1 −1 src/validation/aerosol_optics/aer_rad_props_lw.cpp
+1 −1 src/validation/aerosol_optics/aer_rad_props_sw.cpp
+2 −2 src/validation/aerosol_optics/modal_aero_lw.cpp
+1 −1 src/validation/aerosol_optics/modal_aero_sw.cpp
+24 −16 src/validation/aerosol_optics/volcanic_cmip_sw.cpp
+3 −4 src/validation/calcsize/modal_aero_calcsize_sub.cpp
+6 −6 src/validation/convproc/compute_tendencies.cpp
+2 −2 src/validation/convproc/initialize_tmr_array.cpp
+3 −4 src/validation/convproc/ma_convproc_dp_intr.cpp
+3 −4 src/validation/convproc/ma_convproc_tend.cpp
+6 −6 src/validation/convproc/ma_precpevap_convproc.cpp
+10 −10 src/validation/convproc/ma_precpprod.cpp
+7 −7 src/validation/convproc/ma_resuspend_convproc.cpp
+22 −22 src/validation/convproc/update_qnew_ptend.cpp
+12 −13 src/validation/convproc/update_tendency_final.cpp
+65 −11 src/validation/drydep/CMakeLists.txt
+200 −0 src/validation/drydep/aero_model_drydep.cpp
+8 −2 src/validation/drydep/air_dynamic_viscosity.cpp
+8 −2 src/validation/drydep/air_kinematic_viscosity.cpp
+61 −0 src/validation/drydep/calcram.cpp
+240 −0 src/validation/drydep/compute_tendencies.cpp
+24 −11 src/validation/drydep/drydep_driver.cpp
+10 −4 src/validation/drydep/gravit_settling_velocity.cpp
+88 −0 src/validation/drydep/modal_aero_depvel_part.cpp
+75 −0 src/validation/drydep/modal_aero_gravit_settling_velocity.cpp
+82 −0 src/validation/drydep/modal_aero_turb_drydep_velocity.cpp
+9 −4 src/validation/drydep/radius_for_moment.cpp
+9 −4 src/validation/drydep/schmidt_number.cpp
+9 −4 src/validation/drydep/slip_correction_factor.cpp
+3 −2 src/validation/hetfrz/hetfrz_rates_1box.cpp
+1 −1 src/validation/mam_x_validation
+64 −0 src/validation/mo_sethet/CMakeLists.txt
+32 −0 src/validation/mo_sethet/calc_het_rates.cpp
+57 −0 src/validation/mo_sethet/calc_precip_rescale.cpp
+45 −0 src/validation/mo_sethet/find_ktop.cpp
+69 −0 src/validation/mo_sethet/gas_washout.cpp
+77 −0 src/validation/mo_sethet/sethet_driver.cpp
+59 −0 src/validation/mo_setinv/CMakeLists.txt
+71 −0 src/validation/mo_setinv/mo_setinv_driver.cpp
+106 −0 src/validation/mo_setinv/setinv_test_nlev.cpp
+57 −0 src/validation/mo_setinv/setinv_test_single_level.cpp
+3 −3 src/validation/ndrop/ccncalc.cpp
+6 −7 src/validation/ndrop/dropmixnuc.cpp
+3 −3 src/validation/ndrop/get_activate_frac.cpp
+26 −0 src/validation/validation.cpp
+15 −2 src/validation/validation.hpp
+2 −2 src/validation/water_uptake/modal_aero_water_uptake_dr_col.cpp
+15 −13 src/validation/wetdep/compute_tendencies.cpp

0 comments on commit c2ad201

Please sign in to comment.