Skip to content

Commit

Permalink
Changes due to code review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
overfelt committed Jul 29, 2024
1 parent c75615f commit 1f77bf0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void MAMWetscav::set_grids(
// The units of mixing ratio Q are technically non-dimensional.
// Nevertheless, for output reasons, we like to see 'kg/kg'.
auto q_unit = kg / kg;
auto dqdt_unit = kg / kg / s;
auto n_unit = 1 / kg; // units of number mixing ratios of tracers

m_grid = grids_manager->get_grid("Physics");
Expand Down Expand Up @@ -206,7 +205,7 @@ void MAMWetscav::set_grids(
// -------------------------------------------------------------
// These variables are "Computed" or outputs for the process
// -------------------------------------------------------------
static constexpr auto m3 = m2 * m;
static constexpr auto m3 = m * m * m;

// Aerosol dry particle diameter [m]
add_field<Computed>("dgncur_a", scalar3d_mid_nmodes, m, grid_name);
Expand Down Expand Up @@ -357,6 +356,44 @@ void MAMWetscav::initialize_impl(const RunType run_type) {
const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len();
work_ = view_2d("work", ncol_, work_len);

// TODO: Following variables are from convective parameterization (not
// implemented yet in EAMxx), so should be zero for now

sh_frac_ = view_2d("sh_frac", ncol_, nlev_);
Kokkos::deep_copy(sh_frac_, 0);

// Deep convective cloud fraction [fraction]
dp_frac_ = view_2d("dp_frac", ncol_, nlev_);
Kokkos::deep_copy(dp_frac_, 0);

// Evaporation rate of shallow convective precipitation >=0. [kg/kg/s]
evapcsh_ = view_2d("evapcsh", ncol_, nlev_);
Kokkos::deep_copy(evapcsh_, 0);

// Evaporation rate of deep convective precipitation >=0. [kg/kg/s]
evapcdp_ = view_2d("evapcdp", ncol_, nlev_);
Kokkos::deep_copy(evapcdp_, 0);

// Rain production, shallow convection [kg/kg/s]
rprdsh_ = view_2d("rprdsh", ncol_, nlev_);
Kokkos::deep_copy(rprdsh_, 0);

// Rain production, deep convection [kg/kg/s]
rprddp_ = view_2d("rprddp", ncol_, nlev_);
Kokkos::deep_copy(rprddp_, 0);

// In cloud water mixing ratio, deep convection
icwmrdp_ = view_2d("icwmrdp", ncol_, nlev_);
Kokkos::deep_copy(icwmrdp_, 0);

// In cloud water mixing ratio, shallow convection
icwmrsh_ = view_2d("icwmrsh", ncol_, nlev_);
Kokkos::deep_copy(icwmrsh_, 0);

// Detraining cld H20 from deep convection [kg/kg/s]
dlf_ = view_2d("dlf", ncol_, nlev_);
Kokkos::deep_copy(dlf_, 0);

//---------------------------------------------------------------------------------
// Setup preprocessing and post processing
//---------------------------------------------------------------------------------
Expand Down Expand Up @@ -394,40 +431,31 @@ void MAMWetscav::run_impl(const double dt) {
// TODO: Following variables are from convective parameterization (not
// implemented yet in EAMxx), so should be zero for now

auto sh_frac = view_2d("sh_frac", ncol_, nlev_);
Kokkos::deep_copy(sh_frac, 0);
auto sh_frac = sh_frac_;

// Deep convective cloud fraction [fraction]
auto dp_frac = view_2d("dp_frac", ncol_, nlev_);
Kokkos::deep_copy(dp_frac, 0);
auto dp_frac = dp_frac_;

// Evaporation rate of shallow convective precipitation >=0. [kg/kg/s]
auto evapcsh = view_2d("evapcsh", ncol_, nlev_);
Kokkos::deep_copy(evapcsh, 0);
auto evapcsh = evapcsh_;

// Evaporation rate of deep convective precipitation >=0. [kg/kg/s]
auto evapcdp = view_2d("evapcdp", ncol_, nlev_);
Kokkos::deep_copy(evapcdp, 0);
auto evapcdp = evapcdp_;

// Rain production, shallow convection [kg/kg/s]
auto rprdsh = view_2d("rprdsh", ncol_, nlev_);
Kokkos::deep_copy(rprdsh, 0);
auto rprdsh = rprdsh_;

// Rain production, deep convection [kg/kg/s]
auto rprddp = view_2d("rprddp", ncol_, nlev_);
Kokkos::deep_copy(rprddp, 0);
auto rprddp = rprddp_;

// In cloud water mixing ratio, deep convection
auto icwmrdp = view_2d("icwmrdp", ncol_, nlev_);
Kokkos::deep_copy(icwmrdp, 0);
auto icwmrdp = icwmrdp_;

// In cloud water mixing ratio, shallow convection
auto icwmrsh = view_2d("icwmrsh", ncol_, nlev_);
Kokkos::deep_copy(icwmrsh, 0);
auto icwmrsh = icwmrsh_;

// Detraining cld H20 from deep convection [kg/kg/s]
auto dlf = view_2d("dlf", ncol_, nlev_);
Kokkos::deep_copy(dlf, 0);
auto dlf = dlf_;

//----------- Variables from macrophysics scheme -------------
// Total cloud fraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class MAMWetscav : public scream::AtmosphereProcess {
MAMWetscav(const ekat::Comm &comm, const ekat::ParameterList &params);

// 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 "mam4_wetscav"; }
std::string name() const override { return "mam4_wetscav"; }

// Set the grid and input output variables
void set_grids(
Expand All @@ -52,7 +52,7 @@ class MAMWetscav : public scream::AtmosphereProcess {
// management of common atm process memory
// ON HOST, returns the number of bytes of device memory needed by the above
// Buffer type given the number of columns and vertical levels
size_t requested_buffer_size_in_bytes() const {
size_t requested_buffer_size_in_bytes() const override {
return mam_coupling::buffer_size(ncol_, nlev_);
}
void init_buffers(const ATMBufferManager &buffer_manager) override;
Expand All @@ -64,7 +64,7 @@ class MAMWetscav : 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 @@ -168,6 +168,34 @@ class MAMWetscav : public scream::AtmosphereProcess {
// Work arrays
view_2d work_;

// TODO: Following variables are from convective parameterization (not
// implemented yet in EAMxx), so should be zero for now

view_2d sh_frac_;

// Deep convective cloud fraction [fraction]
view_2d dp_frac_;

// Evaporation rate of shallow convective precipitation >=0. [kg/kg/s]
view_2d evapcsh_;

view_2d evapcdp_;

// Rain production, shallow convection [kg/kg/s]
view_2d rprdsh_;

// Rain production, deep convection [kg/kg/s]
view_2d rprddp_;

// In cloud water mixing ratio, deep convection
view_2d icwmrdp_;

// In cloud water mixing ratio, shallow convection
view_2d icwmrsh_;

// Detraining cld H20 from deep convection [kg/kg/s]
view_2d dlf_;

// Aerosol states
mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_;

Expand Down

0 comments on commit 1f77bf0

Please sign in to comment.