From 636c7654d2fab21b3a7f19eede1a1f9106ff81b7 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 11 Mar 2024 08:52:57 -0600 Subject: [PATCH 01/71] wet_scav - get code from balwinder branch. --- .../eamxx/src/physics/mam/CMakeLists.txt | 3 +- .../eamxx_mam_wetscav_process_interface.cpp | 874 ++++++++++++++++++ .../eamxx_mam_wetscav_process_interface.hpp | 210 +++++ .../uncoupled/mam4_wet_scav/CMakeLists.txt | 30 + .../tests/uncoupled/mam4_wet_scav/input.yaml | 68 ++ .../mam4_wet_scav/mam4_wetscav_standalone.cpp | 69 ++ .../tests/uncoupled/mam4_wet_scav/output.yaml | 14 + 7 files changed, 1267 insertions(+), 1 deletion(-) create mode 100644 components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp create mode 100644 components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp create mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt create mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml create mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp create mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/output.yaml diff --git a/components/eamxx/src/physics/mam/CMakeLists.txt b/components/eamxx/src/physics/mam/CMakeLists.txt index 40f43cbf3a7..dd8cf6e6b30 100644 --- a/components/eamxx/src/physics/mam/CMakeLists.txt +++ b/components/eamxx/src/physics/mam/CMakeLists.txt @@ -43,7 +43,8 @@ add_subdirectory(${EXTERNALS_SOURCE_DIR}/mam4xx ${CMAKE_BINARY_DIR}/externals/ma add_library(mam eamxx_mam_microphysics_process_interface.cpp eamxx_mam_optics_process_interface.cpp - eamxx_mam_aci_process_interface.cpp) + eamxx_mam_aci_process_interface.cpp + eamxx_mam_microphysics_process_interface.cpp) target_compile_definitions(mam PUBLIC EAMXX_HAS_MAM) add_dependencies(mam mam4xx) target_include_directories(mam PUBLIC diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp new file mode 100644 index 00000000000..7229419b378 --- /dev/null +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -0,0 +1,874 @@ +#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" + +// NOTE: see the impl/ directory for the contents of the impl namespace +#include "impl/compute_particle_size.cpp" + +// Remove the following<<<< +#include +#include +//>>>>>>> + +/* +Future work: +Wirte comments +write in/outs for all variables clearly + + +*/ + +namespace scream { + +// ========================================================================================= +MAMWetscav::MAMWetscav(const ekat::Comm &comm, + const ekat::ParameterList ¶ms) + : AtmosphereProcess(comm, params) { + /* Anything that can be initialized without grid information can be + * initialized here. Like universal constants, mam wetscav options. + */ +} + +// ========================================================================================= +void MAMWetscav::set_grids( + const std::shared_ptr grids_manager) { + using namespace ekat::units; + + // 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; + q_unit.set_string("kg/kg"); + + auto n_unit = 1 / kg; // units of number mixing ratios of tracers + n_unit.set_string("#/kg"); + + m_grid = grids_manager->get_grid("Physics"); + const auto &grid_name = m_grid->name(); + + ncol_ = m_grid->get_num_local_dofs(); // Number of columns on this rank + nlev_ = m_grid->get_num_vertical_levels(); // Number of levels per column + + // Define the different field layouts that will be used for this process + using namespace ShortFieldTagsNames; + + // Layout for 3D (2d horiz X 1d vertical) variable defined at mid-level and + // interfaces + const FieldLayout scalar3d_layout_mid{{COL, LEV}, {ncol_, nlev_}}; + + // Layout for 2D (2d horiz) variable defined at mid-level and + // interfaces + const FieldLayout scalar2d_layout_mid{{COL}, {ncol_}}; + + // ------------------------------------------------------------------------------------------------------------------------- + // These variables are "required" or pure inputs for the process + // ------------------------------------------------------------------------------------------------------------------------- + add_field("T_mid", scalar3d_layout_mid, K, + grid_name); // temperature [K] + add_field("p_mid", scalar3d_layout_mid, Pa, + grid_name); // pressure at mid points in [Pa + add_field("pseudo_density", scalar3d_layout_mid, Pa, + grid_name); // pseudo density in [Pa] + add_field("qc", scalar3d_layout_mid, q_unit, grid_name, + "tracers"); // liquid cloud water [kg/kg] wet + add_field("qi", scalar3d_layout_mid, q_unit, grid_name, + "tracers"); // ice cloud water [kg/kg] wet + + // -- Input variables that exists in PBUF in EAM + static constexpr auto nondim = + Units::nondimensional(); // for variables that are fractions etc. + + // MUST FIXME: cldt and cldn are the same variables. They must be their + // previous step values. + add_field("cldn_prev_step", scalar3d_layout_mid, nondim, + grid_name); // layer cloud fraction [fraction] + add_field("cldst", scalar3d_layout_mid, nondim, + grid_name); //?? + add_field("rprdsh", scalar3d_layout_mid, kg / kg / s, + grid_name); // rain production, shallow convection + // [kg/kg/s] //NOT updated + add_field( + "rprddp", scalar3d_layout_mid, kg / kg / s, + grid_name); // rain production, deep convection [kg/kg/s] //NOT updated + add_field("evapcsh", scalar3d_layout_mid, kg / kg / s, + grid_name); // Evaporation rate of shallow convective + // //NOT updated precipitation >=0. [kg/kg/s] + add_field("evapcdp", scalar3d_layout_mid, kg / kg / s, + grid_name); // Evaporation rate of deep convective //NOT + // updated precipitation >=0. [kg/kg/s] + + // -- Input variables that exists in PBUF in EAM (in wetdep.F90) in the + // "inputs" data structure + // MUST FIXME: cldt and cldn are the same variables. They must be their + // previous step values. + add_field("cldt_prev_step", scalar3d_layout_mid, nondim, + grid_name); // total cloud fraction [fraction] + add_field( + "qme", scalar3d_layout_mid, kg / kg / s, + grid_name); // net condensation/evaporation of cloud water [kg/kg/s] + add_field("prain", scalar3d_layout_mid, kg / kg / s, + grid_name); // stratiform rain production rate [kg/kg/s] + add_field( + "evapr", scalar3d_layout_mid, kg / kg / s, + grid_name); // evaporation from stratiform rain [kg/kg/s] //NOT updated + + // -- Input variables that exists in PBUF in EAM (in wetdep.F90) + add_field("icwmrdp", scalar3d_layout_mid, kg / kg, + grid_name); // In cloud water mixing ratio, deep + // convection [kg/kg] //NOT updated + add_field("icwmrsh", scalar3d_layout_mid, kg / kg, + grid_name); // In cloud water mixing ratio, shallow + // convection [kg/kg] //NOT updated + add_field("rprddp", scalar3d_layout_mid, kg / kg / s, + grid_name); // Rain production, deep convection [kg/kg/s] + add_field( + "sh_frac", scalar3d_layout_mid, nondim, + grid_name); // Shallow convective cloud fraction [fraction] //NOT updated + add_field( + "dp_frac", scalar3d_layout_mid, nondim, + grid_name); // Deep convective cloud fraction [fraction] //NOT updated + add_field( + "icwmrsh", scalar3d_layout_mid, nondim, + grid_name); + add_field( + "icwmrdp", scalar3d_layout_mid, nondim, + grid_name); + add_field("evapcsh", scalar3d_layout_mid, kg / kg / s, + grid_name); // Evaporation rate of shallow convective + // precipitation >=0. [kg/kg/s] + add_field("evapcdp", scalar3d_layout_mid, kg / kg / s, + grid_name); // Evaporation rate of deep convective + // precipitation >=0. [kg/kg/s] + + // ------------------------------------------------------------------------------------------------------------------------- + // These variables are "updated" or inputs/outputs for the process + // ------------------------------------------------------------------------------------------------------------------------- + + // -- surface fluxes (input/outpts) for the coupler's cam_out data struture + // for the land model + static constexpr auto m2 = m * m; + add_field( + "bcphiwet", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of hydrophilic black carbon [kg/m2/s] + add_field( + "bcphidry", scalar3d_layout_mid, kg / m2 / s, + grid_name); // dry deposition of hydrophilic black carbon [kg/m2/s] + add_field( + "ocphiwet", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of hydrophilic organic carbon [kg/m2/s] + add_field( + "ocphidry", scalar3d_layout_mid, kg / m2 / s, + grid_name); // dry deposition of hydrophilic organic carbon [kg/m2/s] + + add_field("dstwet1", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of dust (bin1) [kg/m2/s] + add_field("dstwet2", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of dust (bin2) [kg/m2/s] + add_field("dstwet3", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of dust (bin3) [kg/m2/s] + add_field("dstwet4", scalar3d_layout_mid, kg / m2 / s, + grid_name); // wet deposition of dust (bin4) [kg/m2/s] + + // -- input/ouputs from PBUF for updating particle size and water uptake by + // particles + static constexpr auto m3 = m2 * m; + add_field("dgncur_a", scalar3d_layout_mid, m, + grid_name); // aerosol particle diameter [m] + add_field("wetdens", scalar3d_layout_mid, kg / m3, + grid_name); // wet aerosol density [kg/m3] + add_field("qaerwat", scalar3d_layout_mid, kg / kg, + grid_name); // aerosol water [kg/kg] + add_field("dgnumwet", scalar3d_layout_mid, m, + grid_name); // wet aerosol diameter [m] + add_field("fracis", scalar3d_layout_mid, nondim, + grid_name); // fraction of transported species that are + // insoluble [fraction] + + // -- interstitial and cloudborne aerosol tracers of interest: mass (q) and + // number (n) mixing ratios + // -- NOTE: Interstitial aerosols are updated in the interface using the + // "tendencies" from the wetscavenging process + for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { + // interstitial aerosol tracers of interest: number (n) mixing ratios + const char *int_nmr_field_name = + mam_coupling::int_aero_nmr_field_name(imode); + add_field(int_nmr_field_name, scalar3d_layout_mid, n_unit, + grid_name, "tracers"); + + // cloudborne aerosol tracers of interest: number (n) mixing ratios + const char *cld_nmr_field_name = + mam_coupling::cld_aero_nmr_field_name(imode); + + // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are + // NOT advected + add_field(cld_nmr_field_name, scalar3d_layout_mid, n_unit, + grid_name); + + for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { + // (interstitial) aerosol tracers of interest: mass (q) mixing ratios + const char *int_mmr_field_name = + mam_coupling::int_aero_mmr_field_name(imode, ispec); + if(strlen(int_mmr_field_name) > 0) { + add_field(int_mmr_field_name, scalar3d_layout_mid, q_unit, + grid_name, "tracers"); + } + + // (cloudborne) aerosol tracers of interest: mass (q) mixing ratios + const char *cld_mmr_field_name = + mam_coupling::cld_aero_mmr_field_name(imode, ispec); + if(strlen(cld_mmr_field_name) > 0) { + // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these + // are NOT advected + add_field(cld_mmr_field_name, scalar3d_layout_mid, q_unit, + grid_name); + } + } + } + + // Tracers group -- do we need this in addition to the tracers above? In any + // case, this call should be idempotent, so it can't hurt. + add_group("tracers", grid_name, 1, Bundling::Required); + + // The following fields are not needed by this process but we define them so + // that we can create MAM4xx class objects like atmosphere, prognostics etc. + + // aerosol-related gases: mass mixing ratios + for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { + const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g); + add_field(gas_mmr_field_name, scalar3d_layout_mid, q_unit, + grid_name, "tracers"); + } + + add_field("cldfrac_tot", scalar3d_layout_mid, nondim, + grid_name); // Cloud fraction + add_field("pbl_height", scalar2d_layout_mid, m, + grid_name); // PBL height + + static constexpr auto s2 = s * s; + add_field("phis", scalar2d_layout_mid, m2 / s2, + grid_name); // surface geopotential + add_field("qv", scalar3d_layout_mid, q_unit, + grid_name); // specific humidity + add_field("nc", scalar3d_layout_mid, n_unit, + grid_name); // cloud water number conc + add_field("ni", scalar3d_layout_mid, n_unit, + grid_name); // cloud ice number conc + add_field("omega", scalar3d_layout_mid, Pa / s, + grid_name); // vertical pressure velocity +} + +// ========================================================================================= +// 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 MAMWetscav::requested_buffer_size_in_bytes() const { + return mam_coupling::buffer_size(ncol_, nlev_); +} + +// ========================================================================================= +// ON HOST, initializeŃ• the Buffer type with sufficient memory to store +// intermediate (dry) quantities on the given number of columns with the given +// number of vertical levels. Returns the number of bytes allocated. +void MAMWetscav::init_buffers(const ATMBufferManager &buffer_manager) { + EKAT_REQUIRE_MSG( + buffer_manager.allocated_bytes() >= requested_buffer_size_in_bytes(), + "Error! Insufficient buffer size.\n"); + + size_t used_mem = + mam_coupling::init_buffer(buffer_manager, ncol_, nlev_, buffer_); + EKAT_REQUIRE_MSG(used_mem == requested_buffer_size_in_bytes(), + "Error! Used memory != requested memory for MAMWetscav."); +} + +// ========================================================================================= +void MAMWetscav::initialize_impl(const RunType run_type) { + // Gather runtime options + //(e.g.) runtime_options.lambda_low = m_params.get("lambda_low"); + + // populate the wet atmosphere state with views from fields and + // the buffer (NOTE: wet atmosphere only has qv, qc, qi, nc, ni and omega) + wet_atm_.qc = get_field_in("qc").get_view(); + wet_atm_.qi = get_field_in("qi").get_view(); + + // -- Following wet atm variables are NOT used by the process but we still + // need them to + // -- create atmosphere object + wet_atm_.qv = get_field_in("qv").get_view(); + wet_atm_.nc = get_field_in("nc").get_view(); + wet_atm_.ni = get_field_in("ni").get_view(); + wet_atm_.omega = get_field_in("omega").get_view(); + + // populate the dry atmosphere state with views from fields + // (NOTE: dry atmosphere has everything that wet + // atmosphere has along with z_surf, T_mid, p_mid, z_mid, z_iface, + // dz, p_del, cldfrac, w_updraft, pblh, phis) + dry_atm_.T_mid = get_field_in("T_mid").get_view(); + dry_atm_.p_mid = get_field_in("p_mid").get_view(); + dry_atm_.p_del = get_field_in("pseudo_density").get_view(); + + // How "buffer_" works: We use buffer to allocate memory for the members of + // dry_atm_ object. Here we are providing those memory locations to the + // dry_atm_ members. These members are computed from the above wet_atm_ or + // dry_atm_ members that are explicitly getting their values either from the + // input file or from other processes. These members are null at this point, + // they are assigned in "Kokkos::parallel_for("preprocess", scan_policy, + // preprocess_);" call in the run_impl + + dry_atm_.qv = buffer_.qv_dry; + dry_atm_.qc = buffer_.qc_dry; + dry_atm_.nc = buffer_.nc_dry; + dry_atm_.qi = buffer_.qi_dry; + dry_atm_.ni = buffer_.ni_dry; + dry_atm_.z_mid = buffer_.z_mid; + dry_atm_.dz = buffer_.dz; + dry_atm_.z_iface = buffer_.z_iface; + dry_atm_.w_updraft = buffer_.w_updraft; + + // The following dry_atm_ members *may* not be used by the process but they + // are needed for creating MAM4xx class objects like Atmosphere + dry_atm_.cldfrac = get_field_in("cldfrac_tot").get_view(); + dry_atm_.pblh = get_field_in("pbl_height").get_view(); + dry_atm_.phis = get_field_in("phis").get_view(); + dry_atm_.z_surf = 0.0; // MUST FIXME: for now + // ---- set wet/dry aerosol-related gas state data + for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { + const char *mmr_field_name = mam_coupling::gas_mmr_field_name(g); + wet_aero_.gas_mmr[g] = get_field_out(mmr_field_name).get_view(); + dry_aero_.gas_mmr[g] = buffer_.dry_gas_mmr[g]; + } + + // Other required variables + cldn_prev_step_ = get_field_out("cldn_prev_step").get_view< Real **>(); + cldt_prev_step_ = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? + cldst_ = get_field_out("cldst").get_view< Real **>();//?? + evapr_ = get_field_out("evapr").get_view< Real **>(); + rprdsh_ = + get_field_out("rprdsh").get_view(); // rain production, shallow + // convection [kg/kg/s] + evapcsh_ = + get_field_out("evapcsh") + .get_view(); // Evaporation rate of shallow convective + // precipitation >=0. [kg/kg/s] + + sh_frac_ = get_field_out("sh_frac") + .get_view(); // Shallow convective cloud fraction [fraction] + + rprddp_ = + get_field_out("rprddp") + .get_view(); // rain production, deep convection [kg/kg/s] + + evapcdp_ = get_field_out("evapcdp") + .get_view(); // Evaporation rate of deep convective + // precipitation >=0. [kg/kg/s] + dp_frac_ = get_field_out("dp_frac") + .get_view(); // Deep convective cloud fraction [fraction] + + icwmrsh_ = get_field_out("icwmrsh") + .get_view(); // ?? + + icwmrdp_ = get_field_out("icwmrdp") + .get_view(); // ?? + + // set wet/dry aerosol state data (interstitial aerosols only) + for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { + const char *int_nmr_field_name = + mam_coupling::int_aero_nmr_field_name(imode); + wet_aero_.int_aero_nmr[imode] = + get_field_out(int_nmr_field_name).get_view(); + dry_aero_.int_aero_nmr[imode] = buffer_.dry_int_aero_nmr[imode]; + + const char *cld_nmr_field_name = + mam_coupling::cld_aero_nmr_field_name(imode); + wet_aero_.cld_aero_nmr[imode] = + get_field_out(cld_nmr_field_name).get_view(); + dry_aero_.cld_aero_nmr[imode] = wet_aero_.cld_aero_nmr[imode]; + + for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { + const char *int_mmr_field_name = + mam_coupling::int_aero_mmr_field_name(imode, ispec); + if(strlen(int_mmr_field_name) > 0) { + wet_aero_.int_aero_mmr[imode][ispec] = + get_field_out(int_mmr_field_name).get_view(); + dry_aero_.int_aero_mmr[imode][ispec] = + buffer_.dry_int_aero_mmr[imode][ispec]; + } + + const char *cld_mmr_field_name = + mam_coupling::cld_aero_mmr_field_name(imode, ispec); + if(strlen(cld_mmr_field_name) > 0) { + wet_aero_.cld_aero_mmr[imode][ispec] = + get_field_out(cld_mmr_field_name).get_view(); + dry_aero_.cld_aero_mmr[imode][ispec] = + buffer_.dry_cld_aero_mmr[imode][ispec]; + } + } + } + + // set up our preprocess/postprocess functors + // Here we initialize (not compute) objects in preprocess struct using the + // objects in the argument list + preprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, + dry_aero_); +} + +// ========================================================================================= +void MAMWetscav::run_impl(const double dt) { + const auto scan_policy = ekat::ExeSpaceUtils< + KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); + + // preprocess input -- needs a scan for the calculation of all variables + // needed by this process or setting up MAM4xx classes and their objects + Kokkos::parallel_for("preprocess", scan_policy, preprocess_); + Kokkos::fence(); + + /*Fortran code: + call modal_aero_calcsize_sub(state%ncol, state%lchnk, state%q, state%pdel, + dt, & !in qqcw, ptend, dgnumdry_m=dgncur_a) !inout + + ----subroutine modal_aero_calcsize_sub(ncol, lchnk, state_q, pdel, deltat, + qqcw, ptend, do_adjust_in, & do_aitacc_transfer_in, list_idx_in, + update_mmr_in, dgnumdry_m) */ + // mam4::CalcSizeProcess process_(aero_config_); //initiate MAM4xx calcsize + // process + + /* ---------------------------------------------------------------------------------------- + * Compute particle size using the calcsize process + * ---------------------------------------------------------------------------------------- + */ + + // -- configure the process + /* + * -- NOTES: 1. Flags for the inter-mode particle transfer + * (do_aitacc_transfer) and size adjustment (do_adjust) are TRUE by default + * a. Size adjustment is only done by changing aerosol + * numbers in the modes. + * 2. Interstitial and cld borne aerosols (i.e. "tends") mmr will + * be updated (update_mmr is TRUE by default) + */ + // MUST: FIXME: Make sure state is not updated...only tendencies should be + // updated!! + static constexpr int maxd_aspectype = mam4::ndrop::maxd_aspectype; + int nspec_amode[ntot_amode_]; + int lspectype_amode[maxd_aspectype][ntot_amode_]; + mam4::Real specdens_amode[maxd_aspectype]; + int lmassptr_amode[maxd_aspectype][ntot_amode_]; + Real spechygro[maxd_aspectype]; + + int numptr_amode[ntot_amode_]; + int mam_idx[ntot_amode_][mam4::ndrop::nspec_max]; + int mam_cnst_idx[ntot_amode_][mam4::ndrop::nspec_max]; + + mam4::ndrop::get_e3sm_parameters(nspec_amode, lspectype_amode, lmassptr_amode, + numptr_amode, specdens_amode, spechygro, + mam_idx, mam_cnst_idx); + + Real inv_density[ntot_amode_][mam4::AeroConfig::num_aerosol_ids()] = {}; + Real num2vol_ratio_min[ntot_amode_] = {}; + Real num2vol_ratio_max[ntot_amode_] = {}; + Real num2vol_ratio_max_nmodes[ntot_amode_] = {}; + Real num2vol_ratio_min_nmodes[ntot_amode_] = {}; + Real num2vol_ratio_nom_nmodes[ntot_amode_] = {}; + Real dgnmin_nmodes[ntot_amode_] = {}; + Real dgnmax_nmodes[ntot_amode_] = {}; + Real dgnnom_nmodes[ntot_amode_] = {}; + Real mean_std_dev_nmodes[ntot_amode_] = {}; + + bool noxf_acc2ait[mam4::AeroConfig::num_aerosol_ids()] = {}; + int n_common_species_ait_accum = {}; + int ait_spec_in_acc[mam4::AeroConfig::num_aerosol_ids()] = {}; + int acc_spec_in_ait[mam4::AeroConfig::num_aerosol_ids()] = {}; + mam4::modal_aero_calcsize::init_calcsize( + inv_density, num2vol_ratio_min, num2vol_ratio_max, + num2vol_ratio_max_nmodes, num2vol_ratio_min_nmodes, + num2vol_ratio_nom_nmodes, dgnmin_nmodes, dgnmax_nmodes, dgnnom_nmodes, + mean_std_dev_nmodes, noxf_acc2ait, n_common_species_ait_accum, + ait_spec_in_acc, acc_spec_in_ait); + + // diagnostics for visible band summed over modes + + // Note: Need to compute inv density using indexing from e3sm + for(int imode = 0; imode < ntot_amode_; ++imode) { + const int nspec = nspec_amode[imode]; + for(int isp = 0; isp < nspec; ++isp) { + const int idx = lspectype_amode[isp][imode] - 1; + inv_density[imode][isp] = 1.0 / specdens_amode[idx]; + } // isp + } // imode + + view_2d state_q( + "state_q", nlev_, + nvars_); // MUST FIXME: make it is 3d view to avoid race condition + view_2d qqcw("qqcw", nlev_, nvars_); + + + //create a const column view of zeros + view_1d zeros_nlev("zeros_nlev", nlev_); + Kokkos::deep_copy(zeros_nlev,0); + const_view_1d const_zeros_nlev(zeros_nlev); + + mam4::AeroConfig aero_config; + mam4::WetDeposition::Config wetdep_config;// = wetdep_.Config(); + wetdep_.init(aero_config,wetdep_config);//FIXME: Should we call this in the initialize???? + + + + const auto policy = + ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); + + // loop over atmosphere columns and compute aerosol particle size + Kokkos::parallel_for( + policy, KOKKOS_LAMBDA(const ThreadTeam &team) { + const int icol = team.league_rank(); // column index*/ + + Kokkos::parallel_for( + Kokkos::TeamThreadRange(team, 0, nlev_), [&](int klev) { + view_1d state_q_k = ekat::subview( + state_q, klev); // 1d view of size (nvars_) for storing all + // gasses and aerosols + mam_coupling::state_q_for_column_at_one_lev(dry_aero_, icol, klev, + state_q_k); + + view_1d qqcw_k = + ekat::subview(qqcw, klev); // 1d view of size (nvars_) for + // storing all gasses and aerosols + mam_coupling::qqcw_for_column_at_one_lev(dry_aero_, icol, klev, + qqcw_k); + + static constexpr bool do_adjust = true, do_aitacc_transfer = true, + update_mmr = true; + + Real dgncur_c_kk[ntot_amode_] = {}; + Real dgnumdry_m_kk[ntot_amode_] = {}; + // Calculate aerosol size distribution parameters and aerosol + // water + // uptake + mam4::modal_aero_calcsize::modal_aero_calcsize_sub( + state_q_k.data(), // in + qqcw_k.data(), // in/out + dt, do_adjust, do_aitacc_transfer, update_mmr, lmassptr_amode, + numptr_amode, + inv_density, // in + num2vol_ratio_min, num2vol_ratio_max, + num2vol_ratio_max_nmodes, num2vol_ratio_min_nmodes, + num2vol_ratio_nom_nmodes, dgnmin_nmodes, dgnmax_nmodes, + dgnnom_nmodes, mean_std_dev_nmodes, + // outputs + noxf_acc2ait, n_common_species_ait_accum, ait_spec_in_acc, + acc_spec_in_ait, dgnumdry_m_kk, dgncur_c_kk); + + Real dgnumwet_m_kk[ntot_amode_] = {}; + Real qaerwat_m_kk[ntot_amode_] = {}; + // std::cout< qqcw_get_field(pbuf,mm,lchnk) + qqcw_sav(1:ncol,:,lspec) = fldcw(1:ncol,:) !RCE 2012/01/12 + + ! FIXME: Not sure if this is a bug or not as qqcw_tmp seem + different ! from the previous call and qqcw_tmp is always zero. May need ! + further check. - Shuaiqi Tang in refactoring for MAM4xx call wetdepa_v2( & + ncol, dt, state%pdel, & ! in dep_inputs%cmfdqr, + dep_inputs%evapc, dlf, dep_inputs%conicw, & ! in dep_inputs%prain, + dep_inputs%evapr, dep_inputs%totcond, & ! in dep_inputs%cldt, + dep_inputs%cldcu, & ! in dep_inputs%cldvcu, + dep_inputs%cldvst, & ! in sol_factb, sol_facti, + sol_factic, & ! in mam_prevap_resusp_optcc, + .true., scavcoefnv(:,:,jnv), f_act_conv, & ! in fldcw, qqcw_tmp, & ! in + fracis_cw, dqdt_tmp, iscavt, & ! out icscavt, isscavt, + bcscavt, bsscavt, rcscavt, rsscavt ) ! out + + ! resuspension goes to coarse mode + call calc_resusp_to_coarse( ncol, mm, & ! in + mmtoo_prevap_resusp, .false., & ! in + rcscavt, rsscavt, & ! in + dqdt_tmp, rtscavt_sv ) ! inout + + fldcw(1:ncol,:) = fldcw(1:ncol,:) + dqdt_tmp(1:ncol,:) * dt + + call calc_sfc_flux(dqdt_tmp(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFWET', + sflx, pcols, lchnk) aerdepwetcw(:ncol,mm) = sflx(:ncol) + + call calc_sfc_flux(icscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSIC', + sflx, pcols, lchnk) + + call calc_sfc_flux(isscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSIS', + sflx, pcols, lchnk) + + call calc_sfc_flux(bcscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSBC', + sflx, pcols, lchnk) + + call calc_sfc_flux(bsscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSBS', + sflx, pcols, lchnk) + + call calc_sfc_flux(rcscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSEC', + sflx, pcols, lchnk) + + call calc_sfc_flux(rsscavt(:ncol,:), state%pdel(:ncol,:), + sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSES', + sflx, pcols, lchnk) + + endif lphase_jnmw_conditional + + enddo lspec_loop_aa ! lspec = 1, nspec_amode(m)+2 + enddo lphase_loop_aa ! lphase = 1, 2 + enddo mmode_loop_aa ! m = 1, ntot_amode + + ! if the user has specified prescribed aerosol dep fluxes then + ! do not set cam_out dep fluxes according to the prognostic aerosols + if (.not.aerodep_flx_prescribed()) then + call set_srf_wetdep(aerdepwetis, aerdepwetcw, cam_out) + endif + + call wetdep_inputs_unset(dep_inputs) + */ + std::cout << "End of wetscav run" << std::endl; +} + +// ========================================================================================= +} // namespace scream diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp new file mode 100644 index 00000000000..bec616e260a --- /dev/null +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -0,0 +1,210 @@ +#ifndef EAMXX_MAM_WETSCAV_HPP +#define EAMXX_MAM_WETSCAV_HPP + +// For MAM4 aerosol configuration +#include + +// For declaring wetscav class derived from atm process class +#include "share/atm_process/atmosphere_process.hpp" + +// For MAM4 processes +#include + +// For MAM4 calcsize process (FIXME:should we include it in mam4 or mam_coupling??) +#include + +// For wetdep processes +#include + +// For component name +#include + +#include + +namespace scream { + +/* + * The class responsible to handle the aerosol wetscavenging + * + * The AD should store exactly ONE instance of this class stored + * in its list of subcomponents (the AD should make sure of this). + * + */ + +class MAMWetscav : public scream::AtmosphereProcess { + + using KT = ekat::KokkosTypes; + using view_1d = typename KT::template view_1d; + using view_2d = typename KT::template view_2d; + + using const_view_2d = typename KT::template view_2d; + using const_view_1d = typename KT::template view_1d; // remove it if possible + + + // a thread team dispatched to a single vertical column + using ThreadTeam = mam4::ThreadTeam; + + public: + // Constructors + MAMWetscav(const ekat::Comm &comm, const ekat::ParameterList ¶ms); + + // The type of subcomponent + AtmosphereProcessType type() const { return AtmosphereProcessType::Physics; } + + // The name of the subcomponent + std::string name() const { return "mam_wetscavenging"; } + + // Set the grid and input output variables + void set_grids( + const std::shared_ptr grids_manager) override; + + // management of common atm process memory + size_t requested_buffer_size_in_bytes() const override; + void init_buffers(const ATMBufferManager &buffer_manager) override; + + // Initialize variables + void initialize_impl(const RunType run_type) override; + + // Run the process by one time step + void run_impl(const double dt) override; + + // Finalize + void finalize_impl(){/*Do nothing*/}; + + + // Atmosphere processes often have a pre-processing step that constructs + // required variables from the set of fields stored in the field manager. + // This functor implements this step, which is called during run_impl. + struct Preprocess { + Preprocess() = default; + + // on host: initializes preprocess functor with necessary state data + void initialize(const int ncol_in, const int nlev_in, + const mam_coupling::WetAtmosphere& wet_atm_in, + const mam_coupling::AerosolState& wet_aero_in, + const mam_coupling::DryAtmosphere& dry_atm_in, + const mam_coupling::AerosolState& dry_aero_in) { + ncol_pre_ = ncol_in; + nlev_pre_ = nlev_in; + wet_atm_pre_ = wet_atm_in; + wet_aero_pre_ = wet_aero_in; + dry_atm_pre_ = dry_atm_in; + dry_aero_pre_ = dry_aero_in; + } + + KOKKOS_INLINE_FUNCTION + void operator()(const Kokkos::TeamPolicy::member_type& team) const { + const int i = team.league_rank(); // column index + + compute_dry_mixing_ratios(team, wet_atm_pre_, dry_atm_pre_, i); + compute_vertical_layer_heights(team, dry_atm_pre_, i); + team.team_barrier(); // allows kernels below to use layer heights + compute_updraft_velocities(team, wet_atm_pre_, dry_atm_pre_, i); + team.team_barrier(); + } // operator() + + // number of horizontal columns and vertical levels + int ncol_pre_, nlev_pre_; + + // local atmospheric and aerosol state data + mam_coupling::WetAtmosphere wet_atm_pre_; + mam_coupling::DryAtmosphere dry_atm_pre_; + mam_coupling::AerosolState wet_aero_pre_, dry_aero_pre_; + + }; // MAMWetscav::Preprocess + + // Postprocessing functor + struct Postprocess { + Postprocess() = default; + + // on host: initializes postprocess functor with necessary state data + void initialize(const int ncol, const int nlev, + const mam_coupling::WetAtmosphere& wet_atm, + const mam_coupling::AerosolState& wet_aero, + const mam_coupling::DryAtmosphere& dry_atm, + const mam_coupling::AerosolState& dry_aero) { + ncol_post_ = ncol; + nlev_post_ = nlev; + wet_atm_post_ = wet_atm; + wet_aero_post_ = wet_aero; + dry_atm_post_ = dry_atm; + dry_aero_post_ = dry_aero; + } + + KOKKOS_INLINE_FUNCTION + void operator()(const Kokkos::TeamPolicy::member_type& team) const { + const int i = team.league_rank(); // column index + compute_wet_mixing_ratios(team, dry_atm_post_, dry_aero_post_, wet_aero_post_, i); + team.team_barrier(); + } // operator() + + // number of horizontal columns and vertical levels + int ncol_post_, nlev_post_; + + // local atmospheric and aerosol state data + mam_coupling::WetAtmosphere wet_atm_post_; + mam_coupling::DryAtmosphere dry_atm_post_; + mam_coupling::AerosolState wet_aero_post_, dry_aero_post_; + }; // MAMWetscav::Postprocess + + + /* ----------------------------------------------- + * Local variables + * ------------------------------------------------ + */ + + // pre- and postprocessing scratch pads (for wet <-> dry conversions) + Preprocess preprocess_; + Postprocess postprocess_; + + + // Number of horizontal columns and vertical levels + int ncol_, nlev_; + + //Number of aerosol modes + static constexpr int ntot_amode_ = mam4::AeroConfig::num_modes(); + + //Extent for the e3sm's state vector for tracers + //--NOTE: The aerosol species are from index 16 to 40 ( or 15 to 39 in C++) + // but we define this variable from 0 to nvars_, where nvars_ is 39. + // Index 0 to 14 has no value + static constexpr int nvars_ = mam4::ndrop::nvars; + + + // atmospheric variables + mam_coupling::WetAtmosphere wet_atm_; + mam_coupling::DryAtmosphere dry_atm_; + + view_2d cldn_prev_step_, cldt_prev_step_; // cloud fraction from the previous step, FIXME: they carry same info, we might remove one later + view_2d evapr_; + view_2d cldst_; + + view_2d rprdsh_; // rain production, shallow convection [kg/kg/s] + view_2d evapcsh_; + view_2d sh_frac_; + view_2d icwmrsh_; + + view_2d rprddp_; + view_2d evapcdp_; + view_2d dp_frac_; + view_2d icwmrdp_; + + + + // aerosol states + mam_coupling::AerosolState wet_aero_, dry_aero_; + + // workspace manager for internal local variables + //ekat::WorkspaceManager workspace_mgr_; + mam_coupling::Buffer buffer_; + + mam4::WetDeposition wetdep_; + + + + std::shared_ptr m_grid; +}; // class MAMWetscav + +} // namespace scream + +#endif // EAMXX_MAM_WETSCAV_HPP diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt b/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt new file mode 100644 index 00000000000..1db8448fd84 --- /dev/null +++ b/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt @@ -0,0 +1,30 @@ +include (ScreamUtils) + +# This test needs to be reworked for microphysics -- currently it's still using +# input for nucleation. + +# Create the test +CreateADUnitTest(mam4_wetscav_standalone + LABELS mam4_wetscav physics + LIBS mam + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} +) + +# Set AD configurable options +set (ATM_TIME_STEP 1) +SetVarDependingOnTestSize(NUM_STEPS 12 24 36) +set (RUN_T0 2021-10-12-45000) + +# ## Copy (and configure) yaml files needed by tests +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml + ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml + ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) + +# Ensure test input files are present in the data dir +set (TEST_INPUT_FILES + scream/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc +) +foreach (file IN ITEMS ${TEST_INPUT_FILES}) + GetInputFile(${file}) +endforeach() diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml b/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml new file mode 100644 index 00000000000..ce1c8d4eeef --- /dev/null +++ b/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml @@ -0,0 +1,68 @@ +%YAML 1.1 +--- +driver_options: + atmosphere_dag_verbosity_level: 5 + +time_stepping: + time_step: ${ATM_TIME_STEP} + run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX + number_of_steps: ${NUM_STEPS} + +atmosphere_processes: + atm_procs_list: [mam4_wetscav] + mam_wetscav: + number_of_subcycles: ${NUM_SUBCYCLES} + compute_tendencies: [all] + lambda_low: 0.001 + +grids_manager: + Type: Mesh Free + grids_names: [Physics] + Physics: + type: point_grid + number_of_global_columns: 218 + number_of_vertical_levels: 72 + +initial_conditions: + Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + cldn_prev_step: 0.5 + rprdsh: 1e-5 + rprddp: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + cldt_prev_step: 1e-5 + cldst: 1e-5 + qme: 1e-5 + prain: 1e-5 + evapr: 1e-5 + icwmrdp: 1e-5 + icwmrsh: 1e-5 + rprddp: 1e-5 + rprdsh: 1e-5 + sh_frac: 1e-5 + dp_frac: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + pbuf: 1e-5 # cloud-borne aerosols + dgncur_a: 1e-5 # aerosol particle diameter [m] + wetdens: 1e-5 # wet aerosol density [kg/m3] + qaerwat: 1e-5 # aerosol water [kg/kg] + dgnumwet: 1e-5 # wet aerosol diameter [m] + fracis: 1e-5 # fraction of transported species that are insoluble [fraction] + cldfrac_tot: 0.5 + pbl_height: 25.0 + phis : 0.1 + +# The parameters for I/O control +Scorpio: + output_yaml_files: ["output.yaml"] +... diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp b/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp new file mode 100644 index 00000000000..203b51681d0 --- /dev/null +++ b/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp @@ -0,0 +1,69 @@ +#include + +#include "control/atmosphere_driver.hpp" +#include "diagnostics/register_diagnostics.hpp" + +#include "physics/register_physics.hpp" +#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" + +#include "share/grid/mesh_free_grids_manager.hpp" +#include "share/atm_process/atmosphere_process.hpp" + +#include "ekat/ekat_parse_yaml_file.hpp" +#include "ekat/logging/ekat_logger.hpp" + +#include + +namespace scream { + +TEST_CASE("mam4_wetscav-stand-alone", "") { + using namespace scream; + using namespace scream::control; + + // Create a comm + ekat::Comm atm_comm (MPI_COMM_WORLD); + + // Load ad parameter list + std::string fname = "input.yaml"; + ekat::ParameterList ad_params("Atmosphere Driver"); + parse_yaml_file(fname,ad_params); + logger.debug("yaml parsed."); + + // Time stepping parameters + const auto& ts = ad_params.sublist("time_stepping"); + const auto dt = ts.get("time_step"); + const auto nsteps = ts.get("number_of_steps"); + const auto t0_str = ts.get("run_t0"); + const auto t0 = util::str_to_time_stamp(t0_str); + + logger.info("running MAMWetscav standalone test with dt = {} for {} steps.", dt, nsteps); + EKAT_ASSERT_MSG (dt>0, "Error! Time step must be positive.\n"); + + // Need to register products in the factory *before* we create any atm process or grids manager. + register_physics(); + register_mesh_free_grids_manager(); + register_diagnostics(); + logger.debug("products registered."); + + // Create the driver + AtmosphereDriver ad; + logger.debug("driver created."); + + // Init and run + ad.initialize(atm_comm,ad_params,t0); + logger.debug("driver initialized."); + + logger.info("Start time stepping loop ... [0%]"); + for (int i=0; i Date: Mon, 11 Mar 2024 09:31:06 -0600 Subject: [PATCH 02/71] wet_scav - update interface --- .../eamxx_mam_wetscav_process_interface.cpp | 7 +++++++ .../eamxx_mam_wetscav_process_interface.hpp | 21 +++++++++++++------ .../mam/impl/compute_particle_size.cpp | 9 ++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 components/eamxx/src/physics/mam/impl/compute_particle_size.cpp diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 7229419b378..6aebcd75f89 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -1,4 +1,6 @@ +#include #include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" +#include "scream_config.h" // for SCREAM_CIME_BUILD // NOTE: see the impl/ directory for the contents of the impl namespace #include "impl/compute_particle_size.cpp" @@ -27,6 +29,11 @@ MAMWetscav::MAMWetscav(const ekat::Comm &comm, */ } +AtmosphereProcessType MAMWetscav::type() const { + return AtmosphereProcessType::Physics; +} + +std::string MAMOptics::name() const { return "mam4_wet_scav"; } // ========================================================================================= void MAMWetscav::set_grids( const std::shared_ptr grids_manager) { diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index bec616e260a..8a03529b5e1 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -20,6 +20,13 @@ #include #include +#ifndef KOKKOS_ENABLE_CUDA +#define protected_except_cuda public +#define private_except_cuda public +#else +#define protected_except_cuda protected +#define private_except_cuda private +#endif namespace scream { @@ -49,10 +56,10 @@ class MAMWetscav : public scream::AtmosphereProcess { MAMWetscav(const ekat::Comm &comm, const ekat::ParameterList ¶ms); // The type of subcomponent - AtmosphereProcessType type() const { return AtmosphereProcessType::Physics; } - + AtmosphereProcessType + type() const override; // The name of the subcomponent - std::string name() const { return "mam_wetscavenging"; } + std::string name() const override; // Set the grid and input output variables void set_grids( @@ -95,12 +102,14 @@ class MAMWetscav : public scream::AtmosphereProcess { KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy::member_type& team) const { const int i = team.league_rank(); // column index - + // first, compute dry fields compute_dry_mixing_ratios(team, wet_atm_pre_, dry_atm_pre_, i); + compute_dry_mixing_ratios(team, wet_atm_pre_, wet_aero_pre_, dry_aero_pre_, i); + team.team_barrier(); + // second, we can use dry fields to compute dz, zmin, zint compute_vertical_layer_heights(team, dry_atm_pre_, i); - team.team_barrier(); // allows kernels below to use layer heights compute_updraft_velocities(team, wet_atm_pre_, dry_atm_pre_, i); - team.team_barrier(); + team.team_barrier(); // allows kernels below to use layer heights } // operator() // number of horizontal columns and vertical levels diff --git a/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp b/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp new file mode 100644 index 00000000000..06a4c4cb3be --- /dev/null +++ b/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp @@ -0,0 +1,9 @@ +namespace scream::impl { + +/*KOKKOS_INLINE_FUNCTION +void compute_particle_size(int icol, int nlev_, //in + view_1d& state_q, view_1d& qqcw) { + +}*/ + +} // namespace scream::impl From 912e0bc1db38448d7d2b751de7c55ce082d3c247 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 11 Mar 2024 11:54:44 -0600 Subject: [PATCH 03/71] wet_scav - using compute_calcsize_and_water_uptake_dr --- .../eamxx/src/physics/mam/CMakeLists.txt | 2 +- .../eamxx_mam_wetscav_process_interface.cpp | 91 +++++++++++++------ .../eamxx_mam_wetscav_process_interface.hpp | 17 ++-- .../eamxx/src/physics/register_physics.hpp | 2 + 4 files changed, 74 insertions(+), 38 deletions(-) diff --git a/components/eamxx/src/physics/mam/CMakeLists.txt b/components/eamxx/src/physics/mam/CMakeLists.txt index dd8cf6e6b30..3182e383794 100644 --- a/components/eamxx/src/physics/mam/CMakeLists.txt +++ b/components/eamxx/src/physics/mam/CMakeLists.txt @@ -44,7 +44,7 @@ add_library(mam eamxx_mam_microphysics_process_interface.cpp eamxx_mam_optics_process_interface.cpp eamxx_mam_aci_process_interface.cpp - eamxx_mam_microphysics_process_interface.cpp) + eamxx_mam_wetscav_process_interface.cpp) target_compile_definitions(mam PUBLIC EAMXX_HAS_MAM) add_dependencies(mam mam4xx) target_include_directories(mam PUBLIC diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 6aebcd75f89..c778070f448 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -33,7 +33,7 @@ AtmosphereProcessType MAMWetscav::type() const { return AtmosphereProcessType::Physics; } -std::string MAMOptics::name() const { return "mam4_wet_scav"; } +std::string MAMWetscav::name() const { return "mam4_wetscav"; } // ========================================================================================= void MAMWetscav::set_grids( const std::shared_ptr grids_manager) { @@ -371,7 +371,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { icwmrdp_ = get_field_out("icwmrdp") .get_view(); // ?? - + // set wet/dry aerosol state data (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { const char *int_nmr_field_name = @@ -418,7 +418,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { void MAMWetscav::run_impl(const double dt) { const auto scan_policy = ekat::ExeSpaceUtils< KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); - + printf("Working on wet_sav \n"); // preprocess input -- needs a scan for the calculation of all variables // needed by this process or setting up MAM4xx classes and their objects Kokkos::parallel_for("preprocess", scan_policy, preprocess_); @@ -450,6 +450,7 @@ void MAMWetscav::run_impl(const double dt) { */ // MUST: FIXME: Make sure state is not updated...only tendencies should be // updated!! +#if 0 static constexpr int maxd_aspectype = mam4::ndrop::maxd_aspectype; int nspec_amode[ntot_amode_]; int lspectype_amode[maxd_aspectype][ntot_amode_]; @@ -490,8 +491,8 @@ void MAMWetscav::run_impl(const double dt) { // diagnostics for visible band summed over modes // Note: Need to compute inv density using indexing from e3sm - for(int imode = 0; imode < ntot_amode_; ++imode) { - const int nspec = nspec_amode[imode]; + // for(int imode = 0; imode < ntot_amode_; ++imode) { + // const int nspec = nspec_amode[imode]; for(int isp = 0; isp < nspec; ++isp) { const int idx = lspectype_amode[isp][imode] - 1; inv_density[imode][isp] = 1.0 / specdens_amode[idx]; @@ -503,18 +504,19 @@ void MAMWetscav::run_impl(const double dt) { nvars_); // MUST FIXME: make it is 3d view to avoid race condition view_2d qqcw("qqcw", nlev_, nvars_); - - //create a const column view of zeros + //create a const column view of zeros view_1d zeros_nlev("zeros_nlev", nlev_); Kokkos::deep_copy(zeros_nlev,0); const_view_1d const_zeros_nlev(zeros_nlev); +#endif + constexpr int pcnst = mam4::aero_model::pcnst; + constexpr int ntot_amode = mam4::AeroConfig::num_modes(); + constexpr int maxd_aspectype= mam4::ndrop::maxd_aspectype; mam4::AeroConfig aero_config; mam4::WetDeposition::Config wetdep_config;// = wetdep_.Config(); wetdep_.init(aero_config,wetdep_config);//FIXME: Should we call this in the initialize???? - - const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); @@ -523,6 +525,51 @@ void MAMWetscav::run_impl(const double dt) { policy, KOKKOS_LAMBDA(const ThreadTeam &team) { const int icol = team.league_rank(); // column index*/ + // call wetdep for computing....add mod=re descriptive comment + // here? + auto atm = mam_coupling::atmosphere_for_column(dry_atm_, icol); + // set surface state data + const haero::Surface + sfc{}; // sfc object is NEVER used in wetdep process + + // fetch column-specific subviews into aerosol prognostics + mam4::Prognostics progs = + mam_coupling::interstitial_aerosols_for_column(dry_aero_, icol); + + // compute calcsize and + Kokkos::parallel_for( + Kokkos::TeamThreadRange(team, 0, nlev_), [&](int kk) { + + Real state_q[pcnst] = {}; + Real qqcw[pcnst] = {}; + + int nspec_amode[ntot_amode]; + int lspectype_amode[maxd_aspectype][ntot_amode]; + int lmassptr_amode[maxd_aspectype][ntot_amode]; + Real specdens_amode[maxd_aspectype]; + Real spechygro[maxd_aspectype]; + + mam4::utils::extract_stateq_from_prognostics(progs, atm, state_q, kk); + mam4::utils::extract_qqcw_from_prognostics(progs, qqcw, kk); + team.team_barrier(); + + Real mean_std_dev_nmodes[ntot_amode] = {}; + Real dgnumwet_m_kk[ntot_amode] = {}; + Real qaerwat_m_kk[ntot_amode] = {}; + + mam4::modal_aer_opt::compute_calcsize_and_water_uptake_dr( + dry_atm_.p_mid(icol, kk), dry_atm_.T_mid(icol, kk), + cldn_prev_step_(icol, kk), state_q, qqcw, dt, // in + nspec_amode, lspectype_amode, specdens_amode, lmassptr_amode, spechygro, + mean_std_dev_nmodes, dgnumwet_m_kk, qaerwat_m_kk); + + team.team_barrier(); + mam4::utils::inject_qqcw_to_prognostics(qqcw, progs, kk); + mam4::utils::inject_stateq_to_prognostics(state_q, progs, kk); + + }); // klev parallel_for loop + +#if 0 Kokkos::parallel_for( Kokkos::TeamThreadRange(team, 0, nlev_), [&](int klev) { view_1d state_q_k = ekat::subview( @@ -585,19 +632,7 @@ void MAMWetscav::run_impl(const double dt) { cldn_prev_step_(icol, klev), dgnumdry_m_kk, dgnumwet_m_kk, qaerwat_m_kk); }); // klev parallel_for loop - - // call wetdep for computing....add mod=re descriptive comment - // here? - - auto atm = mam_coupling::atmosphere_for_column(dry_atm_, icol); - - // set surface state data - const haero::Surface - sfc{}; // sfc object is NEVER used in wetdep process - - // fetch column-specific subviews into aerosol prognostics - mam4::Prognostics progs = - mam_coupling::interstitial_aerosols_for_column(dry_aero_, icol); +#endif // set up diagnostics mam4::Diagnostics diags(nlev_); @@ -606,18 +641,16 @@ void MAMWetscav::run_impl(const double dt) { diags.shallow_convective_precipitation_evaporation = ekat::subview(evapcsh_, icol); - diags.deep_convective_cloud_fraction = ekat::subview(dp_frac_, - icol); + icol); //std::cout<<"BALLI:"< grids_manager) override; - + // management of common atm process memory size_t requested_buffer_size_in_bytes() const override; void init_buffers(const ATMBufferManager &buffer_manager) override; @@ -111,7 +111,7 @@ class MAMWetscav : public scream::AtmosphereProcess { compute_updraft_velocities(team, wet_atm_pre_, dry_atm_pre_, i); team.team_barrier(); // allows kernels below to use layer heights } // operator() - + // number of horizontal columns and vertical levels int ncol_pre_, nlev_pre_; @@ -166,7 +166,7 @@ class MAMWetscav : public scream::AtmosphereProcess { Preprocess preprocess_; Postprocess postprocess_; - + // Number of horizontal columns and vertical levels int ncol_, nlev_; @@ -177,7 +177,8 @@ class MAMWetscav : public scream::AtmosphereProcess { //--NOTE: The aerosol species are from index 16 to 40 ( or 15 to 39 in C++) // but we define this variable from 0 to nvars_, where nvars_ is 39. // Index 0 to 14 has no value - static constexpr int nvars_ = mam4::ndrop::nvars; + // FIXME: do we need nvars_? + static constexpr int nvars_ = mam4::aero_model::pcnst; // atmospheric variables @@ -197,9 +198,9 @@ class MAMWetscav : public scream::AtmosphereProcess { view_2d evapcdp_; view_2d dp_frac_; view_2d icwmrdp_; - - + + // aerosol states mam_coupling::AerosolState wet_aero_, dry_aero_; @@ -209,8 +210,8 @@ class MAMWetscav : public scream::AtmosphereProcess { mam4::WetDeposition wetdep_; - - + + std::shared_ptr m_grid; }; // class MAMWetscav diff --git a/components/eamxx/src/physics/register_physics.hpp b/components/eamxx/src/physics/register_physics.hpp index 36afabf8de9..44becc2f3e6 100644 --- a/components/eamxx/src/physics/register_physics.hpp +++ b/components/eamxx/src/physics/register_physics.hpp @@ -27,6 +27,7 @@ #include "physics/mam/eamxx_mam_microphysics_process_interface.hpp" #include "physics/mam/eamxx_mam_optics_process_interface.hpp" #include "physics/mam/eamxx_mam_aci_process_interface.hpp" +#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" #endif #ifdef EAMXX_HAS_COSP #include "physics/cosp/eamxx_cosp.hpp" @@ -64,6 +65,7 @@ inline void register_physics () { proc_factory.register_product("mam4_micro",&create_atmosphere_process); proc_factory.register_product("mam4_optics",&create_atmosphere_process); proc_factory.register_product("mam4_aci",&create_atmosphere_process); + proc_factory.register_product("mam4_wetscav",&create_atmosphere_process); #endif #ifdef EAMXX_HAS_COSP proc_factory.register_product("Cosp",&create_atmosphere_process); From 68c9a9dc45ce2a3174bc94dc1b925021a1bab7f4 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 11 Mar 2024 11:57:33 -0600 Subject: [PATCH 04/71] wet_scav - delete old code. --- .../eamxx_mam_wetscav_process_interface.cpp | 128 +----------------- 1 file changed, 3 insertions(+), 125 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index c778070f448..d198a170646 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -418,6 +418,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { void MAMWetscav::run_impl(const double dt) { const auto scan_policy = ekat::ExeSpaceUtils< KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); + printf("Working on wet_sav \n"); // preprocess input -- needs a scan for the calculation of all variables // needed by this process or setting up MAM4xx classes and their objects @@ -450,65 +451,6 @@ void MAMWetscav::run_impl(const double dt) { */ // MUST: FIXME: Make sure state is not updated...only tendencies should be // updated!! -#if 0 - static constexpr int maxd_aspectype = mam4::ndrop::maxd_aspectype; - int nspec_amode[ntot_amode_]; - int lspectype_amode[maxd_aspectype][ntot_amode_]; - mam4::Real specdens_amode[maxd_aspectype]; - int lmassptr_amode[maxd_aspectype][ntot_amode_]; - Real spechygro[maxd_aspectype]; - - int numptr_amode[ntot_amode_]; - int mam_idx[ntot_amode_][mam4::ndrop::nspec_max]; - int mam_cnst_idx[ntot_amode_][mam4::ndrop::nspec_max]; - - mam4::ndrop::get_e3sm_parameters(nspec_amode, lspectype_amode, lmassptr_amode, - numptr_amode, specdens_amode, spechygro, - mam_idx, mam_cnst_idx); - - Real inv_density[ntot_amode_][mam4::AeroConfig::num_aerosol_ids()] = {}; - Real num2vol_ratio_min[ntot_amode_] = {}; - Real num2vol_ratio_max[ntot_amode_] = {}; - Real num2vol_ratio_max_nmodes[ntot_amode_] = {}; - Real num2vol_ratio_min_nmodes[ntot_amode_] = {}; - Real num2vol_ratio_nom_nmodes[ntot_amode_] = {}; - Real dgnmin_nmodes[ntot_amode_] = {}; - Real dgnmax_nmodes[ntot_amode_] = {}; - Real dgnnom_nmodes[ntot_amode_] = {}; - Real mean_std_dev_nmodes[ntot_amode_] = {}; - - bool noxf_acc2ait[mam4::AeroConfig::num_aerosol_ids()] = {}; - int n_common_species_ait_accum = {}; - int ait_spec_in_acc[mam4::AeroConfig::num_aerosol_ids()] = {}; - int acc_spec_in_ait[mam4::AeroConfig::num_aerosol_ids()] = {}; - mam4::modal_aero_calcsize::init_calcsize( - inv_density, num2vol_ratio_min, num2vol_ratio_max, - num2vol_ratio_max_nmodes, num2vol_ratio_min_nmodes, - num2vol_ratio_nom_nmodes, dgnmin_nmodes, dgnmax_nmodes, dgnnom_nmodes, - mean_std_dev_nmodes, noxf_acc2ait, n_common_species_ait_accum, - ait_spec_in_acc, acc_spec_in_ait); - - // diagnostics for visible band summed over modes - - // Note: Need to compute inv density using indexing from e3sm - // for(int imode = 0; imode < ntot_amode_; ++imode) { - // const int nspec = nspec_amode[imode]; - for(int isp = 0; isp < nspec; ++isp) { - const int idx = lspectype_amode[isp][imode] - 1; - inv_density[imode][isp] = 1.0 / specdens_amode[idx]; - } // isp - } // imode - - view_2d state_q( - "state_q", nlev_, - nvars_); // MUST FIXME: make it is 3d view to avoid race condition - view_2d qqcw("qqcw", nlev_, nvars_); - - //create a const column view of zeros - view_1d zeros_nlev("zeros_nlev", nlev_); - Kokkos::deep_copy(zeros_nlev,0); - const_view_1d const_zeros_nlev(zeros_nlev); -#endif constexpr int pcnst = mam4::aero_model::pcnst; constexpr int ntot_amode = mam4::AeroConfig::num_modes(); constexpr int maxd_aspectype= mam4::ndrop::maxd_aspectype; @@ -563,77 +505,13 @@ void MAMWetscav::run_impl(const double dt) { nspec_amode, lspectype_amode, specdens_amode, lmassptr_amode, spechygro, mean_std_dev_nmodes, dgnumwet_m_kk, qaerwat_m_kk); - team.team_barrier(); + mam4::utils::inject_qqcw_to_prognostics(qqcw, progs, kk); mam4::utils::inject_stateq_to_prognostics(state_q, progs, kk); }); // klev parallel_for loop -#if 0 - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, nlev_), [&](int klev) { - view_1d state_q_k = ekat::subview( - state_q, klev); // 1d view of size (nvars_) for storing all - // gasses and aerosols - mam_coupling::state_q_for_column_at_one_lev(dry_aero_, icol, klev, - state_q_k); - - view_1d qqcw_k = - ekat::subview(qqcw, klev); // 1d view of size (nvars_) for - // storing all gasses and aerosols - mam_coupling::qqcw_for_column_at_one_lev(dry_aero_, icol, klev, - qqcw_k); - - static constexpr bool do_adjust = true, do_aitacc_transfer = true, - update_mmr = true; - - Real dgncur_c_kk[ntot_amode_] = {}; - Real dgnumdry_m_kk[ntot_amode_] = {}; - // Calculate aerosol size distribution parameters and aerosol - // water - // uptake - mam4::modal_aero_calcsize::modal_aero_calcsize_sub( - state_q_k.data(), // in - qqcw_k.data(), // in/out - dt, do_adjust, do_aitacc_transfer, update_mmr, lmassptr_amode, - numptr_amode, - inv_density, // in - num2vol_ratio_min, num2vol_ratio_max, - num2vol_ratio_max_nmodes, num2vol_ratio_min_nmodes, - num2vol_ratio_nom_nmodes, dgnmin_nmodes, dgnmax_nmodes, - dgnnom_nmodes, mean_std_dev_nmodes, - // outputs - noxf_acc2ait, n_common_species_ait_accum, ait_spec_in_acc, - acc_spec_in_ait, dgnumdry_m_kk, dgncur_c_kk); - - Real dgnumwet_m_kk[ntot_amode_] = {}; - Real qaerwat_m_kk[ntot_amode_] = {}; - // std::cout< Date: Mon, 11 Mar 2024 14:34:53 -0600 Subject: [PATCH 05/71] wet_scav - remove private member of parallel_for --- .../eamxx_mam_wetscav_process_interface.cpp | 56 +++++++++++++------ .../uncoupled/mam4_wet_scav/CMakeLists.txt | 2 +- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index d198a170646..cb4ef513093 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -412,6 +412,9 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // objects in the argument list preprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, dry_aero_); + + postprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, + dry_aero_); } // ========================================================================================= @@ -459,6 +462,23 @@ void MAMWetscav::run_impl(const double dt) { mam4::WetDeposition::Config wetdep_config;// = wetdep_.Config(); wetdep_.init(aero_config,wetdep_config);//FIXME: Should we call this in the initialize???? + // NOTE! we need a const mam_coupling::DryAtmosphere dry_atm for gpu access. + // We cannot use member of this class inside of the parallel_for + const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; + const auto &dry_aero = dry_aero_; + const auto &cldn_prev_step =cldn_prev_step_; + const auto &rprdsh = rprdsh_; + const auto &evapcsh = evapcsh_; + const auto &dp_frac=dp_frac_; + const auto &sh_frac=sh_frac_; + const auto &icwmrsh=icwmrsh_; + const auto &cldt_prev_step=cldt_prev_step_; + const auto &cldst=cldst_; + const auto &evapr=evapr_; + const auto &rprddp=rprddp_; + const auto &evapcdp=evapcdp_; + const auto &icwmrdp=icwmrdp_; + const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); @@ -469,14 +489,14 @@ void MAMWetscav::run_impl(const double dt) { // call wetdep for computing....add mod=re descriptive comment // here? - auto atm = mam_coupling::atmosphere_for_column(dry_atm_, icol); + auto atm = mam_coupling::atmosphere_for_column(dry_atm, icol); // set surface state data const haero::Surface sfc{}; // sfc object is NEVER used in wetdep process // fetch column-specific subviews into aerosol prognostics mam4::Prognostics progs = - mam_coupling::interstitial_aerosols_for_column(dry_aero_, icol); + mam_coupling::aerosols_for_column(dry_aero, icol); // compute calcsize and Kokkos::parallel_for( @@ -492,6 +512,7 @@ void MAMWetscav::run_impl(const double dt) { Real spechygro[maxd_aspectype]; mam4::utils::extract_stateq_from_prognostics(progs, atm, state_q, kk); + mam4::utils::extract_qqcw_from_prognostics(progs, qqcw, kk); team.team_barrier(); @@ -500,47 +521,48 @@ void MAMWetscav::run_impl(const double dt) { Real qaerwat_m_kk[ntot_amode] = {}; mam4::modal_aer_opt::compute_calcsize_and_water_uptake_dr( - dry_atm_.p_mid(icol, kk), dry_atm_.T_mid(icol, kk), - cldn_prev_step_(icol, kk), state_q, qqcw, dt, // in + dry_atm.p_mid(icol, kk), dry_atm.T_mid(icol, kk), + cldn_prev_step(icol, kk), state_q, qqcw, dt, // in nspec_amode, lspectype_amode, specdens_amode, lmassptr_amode, spechygro, mean_std_dev_nmodes, dgnumwet_m_kk, qaerwat_m_kk); - mam4::utils::inject_qqcw_to_prognostics(qqcw, progs, kk); mam4::utils::inject_stateq_to_prognostics(state_q, progs, kk); - }); // klev parallel_for loop team.team_barrier(); // set up diagnostics mam4::Diagnostics diags(nlev_); diags.shallow_convective_precipitation_production = - ekat::subview(rprdsh_, icol); + ekat::subview(rprdsh, icol); diags.shallow_convective_precipitation_evaporation = - ekat::subview(evapcsh_, icol); + ekat::subview(evapcsh, icol); + - diags.deep_convective_cloud_fraction = ekat::subview(dp_frac_, + diags.deep_convective_cloud_fraction = ekat::subview(dp_frac, icol); //std::cout<<"BALLI:"< Date: Mon, 11 Mar 2024 17:56:18 -0600 Subject: [PATCH 06/71] wet_scav - add dig variables. Unit tests is working. --- .../eamxx_mam_wetscav_process_interface.cpp | 111 ++++++++++++------ .../eamxx_mam_wetscav_process_interface.hpp | 10 +- 2 files changed, 84 insertions(+), 37 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index cb4ef513093..09a808b79b1 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -340,38 +340,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_aero_.gas_mmr[g] = buffer_.dry_gas_mmr[g]; } - // Other required variables - cldn_prev_step_ = get_field_out("cldn_prev_step").get_view< Real **>(); - cldt_prev_step_ = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? - cldst_ = get_field_out("cldst").get_view< Real **>();//?? - evapr_ = get_field_out("evapr").get_view< Real **>(); - rprdsh_ = - get_field_out("rprdsh").get_view(); // rain production, shallow - // convection [kg/kg/s] - evapcsh_ = - get_field_out("evapcsh") - .get_view(); // Evaporation rate of shallow convective - // precipitation >=0. [kg/kg/s] - - sh_frac_ = get_field_out("sh_frac") - .get_view(); // Shallow convective cloud fraction [fraction] - - rprddp_ = - get_field_out("rprddp") - .get_view(); // rain production, deep convection [kg/kg/s] - - evapcdp_ = get_field_out("evapcdp") - .get_view(); // Evaporation rate of deep convective - // precipitation >=0. [kg/kg/s] - dp_frac_ = get_field_out("dp_frac") - .get_view(); // Deep convective cloud fraction [fraction] - - icwmrsh_ = get_field_out("icwmrsh") - .get_view(); // ?? - - icwmrdp_ = get_field_out("icwmrdp") - .get_view(); // ?? - // set wet/dry aerosol state data (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { const char *int_nmr_field_name = @@ -407,6 +375,39 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } + // Other required variables + cldn_prev_step_ = get_field_out("cldn_prev_step").get_view< Real **>(); + cldt_prev_step_ = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? + cldst_ = get_field_out("cldst").get_view< Real **>();//?? + evapr_ = get_field_out("evapr").get_view< Real **>(); + rprdsh_ = + get_field_out("rprdsh").get_view(); // rain production, shallow + // convection [kg/kg/s] + evapcsh_ = + get_field_out("evapcsh") + .get_view(); // Evaporation rate of shallow convective + // precipitation >=0. [kg/kg/s] + + sh_frac_ = get_field_out("sh_frac") + .get_view(); // Shallow convective cloud fraction [fraction] + + rprddp_ = + get_field_out("rprddp") + .get_view(); // rain production, deep convection [kg/kg/s] + + evapcdp_ = get_field_out("evapcdp") + .get_view(); // Evaporation rate of deep convective + // precipitation >=0. [kg/kg/s] + dp_frac_ = get_field_out("dp_frac") + .get_view(); // Deep convective cloud fraction [fraction] + + icwmrsh_ = get_field_out("icwmrsh") + .get_view(); // ?? + + icwmrdp_ = get_field_out("icwmrdp") + .get_view(); // ?? + + // set up our preprocess/postprocess functors // Here we initialize (not compute) objects in preprocess struct using the // objects in the argument list @@ -415,6 +416,24 @@ void MAMWetscav::initialize_impl(const RunType run_type) { postprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, dry_aero_); + + // wetdep + constexpr int pcnst = mam4::aero_model::pcnst; + + tracer_mixing_ratio_work_ = view_3d("tracer_mixing_ratio_work_", ncol_, nlev_, pcnst); + d_tracer_mixing_ratio_dt_work_ = view_3d("d_tracer_mixing_ratio_dt_work_", ncol_, nlev_, pcnst); + + aerosol_wet_deposition_interstitial_work_ = view_2d("aerosol_wet_deposition_interstitial",ncol_, nlev_); + aerosol_wet_deposition_cloud_water_work_ = view_2d("aerosol_wet_deposition_cloud_water",ncol_, nlev_); + + for (int m = 0; m < mam_coupling::num_aero_modes(); m++) + { + wet_geometric_mean_diameter_i_work_[m] + = view_2d("wet_geometric_mean_diameter_i_work_1",ncol_, nlev_); + } + + total_convective_detrainment_work_= view_2d("total_convective_detrainment_work_",ncol_, nlev_); + } // ========================================================================================= @@ -455,7 +474,7 @@ void MAMWetscav::run_impl(const double dt) { // MUST: FIXME: Make sure state is not updated...only tendencies should be // updated!! constexpr int pcnst = mam4::aero_model::pcnst; - constexpr int ntot_amode = mam4::AeroConfig::num_modes(); + constexpr int ntot_amode = mam_coupling::num_aero_modes(); constexpr int maxd_aspectype= mam4::ndrop::maxd_aspectype; mam4::AeroConfig aero_config; @@ -478,7 +497,16 @@ void MAMWetscav::run_impl(const double dt) { const auto &rprddp=rprddp_; const auto &evapcdp=evapcdp_; const auto &icwmrdp=icwmrdp_; - + const auto &tracer_mixing_ratio_work=tracer_mixing_ratio_work_; + const auto &d_tracer_mixing_ratio_dt_work=d_tracer_mixing_ratio_dt_work_; + const auto &aerosol_wet_deposition_interstitial_work=aerosol_wet_deposition_interstitial_work_; + const auto &aerosol_wet_deposition_cloud_water_work=aerosol_wet_deposition_cloud_water_work_; + const auto &total_convective_detrainment_work=total_convective_detrainment_work_; + view_2d wet_geometric_mean_diameter_i_work[ntot_amode]; + for (int m = 0; m < ntot_amode; m++) + { + wet_geometric_mean_diameter_i_work[m] = wet_geometric_mean_diameter_i_work_[m]; + } const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); @@ -546,6 +574,7 @@ void MAMWetscav::run_impl(const double dt) { diags.shallow_convective_cloud_condensate = ekat::subview(icwmrsh_, icol); // FIXME: why are we setting deep_convective_cloud_fraction to zeros_nlev? // diags.deep_convective_cloud_fraction = zeros_nlev; + // FXIME: shallow_convective_cloud_fraction was previously set to dp_frac_icol. diags.shallow_convective_cloud_fraction = ekat::subview(cldt_prev_step, icol); diags.stratiform_cloud_fraction = ekat::subview(cldst, icol); diags.evaporation_of_falling_precipitation = ekat::subview(evapr, icol); @@ -556,7 +585,19 @@ void MAMWetscav::run_impl(const double dt) { ekat::subview(evapcdp, icol); diags.deep_convective_cloud_condensate = ekat::subview(icwmrdp, icol); - // setup tendencies + diags.tracer_mixing_ratio = ekat::subview(tracer_mixing_ratio_work, icol); + diags.d_tracer_mixing_ratio_dt = ekat::subview(d_tracer_mixing_ratio_dt_work, icol); + + diags.aerosol_wet_deposition_interstitial = ekat::subview(aerosol_wet_deposition_interstitial_work, icol); + diags.aerosol_wet_deposition_cloud_water = ekat::subview(aerosol_wet_deposition_cloud_water_work, icol); + + // FIXME where is dp computed? calcsize? + for (int m = 0; m < ntot_amode; m++) + { + diags.wet_geometric_mean_diameter_i[m] = ekat::subview(wet_geometric_mean_diameter_i_work[m], icol); + } + // // setup tendencies + diags.total_convective_detrainment = ekat::subview(total_convective_detrainment_work, icol); mam4::Tendencies tends{}; #if 1 wetdep_.compute_tendencies(aero_config, team, 0, dt, atm, sfc, diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index b6a1dc67a1c..e85a6c3f3c6 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -43,6 +43,7 @@ class MAMWetscav : public scream::AtmosphereProcess { using KT = ekat::KokkosTypes; using view_1d = typename KT::template view_1d; using view_2d = typename KT::template view_2d; + using view_3d = typename KT::template view_3d; using const_view_2d = typename KT::template view_2d; using const_view_1d = typename KT::template view_1d; // remove it if possible @@ -119,7 +120,6 @@ class MAMWetscav : public scream::AtmosphereProcess { mam_coupling::WetAtmosphere wet_atm_pre_; mam_coupling::DryAtmosphere dry_atm_pre_; mam_coupling::AerosolState wet_aero_pre_, dry_aero_pre_; - }; // MAMWetscav::Preprocess // Postprocessing functor @@ -199,7 +199,13 @@ class MAMWetscav : public scream::AtmosphereProcess { view_2d dp_frac_; view_2d icwmrdp_; - + // wet dep + view_3d tracer_mixing_ratio_work_; + view_3d d_tracer_mixing_ratio_dt_work_; + view_2d aerosol_wet_deposition_interstitial_work_; + view_2d aerosol_wet_deposition_cloud_water_work_; + view_2d wet_geometric_mean_diameter_i_work_[mam4::AeroConfig::num_modes()]; + view_2d total_convective_detrainment_work_; // aerosol states mam_coupling::AerosolState wet_aero_, dry_aero_; From 7d3cbff26cbe52e8c1a3f96c507f3443d31961cd Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Fri, 22 Mar 2024 14:10:37 -0600 Subject: [PATCH 07/71] wet_scav - update interface --- .../eamxx_mam_wetscav_process_interface.cpp | 260 +++++++----------- .../eamxx_mam_wetscav_process_interface.hpp | 39 +-- 2 files changed, 102 insertions(+), 197 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 09a808b79b1..48643fe084a 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -259,6 +259,19 @@ void MAMWetscav::set_grids( grid_name); // cloud ice number conc add_field("omega", scalar3d_layout_mid, Pa / s, grid_name); // vertical pressure velocity + + // FIXME: units + add_field("dlf", scalar3d_layout_mid, n_unit, + grid_name); // + add_field("dp_ccf", scalar3d_layout_mid, n_unit, + grid_name); // + add_field("sh_ccf", scalar3d_layout_mid, n_unit, + grid_name); // + // + add_field("aerdepwetis", scalar3d_layout_mid, n_unit, + grid_name); // + add_field("aerdepwetcw", scalar3d_layout_mid, n_unit, + grid_name); // } // ========================================================================================= @@ -374,40 +387,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } } - - // Other required variables - cldn_prev_step_ = get_field_out("cldn_prev_step").get_view< Real **>(); - cldt_prev_step_ = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? - cldst_ = get_field_out("cldst").get_view< Real **>();//?? - evapr_ = get_field_out("evapr").get_view< Real **>(); - rprdsh_ = - get_field_out("rprdsh").get_view(); // rain production, shallow - // convection [kg/kg/s] - evapcsh_ = - get_field_out("evapcsh") - .get_view(); // Evaporation rate of shallow convective - // precipitation >=0. [kg/kg/s] - - sh_frac_ = get_field_out("sh_frac") - .get_view(); // Shallow convective cloud fraction [fraction] - - rprddp_ = - get_field_out("rprddp") - .get_view(); // rain production, deep convection [kg/kg/s] - - evapcdp_ = get_field_out("evapcdp") - .get_view(); // Evaporation rate of deep convective - // precipitation >=0. [kg/kg/s] - dp_frac_ = get_field_out("dp_frac") - .get_view(); // Deep convective cloud fraction [fraction] - - icwmrsh_ = get_field_out("icwmrsh") - .get_view(); // ?? - - icwmrdp_ = get_field_out("icwmrdp") - .get_view(); // ?? - - // set up our preprocess/postprocess functors // Here we initialize (not compute) objects in preprocess struct using the // objects in the argument list @@ -419,21 +398,11 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // wetdep constexpr int pcnst = mam4::aero_model::pcnst; - - tracer_mixing_ratio_work_ = view_3d("tracer_mixing_ratio_work_", ncol_, nlev_, pcnst); - d_tracer_mixing_ratio_dt_work_ = view_3d("d_tracer_mixing_ratio_dt_work_", ncol_, nlev_, pcnst); - - aerosol_wet_deposition_interstitial_work_ = view_2d("aerosol_wet_deposition_interstitial",ncol_, nlev_); - aerosol_wet_deposition_cloud_water_work_ = view_2d("aerosol_wet_deposition_cloud_water",ncol_, nlev_); - - for (int m = 0; m < mam_coupling::num_aero_modes(); m++) - { - wet_geometric_mean_diameter_i_work_[m] - = view_2d("wet_geometric_mean_diameter_i_work_1",ncol_, nlev_); - } - - total_convective_detrainment_work_= view_2d("total_convective_detrainment_work_",ncol_, nlev_); - + // FIXME: qqcw_sav_ should be part of work_ + Kokkos::View + qqcw_sav_("qqcw_sav", mam4::nlev); + const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); + work_ = view_2d("work", ncol_, work_len); } // ========================================================================================= @@ -473,40 +442,43 @@ void MAMWetscav::run_impl(const double dt) { */ // MUST: FIXME: Make sure state is not updated...only tendencies should be // updated!! - constexpr int pcnst = mam4::aero_model::pcnst; - constexpr int ntot_amode = mam_coupling::num_aero_modes(); - constexpr int maxd_aspectype= mam4::ndrop::maxd_aspectype; - - mam4::AeroConfig aero_config; - mam4::WetDeposition::Config wetdep_config;// = wetdep_.Config(); - wetdep_.init(aero_config,wetdep_config);//FIXME: Should we call this in the initialize???? - // NOTE! we need a const mam_coupling::DryAtmosphere dry_atm for gpu access. // We cannot use member of this class inside of the parallel_for const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; - const auto &cldn_prev_step =cldn_prev_step_; - const auto &rprdsh = rprdsh_; - const auto &evapcsh = evapcsh_; - const auto &dp_frac=dp_frac_; - const auto &sh_frac=sh_frac_; - const auto &icwmrsh=icwmrsh_; - const auto &cldt_prev_step=cldt_prev_step_; - const auto &cldst=cldst_; - const auto &evapr=evapr_; - const auto &rprddp=rprddp_; - const auto &evapcdp=evapcdp_; - const auto &icwmrdp=icwmrdp_; - const auto &tracer_mixing_ratio_work=tracer_mixing_ratio_work_; - const auto &d_tracer_mixing_ratio_dt_work=d_tracer_mixing_ratio_dt_work_; - const auto &aerosol_wet_deposition_interstitial_work=aerosol_wet_deposition_interstitial_work_; - const auto &aerosol_wet_deposition_cloud_water_work=aerosol_wet_deposition_cloud_water_work_; - const auto &total_convective_detrainment_work=total_convective_detrainment_work_; - view_2d wet_geometric_mean_diameter_i_work[ntot_amode]; - for (int m = 0; m < ntot_amode; m++) - { - wet_geometric_mean_diameter_i_work[m] = wet_geometric_mean_diameter_i_work_[m]; - } + const auto &qqcw_sav = qqcw_sav_; + const auto &work = work_; + + // inputs + auto dlf = get_field_in("dlf").get_view(); + auto dp_ccf = get_field_in("dp_ccf").get_view(); + auto sh_ccf = get_field_in("sh_ccf").get_view(); + auto cldn_prev_step = get_field_out("cldn_prev_step").get_view< Real **>(); + // where is cldt_prev_step used? + auto cldt_prev_step = get_field_in("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? + auto cldst = get_field_in("cldst").get_view< Real **>();//?? + auto evapr = get_field_in("evapr").get_view< Real **>(); + auto rprdsh = get_field_in("rprdsh").get_view(); // rain production, shallow + // convection [kg/kg/s] + auto evapcsh = get_field_in("evapcsh").get_view(); // Evaporation rate of shallow convective + // precipitation >=0. [kg/kg/s] + auto sh_frac = get_field_in("sh_frac").get_view(); // Shallow convective cloud fraction [fraction] + auto rprddp = get_field_in("rprddp").get_view(); // rain production, deep convection [kg/kg/s] + auto evapcdp = get_field_in("evapcdp").get_view(); // Evaporation rate of deep convective + // precipitation >=0. [kg/kg/s] + auto dp_frac = get_field_in("dp_frac") + .get_view(); // Deep convective cloud fraction [fraction] + + auto icwmrsh = get_field_in("icwmrsh") + .get_view(); // ?? + + auto icwmrdp = get_field_in("icwmrdp") + .get_view(); // ?? + + // outputs + const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); + const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); + const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); @@ -515,95 +487,61 @@ void MAMWetscav::run_impl(const double dt) { policy, KOKKOS_LAMBDA(const ThreadTeam &team) { const int icol = team.league_rank(); // column index*/ - // call wetdep for computing....add mod=re descriptive comment - // here? auto atm = mam_coupling::atmosphere_for_column(dry_atm, icol); // set surface state data - const haero::Surface - sfc{}; // sfc object is NEVER used in wetdep process - // fetch column-specific subviews into aerosol prognostics mam4::Prognostics progs = mam_coupling::aerosols_for_column(dry_aero, icol); - - // compute calcsize and - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, nlev_), [&](int kk) { - - Real state_q[pcnst] = {}; - Real qqcw[pcnst] = {}; - - int nspec_amode[ntot_amode]; - int lspectype_amode[maxd_aspectype][ntot_amode]; - int lmassptr_amode[maxd_aspectype][ntot_amode]; - Real specdens_amode[maxd_aspectype]; - Real spechygro[maxd_aspectype]; - - mam4::utils::extract_stateq_from_prognostics(progs, atm, state_q, kk); - - mam4::utils::extract_qqcw_from_prognostics(progs, qqcw, kk); - team.team_barrier(); - - Real mean_std_dev_nmodes[ntot_amode] = {}; - Real dgnumwet_m_kk[ntot_amode] = {}; - Real qaerwat_m_kk[ntot_amode] = {}; - - mam4::modal_aer_opt::compute_calcsize_and_water_uptake_dr( - dry_atm.p_mid(icol, kk), dry_atm.T_mid(icol, kk), - cldn_prev_step(icol, kk), state_q, qqcw, dt, // in - nspec_amode, lspectype_amode, specdens_amode, lmassptr_amode, spechygro, - mean_std_dev_nmodes, dgnumwet_m_kk, qaerwat_m_kk); - - mam4::utils::inject_qqcw_to_prognostics(qqcw, progs, kk); - mam4::utils::inject_stateq_to_prognostics(state_q, progs, kk); - }); // klev parallel_for loop - - team.team_barrier(); - // set up diagnostics - mam4::Diagnostics diags(nlev_); - diags.shallow_convective_precipitation_production = - ekat::subview(rprdsh, icol); - diags.shallow_convective_precipitation_evaporation = - ekat::subview(evapcsh, icol); - - - diags.deep_convective_cloud_fraction = ekat::subview(dp_frac, - icol); - //std::cout<<"BALLI:"< + qqcw_sav_; // aerosol states mam_coupling::AerosolState wet_aero_, dry_aero_; - // workspace manager for internal local variables - //ekat::WorkspaceManager workspace_mgr_; mam_coupling::Buffer buffer_; - mam4::WetDeposition wetdep_; - - - std::shared_ptr m_grid; }; // class MAMWetscav From 8363b750b59881d56c981b8d6ac9297648c94050 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Tue, 26 Mar 2024 16:32:30 -0600 Subject: [PATCH 08/71] wet_scav - test is working in cpu/gpus. --- .../eamxx_mam_wetscav_process_interface.cpp | 51 +++++++++++-------- .../tests/uncoupled/mam4_wet_scav/input.yaml | 4 +- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 48643fe084a..60f352f06e3 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -261,11 +261,11 @@ void MAMWetscav::set_grids( grid_name); // vertical pressure velocity // FIXME: units - add_field("dlf", scalar3d_layout_mid, n_unit, + add_field("dlf", scalar3d_layout_mid, n_unit, grid_name); // - add_field("dp_ccf", scalar3d_layout_mid, n_unit, + add_field("dp_ccf", scalar3d_layout_mid, n_unit, grid_name); // - add_field("sh_ccf", scalar3d_layout_mid, n_unit, + add_field("sh_ccf", scalar3d_layout_mid, n_unit, grid_name); // // add_field("aerdepwetis", scalar3d_layout_mid, n_unit, @@ -399,8 +399,10 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // wetdep constexpr int pcnst = mam4::aero_model::pcnst; // FIXME: qqcw_sav_ should be part of work_ - Kokkos::View - qqcw_sav_("qqcw_sav", mam4::nlev); + // we need to add columns + qqcw_sav_ =Kokkos::View("qqcw_sav", mam4::nlev); + + const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); } @@ -449,30 +451,33 @@ void MAMWetscav::run_impl(const double dt) { const auto &qqcw_sav = qqcw_sav_; const auto &work = work_; - // inputs - auto dlf = get_field_in("dlf").get_view(); - auto dp_ccf = get_field_in("dp_ccf").get_view(); - auto sh_ccf = get_field_in("sh_ccf").get_view(); + // inputs/outputs + auto dlf = get_field_out("dlf").get_view(); + auto dp_ccf = get_field_out("dp_ccf").get_view(); + auto sh_ccf = get_field_out("sh_ccf").get_view(); + auto cldn_prev_step = get_field_out("cldn_prev_step").get_view< Real **>(); + // where is cldt_prev_step used? - auto cldt_prev_step = get_field_in("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? - auto cldst = get_field_in("cldst").get_view< Real **>();//?? - auto evapr = get_field_in("evapr").get_view< Real **>(); - auto rprdsh = get_field_in("rprdsh").get_view(); // rain production, shallow - // convection [kg/kg/s] - auto evapcsh = get_field_in("evapcsh").get_view(); // Evaporation rate of shallow convective + auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? + auto cldst = get_field_out("cldst").get_view< Real **>();//?? + auto evapr = get_field_out("evapr").get_view< Real **>(); + auto rprdsh = get_field_out("rprdsh").get_view(); // rain production, shallow + + // convection [kg/kg/s] + auto evapcsh = get_field_out("evapcsh").get_view(); // Evaporation rate of shallow convective // precipitation >=0. [kg/kg/s] - auto sh_frac = get_field_in("sh_frac").get_view(); // Shallow convective cloud fraction [fraction] - auto rprddp = get_field_in("rprddp").get_view(); // rain production, deep convection [kg/kg/s] - auto evapcdp = get_field_in("evapcdp").get_view(); // Evaporation rate of deep convective + auto sh_frac = get_field_out("sh_frac").get_view(); // Shallow convective cloud fraction [fraction] + auto rprddp = get_field_out("rprddp").get_view(); // rain production, deep convection [kg/kg/s] + auto evapcdp = get_field_out("evapcdp").get_view(); // Evaporation rate of deep convective // precipitation >=0. [kg/kg/s] - auto dp_frac = get_field_in("dp_frac") + auto dp_frac = get_field_out("dp_frac") .get_view(); // Deep convective cloud fraction [fraction] - auto icwmrsh = get_field_in("icwmrsh") + auto icwmrsh = get_field_out("icwmrsh") .get_view(); // ?? - auto icwmrdp = get_field_in("icwmrdp") + auto icwmrdp = get_field_out("icwmrdp") .get_view(); // ?? // outputs @@ -531,7 +536,8 @@ void MAMWetscav::run_impl(const double dt) { // diags.aerosol_wet_deposition_cloud_water; auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol);\ auto work_icol = ekat::subview(work, icol); - + // auto qqcw_sav_icol = ekat::subview(qqcw_sav,icol); +#if 1 mam4::wetdep::aero_model_wetdep(team, atm, progs, tends, dt, // inputs cldn_prev_step_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, @@ -542,6 +548,7 @@ void MAMWetscav::run_impl(const double dt) { aerdepwetis_icol, aerdepwetcw_icol, // FIXME remove qqcw_sav qqcw_sav, work_icol); +#endif }); // icol parallel_for loop /* diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml b/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml index ce1c8d4eeef..c73e2dbaa9a 100644 --- a/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml +++ b/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml @@ -61,7 +61,9 @@ initial_conditions: cldfrac_tot: 0.5 pbl_height: 25.0 phis : 0.1 - + dlf : 0.0 + dp_ccf : 0.0 + sh_ccf : 0.0 # The parameters for I/O control Scorpio: output_yaml_files: ["output.yaml"] From 604c2fa3c228ff7fd84b71daec008bddbca58f1d Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Wed, 27 Mar 2024 08:59:18 -0600 Subject: [PATCH 09/71] wet_scav - adding single-process. --- .../eamxx_mam_wetscav_process_interface.cpp | 6 +- .../eamxx/tests/single-process/CMakeLists.txt | 1 + .../mam/wet_scav/CMakeLists.txt | 46 ++++++++++++ .../single-process/mam/wet_scav/input.yaml | 70 +++++++++++++++++++ .../mam/wet_scav/mam4_wetscav_standalone.cpp | 69 ++++++++++++++++++ .../single-process/mam/wet_scav/output.yaml | 14 ++++ 6 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt create mode 100644 components/eamxx/tests/single-process/mam/wet_scav/input.yaml create mode 100644 components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp create mode 100644 components/eamxx/tests/single-process/mam/wet_scav/output.yaml diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 60f352f06e3..226dcb14d6e 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -64,6 +64,8 @@ void MAMWetscav::set_grids( // interfaces const FieldLayout scalar2d_layout_mid{{COL}, {ncol_}}; + FieldLayout scalar3d_layout_int{{COL, ILEV}, {ncol_, nlev_ + 1}}; + // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -77,6 +79,8 @@ void MAMWetscav::set_grids( "tracers"); // liquid cloud water [kg/kg] wet add_field("qi", scalar3d_layout_mid, q_unit, grid_name, "tracers"); // ice cloud water [kg/kg] wet + add_field("p_int", scalar3d_layout_int, Pa, + grid_name); // total pressure // -- Input variables that exists in PBUF in EAM static constexpr auto nondim = @@ -321,7 +325,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_atm_.T_mid = get_field_in("T_mid").get_view(); dry_atm_.p_mid = get_field_in("p_mid").get_view(); dry_atm_.p_del = get_field_in("pseudo_density").get_view(); - + dry_atm_.p_int = get_field_in("p_int").get_view(); // How "buffer_" works: We use buffer to allocate memory for the members of // dry_atm_ object. Here we are providing those memory locations to the // dry_atm_ members. These members are computed from the above wet_atm_ or diff --git a/components/eamxx/tests/single-process/CMakeLists.txt b/components/eamxx/tests/single-process/CMakeLists.txt index c6b4e0748af..3e1629ae0f3 100644 --- a/components/eamxx/tests/single-process/CMakeLists.txt +++ b/components/eamxx/tests/single-process/CMakeLists.txt @@ -21,6 +21,7 @@ if (SCREAM_ENABLE_MAM) # initial conditions. add_subdirectory(mam/optics) add_subdirectory(mam/aci) + add_subdirectory(mam/wet_scav) endif() if (SCREAM_TEST_LEVEL GREATER_EQUAL SCREAM_TEST_LEVEL_EXPERIMENTAL) add_subdirectory(zm) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt new file mode 100644 index 00000000000..dbddf4d26e2 --- /dev/null +++ b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt @@ -0,0 +1,46 @@ +include (ScreamUtils) + +set (TEST_BASE_NAME mam4_wetscav_standalone) +set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files) +# Create the test +CreateADUnitTest(${TEST_BASE_NAME} + LABELS mam4_wetscav physics + LIBS mam + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} +) + +# Set AD configurable options +SetVarDependingOnTestSize(NUM_STEPS 2 4 6) +set (ATM_TIME_STEP 1800) +set (RUN_T0 2021-10-12-45000) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml + ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml + ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) + +# Ensure test input files are present in the data dir +set (TEST_INPUT_FILES + scream/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc +) +foreach (file IN ITEMS ${TEST_INPUT_FILES}) + GetInputFile(${file}) +endforeach() + +# Compare output files produced by npX tests, to ensure they are bfb +include (CompareNCFiles) + +CompareNCFilesFamilyMpi ( + TEST_BASE_NAME ${TEST_BASE_NAME} + FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x2.npMPIRANKS.${RUN_T0}.nc + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + LABELS mam4_wetscav physics + META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_npMPIRANKS_omp1 +) + +if (SCREAM_ENABLE_BASELINE_TESTS) + # Compare one of the output files with the baselines. + # Note: one is enough, since we already check that np1 is BFB with npX + set (OUT_FILE ${TEST_BASE_NAME}_output.INSTANT.nsteps_x2.np${TEST_RANK_END}.${RUN_T0}.nc) + CreateBaselineTest(${TEST_BASE_NAME} ${TEST_RANK_END} ${OUT_FILE} ${FIXTURES_BASE_NAME}) +endif() diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml new file mode 100644 index 00000000000..c73e2dbaa9a --- /dev/null +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -0,0 +1,70 @@ +%YAML 1.1 +--- +driver_options: + atmosphere_dag_verbosity_level: 5 + +time_stepping: + time_step: ${ATM_TIME_STEP} + run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX + number_of_steps: ${NUM_STEPS} + +atmosphere_processes: + atm_procs_list: [mam4_wetscav] + mam_wetscav: + number_of_subcycles: ${NUM_SUBCYCLES} + compute_tendencies: [all] + lambda_low: 0.001 + +grids_manager: + Type: Mesh Free + grids_names: [Physics] + Physics: + type: point_grid + number_of_global_columns: 218 + number_of_vertical_levels: 72 + +initial_conditions: + Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + cldn_prev_step: 0.5 + rprdsh: 1e-5 + rprddp: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + cldt_prev_step: 1e-5 + cldst: 1e-5 + qme: 1e-5 + prain: 1e-5 + evapr: 1e-5 + icwmrdp: 1e-5 + icwmrsh: 1e-5 + rprddp: 1e-5 + rprdsh: 1e-5 + sh_frac: 1e-5 + dp_frac: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + pbuf: 1e-5 # cloud-borne aerosols + dgncur_a: 1e-5 # aerosol particle diameter [m] + wetdens: 1e-5 # wet aerosol density [kg/m3] + qaerwat: 1e-5 # aerosol water [kg/kg] + dgnumwet: 1e-5 # wet aerosol diameter [m] + fracis: 1e-5 # fraction of transported species that are insoluble [fraction] + cldfrac_tot: 0.5 + pbl_height: 25.0 + phis : 0.1 + dlf : 0.0 + dp_ccf : 0.0 + sh_ccf : 0.0 +# The parameters for I/O control +Scorpio: + output_yaml_files: ["output.yaml"] +... diff --git a/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp b/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp new file mode 100644 index 00000000000..203b51681d0 --- /dev/null +++ b/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp @@ -0,0 +1,69 @@ +#include + +#include "control/atmosphere_driver.hpp" +#include "diagnostics/register_diagnostics.hpp" + +#include "physics/register_physics.hpp" +#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" + +#include "share/grid/mesh_free_grids_manager.hpp" +#include "share/atm_process/atmosphere_process.hpp" + +#include "ekat/ekat_parse_yaml_file.hpp" +#include "ekat/logging/ekat_logger.hpp" + +#include + +namespace scream { + +TEST_CASE("mam4_wetscav-stand-alone", "") { + using namespace scream; + using namespace scream::control; + + // Create a comm + ekat::Comm atm_comm (MPI_COMM_WORLD); + + // Load ad parameter list + std::string fname = "input.yaml"; + ekat::ParameterList ad_params("Atmosphere Driver"); + parse_yaml_file(fname,ad_params); + logger.debug("yaml parsed."); + + // Time stepping parameters + const auto& ts = ad_params.sublist("time_stepping"); + const auto dt = ts.get("time_step"); + const auto nsteps = ts.get("number_of_steps"); + const auto t0_str = ts.get("run_t0"); + const auto t0 = util::str_to_time_stamp(t0_str); + + logger.info("running MAMWetscav standalone test with dt = {} for {} steps.", dt, nsteps); + EKAT_ASSERT_MSG (dt>0, "Error! Time step must be positive.\n"); + + // Need to register products in the factory *before* we create any atm process or grids manager. + register_physics(); + register_mesh_free_grids_manager(); + register_diagnostics(); + logger.debug("products registered."); + + // Create the driver + AtmosphereDriver ad; + logger.debug("driver created."); + + // Init and run + ad.initialize(atm_comm,ad_params,t0); + logger.debug("driver initialized."); + + logger.info("Start time stepping loop ... [0%]"); + for (int i=0; i Date: Sat, 13 Apr 2024 20:16:45 -0600 Subject: [PATCH 10/71] wet_dep - update to match mam4xx interface. --- .../eamxx_mam_wetscav_process_interface.cpp | 122 ++++++++++++++---- .../eamxx_mam_wetscav_process_interface.hpp | 3 +- .../eamxx/src/physics/mam/mam_coupling.hpp | 48 ++++++- 3 files changed, 147 insertions(+), 26 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 226dcb14d6e..be6e4d348cb 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -43,6 +43,9 @@ void MAMWetscav::set_grids( // Nevertheless, for output reasons, we like to see 'kg/kg'. auto q_unit = kg / kg; q_unit.set_string("kg/kg"); + // FIXME: units of tendencies; check units + auto dqdt_unit = kg / kg / s; + dqdt_unit.set_string("kg/kg/t"); auto n_unit = 1 / kg; // units of number mixing ratios of tracers n_unit.set_string("#/kg"); @@ -52,7 +55,7 @@ void MAMWetscav::set_grids( ncol_ = m_grid->get_num_local_dofs(); // Number of columns on this rank nlev_ = m_grid->get_num_vertical_levels(); // Number of levels per column - + const int nmodes = mam4::AeroConfig::num_modes();; // Define the different field layouts that will be used for this process using namespace ShortFieldTagsNames; @@ -66,6 +69,9 @@ void MAMWetscav::set_grids( FieldLayout scalar3d_layout_int{{COL, ILEV}, {ncol_, nlev_ + 1}}; + // Layout for 3D for nmodes + const FieldLayout scalar3d_layout_nmodes_mid{{COL, NMODES, LEV}, {ncol_, nmodes, nlev_}}; + // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -180,13 +186,14 @@ void MAMWetscav::set_grids( // -- input/ouputs from PBUF for updating particle size and water uptake by // particles static constexpr auto m3 = m2 * m; - add_field("dgncur_a", scalar3d_layout_mid, m, - grid_name); // aerosol particle diameter [m] - add_field("wetdens", scalar3d_layout_mid, kg / m3, + add_field("dgncur_a", scalar3d_layout_nmodes_mid, m, + grid_name); // aerosol dry particle diameter [m] + add_field("wetdens", scalar3d_layout_nmodes_mid, kg / m3, grid_name); // wet aerosol density [kg/m3] - add_field("qaerwat", scalar3d_layout_mid, kg / kg, + add_field("qaerwat", scalar3d_layout_nmodes_mid, kg / kg, grid_name); // aerosol water [kg/kg] - add_field("dgnumwet", scalar3d_layout_mid, m, + // + add_field("dgnumwet", scalar3d_layout_nmodes_mid, m, grid_name); // wet aerosol diameter [m] add_field("fracis", scalar3d_layout_mid, nondim, grid_name); // fraction of transported species that are @@ -247,6 +254,33 @@ void MAMWetscav::set_grids( grid_name, "tracers"); } + // aerosol-related gases: mass mixing ratios + for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { + std::string ptend_gas_name(mam_coupling::gas_mmr_field_name(g)); + ptend_gas_name += "ptend_"; + add_field(ptend_gas_name, scalar3d_layout_mid, dqdt_unit, + grid_name); + } + + // tendencies for interstitial aerosols + for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { + std::string ptend_num(mam_coupling::int_aero_nmr_field_name(imode)); + ptend_num += "ptend_"; + add_field(ptend_num, scalar3d_layout_mid, n_unit, + grid_name); + for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { + // (interstitial) aerosol tracers of interest: mass (q) mixing ratios + const char *int_mmr_field_name = + mam_coupling::int_aero_mmr_field_name(imode, ispec); + if(strlen(int_mmr_field_name) > 0) { + std::string ptend_int_mmr_field_name (int_mmr_field_name); + ptend_int_mmr_field_name += "ptend_"; + add_field(ptend_int_mmr_field_name, scalar3d_layout_mid, dqdt_unit, + grid_name); + } + } + } + add_field("cldfrac_tot", scalar3d_layout_mid, nondim, grid_name); // Cloud fraction add_field("pbl_height", scalar2d_layout_mid, m, @@ -271,11 +305,11 @@ void MAMWetscav::set_grids( grid_name); // add_field("sh_ccf", scalar3d_layout_mid, n_unit, grid_name); // - // - add_field("aerdepwetis", scalar3d_layout_mid, n_unit, - grid_name); // - add_field("aerdepwetcw", scalar3d_layout_mid, n_unit, - grid_name); // + // FIXME: do we need to write aerdepwetis and aerdepwetcw? + // add_field("aerdepwetis", scalar3d_layout_mid, n_unit, + // grid_name); // + // add_field("aerdepwetcw", scalar3d_layout_mid, n_unit, + // grid_name); // } // ========================================================================================= @@ -349,7 +383,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_atm_.cldfrac = get_field_in("cldfrac_tot").get_view(); dry_atm_.pblh = get_field_in("pbl_height").get_view(); dry_atm_.phis = get_field_in("phis").get_view(); - dry_atm_.z_surf = 0.0; // MUST FIXME: for now + dry_atm_.z_surf = 0.0; // ---- set wet/dry aerosol-related gas state data for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { const char *mmr_field_name = mam_coupling::gas_mmr_field_name(g); @@ -391,6 +425,33 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } } + + // ---- set aerosol-related gas tendencies data + for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { + std::string ptend_mmr_field_name(mam_coupling::gas_mmr_field_name(g)); + ptend_mmr_field_name += "ptend_"; + dry_aero_tends_.gas_mmr[g] = get_field_out(ptend_mmr_field_name).get_view(); + } + + // set aerosol state tendencies data (interstitial aerosols only) + for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { + std::string ptend_int_nmr_field_name(mam_coupling::int_aero_nmr_field_name(imode)); + ptend_int_nmr_field_name +="ptend_"; + dry_aero_tends_.int_aero_nmr[imode] = + get_field_out(ptend_int_nmr_field_name).get_view(); + + for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { + const char *int_mmr_field_name = + mam_coupling::int_aero_mmr_field_name(imode, ispec); + if(strlen(int_mmr_field_name) > 0) { + std::string ptend_int_nmr_field_name(int_mmr_field_name); + ptend_int_nmr_field_name +="ptend_"; + dry_aero_tends_.int_aero_mmr[imode][ispec] = + get_field_out(ptend_int_nmr_field_name).get_view(); + } + } + } + // set up our preprocess/postprocess functors // Here we initialize (not compute) objects in preprocess struct using the // objects in the argument list @@ -409,6 +470,8 @@ 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); + aerdepwetis_ = view_2d("aerdepwetis", ncol_, mam4::aero_model::pcnst); + aerdepwetcw_ = view_2d("aerdepwetcw", ncol_, mam4::aero_model::pcnst); } // ========================================================================================= @@ -454,6 +517,7 @@ void MAMWetscav::run_impl(const double dt) { const auto &dry_aero = dry_aero_; const auto &qqcw_sav = qqcw_sav_; const auto &work = work_; + const auto & dry_aero_tends= dry_aero_tends_; // inputs/outputs auto dlf = get_field_out("dlf").get_view(); @@ -485,8 +549,13 @@ void MAMWetscav::run_impl(const double dt) { .get_view(); // ?? // outputs - const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); - const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); + const auto aerdepwetis = aerdepwetis_;//get_field_out("aerdepwetis").get_view(); + const auto aerdepwetcw = aerdepwetcw_;// get_field_out("aerdepwetcw").get_view(); + + const auto wet_geometric_mean_diameter_i = get_field_out("dgnumwet").get_view(); + const auto dry_geometric_mean_diameter_i = get_field_out("dgncur_a").get_view(); + const auto qaerwat = get_field_out("qaerwat").get_view(); + const auto wetdens = get_field_out("wetdens").get_view(); const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); @@ -501,8 +570,8 @@ void MAMWetscav::run_impl(const double dt) { // fetch column-specific subviews into aerosol prognostics mam4::Prognostics progs = mam_coupling::aerosols_for_column(dry_aero, icol); - // FIXME: we need to create tendecies... - mam4::Tendencies tends{}; + // fetch column-specific subviews into aerosol tendencies + mam4::Tendencies tends = mam_coupling::aerosols_tendencies_for_column(dry_aero_tends, icol); // shallow_convective_cloud_fraction auto cldn_prev_step_icol = ekat::subview(cldn_prev_step, icol); @@ -530,9 +599,9 @@ void MAMWetscav::run_impl(const double dt) { auto cldst_icol = ekat::subview(cldst, icol); // deep_convective_cloud_fraction; - auto dp_ccf_icol = ekat::subview(dp_ccf, icol); - // shallow_convective_cloud_fraction; - auto sh_ccf_icol = ekat::subview(sh_ccf, icol); + // auto dp_ccf_icol = ekat::subview(dp_ccf, icol); + // // shallow_convective_cloud_fraction; + // auto sh_ccf_icol = ekat::subview(sh_ccf, icol); // total_convective_detrainment; auto dlf_icol = ekat::subview(dlf, icol); //aerosol_wet_deposition_interstitial; @@ -541,18 +610,23 @@ void MAMWetscav::run_impl(const double dt) { auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol);\ auto work_icol = ekat::subview(work, icol); // auto qqcw_sav_icol = ekat::subview(qqcw_sav,icol); -#if 1 + auto wet_diameter_icol = ekat::subview(wet_geometric_mean_diameter_i,icol); + auto dry_diameter_icol = ekat::subview(dry_geometric_mean_diameter_i,icol); + auto qaerwat_icol = ekat::subview(qaerwat,icol); + auto wetdens_icol = ekat::subview(wetdens,icol); + mam4::wetdep::aero_model_wetdep(team, atm, progs, tends, dt, // inputs - cldn_prev_step_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, - evapcsh_icol, dp_frac_icol, sh_frac_icol, dp_ccf_icol, sh_ccf_icol, - icwmrdp_col, icwmrsh_icol, evapr_icol, cldst_icol, + cldst_icol, cldn_prev_step_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, + evapcsh_icol, dp_frac_icol, sh_frac_icol, + icwmrdp_col, icwmrsh_icol, evapr_icol, dlf_icol, + wet_diameter_icol,dry_diameter_icol, + qaerwat_icol, wetdens_icol, // output aerdepwetis_icol, aerdepwetcw_icol, // FIXME remove qqcw_sav qqcw_sav, work_icol); -#endif }); // icol parallel_for loop /* diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index beb3d0c6789..fc688635785 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -181,9 +181,10 @@ class MAMWetscav : public scream::AtmosphereProcess { Kokkos::View qqcw_sav_; // aerosol states - mam_coupling::AerosolState wet_aero_, dry_aero_; + mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_; mam_coupling::Buffer buffer_; + mam_coupling::view_2d aerdepwetis_, aerdepwetcw_; std::shared_ptr m_grid; }; // class MAMWetscav diff --git a/components/eamxx/src/physics/mam/mam_coupling.hpp b/components/eamxx/src/physics/mam/mam_coupling.hpp index 3a001146882..99a116d4872 100644 --- a/components/eamxx/src/physics/mam/mam_coupling.hpp +++ b/components/eamxx/src/physics/mam/mam_coupling.hpp @@ -562,6 +562,34 @@ mam4::Prognostics interstitial_aerosols_for_column(const AerosolState& dry_aero, return progs; } + +// Given an AerosolState with views for dry aerosol quantities, creates a +// mam4::Tendencies object for the column with the given index with +// ONLY INTERSTITIAL AEROSOL VIEWS DEFINED. This object can be provided to +// mam4xx for the column. +KOKKOS_INLINE_FUNCTION +mam4::Tendencies interstitial_aerosols_tendencies_for_column(const AerosolState& dry_aero, + const int column_index) { + constexpr int nlev = mam4::nlev; + mam4::Tendencies tends(nlev); + for (int m = 0; m < num_aero_modes(); ++m) { + EKAT_KERNEL_ASSERT_MSG(dry_aero.int_aero_nmr[m].data(), + "int_aero_nmr not defined for dry aerosol state!"); + tends.n_mode_i[m] = ekat::subview(dry_aero.int_aero_nmr[m], column_index); + for (int a = 0; a < num_aero_species(); ++a) { + if (dry_aero.int_aero_mmr[m][a].data()) { + tends.q_aero_i[m][a] = ekat::subview(dry_aero.int_aero_mmr[m][a], column_index); + } + } + } + for (int g = 0; g < num_aero_gases(); ++g) { + EKAT_KERNEL_ASSERT_MSG(dry_aero.gas_mmr[g].data(), + "gas_mmr not defined for dry aerosol state!"); + tends.q_gas[g] = ekat::subview(dry_aero.gas_mmr[g], column_index); + } + return tends; +} + // Given a dry aerosol state, creates a mam4::Prognostics object for the column // with the given index with interstitial and cloudborne aerosol views defined. // This object can be provided to mam4xx for the column. @@ -581,7 +609,25 @@ mam4::Prognostics aerosols_for_column(const AerosolState& dry_aero, } return progs; } - +// Given a dry aerosol state tendencies, creates a mam4::Tendencies object for the column +// with the given index with interstitial and cloudborne aerosol views defined. +// This object can be provided to mam4xx for the column. +KOKKOS_INLINE_FUNCTION +mam4::Tendencies aerosols_tendencies_for_column(const AerosolState& dry_aero, + const int column_index) { + auto tends = interstitial_aerosols_tendencies_for_column(dry_aero, column_index); + for (int m = 0; m < num_aero_modes(); ++m) { + EKAT_KERNEL_ASSERT_MSG(dry_aero.cld_aero_nmr[m].data(), + "dry_cld_aero_nmr not defined for aerosol state!"); + tends.n_mode_c[m] = ekat::subview(dry_aero.cld_aero_nmr[m], column_index); + for (int a = 0; a < num_aero_species(); ++a) { + if (dry_aero.cld_aero_mmr[m][a].data()) { + tends.q_aero_c[m][a] = ekat::subview(dry_aero.cld_aero_mmr[m][a], column_index); + } + } + } + return tends; +} // Given a thread team and a dry atmosphere state, dispatches threads from the // team to compute vertical layer heights and interfaces for the column with // the given index. From 1ac385d8c448dcefae71c4529799f1c9fd08695e Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Sat, 13 Apr 2024 20:51:59 -0600 Subject: [PATCH 11/71] wet_dep - update mam4xx interface. --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 15 ++++----------- .../mam/eamxx_mam_wetscav_process_interface.hpp | 2 -- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index be6e4d348cb..7fa333f97bd 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -463,15 +463,10 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // wetdep constexpr int pcnst = mam4::aero_model::pcnst; - // FIXME: qqcw_sav_ should be part of work_ - // we need to add columns - qqcw_sav_ =Kokkos::View("qqcw_sav", mam4::nlev); - - const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); - aerdepwetis_ = view_2d("aerdepwetis", ncol_, mam4::aero_model::pcnst); - aerdepwetcw_ = view_2d("aerdepwetcw", ncol_, mam4::aero_model::pcnst); + aerdepwetis_ = view_2d("aerdepwetis", ncol_, pcnst); + aerdepwetcw_ = view_2d("aerdepwetcw", ncol_, pcnst); } // ========================================================================================= @@ -515,7 +510,6 @@ void MAMWetscav::run_impl(const double dt) { // We cannot use member of this class inside of the parallel_for const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; - const auto &qqcw_sav = qqcw_sav_; const auto &work = work_; const auto & dry_aero_tends= dry_aero_tends_; @@ -624,9 +618,8 @@ void MAMWetscav::run_impl(const double dt) { wet_diameter_icol,dry_diameter_icol, qaerwat_icol, wetdens_icol, // output - aerdepwetis_icol, aerdepwetcw_icol, - // FIXME remove qqcw_sav - qqcw_sav, work_icol); + aerdepwetis_icol, aerdepwetcw_icol, + work_icol); }); // icol parallel_for loop /* diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index fc688635785..c09a789b6c7 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -178,8 +178,6 @@ class MAMWetscav : public scream::AtmosphereProcess { mam_coupling::DryAtmosphere dry_atm_; // wet dep view_2d work_; - Kokkos::View - qqcw_sav_; // aerosol states mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_; From c5c0cfab20ebe02a22eeab1aa0416b2ddba4adae Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Sun, 14 Apr 2024 12:14:55 -0600 Subject: [PATCH 12/71] wet_dep - update name of tendencies. --- .../eamxx_mam_wetscav_process_interface.cpp | 34 ++++++++----------- .../eamxx/src/physics/mam/mam_coupling.hpp | 2 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 7fa333f97bd..1b8ee2d8e28 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -256,26 +256,23 @@ void MAMWetscav::set_grids( // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_gas_name(mam_coupling::gas_mmr_field_name(g)); - ptend_gas_name += "ptend_"; - add_field(ptend_gas_name, scalar3d_layout_mid, dqdt_unit, + std::string ptend_gas_name = "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); + add_field(ptend_gas_name, scalar3d_layout_mid, dqdt_unit, grid_name); } // tendencies for interstitial aerosols for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_num(mam_coupling::int_aero_nmr_field_name(imode)); - ptend_num += "ptend_"; - add_field(ptend_num, scalar3d_layout_mid, n_unit, + std::string ptend_num = "ptend_" +std::string(mam_coupling::int_aero_nmr_field_name(imode)); + add_field(ptend_num, scalar3d_layout_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { // (interstitial) aerosol tracers of interest: mass (q) mixing ratios const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_mmr_field_name (int_mmr_field_name); - ptend_int_mmr_field_name += "ptend_"; - add_field(ptend_int_mmr_field_name, scalar3d_layout_mid, dqdt_unit, + std::string ptend_int_mmr_field_name = "ptend_" + std::string(int_mmr_field_name); + add_field(ptend_int_mmr_field_name, scalar3d_layout_mid, dqdt_unit, grid_name); } } @@ -428,15 +425,15 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // ---- set aerosol-related gas tendencies data for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_mmr_field_name(mam_coupling::gas_mmr_field_name(g)); - ptend_mmr_field_name += "ptend_"; + std::string ptend_mmr_field_name = "ptend_" + + std::string(mam_coupling::gas_mmr_field_name(g)); dry_aero_tends_.gas_mmr[g] = get_field_out(ptend_mmr_field_name).get_view(); } // set aerosol state tendencies data (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_int_nmr_field_name(mam_coupling::int_aero_nmr_field_name(imode)); - ptend_int_nmr_field_name +="ptend_"; + std::string ptend_int_nmr_field_name ="ptend_"+ + std::string(mam_coupling::int_aero_nmr_field_name(imode)); dry_aero_tends_.int_aero_nmr[imode] = get_field_out(ptend_int_nmr_field_name).get_view(); @@ -444,10 +441,9 @@ void MAMWetscav::initialize_impl(const RunType run_type) { const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_nmr_field_name(int_mmr_field_name); - ptend_int_nmr_field_name +="ptend_"; + std::string ptend_int_aero_mmr_field_name = "ptend_" + std::string(int_mmr_field_name); dry_aero_tends_.int_aero_mmr[imode][ispec] = - get_field_out(ptend_int_nmr_field_name).get_view(); + get_field_out(ptend_int_aero_mmr_field_name).get_view(); } } } @@ -511,7 +507,7 @@ void MAMWetscav::run_impl(const double dt) { const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; const auto &work = work_; - const auto & dry_aero_tends= dry_aero_tends_; + const auto &dry_aero_tends= dry_aero_tends_; // inputs/outputs auto dlf = get_field_out("dlf").get_view(); @@ -565,8 +561,8 @@ void MAMWetscav::run_impl(const double dt) { mam4::Prognostics progs = mam_coupling::aerosols_for_column(dry_aero, icol); // fetch column-specific subviews into aerosol tendencies - mam4::Tendencies tends = mam_coupling::aerosols_tendencies_for_column(dry_aero_tends, icol); - + // Note: we are only updating interstitial aerosols. + mam4::Tendencies tends = mam_coupling::interstitial_aerosols_tendencies_for_column(dry_aero_tends, icol); // shallow_convective_cloud_fraction auto cldn_prev_step_icol = ekat::subview(cldn_prev_step, icol); ///shallow_convective_precipitation_production diff --git a/components/eamxx/src/physics/mam/mam_coupling.hpp b/components/eamxx/src/physics/mam/mam_coupling.hpp index 99a116d4872..e48b5c9f2e1 100644 --- a/components/eamxx/src/physics/mam/mam_coupling.hpp +++ b/components/eamxx/src/physics/mam/mam_coupling.hpp @@ -618,7 +618,7 @@ mam4::Tendencies aerosols_tendencies_for_column(const AerosolState& dry_aero, auto tends = interstitial_aerosols_tendencies_for_column(dry_aero, column_index); for (int m = 0; m < num_aero_modes(); ++m) { EKAT_KERNEL_ASSERT_MSG(dry_aero.cld_aero_nmr[m].data(), - "dry_cld_aero_nmr not defined for aerosol state!"); + "Tendencies : dry_cld_aero_nmr not defined for aerosol state!"); tends.n_mode_c[m] = ekat::subview(dry_aero.cld_aero_nmr[m], column_index); for (int a = 0; a < num_aero_species(); ++a) { if (dry_aero.cld_aero_mmr[m][a].data()) { From 593c8b169a63f608d7403aafc3ca769a1bcd90f3 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 20 May 2024 14:16:18 -0600 Subject: [PATCH 13/71] wet_scav - rebase code --- .../eamxx_mam_wetscav_process_interface.cpp | 137 +++++++++--------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 1b8ee2d8e28..123de4d95f6 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -55,37 +55,32 @@ void MAMWetscav::set_grids( ncol_ = m_grid->get_num_local_dofs(); // Number of columns on this rank nlev_ = m_grid->get_num_vertical_levels(); // Number of levels per column - const int nmodes = mam4::AeroConfig::num_modes();; - // Define the different field layouts that will be used for this process - using namespace ShortFieldTagsNames; + const int nmodes = mam4::AeroConfig::num_modes(); - // Layout for 3D (2d horiz X 1d vertical) variable defined at mid-level and - // interfaces - const FieldLayout scalar3d_layout_mid{{COL, LEV}, {ncol_, nlev_}}; + // layout for 3D (2d horiz X 1d vertical) variables at level midpoints/interfaces + FieldLayout scalar3d_mid = m_grid->get_3d_scalar_layout(true); + FieldLayout scalar3d_int = m_grid->get_3d_scalar_layout(false); - // Layout for 2D (2d horiz) variable defined at mid-level and - // interfaces - const FieldLayout scalar2d_layout_mid{{COL}, {ncol_}}; + // layout for 2D (1d horiz X 1d vertical) variables + FieldLayout scalar2d = m_grid->get_2d_scalar_layout(); - FieldLayout scalar3d_layout_int{{COL, ILEV}, {ncol_, nlev_ + 1}}; - - // Layout for 3D for nmodes - const FieldLayout scalar3d_layout_nmodes_mid{{COL, NMODES, LEV}, {ncol_, nmodes, nlev_}}; + // layout for 3D (ncol, nmodes, nlevs) + FieldLayout scalar3d_mid_nmodes = m_grid->get_3d_vector_layout(true,nmodes,"nmodes"); // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- - add_field("T_mid", scalar3d_layout_mid, K, + add_field("T_mid", scalar3d_mid, K, grid_name); // temperature [K] - add_field("p_mid", scalar3d_layout_mid, Pa, + add_field("p_mid", scalar3d_mid, Pa, grid_name); // pressure at mid points in [Pa - add_field("pseudo_density", scalar3d_layout_mid, Pa, + add_field("pseudo_density", scalar3d_mid, Pa, grid_name); // pseudo density in [Pa] - add_field("qc", scalar3d_layout_mid, q_unit, grid_name, + add_field("qc", scalar3d_mid, q_unit, grid_name, "tracers"); // liquid cloud water [kg/kg] wet - add_field("qi", scalar3d_layout_mid, q_unit, grid_name, + add_field("qi", scalar3d_mid, q_unit, grid_name, "tracers"); // ice cloud water [kg/kg] wet - add_field("p_int", scalar3d_layout_int, Pa, + add_field("p_int", scalar3d_int, Pa, grid_name); // total pressure // -- Input variables that exists in PBUF in EAM @@ -94,20 +89,20 @@ void MAMWetscav::set_grids( // MUST FIXME: cldt and cldn are the same variables. They must be their // previous step values. - add_field("cldn_prev_step", scalar3d_layout_mid, nondim, + add_field("cldn_prev_step", scalar3d_mid, nondim, grid_name); // layer cloud fraction [fraction] - add_field("cldst", scalar3d_layout_mid, nondim, + add_field("cldst", scalar3d_mid, nondim, grid_name); //?? - add_field("rprdsh", scalar3d_layout_mid, kg / kg / s, + add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); // rain production, shallow convection // [kg/kg/s] //NOT updated add_field( - "rprddp", scalar3d_layout_mid, kg / kg / s, + "rprddp", scalar3d_mid, kg / kg / s, grid_name); // rain production, deep convection [kg/kg/s] //NOT updated - add_field("evapcsh", scalar3d_layout_mid, kg / kg / s, + add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); // Evaporation rate of shallow convective // //NOT updated precipitation >=0. [kg/kg/s] - add_field("evapcdp", scalar3d_layout_mid, kg / kg / s, + add_field("evapcdp", scalar3d_mid, kg / kg / s, grid_name); // Evaporation rate of deep convective //NOT // updated precipitation >=0. [kg/kg/s] @@ -115,42 +110,42 @@ void MAMWetscav::set_grids( // "inputs" data structure // MUST FIXME: cldt and cldn are the same variables. They must be their // previous step values. - add_field("cldt_prev_step", scalar3d_layout_mid, nondim, + add_field("cldt_prev_step", scalar3d_mid, nondim, grid_name); // total cloud fraction [fraction] add_field( - "qme", scalar3d_layout_mid, kg / kg / s, + "qme", scalar3d_mid, kg / kg / s, grid_name); // net condensation/evaporation of cloud water [kg/kg/s] - add_field("prain", scalar3d_layout_mid, kg / kg / s, + add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // stratiform rain production rate [kg/kg/s] add_field( - "evapr", scalar3d_layout_mid, kg / kg / s, + "evapr", scalar3d_mid, kg / kg / s, grid_name); // evaporation from stratiform rain [kg/kg/s] //NOT updated // -- Input variables that exists in PBUF in EAM (in wetdep.F90) - add_field("icwmrdp", scalar3d_layout_mid, kg / kg, + add_field("icwmrdp", scalar3d_mid, kg / kg, grid_name); // In cloud water mixing ratio, deep // convection [kg/kg] //NOT updated - add_field("icwmrsh", scalar3d_layout_mid, kg / kg, + add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); // In cloud water mixing ratio, shallow // convection [kg/kg] //NOT updated - add_field("rprddp", scalar3d_layout_mid, kg / kg / s, + add_field("rprddp", scalar3d_mid, kg / kg / s, grid_name); // Rain production, deep convection [kg/kg/s] add_field( - "sh_frac", scalar3d_layout_mid, nondim, + "sh_frac", scalar3d_mid, nondim, grid_name); // Shallow convective cloud fraction [fraction] //NOT updated add_field( - "dp_frac", scalar3d_layout_mid, nondim, + "dp_frac", scalar3d_mid, nondim, grid_name); // Deep convective cloud fraction [fraction] //NOT updated add_field( - "icwmrsh", scalar3d_layout_mid, nondim, + "icwmrsh", scalar3d_mid, nondim, grid_name); add_field( - "icwmrdp", scalar3d_layout_mid, nondim, + "icwmrdp", scalar3d_mid, nondim, grid_name); - add_field("evapcsh", scalar3d_layout_mid, kg / kg / s, + add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); // Evaporation rate of shallow convective // precipitation >=0. [kg/kg/s] - add_field("evapcdp", scalar3d_layout_mid, kg / kg / s, + add_field("evapcdp", scalar3d_mid, kg / kg / s, grid_name); // Evaporation rate of deep convective // precipitation >=0. [kg/kg/s] @@ -162,40 +157,40 @@ void MAMWetscav::set_grids( // for the land model static constexpr auto m2 = m * m; add_field( - "bcphiwet", scalar3d_layout_mid, kg / m2 / s, + "bcphiwet", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of hydrophilic black carbon [kg/m2/s] add_field( - "bcphidry", scalar3d_layout_mid, kg / m2 / s, + "bcphidry", scalar3d_mid, kg / m2 / s, grid_name); // dry deposition of hydrophilic black carbon [kg/m2/s] add_field( - "ocphiwet", scalar3d_layout_mid, kg / m2 / s, + "ocphiwet", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of hydrophilic organic carbon [kg/m2/s] add_field( - "ocphidry", scalar3d_layout_mid, kg / m2 / s, + "ocphidry", scalar3d_mid, kg / m2 / s, grid_name); // dry deposition of hydrophilic organic carbon [kg/m2/s] - add_field("dstwet1", scalar3d_layout_mid, kg / m2 / s, + add_field("dstwet1", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of dust (bin1) [kg/m2/s] - add_field("dstwet2", scalar3d_layout_mid, kg / m2 / s, + add_field("dstwet2", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of dust (bin2) [kg/m2/s] - add_field("dstwet3", scalar3d_layout_mid, kg / m2 / s, + add_field("dstwet3", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of dust (bin3) [kg/m2/s] - add_field("dstwet4", scalar3d_layout_mid, kg / m2 / s, + add_field("dstwet4", scalar3d_mid, kg / m2 / s, grid_name); // wet deposition of dust (bin4) [kg/m2/s] // -- input/ouputs from PBUF for updating particle size and water uptake by // particles static constexpr auto m3 = m2 * m; - add_field("dgncur_a", scalar3d_layout_nmodes_mid, m, + add_field("dgncur_a", scalar3d_mid_nmodes, m, grid_name); // aerosol dry particle diameter [m] - add_field("wetdens", scalar3d_layout_nmodes_mid, kg / m3, + add_field("wetdens", scalar3d_mid_nmodes, kg / m3, grid_name); // wet aerosol density [kg/m3] - add_field("qaerwat", scalar3d_layout_nmodes_mid, kg / kg, + add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, grid_name); // aerosol water [kg/kg] // - add_field("dgnumwet", scalar3d_layout_nmodes_mid, m, + add_field("dgnumwet", scalar3d_mid_nmodes, m, grid_name); // wet aerosol diameter [m] - add_field("fracis", scalar3d_layout_mid, nondim, + add_field("fracis", scalar3d_mid, nondim, grid_name); // fraction of transported species that are // insoluble [fraction] @@ -207,7 +202,7 @@ void MAMWetscav::set_grids( // interstitial aerosol tracers of interest: number (n) mixing ratios const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(imode); - add_field(int_nmr_field_name, scalar3d_layout_mid, n_unit, + add_field(int_nmr_field_name, scalar3d_mid, n_unit, grid_name, "tracers"); // cloudborne aerosol tracers of interest: number (n) mixing ratios @@ -216,7 +211,7 @@ void MAMWetscav::set_grids( // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are // NOT advected - add_field(cld_nmr_field_name, scalar3d_layout_mid, n_unit, + add_field(cld_nmr_field_name, scalar3d_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { @@ -224,7 +219,7 @@ void MAMWetscav::set_grids( const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - add_field(int_mmr_field_name, scalar3d_layout_mid, q_unit, + add_field(int_mmr_field_name, scalar3d_mid, q_unit, grid_name, "tracers"); } @@ -234,7 +229,7 @@ void MAMWetscav::set_grids( if(strlen(cld_mmr_field_name) > 0) { // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these // are NOT advected - add_field(cld_mmr_field_name, scalar3d_layout_mid, q_unit, + add_field(cld_mmr_field_name, scalar3d_mid, q_unit, grid_name); } } @@ -250,21 +245,21 @@ void MAMWetscav::set_grids( // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g); - add_field(gas_mmr_field_name, scalar3d_layout_mid, q_unit, + add_field(gas_mmr_field_name, scalar3d_mid, q_unit, grid_name, "tracers"); } // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { std::string ptend_gas_name = "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); - add_field(ptend_gas_name, scalar3d_layout_mid, dqdt_unit, + add_field(ptend_gas_name, scalar3d_mid, dqdt_unit, grid_name); } // tendencies for interstitial aerosols for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { std::string ptend_num = "ptend_" +std::string(mam_coupling::int_aero_nmr_field_name(imode)); - add_field(ptend_num, scalar3d_layout_mid, n_unit, + add_field(ptend_num, scalar3d_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { // (interstitial) aerosol tracers of interest: mass (q) mixing ratios @@ -272,40 +267,40 @@ void MAMWetscav::set_grids( mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { std::string ptend_int_mmr_field_name = "ptend_" + std::string(int_mmr_field_name); - add_field(ptend_int_mmr_field_name, scalar3d_layout_mid, dqdt_unit, + add_field(ptend_int_mmr_field_name, scalar3d_mid, dqdt_unit, grid_name); } } } - add_field("cldfrac_tot", scalar3d_layout_mid, nondim, + add_field("cldfrac_tot", scalar3d_mid, nondim, grid_name); // Cloud fraction - add_field("pbl_height", scalar2d_layout_mid, m, + add_field("pbl_height", scalar2d, m, grid_name); // PBL height static constexpr auto s2 = s * s; - add_field("phis", scalar2d_layout_mid, m2 / s2, + add_field("phis", scalar2d, m2 / s2, grid_name); // surface geopotential - add_field("qv", scalar3d_layout_mid, q_unit, + add_field("qv", scalar3d_mid, q_unit, grid_name); // specific humidity - add_field("nc", scalar3d_layout_mid, n_unit, + add_field("nc", scalar3d_mid, n_unit, grid_name); // cloud water number conc - add_field("ni", scalar3d_layout_mid, n_unit, + add_field("ni", scalar3d_mid, n_unit, grid_name); // cloud ice number conc - add_field("omega", scalar3d_layout_mid, Pa / s, + add_field("omega", scalar3d_mid, Pa / s, grid_name); // vertical pressure velocity // FIXME: units - add_field("dlf", scalar3d_layout_mid, n_unit, + add_field("dlf", scalar3d_mid, n_unit, grid_name); // - add_field("dp_ccf", scalar3d_layout_mid, n_unit, + add_field("dp_ccf", scalar3d_mid, n_unit, grid_name); // - add_field("sh_ccf", scalar3d_layout_mid, n_unit, + add_field("sh_ccf", scalar3d_mid, n_unit, grid_name); // // FIXME: do we need to write aerdepwetis and aerdepwetcw? - // add_field("aerdepwetis", scalar3d_layout_mid, n_unit, + // add_field("aerdepwetis", scalar3d_mid, n_unit, // grid_name); // - // add_field("aerdepwetcw", scalar3d_layout_mid, n_unit, + // add_field("aerdepwetcw", scalar3d_mid, n_unit, // grid_name); // } From a76689c251480912e9333078c993c147dd3fa8de Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 20 May 2024 17:06:21 -0600 Subject: [PATCH 14/71] wet_scav - adding missing input variable. --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 123de4d95f6..2f444f36678 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -142,6 +142,10 @@ void MAMWetscav::set_grids( add_field( "icwmrdp", scalar3d_mid, nondim, grid_name); + + add_field( + "prain", scalar3d_mid, nondim, + grid_name); add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); // Evaporation rate of shallow convective // precipitation >=0. [kg/kg/s] @@ -533,6 +537,9 @@ void MAMWetscav::run_impl(const double dt) { auto icwmrdp = get_field_out("icwmrdp") .get_view(); // ?? + auto prain = get_field_out("prain") + .get_view(); // ?? + // outputs const auto aerdepwetis = aerdepwetis_;//get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = aerdepwetcw_;// get_field_out("aerdepwetcw").get_view(); @@ -599,13 +606,15 @@ void MAMWetscav::run_impl(const double dt) { auto dry_diameter_icol = ekat::subview(dry_geometric_mean_diameter_i,icol); auto qaerwat_icol = ekat::subview(qaerwat,icol); auto wetdens_icol = ekat::subview(wetdens,icol); + auto prain_icol = ekat::subview(prain,icol); + mam4::wetdep::aero_model_wetdep(team, atm, progs, tends, dt, // inputs cldst_icol, cldn_prev_step_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, evapcsh_icol, dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, evapr_icol, - dlf_icol, + dlf_icol, prain_icol, wet_diameter_icol,dry_diameter_icol, qaerwat_icol, wetdens_icol, // output From 5cd64aef926b0a7633797e60068445cf78978e36 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 20 May 2024 20:52:16 -0600 Subject: [PATCH 15/71] wet_scav - removing old comments and variables that not needed. --- .../eamxx_mam_wetscav_process_interface.cpp | 371 +++--------------- 1 file changed, 46 insertions(+), 325 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 2f444f36678..9ac0720d8ab 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -2,9 +2,6 @@ #include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" #include "scream_config.h" // for SCREAM_CIME_BUILD -// NOTE: see the impl/ directory for the contents of the impl namespace -#include "impl/compute_particle_size.cpp" - // Remove the following<<<< #include #include @@ -65,8 +62,9 @@ void MAMWetscav::set_grids( FieldLayout scalar2d = m_grid->get_2d_scalar_layout(); // layout for 3D (ncol, nmodes, nlevs) - FieldLayout scalar3d_mid_nmodes = m_grid->get_3d_vector_layout(true,nmodes,"nmodes"); + FieldLayout scalar3d_mid_nmodes = m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); + // FieldLayout scalar2d = m_grid->get_2d_scalar_layout // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -89,9 +87,9 @@ void MAMWetscav::set_grids( // MUST FIXME: cldt and cldn are the same variables. They must be their // previous step values. - add_field("cldn_prev_step", scalar3d_mid, nondim, + add_field("cldn", scalar3d_mid, nondim, grid_name); // layer cloud fraction [fraction] - add_field("cldst", scalar3d_mid, nondim, + add_field("cldt", scalar3d_mid, nondim, grid_name); //?? add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); // rain production, shallow convection @@ -110,11 +108,13 @@ void MAMWetscav::set_grids( // "inputs" data structure // MUST FIXME: cldt and cldn are the same variables. They must be their // previous step values. - add_field("cldt_prev_step", scalar3d_mid, nondim, - grid_name); // total cloud fraction [fraction] - add_field( - "qme", scalar3d_mid, kg / kg / s, - grid_name); // net condensation/evaporation of cloud water [kg/kg/s] + // add_field("cldt_prev_step", scalar3d_mid, nondim, + // grid_name); // total cloud fraction [fraction] + + // FIXME: we do not need qme + // add_field( + // "qme", scalar3d_mid, kg / kg / s, + // grid_name); // net condensation/evaporation of cloud water [kg/kg/s] add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // stratiform rain production rate [kg/kg/s] add_field( @@ -128,30 +128,27 @@ void MAMWetscav::set_grids( add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); // In cloud water mixing ratio, shallow // convection [kg/kg] //NOT updated - add_field("rprddp", scalar3d_mid, kg / kg / s, - grid_name); // Rain production, deep convection [kg/kg/s] + // add_field("rprddp", scalar3d_mid, kg / kg / s, + // grid_name); // Rain production, deep convection [kg/kg/s] add_field( "sh_frac", scalar3d_mid, nondim, grid_name); // Shallow convective cloud fraction [fraction] //NOT updated add_field( "dp_frac", scalar3d_mid, nondim, grid_name); // Deep convective cloud fraction [fraction] //NOT updated + // in cloud water mixing ratio, deep shallow [kg/kg] add_field( "icwmrsh", scalar3d_mid, nondim, grid_name); - add_field( - "icwmrdp", scalar3d_mid, nondim, - grid_name); - - add_field( - "prain", scalar3d_mid, nondim, - grid_name); - add_field("evapcsh", scalar3d_mid, kg / kg / s, - grid_name); // Evaporation rate of shallow convective - // precipitation >=0. [kg/kg/s] - add_field("evapcdp", scalar3d_mid, kg / kg / s, - grid_name); // Evaporation rate of deep convective - // precipitation >=0. [kg/kg/s] + // add_field( + // "icwmrdp", scalar3d_mid, nondim, + // grid_name); + // add_field("evapcsh", scalar3d_mid, kg / kg / s, + // grid_name); // Evaporation rate of shallow convective + // // precipitation >=0. [kg/kg/s] + // add_field("evapcdp", scalar3d_mid, kg / kg / s, + // grid_name); // Evaporation rate of deep convective + // // precipitation >=0. [kg/kg/s] // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process @@ -295,15 +292,17 @@ void MAMWetscav::set_grids( grid_name); // vertical pressure velocity // FIXME: units - add_field("dlf", scalar3d_mid, n_unit, - grid_name); // - add_field("dp_ccf", scalar3d_mid, n_unit, - grid_name); // - add_field("sh_ccf", scalar3d_mid, n_unit, + add_field("dlf", scalar3d_mid, kg / kg / s, grid_name); // + // add_field("dp_ccf", scalar3d_mid, n_unit, + // grid_name); // + // add_field("sh_ccf", scalar3d_mid, n_unit, + // grid_name); // + // FIXME: do we need to write aerdepwetis and aerdepwetcw? // add_field("aerdepwetis", scalar3d_mid, n_unit, // grid_name); // + // add_field("aerdepwetcw", scalar3d_mid, n_unit, // grid_name); // } @@ -460,7 +459,10 @@ void MAMWetscav::initialize_impl(const RunType run_type) { constexpr int pcnst = mam4::aero_model::pcnst; const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); + // FIXME: do I need to move these variables to FM? + // aerosol wet deposition (interstitial) [kg/m2/s] aerdepwetis_ = view_2d("aerdepwetis", ncol_, pcnst); + // aerosol wet deposition (cloud water) [kg/m2/s] aerdepwetcw_ = view_2d("aerdepwetcw", ncol_, pcnst); } @@ -474,35 +476,6 @@ void MAMWetscav::run_impl(const double dt) { // needed by this process or setting up MAM4xx classes and their objects Kokkos::parallel_for("preprocess", scan_policy, preprocess_); Kokkos::fence(); - - /*Fortran code: - call modal_aero_calcsize_sub(state%ncol, state%lchnk, state%q, state%pdel, - dt, & !in qqcw, ptend, dgnumdry_m=dgncur_a) !inout - - ----subroutine modal_aero_calcsize_sub(ncol, lchnk, state_q, pdel, deltat, - qqcw, ptend, do_adjust_in, & do_aitacc_transfer_in, list_idx_in, - update_mmr_in, dgnumdry_m) */ - // mam4::CalcSizeProcess process_(aero_config_); //initiate MAM4xx calcsize - // process - - /* ---------------------------------------------------------------------------------------- - * Compute particle size using the calcsize process - * ---------------------------------------------------------------------------------------- - */ - - // -- configure the process - /* - * -- NOTES: 1. Flags for the inter-mode particle transfer - * (do_aitacc_transfer) and size adjustment (do_adjust) are TRUE by default - * a. Size adjustment is only done by changing aerosol - * numbers in the modes. - * 2. Interstitial and cld borne aerosols (i.e. "tends") mmr will - * be updated (update_mmr is TRUE by default) - */ - // MUST: FIXME: Make sure state is not updated...only tendencies should be - // updated!! - // NOTE! we need a const mam_coupling::DryAtmosphere dry_atm for gpu access. - // We cannot use member of this class inside of the parallel_for const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; const auto &work = work_; @@ -510,14 +483,14 @@ void MAMWetscav::run_impl(const double dt) { // inputs/outputs auto dlf = get_field_out("dlf").get_view(); - auto dp_ccf = get_field_out("dp_ccf").get_view(); - auto sh_ccf = get_field_out("sh_ccf").get_view(); + // auto dp_ccf = get_field_out("dp_ccf").get_view(); + // auto sh_ccf = get_field_out("sh_ccf").get_view(); - auto cldn_prev_step = get_field_out("cldn_prev_step").get_view< Real **>(); + auto cldn = get_field_out("cldn").get_view< Real **>(); // where is cldt_prev_step used? auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? - auto cldst = get_field_out("cldst").get_view< Real **>();//?? + auto cldt = get_field_out("cldt").get_view< Real **>();//?? auto evapr = get_field_out("evapr").get_view< Real **>(); auto rprdsh = get_field_out("rprdsh").get_view(); // rain production, shallow @@ -540,9 +513,11 @@ void MAMWetscav::run_impl(const double dt) { auto prain = get_field_out("prain") .get_view(); // ?? + const auto aerdepwetis = aerdepwetis_;// + const auto aerdepwetcw = aerdepwetcw_;// // outputs - const auto aerdepwetis = aerdepwetis_;//get_field_out("aerdepwetis").get_view(); - const auto aerdepwetcw = aerdepwetcw_;// get_field_out("aerdepwetcw").get_view(); + // const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); + // const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); const auto wet_geometric_mean_diameter_i = get_field_out("dgnumwet").get_view(); const auto dry_geometric_mean_diameter_i = get_field_out("dgncur_a").get_view(); @@ -566,7 +541,7 @@ void MAMWetscav::run_impl(const double dt) { // Note: we are only updating interstitial aerosols. mam4::Tendencies tends = mam_coupling::interstitial_aerosols_tendencies_for_column(dry_aero_tends, icol); // shallow_convective_cloud_fraction - auto cldn_prev_step_icol = ekat::subview(cldn_prev_step, icol); + auto cldn_icol = ekat::subview(cldn, icol); ///shallow_convective_precipitation_production auto rprdsh_icol = ekat::subview(rprdsh, icol); // deep_convective_precipitation_production @@ -581,40 +556,28 @@ void MAMWetscav::run_impl(const double dt) { auto sh_frac_icol = ekat::subview(sh_frac, icol); // FIXME: what is this? - // diags.deep_convective_cloud_condensate auto icwmrdp_col = ekat::subview(icwmrdp, icol); - // diags.shallow_convective_cloud_condensate auto icwmrsh_icol = ekat::subview(icwmrsh, icol); - // diags.evaporation_of_falling_precipitation = auto evapr_icol = ekat::subview(evapr, icol); - // diags.stratiform_cloud_fraction = - auto cldst_icol = ekat::subview(cldst, icol); - - // deep_convective_cloud_fraction; - // auto dp_ccf_icol = ekat::subview(dp_ccf, icol); - // // shallow_convective_cloud_fraction; - // auto sh_ccf_icol = ekat::subview(sh_ccf, icol); - // total_convective_detrainment; + auto cldt_icol = ekat::subview(cldt, icol); + auto dlf_icol = ekat::subview(dlf, icol); - //aerosol_wet_deposition_interstitial; auto aerdepwetis_icol = ekat::subview(aerdepwetis, icol); - // diags.aerosol_wet_deposition_cloud_water; auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol);\ auto work_icol = ekat::subview(work, icol); - // auto qqcw_sav_icol = ekat::subview(qqcw_sav,icol); auto wet_diameter_icol = ekat::subview(wet_geometric_mean_diameter_i,icol); auto dry_diameter_icol = ekat::subview(dry_geometric_mean_diameter_i,icol); auto qaerwat_icol = ekat::subview(qaerwat,icol); auto wetdens_icol = ekat::subview(wetdens,icol); auto prain_icol = ekat::subview(prain,icol); - mam4::wetdep::aero_model_wetdep(team, atm, progs, tends, dt, // inputs - cldst_icol, cldn_prev_step_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, + cldt_icol, cldn_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, evapcsh_icol, dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, evapr_icol, dlf_icol, prain_icol, + // in/out wet_diameter_icol,dry_diameter_icol, qaerwat_icol, wetdens_icol, // output @@ -622,248 +585,6 @@ void MAMWetscav::run_impl(const double dt) { work_icol); }); // icol parallel_for loop - /* - call calc_sfc_flux(rprdsh(:ncol,:), state%pdel(:ncol,:), - rprdshsum(:ncol)) ! output the last argument call - calc_sfc_flux(rprddp(:ncol,:), state%pdel(:ncol,:), rprddpsum(:ncol)) ! - output the last argument call calc_sfc_flux(evapcsh(:ncol,:), - state%pdel(:ncol,:), evapcshsum(:ncol)) ! output the last argument call - calc_sfc_flux(evapcdp(:ncol,:), state%pdel(:ncol,:), evapcdpsum(:ncol)) ! - output the last argument - - ! initiate variables - qsrflx_mzaer2cnvpr(:,:,:) = 0.0_r8 - aerdepwetis(:,:) = 0.0_r8 - aerdepwetcw(:,:) = 0.0_r8 - qqcw_tmp(:,:) = 0.0_r8 - ! below-cloud scavcoef = 0.0 for cloud-borne species - scavcoefnv(:,:,0) = 0.0_r8 - ! resuspension goes to a different phase or mode - rtscavt_sv(:,:,:) = 0.0_r8 - - ! examine if there is precipitation falling from above in each grid - call examine_prec_exist ( ncol, state%pdel, & ! in - dep_inputs%prain, dep_inputs%cmfdqr,& ! in - dep_inputs%evapr, & ! in - isprx ) ! out - - ! calculate the mass-weighted sol_factic for coarse mode species - call set_f_act_coarse( ncol, & ! in - state%q, ptend%q, dt, & ! in - f_act_conv_coarse, f_act_conv_coarse_dust, & ! out - f_act_conv_coarse_nacl ) ! out - - mmode_loop_aa: do mtmp = 1, ntot_amode ! main loop over aerosol modes - - ! for mam4, do accum, aitken, pcarbon, then coarse - ! so change the order of 3 and 4 here - imode = mode_order_change(mtmp) - - ! loop over interstitial (1) and cloud-borne (2) forms - !BSINGH (09/12/2014):Do cloudborne first for unified convection scheme - so !that the resuspension of cloudborne can be saved then applied to - interstitial (RCE) lphase_loop_aa: do lphase = 2,1,-1 ! do cloudborne (2) - first then interstitial (1) - - if (lphase == 1) then ! interstial aerosol - call modal_aero_bcscavcoef_get( imode, ncol, isprx, dgnumwet, & - scavcoefnv(:,:,1), scavcoefnv(:,:,2) ) - endif - call define_act_frac ( lphase, imode, & ! in - sol_facti, sol_factic, sol_factb, f_act_conv) ! out - - ! REASTER 08/12/2015 - changed ordering (mass then number) for - prevap resuspend to coarse lspec_loop_aa: do lspec = 1, - nspec_amode(imode)+2 ! loop over number + chem constituents + water - - call index_ordering ( & - lspec, imode, lphase, & ! in - jaeronumb, jaeromass, jaerowater, & ! in - mm, jnv, jnummaswtr ) ! out - - if (mm <= 0 .or. jnummaswtr == jaerowater ) cycle ! by pass wet - aerosols - - ! mam_prevap_resusp_optcc values control the prevap_resusp - calculations in wetdepa_v2: ! 0 = no resuspension ! 130 = non-linear - resuspension of aerosol mass based on scavenged aerosol mass ! 230 = - non-linear resuspension of aerosol number based on raindrop number ! the - 130 thru 230 all use the new prevap_resusp code block in subr wetdepa_v2 - ! - mam_prevap_resusp_optcc = mam_prevap_resusp_no - - if ( jnummaswtr == jaeromass ) then ! dry mass - mam_prevap_resusp_optcc = mam_prevap_resusp_mass - elseif ( jnummaswtr == jaeronumb .and. lphase == 1 .and. imode == - modeptr_coarse ) then ! number mam_prevap_resusp_optcc = - mam_prevap_resusp_num endif - - ! set f_act_conv for interstitial (lphase=1) coarse mode species - ! for the convective in-cloud, we conceptually treat the coarse - dust and seasalt ! as being externally mixed, and apply ! f_act_conv = - f_act_conv_coarse_dust/nacl to dust/seasalt ! number and sulfate are - conceptually partitioned to the dust and seasalt ! on a mass basis, so the - f_act_conv for number and sulfate are ! mass-weighted averages of the - values used for dust/seasalt if ((lphase == 1) .and. (imode == - modeptr_coarse)) then f_act_conv = f_act_conv_coarse if (jnummaswtr == - jaeromass) then if (lmassptr_amode(lspec,imode) == - lptr_dust_a_amode(imode)) then f_act_conv = f_act_conv_coarse_dust elseif - (lmassptr_amode(lspec,imode) == lptr_nacl_a_amode(imode)) then f_act_conv = - f_act_conv_coarse_nacl endif endif endif - - lphase_jnmw_conditional: if (lphase == 1) then - ptend%lq(mm) = .true. - ! q_tmp reflects changes from modal_aero_calcsize and is the - "most current" q q_tmp(1:ncol,:) = state%q(1:ncol,:,mm) + - ptend%q(1:ncol,:,mm)*dt !Feed in the saved cloudborne mixing ratios from - phase 2 qqcw_in(:,:) = qqcw_sav(:,:,lspec) - - call wetdepa_v2( & - ncol, dt, state%pdel, & ! in dep_inputs%cmfdqr, - dep_inputs%evapc, dlf, dep_inputs%conicw, & ! in dep_inputs%prain, - dep_inputs%evapr, dep_inputs%totcond, & ! in dep_inputs%cldt, - dep_inputs%cldcu, & ! in dep_inputs%cldvcu, - dep_inputs%cldvst, & ! in sol_factb, sol_facti, - sol_factic, & ! in mam_prevap_resusp_optcc, - .false., scavcoefnv(:,:,jnv), f_act_conv, & ! in q_tmp, qqcw_in(:,:), & ! - in fracis(:,:,mm), dqdt_tmp, iscavt, & ! out - icscavt, isscavt, bcscavt, bsscavt, rcscavt, rsscavt ) ! - out - - ! resuspension goes to coarse mode - call calc_resusp_to_coarse( ncol, mm, & ! in - mmtoo_prevap_resusp, .true., & ! in - rcscavt, rsscavt, & ! in - dqdt_tmp, rtscavt_sv ) ! inout - - ptend%q(1:ncol,:,mm) = ptend%q(1:ncol,:,mm) + - dqdt_tmp(1:ncol,:) - - call outfld( trim(cnst_name(mm))//'WET', dqdt_tmp(:,:), pcols, - lchnk) call outfld( trim(cnst_name(mm))//'SIC', icscavt, pcols, lchnk) call - outfld( trim(cnst_name(mm))//'SIS', isscavt, pcols, lchnk) call outfld( - trim(cnst_name(mm))//'SBC', bcscavt, pcols, lchnk) call outfld( - trim(cnst_name(mm))//'SBS', bsscavt, pcols, lchnk) - - call calc_sfc_flux(dqdt_tmp(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx aerdepwetis(:ncol,mm) = sflx(:ncol) - - call calc_sfc_flux(icscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx sflxic = sflx - - call calc_sfc_flux(isscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name(mm))//'SFSIS', sflx, - pcols, lchnk) - - call calc_sfc_flux(bcscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name(mm))//'SFSBC', sflx, - pcols, lchnk) sflxbc = sflx - - call calc_sfc_flux(bsscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name(mm))//'SFSBS', sflx, - pcols, lchnk) - - ! here the prevap resuspension is in rcscavt & rsscavt and - column integral is written to history !BSINGH(09/15/2014):Following two - nested do-loops are new additions for unified convection - !BSINGH(09/15/2014):After these do-loops, code was added by - RCE, the comments by RCE are kept as it is call - calc_sfc_flux(rcscavt(:ncol,:), state%pdel(:ncol,:), sflx(:ncol)) ! output - sflx sflxec = sflx - - call calc_sfc_flux(rsscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name(mm))//'SFSES', sflx, - pcols, lchnk) - - ! apportion convective surface fluxes to deep and shallow conv - ! this could be done more accurately in subr wetdepa - ! since deep and shallow rarely occur simultaneously, and - these ! fields are just diagnostics, this approximate method is adequate - ! only do this for interstitial aerosol, because conv clouds - to not ! affect the stratiform-cloudborne aerosol call - apportion_sfc_flux_deep ( ncol, & ! in - rprddpsum,rprdshsum,evapcdpsum,evapcshsum,& ! in - sflxbc, sflxec, & ! in - sflxbcdp, sflxecdp ) ! out - - call outfld( trim(cnst_name(mm))//'SFSBD', sflxbcdp, pcols, - lchnk) ! when ma_convproc_intr is used, convective in-cloud wet removal is - done there ! the convective (total and deep) precip-evap-resuspension - includes in- and below-cloud ! contributions, so pass the below-cloud - contribution to ma_convproc_intr qsrflx_mzaer2cnvpr(1:ncol,mm,1) = sflxec( - 1:ncol) qsrflx_mzaer2cnvpr(1:ncol,mm,2) = sflxecdp(1:ncol) - - elseif (lphase == 2) then lphase_jnmw_conditional - ! There is no cloud-borne aerosol water in the model, so this - code block ! should NEVER execute for lspec = nspec_amode(m)+1 (i.e., - jnummaswtr = 2). ! The code only worked because the "do lspec" loop cycles - when lspec = nspec_amode(m)+1, ! but that does not make the code correct. - fldcw => qqcw_get_field(pbuf,mm,lchnk) - qqcw_sav(1:ncol,:,lspec) = fldcw(1:ncol,:) !RCE 2012/01/12 - - ! FIXME: Not sure if this is a bug or not as qqcw_tmp seem - different ! from the previous call and qqcw_tmp is always zero. May need ! - further check. - Shuaiqi Tang in refactoring for MAM4xx call wetdepa_v2( & - ncol, dt, state%pdel, & ! in dep_inputs%cmfdqr, - dep_inputs%evapc, dlf, dep_inputs%conicw, & ! in dep_inputs%prain, - dep_inputs%evapr, dep_inputs%totcond, & ! in dep_inputs%cldt, - dep_inputs%cldcu, & ! in dep_inputs%cldvcu, - dep_inputs%cldvst, & ! in sol_factb, sol_facti, - sol_factic, & ! in mam_prevap_resusp_optcc, - .true., scavcoefnv(:,:,jnv), f_act_conv, & ! in fldcw, qqcw_tmp, & ! in - fracis_cw, dqdt_tmp, iscavt, & ! out icscavt, isscavt, - bcscavt, bsscavt, rcscavt, rsscavt ) ! out - - ! resuspension goes to coarse mode - call calc_resusp_to_coarse( ncol, mm, & ! in - mmtoo_prevap_resusp, .false., & ! in - rcscavt, rsscavt, & ! in - dqdt_tmp, rtscavt_sv ) ! inout - - fldcw(1:ncol,:) = fldcw(1:ncol,:) + dqdt_tmp(1:ncol,:) * dt - - call calc_sfc_flux(dqdt_tmp(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFWET', - sflx, pcols, lchnk) aerdepwetcw(:ncol,mm) = sflx(:ncol) - - call calc_sfc_flux(icscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSIC', - sflx, pcols, lchnk) - - call calc_sfc_flux(isscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSIS', - sflx, pcols, lchnk) - - call calc_sfc_flux(bcscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSBC', - sflx, pcols, lchnk) - - call calc_sfc_flux(bsscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSBS', - sflx, pcols, lchnk) - - call calc_sfc_flux(rcscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSEC', - sflx, pcols, lchnk) - - call calc_sfc_flux(rsscavt(:ncol,:), state%pdel(:ncol,:), - sflx(:ncol)) ! output sflx call outfld( trim(cnst_name_cw(mm))//'SFSES', - sflx, pcols, lchnk) - - endif lphase_jnmw_conditional - - enddo lspec_loop_aa ! lspec = 1, nspec_amode(m)+2 - enddo lphase_loop_aa ! lphase = 1, 2 - enddo mmode_loop_aa ! m = 1, ntot_amode - - ! if the user has specified prescribed aerosol dep fluxes then - ! do not set cam_out dep fluxes according to the prognostic aerosols - if (.not.aerodep_flx_prescribed()) then - call set_srf_wetdep(aerdepwetis, aerdepwetcw, cam_out) - endif - - call wetdep_inputs_unset(dep_inputs) - */ std::cout << "End of wetscav run" << std::endl; } From 711199bac4b1870f284fcc6c0029fda6d9d09ea9 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Thu, 23 May 2024 14:26:34 -0600 Subject: [PATCH 16/71] wet_scav - updating code after rebase. --- .../physics/mam/eamxx_mam_wetscav_process_interface.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 9ac0720d8ab..a3cc31338d8 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -39,13 +39,8 @@ 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; - q_unit.set_string("kg/kg"); - // FIXME: units of tendencies; check units auto dqdt_unit = kg / kg / s; - dqdt_unit.set_string("kg/kg/t"); - auto n_unit = 1 / kg; // units of number mixing ratios of tracers - n_unit.set_string("#/kg"); m_grid = grids_manager->get_grid("Physics"); const auto &grid_name = m_grid->name(); @@ -115,7 +110,7 @@ void MAMWetscav::set_grids( // add_field( // "qme", scalar3d_mid, kg / kg / s, // grid_name); // net condensation/evaporation of cloud water [kg/kg/s] - add_field("prain", scalar3d_mid, kg / kg / s, + add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // stratiform rain production rate [kg/kg/s] add_field( "evapr", scalar3d_mid, kg / kg / s, @@ -489,7 +484,7 @@ void MAMWetscav::run_impl(const double dt) { auto cldn = get_field_out("cldn").get_view< Real **>(); // where is cldt_prev_step used? - auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? + // auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? auto cldt = get_field_out("cldt").get_view< Real **>();//?? auto evapr = get_field_out("evapr").get_view< Real **>(); auto rprdsh = get_field_out("rprdsh").get_view(); // rain production, shallow From 1b8052812bc2fa34c0ee02b898a0bd80f13fbc97 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Thu, 23 May 2024 16:06:35 -0600 Subject: [PATCH 17/71] wet_scav - Adding missing variables in input file. --- components/eamxx/tests/single-process/mam/wet_scav/input.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index c73e2dbaa9a..02290fed670 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -27,11 +27,13 @@ initial_conditions: Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} cldn_prev_step: 0.5 + cldn: 0.5 rprdsh: 1e-5 rprddp: 1e-5 evapcsh: 1e-5 evapcdp: 1e-5 cldt_prev_step: 1e-5 + cldt: 1e-5 cldst: 1e-5 qme: 1e-5 prain: 1e-5 From 8ec139cc95a0440ab6bd43ac896d36dba3b50b4c Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 09:04:48 -0600 Subject: [PATCH 18/71] wet_scav - Moving 'aerdepwetis' and 'aerdepwetcw' to the field manager and adding them to the output.yaml file. --- .../eamxx_mam_wetscav_process_interface.cpp | 33 ++++++++----------- .../single-process/mam/wet_scav/output.yaml | 6 ++-- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index a3cc31338d8..5542ff23d70 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -47,7 +47,8 @@ void MAMWetscav::set_grids( ncol_ = m_grid->get_num_local_dofs(); // Number of columns on this rank nlev_ = m_grid->get_num_vertical_levels(); // Number of levels per column - const int nmodes = mam4::AeroConfig::num_modes(); + const int nmodes = mam4::AeroConfig::num_modes(); // Number of modes + constexpr int pcnst = mam4::aero_model::pcnst; // layout for 3D (2d horiz X 1d vertical) variables at level midpoints/interfaces FieldLayout scalar3d_mid = m_grid->get_3d_scalar_layout(true); @@ -59,7 +60,8 @@ void MAMWetscav::set_grids( // layout for 3D (ncol, nmodes, nlevs) FieldLayout scalar3d_mid_nmodes = m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); - // FieldLayout scalar2d = m_grid->get_2d_scalar_layout + // layout for 2D (ncol, pcnst) + FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "pcnst"); // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -293,13 +295,12 @@ void MAMWetscav::set_grids( // grid_name); // // add_field("sh_ccf", scalar3d_mid, n_unit, // grid_name); // - - // FIXME: do we need to write aerdepwetis and aerdepwetcw? - // add_field("aerdepwetis", scalar3d_mid, n_unit, - // grid_name); // - - // add_field("aerdepwetcw", scalar3d_mid, n_unit, - // grid_name); // + // aerosol wet deposition (interstitial) + add_field("aerdepwetis", scalar2d_pconst, kg/m2/s, + grid_name); // + // aerosol wet deposition (cloud water) + add_field("aerdepwetcw", scalar2d_pconst, kg/m2/s, + grid_name); // } // ========================================================================================= @@ -451,14 +452,9 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_aero_); // wetdep - constexpr int pcnst = mam4::aero_model::pcnst; + const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); - // FIXME: do I need to move these variables to FM? - // aerosol wet deposition (interstitial) [kg/m2/s] - aerdepwetis_ = view_2d("aerdepwetis", ncol_, pcnst); - // aerosol wet deposition (cloud water) [kg/m2/s] - aerdepwetcw_ = view_2d("aerdepwetcw", ncol_, pcnst); } // ========================================================================================= @@ -507,12 +503,9 @@ void MAMWetscav::run_impl(const double dt) { auto prain = get_field_out("prain") .get_view(); // ?? - - const auto aerdepwetis = aerdepwetis_;// - const auto aerdepwetcw = aerdepwetcw_;// // outputs - // const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); - // const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); + const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); + const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); const auto wet_geometric_mean_diameter_i = get_field_out("dgnumwet").get_view(); const auto dry_geometric_mean_diameter_i = get_field_out("dgncur_a").get_view(); diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index 3dc34fdac75..c63885d069d 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -5,10 +5,10 @@ Averaging Type: Instant Fields: Physics: Field Names: - - T_mid - + - aerdepwetis + - aerdepwetcw output_control: - Frequency: 2 + Frequency: 2 frequency_units: nsteps MPI Ranks in Filename: true ... From 7ced79ab1557e90210d36ec1997be3037e0019d7 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 09:11:05 -0600 Subject: [PATCH 19/71] wet_scav - Removing headers that are part of mam_coupling and unused views. --- .../mam/eamxx_mam_wetscav_process_interface.hpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index c09a789b6c7..6f15752953c 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -7,15 +7,6 @@ // For declaring wetscav class derived from atm process class #include "share/atm_process/atmosphere_process.hpp" -// For MAM4 processes -#include - -// For MAM4 calcsize process (FIXME:should we include it in mam4 or mam_coupling??) -#include - -// For wetdep processes -#include - // For component name #include @@ -182,7 +173,6 @@ class MAMWetscav : public scream::AtmosphereProcess { mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_; mam_coupling::Buffer buffer_; - mam_coupling::view_2d aerdepwetis_, aerdepwetcw_; std::shared_ptr m_grid; }; // class MAMWetscav From 6b6a79d7be4526d6d7a1376d4faddc4d4ef96c36 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 09:17:16 -0600 Subject: [PATCH 20/71] wet_scav - Adding output fields. --- .../eamxx/tests/single-process/mam/wet_scav/output.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index c63885d069d..e9ad22d7119 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -7,6 +7,10 @@ Fields: Field Names: - aerdepwetis - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat output_control: Frequency: 2 frequency_units: nsteps From d39659a7d960f22fcc70b4f227806b16c83e92d0 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 09:54:48 -0600 Subject: [PATCH 21/71] wet_scav - Adding outputs and running test for 3 steps. --- .../single-process/mam/wet_scav/input.yaml | 8 +-- .../single-process/mam/wet_scav/output.yaml | 52 ++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index 02290fed670..698966f0559 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -6,7 +6,7 @@ driver_options: time_stepping: time_step: ${ATM_TIME_STEP} run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX - number_of_steps: ${NUM_STEPS} + number_of_steps: 3 atmosphere_processes: atm_procs_list: [mam4_wetscav] @@ -26,8 +26,8 @@ grids_manager: initial_conditions: Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} - cldn_prev_step: 0.5 - cldn: 0.5 + cldn_prev_step: 0.5 + cldn: 0.5 rprdsh: 1e-5 rprddp: 1e-5 evapcsh: 1e-5 @@ -35,7 +35,7 @@ initial_conditions: cldt_prev_step: 1e-5 cldt: 1e-5 cldst: 1e-5 - qme: 1e-5 + qme: 1e-5 prain: 1e-5 evapr: 1e-5 icwmrdp: 1e-5 diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index e9ad22d7119..4912603943d 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -11,8 +11,58 @@ Fields: - dgncur_a - wetdens - qaerwat + - ptend_bc_a1 + - ptend_bc_a3 + - ptend_bc_a4 + - ptend_dst_a1 + - ptend_dst_a3 + - ptend_mom_a1 + - ptend_mom_a2 + - ptend_mom_a3 + - ptend_mom_a4 + - ptend_nacl_a1 + - ptend_nacl_a2 + - ptend_nacl_a3 + - ptend_num_a1 + - ptend_num_a2 + - ptend_num_a3 + - ptend_num_a4 + - ptend_pom_a1 + - ptend_pom_a3 + - ptend_pom_a4 + - ptend_so4_a1 + - ptend_so4_a2 + - ptend_so4_a3 + - ptend_soa_a1 + - ptend_soa_a2 + - ptend_soa_a3 + - bc_c1 + - bc_c3 + - bc_c4 + - dst_c1 + - dst_c3 + - mom_c1 + - mom_c2 + - mom_c3 + - mom_c4 + - nacl_c1 + - nacl_c2 + - nacl_c3 + - num_c1 + - num_c2 + - num_c3 + - num_c4 + - pom_c1 + - pom_c3 + - pom_c4 + - so4_c1 + - so4_c2 + - so4_c3 + - soa_c1 + - soa_c2 + - soa_c3 output_control: - Frequency: 2 + Frequency: 1 frequency_units: nsteps MPI Ranks in Filename: true ... From 6e81baa54c22b4f6d4d8ebed15ada3fb6882f7ed Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 10:03:54 -0600 Subject: [PATCH 22/71] wet_sav- removin unused input. --- components/eamxx/tests/single-process/mam/wet_scav/input.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index 698966f0559..bf7fe8e5380 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -54,7 +54,6 @@ initial_conditions: dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] - pbuf: 1e-5 # cloud-borne aerosols dgncur_a: 1e-5 # aerosol particle diameter [m] wetdens: 1e-5 # wet aerosol density [kg/m3] qaerwat: 1e-5 # aerosol water [kg/kg] From 5b0b24399625a6f9f5c25e4537db031e8e512d00 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 10:05:59 -0600 Subject: [PATCH 23/71] wet_sav - Adding FIXME. --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 5542ff23d70..037c6d17acb 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -150,7 +150,7 @@ void MAMWetscav::set_grids( // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- - + // FIXME: we have not added code to update the surface fluxes. // -- surface fluxes (input/outpts) for the coupler's cam_out data struture // for the land model static constexpr auto m2 = m * m; From 6e553176938fff232725166274a5b2745bbe416c Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 10:11:42 -0600 Subject: [PATCH 24/71] wet_sav - Updating comments. --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 037c6d17acb..418e8b3bf26 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -11,8 +11,6 @@ Future work: Wirte comments write in/outs for all variables clearly - - */ namespace scream { @@ -474,9 +472,6 @@ void MAMWetscav::run_impl(const double dt) { // inputs/outputs auto dlf = get_field_out("dlf").get_view(); - // auto dp_ccf = get_field_out("dp_ccf").get_view(); - // auto sh_ccf = get_field_out("sh_ccf").get_view(); - auto cldn = get_field_out("cldn").get_view< Real **>(); // where is cldt_prev_step used? @@ -496,13 +491,12 @@ void MAMWetscav::run_impl(const double dt) { .get_view(); // Deep convective cloud fraction [fraction] auto icwmrsh = get_field_out("icwmrsh") - .get_view(); // ?? - + .get_view(); //in cloud water mixing ratio, shallow convection auto icwmrdp = get_field_out("icwmrdp") - .get_view(); // ?? + .get_view(); // in cloud water mixing ratio, deep convection auto prain = get_field_out("prain") - .get_view(); // ?? + .get_view(); // stratiform rain production rate // outputs const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); From 8cd04d2c33b50f0a74d1886881a38faef970c391 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 10:25:10 -0600 Subject: [PATCH 25/71] wet_scav - Setting Frequency=2 --- components/eamxx/tests/single-process/mam/wet_scav/input.yaml | 2 +- components/eamxx/tests/single-process/mam/wet_scav/output.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index bf7fe8e5380..c8def99dd62 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -6,7 +6,7 @@ driver_options: time_stepping: time_step: ${ATM_TIME_STEP} run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX - number_of_steps: 3 + number_of_steps: ${NUM_STEPS} atmosphere_processes: atm_procs_list: [mam4_wetscav] diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index 4912603943d..13493a00248 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -62,7 +62,7 @@ Fields: - soa_c2 - soa_c3 output_control: - Frequency: 1 + Frequency: 2 frequency_units: nsteps MPI Ranks in Filename: true ... From e91b2e25fe4ccb4769700025038efbf791707916 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 11:40:17 -0600 Subject: [PATCH 26/71] wet_scav - Adding multi-process test for mam4_wetsav. --- .../dynamics_physics/CMakeLists.txt | 2 +- .../CMakeLists.txt | 95 ++++++++++ .../input.yaml | 107 ++++++++++++ .../output.yaml | 164 ++++++++++++++++++ 4 files changed, 367 insertions(+), 1 deletion(-) create mode 100644 components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/CMakeLists.txt create mode 100644 components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml create mode 100644 components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml diff --git a/components/eamxx/tests/multi-process/dynamics_physics/CMakeLists.txt b/components/eamxx/tests/multi-process/dynamics_physics/CMakeLists.txt index 64ac2187c28..b9b58f2fe86 100644 --- a/components/eamxx/tests/multi-process/dynamics_physics/CMakeLists.txt +++ b/components/eamxx/tests/multi-process/dynamics_physics/CMakeLists.txt @@ -13,7 +13,7 @@ if (SCREAM_DOUBLE_PRECISION) # initial conditions. #add_subdirectory(homme_mam4xx_pg2) add_subdirectory(mam/homme_shoc_cld_p3_mam_optics_rrtmgp) + add_subdirectory(mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav) endif() endif() endif() - diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/CMakeLists.txt b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/CMakeLists.txt new file mode 100644 index 00000000000..41a915b9265 --- /dev/null +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/CMakeLists.txt @@ -0,0 +1,95 @@ +include (ScreamUtils) + +set (TEST_BASE_NAME homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav) +set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files) + +# Get or create the dynamics lib +# HOMME_TARGET NP PLEV QSIZE_D +CreateDynamicsLib("theta-l_kokkos" 4 72 41) + +# Create the test +CreateADUnitTest(${TEST_BASE_NAME} + LIBS cld_fraction shoc spa p3 scream_rrtmgp mam ${dynLibName} + LABELS dynamics shoc cld p3 rrtmgp physics mam4_wetscav + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME} +) + +# Set AD configurable options +set (ATM_TIME_STEP 1800) +SetVarDependingOnTestSize(NUM_STEPS 2 4 48) # 1h 2h 24h +set (RUN_T0 2021-10-12-45000) + +# Determine num subcycles needed to keep shoc dt<=300s +set (SHOC_MAX_DT 300) +math (EXPR MAC_MIC_SUBCYCLES "(${ATM_TIME_STEP} + ${SHOC_MAX_DT} - 1) / ${SHOC_MAX_DT}") + +## Copy (and configure) yaml files needed by tests +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml + ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml + ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) + +# Set homme's test options, so that we can configure the namelist correctly +# Discretization/algorithm settings +set (HOMME_TEST_NE 2) +set (HOMME_TEST_LIM 9) +set (HOMME_TEST_REMAP_FACTOR 3) +set (HOMME_TEST_TRACERS_FACTOR 1) +set (HOMME_TEST_TIME_STEP 300) +set (HOMME_THETA_FORM 1) +set (HOMME_TTYPE 5) +set (HOMME_SE_FTYPE 0) +set (HOMME_TEST_TRANSPORT_ALG 0) +set (HOMME_TEST_CUBED_SPHERE_MAP 0) + +# Hyperviscosity settings +set (HOMME_TEST_HVSCALING 0) +set (HOMME_TEST_HVS 1) +set (HOMME_TEST_HVS_TOM 0) +set (HOMME_TEST_HVS_Q 1) + +set (HOMME_TEST_NU 7e15) +set (HOMME_TEST_NUDIV 1e15) +set (HOMME_TEST_NUTOP 2.5e5) + +# Testcase settings +set (HOMME_TEST_MOISTURE notdry) +set (HOMME_THETA_HY_MODE true) + +# Vert coord settings +set (HOMME_TEST_VCOORD_INT_FILE acme-72i.ascii) +set (HOMME_TEST_VCOORD_MID_FILE acme-72m.ascii) + +# Configure the namelist into the test directory +configure_file(${SCREAM_SRC_DIR}/dynamics/homme/tests/theta.nl + ${CMAKE_CURRENT_BINARY_DIR}/namelist.nl) + +# Ensure test input files are present in the data dir +set (TEST_INPUT_FILES + scream/init/spa_init_ne2np4.nc + scream/init/spa_file_unified_and_complete_ne2np4L72_20231222.nc + scream/init/${EAMxx_tests_IC_FILE_72lev} + cam/topo/${EAMxx_tests_TOPO_FILE} +) +foreach (file IN ITEMS ${TEST_INPUT_FILES}) + GetInputFile(${file}) +endforeach() + +# Compare output files produced by npX tests, to ensure they are bfb +include (CompareNCFiles) + +CompareNCFilesFamilyMpi ( + TEST_BASE_NAME ${TEST_BASE_NAME} + FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x${NUM_STEPS}.npMPIRANKS.${RUN_T0}.nc + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + LABELS dynamics physics shoc cld p3 rrtmgp spa mam4_wetscav + META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_npMPIRANKS_omp1 +) + +if (SCREAM_ENABLE_BASELINE_TESTS) + # Compare one of the output files with the baselines. + # Note: one is enough, since we already check that np1 is BFB with npX + set (OUT_FILE ${TEST_BASE_NAME}_output.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc) + CreateBaselineTest(${TEST_BASE_NAME} ${TEST_RANK_END} ${OUT_FILE} ${FIXTURES_BASE_NAME}) +endif() diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml new file mode 100644 index 00000000000..bfbec956d85 --- /dev/null +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml @@ -0,0 +1,107 @@ +%YAML 1.1 +--- +driver_options: + atmosphere_dag_verbosity_level: 5 + +time_stepping: + time_step: ${ATM_TIME_STEP} + run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX + number_of_steps: ${NUM_STEPS} + +initial_conditions: + Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + surf_evap: 0.0 + surf_sens_flux: 0.0 + precip_liq_surf_mass: 0.0 + precip_ice_surf_mass: 0.0 + cldn: 0.5 + rprdsh: 1e-5 + rprddp: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + cldt: 1e-5 + prain: 1e-5 + evapr: 1e-5 + icwmrdp: 1e-5 + icwmrsh: 1e-5 + rprddp: 1e-5 + rprdsh: 1e-5 + sh_frac: 1e-5 + dp_frac: 1e-5 + evapcsh: 1e-5 + evapcdp: 1e-5 + bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + dgncur_a: 1e-5 # aerosol particle diameter [m] + wetdens: 1e-5 # wet aerosol density [kg/m3] + qaerwat: 1e-5 # aerosol water [kg/kg] + dgnumwet: 1e-5 # wet aerosol diameter [m] + fracis: 1e-5 # fraction of transported species that are insoluble [fraction] + cldfrac_tot: 0.5 + pbl_height: 25.0 + phis : 0.1 + dlf : 0.0 + dp_ccf : 0.0 + sh_ccf : 0.0 + +atmosphere_processes: + atm_procs_list: [homme,physics] + schedule_type: Sequential + homme: + Moisture: moist + physics: + atm_procs_list: [mac_aero_mic,rrtmgp] + schedule_type: Sequential + Type: Group + mac_aero_mic: + atm_procs_list: [shoc,CldFraction,spa,p3,mam4_wetscav] + Type: Group + schedule_type: Sequential + number_of_subcycles: ${MAC_MIC_SUBCYCLES} + spa: + spa_data_file: ${SCREAM_DATA_DIR}/init/spa_file_unified_and_complete_ne2np4L72_20231222.nc + p3: + max_total_ni: 740.0e3 + shoc: + check_flux_state_consistency: true + lambda_low: 0.001 + lambda_high: 0.04 + lambda_slope: 2.65 + lambda_thresh: 0.02 + thl2tune: 1.0 + qw2tune: 1.0 + qwthl2tune: 1.0 + w2tune: 1.0 + length_fac: 0.5 + c_diag_3rd_mom: 7.0 + Ckh: 0.1 + Ckm: 0.1 + rrtmgp: + column_chunk_size: 123 + active_gases: ["h2o", "co2", "o3", "n2o", "co" , "ch4", "o2", "n2"] + rrtmgp_coefficients_file_sw: ${SCREAM_DATA_DIR}/init/rrtmgp-data-sw-g112-210809.nc + rrtmgp_coefficients_file_lw: ${SCREAM_DATA_DIR}/init/rrtmgp-data-lw-g128-210809.nc + rrtmgp_cloud_optics_file_sw: ${SCREAM_DATA_DIR}/init/rrtmgp-cloud-optics-coeffs-sw.nc + rrtmgp_cloud_optics_file_lw: ${SCREAM_DATA_DIR}/init/rrtmgp-cloud-optics-coeffs-lw.nc + mam_wetscav: + number_of_subcycles: ${NUM_SUBCYCLES} + compute_tendencies: [all] + lambda_low: 0.001 + +grids_manager: + Type: Homme + physics_grid_type: GLL + dynamics_namelist_file_name: namelist.nl + vertical_coordinate_filename: IC_FILE + +# The parameters for I/O control +Scorpio: + output_yaml_files: ["output.yaml"] +... diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml new file mode 100644 index 00000000000..f85225d1274 --- /dev/null +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml @@ -0,0 +1,164 @@ +%YAML 1.1 +--- +filename_prefix: homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav_output +Averaging Type: Instant +Max Snapshots Per File: 1 +Fields: + Physics GLL: + Field Names: + # HOMME + - ps + - pseudo_density + - omega + - p_int + - p_mid + - pseudo_density_dry + - p_dry_int + - p_dry_mid + # SHOC + - cldfrac_liq + - eddy_diff_mom + - sgs_buoy_flux + - tke + - inv_qc_relvar + - pbl_height + # CLD + - cldfrac_ice + - cldfrac_tot + # SPA + - aero_g_sw + - aero_ssa_sw + - aero_tau_lw + - aero_tau_sw + - nccn + # P3 + - bm + - nc + - ni + - nr + - qi + - qm + - qr + - T_prev_micro_step + - qv_prev_micro_step + - eff_radius_qc + - eff_radius_qi + - eff_radius_qr + - micro_liq_ice_exchange + - micro_vap_ice_exchange + - micro_vap_liq_exchange + - precip_ice_surf_mass + - precip_liq_surf_mass + - rainfrac + # SHOC + HOMME + - horiz_winds + # SHOC + P3 + - qc + - qv + # SHOC + P3 + RRTMGP + HOMME + - T_mid + # RRTMGP + - sfc_alb_dif_nir + - sfc_alb_dif_vis + - sfc_alb_dir_nir + - sfc_alb_dir_vis + - LW_flux_dn + - LW_flux_up + - SW_flux_dn + - SW_flux_dn_dir + - SW_flux_up + - rad_heating_pdel + - sfc_flux_lw_dn + - sfc_flux_sw_net + # Diagnostics + - T_mid_at_lev_2 + - T_mid_at_model_top + - T_mid_at_model_bot + - T_mid_at_500mb + - T_mid_at_500hPa + - T_mid_at_50000Pa + - PotentialTemperature + - AtmosphereDensity + - Exner + - VirtualTemperature + - z_int + - geopotential_int_at_lev_2 + - z_mid_at_500mb + - geopotential_mid + - dz + - DryStaticEnergy + - SeaLevelPressure + - LiqWaterPath + - IceWaterPath + - VapWaterPath + - RainWaterPath + - RimeWaterPath + - ShortwaveCloudForcing + - LongwaveCloudForcing + - RelativeHumidity + - ZonalVapFlux + - MeridionalVapFlux + - PotentialTemperature_at_model_top + - PotentialTemperature_at_500mb + # MAM4_WETSCAV + - aerdepwetis + - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat + - ptend_bc_a1 + - ptend_bc_a3 + - ptend_bc_a4 + - ptend_dst_a1 + - ptend_dst_a3 + - ptend_mom_a1 + - ptend_mom_a2 + - ptend_mom_a3 + - ptend_mom_a4 + - ptend_nacl_a1 + - ptend_nacl_a2 + - ptend_nacl_a3 + - ptend_num_a1 + - ptend_num_a2 + - ptend_num_a3 + - ptend_num_a4 + - ptend_pom_a1 + - ptend_pom_a3 + - ptend_pom_a4 + - ptend_so4_a1 + - ptend_so4_a2 + - ptend_so4_a3 + - ptend_soa_a1 + - ptend_soa_a2 + - ptend_soa_a3 + - bc_c1 + - bc_c3 + - bc_c4 + - dst_c1 + - dst_c3 + - mom_c1 + - mom_c2 + - mom_c3 + - mom_c4 + - nacl_c1 + - nacl_c2 + - nacl_c3 + - num_c1 + - num_c2 + - num_c3 + - num_c4 + - pom_c1 + - pom_c3 + - pom_c4 + - so4_c1 + - so4_c2 + - so4_c3 + - soa_c1 + - soa_c2 + - soa_c3 + +output_control: + Frequency: ${NUM_STEPS} + frequency_units: nsteps +... From 2570f0613d383e2bfad5f375dfae29093651dfe0 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 27 May 2024 13:11:10 -0600 Subject: [PATCH 27/71] wet_sav - Adding wetscav to namelist. --- cime_config/tests.py | 1 + .../cime_config/namelist_defaults_scream.xml | 62 +++++++++++++++++++ .../scream/mam4xx/wetscav/shell_commands | 7 +++ 3 files changed, 70 insertions(+) create mode 100644 components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands diff --git a/cime_config/tests.py b/cime_config/tests.py index 06c16ca176c..b4fb91cc5ee 100644 --- a/cime_config/tests.py +++ b/cime_config/tests.py @@ -724,6 +724,7 @@ "tests" : ( "SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-optics", "SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-aci", + "SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-wetscav", ) }, diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 50188236e4e..66036956f92 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -261,6 +261,10 @@ be lost if SCREAM_HACK_XML is not enabled. ${DIN_LOC_ROOT}/atm/scream/mam4xx/physprops/poly_rrtmg_c20240206.nc + + + + @@ -530,6 +534,64 @@ be lost if SCREAM_HACK_XML is not enabled. 0 0.001 900.0 + + + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 0.5 + 25.0 + 0.1 + 0.0 + 0.0 + 0.0 diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands new file mode 100644 index 00000000000..821feb10b7d --- /dev/null +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands @@ -0,0 +1,7 @@ + +#Default scream has 10 tracers, MAM4xx adds another 31 making a total of 41 tracer +#Set total number of tracers to 41. We are using append here as last entry wins while parsing xml options +./xmlchange --append SCREAM_CMAKE_OPTIONS="SCREAM_NUM_TRACERS 41" + +$CIMEROOT/../components/eamxx/scripts/atmchange initial_conditions::Filename='$DIN_LOC_ROOT/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc' -b +$CIMEROOT/../components/eamxx/scripts/atmchange mac_aero_mic::atm_procs_list="tms,shoc,cldFraction,spa,p3,mam4_wetscav" -b From 7b1471db26a6c0c29d4a861b82f9d29bbbc13a0c Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Sat, 1 Jun 2024 09:36:13 -0600 Subject: [PATCH 28/71] wet_scav - Removing initial values of pbl_height and phis from namelist_defaults_scream.xml. Upgrading MAM4xx. --- components/eamxx/cime_config/namelist_defaults_scream.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 66036956f92..79fcc64f384 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -587,8 +587,6 @@ be lost if SCREAM_HACK_XML is not enabled. 1e-5 1e-5 0.5 - 25.0 - 0.1 0.0 0.0 0.0 From 25d4a916f9778707662c7d17286cacbf09eec65d Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Sat, 1 Jun 2024 12:07:03 -0600 Subject: [PATCH 29/71] wet_scav - Adding line in CMakeLists. --- .../eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt index dbddf4d26e2..0624c8ed202 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt +++ b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt @@ -7,7 +7,8 @@ CreateADUnitTest(${TEST_BASE_NAME} LABELS mam4_wetscav physics LIBS mam MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} -) + FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME} + ) # Set AD configurable options SetVarDependingOnTestSize(NUM_STEPS 2 4 6) From 3e6bf35a2bb579a68c4e9a69fd4038e81ed38094 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Sun, 2 Jun 2024 10:08:25 -0600 Subject: [PATCH 30/71] wet_scav - Update interstitial aerosol state. --- .../eamxx_mam_wetscav_process_interface.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 418e8b3bf26..0fa9d1d4f25 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -459,8 +459,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { void MAMWetscav::run_impl(const double dt) { const auto scan_policy = ekat::ExeSpaceUtils< KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); - - printf("Working on wet_sav \n"); // preprocess input -- needs a scan for the calculation of all variables // needed by this process or setting up MAM4xx classes and their objects Kokkos::parallel_for("preprocess", scan_policy, preprocess_); @@ -509,6 +507,9 @@ void MAMWetscav::run_impl(const double dt) { const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); + // Making a local copy of 'nlev_' because we cannot use a member of a class inside a parallel_for. + const int nlev= nlev_; + // loop over atmosphere columns and compute aerosol particle size Kokkos::parallel_for( policy, KOKKOS_LAMBDA(const ThreadTeam &team) { @@ -565,9 +566,20 @@ void MAMWetscav::run_impl(const double dt) { // output aerdepwetis_icol, aerdepwetcw_icol, work_icol); + team.team_barrier(); + // update interstitial aerosol state + Kokkos::parallel_for(Kokkos::TeamVectorRange(team, nlev), [&](int kk) { + for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { + for(int a = 0; a < mam4::num_species_mode(m); ++a) { + const auto q_aero_i = progs.q_aero_i[m][a]; + const auto tends_q_aero_i =tends.q_aero_i[m][a]; + q_aero_i(kk) += tends_q_aero_i(kk) * dt; + } + } + }); + }); // icol parallel_for loop - std::cout << "End of wetscav run" << std::endl; } // ========================================================================================= From a55b7a78144ca774328f526f7119975aa61a5986 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Mon, 3 Jun 2024 19:54:35 -0700 Subject: [PATCH 31/71] A working CIME case with wetscav in the process list at the right place --- .../testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands index 821feb10b7d..f0e96c41398 100644 --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands @@ -4,4 +4,4 @@ ./xmlchange --append SCREAM_CMAKE_OPTIONS="SCREAM_NUM_TRACERS 41" $CIMEROOT/../components/eamxx/scripts/atmchange initial_conditions::Filename='$DIN_LOC_ROOT/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc' -b -$CIMEROOT/../components/eamxx/scripts/atmchange mac_aero_mic::atm_procs_list="tms,shoc,cldFraction,spa,p3,mam4_wetscav" -b +$CIMEROOT/../components/eamxx/scripts/atmchange physics::atm_procs_list="mac_aero_mic,mam4_wetscav,rrtmgp" -b From 7299556aab7b1bab086632ed9f7ee741b526e383 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Tue, 4 Jun 2024 14:09:48 -0700 Subject: [PATCH 32/71] Fixes single process test --- .../mam/wet_scav/CMakeLists.txt | 20 +++--- .../mam/wet_scav/mam4_wetscav_standalone.cpp | 69 ------------------- .../single-process/mam/wet_scav/output.yaml | 3 +- 3 files changed, 9 insertions(+), 83 deletions(-) delete mode 100644 components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp diff --git a/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt index 0624c8ed202..3881df3e059 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt +++ b/components/eamxx/tests/single-process/mam/wet_scav/CMakeLists.txt @@ -2,38 +2,34 @@ include (ScreamUtils) set (TEST_BASE_NAME mam4_wetscav_standalone) set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files) + # Create the test CreateADUnitTest(${TEST_BASE_NAME} LABELS mam4_wetscav physics LIBS mam MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME} - ) +) # Set AD configurable options -SetVarDependingOnTestSize(NUM_STEPS 2 4 6) +SetVarDependingOnTestSize(NUM_STEPS 2 5 48) set (ATM_TIME_STEP 1800) set (RUN_T0 2021-10-12-45000) +# Ensure test input files are present in the data dir +GetInputFile(scream/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) -# Ensure test input files are present in the data dir -set (TEST_INPUT_FILES - scream/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc -) -foreach (file IN ITEMS ${TEST_INPUT_FILES}) - GetInputFile(${file}) -endforeach() - # Compare output files produced by npX tests, to ensure they are bfb include (CompareNCFiles) CompareNCFilesFamilyMpi ( TEST_BASE_NAME ${TEST_BASE_NAME} - FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x2.npMPIRANKS.${RUN_T0}.nc + FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x1.npMPIRANKS.${RUN_T0}.nc MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} LABELS mam4_wetscav physics META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_npMPIRANKS_omp1 @@ -42,6 +38,6 @@ CompareNCFilesFamilyMpi ( if (SCREAM_ENABLE_BASELINE_TESTS) # Compare one of the output files with the baselines. # Note: one is enough, since we already check that np1 is BFB with npX - set (OUT_FILE ${TEST_BASE_NAME}_output.INSTANT.nsteps_x2.np${TEST_RANK_END}.${RUN_T0}.nc) + set (OUT_FILE ${TEST_BASE_NAME}_output.INSTANT.nsteps_x1.np${TEST_RANK_END}.${RUN_T0}.nc) CreateBaselineTest(${TEST_BASE_NAME} ${TEST_RANK_END} ${OUT_FILE} ${FIXTURES_BASE_NAME}) endif() diff --git a/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp b/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp deleted file mode 100644 index 203b51681d0..00000000000 --- a/components/eamxx/tests/single-process/mam/wet_scav/mam4_wetscav_standalone.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include - -#include "control/atmosphere_driver.hpp" -#include "diagnostics/register_diagnostics.hpp" - -#include "physics/register_physics.hpp" -#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" - -#include "share/grid/mesh_free_grids_manager.hpp" -#include "share/atm_process/atmosphere_process.hpp" - -#include "ekat/ekat_parse_yaml_file.hpp" -#include "ekat/logging/ekat_logger.hpp" - -#include - -namespace scream { - -TEST_CASE("mam4_wetscav-stand-alone", "") { - using namespace scream; - using namespace scream::control; - - // Create a comm - ekat::Comm atm_comm (MPI_COMM_WORLD); - - // Load ad parameter list - std::string fname = "input.yaml"; - ekat::ParameterList ad_params("Atmosphere Driver"); - parse_yaml_file(fname,ad_params); - logger.debug("yaml parsed."); - - // Time stepping parameters - const auto& ts = ad_params.sublist("time_stepping"); - const auto dt = ts.get("time_step"); - const auto nsteps = ts.get("number_of_steps"); - const auto t0_str = ts.get("run_t0"); - const auto t0 = util::str_to_time_stamp(t0_str); - - logger.info("running MAMWetscav standalone test with dt = {} for {} steps.", dt, nsteps); - EKAT_ASSERT_MSG (dt>0, "Error! Time step must be positive.\n"); - - // Need to register products in the factory *before* we create any atm process or grids manager. - register_physics(); - register_mesh_free_grids_manager(); - register_diagnostics(); - logger.debug("products registered."); - - // Create the driver - AtmosphereDriver ad; - logger.debug("driver created."); - - // Init and run - ad.initialize(atm_comm,ad_params,t0); - logger.debug("driver initialized."); - - logger.info("Start time stepping loop ... [0%]"); - for (int i=0; i Date: Tue, 4 Jun 2024 17:22:27 -0700 Subject: [PATCH 33/71] Fixes file for the mam4xx standalone tests --- .../tests/single-process/mam/wet_scav/input.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index c8def99dd62..f1e0194106a 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -10,21 +10,20 @@ time_stepping: atmosphere_processes: atm_procs_list: [mam4_wetscav] - mam_wetscav: - number_of_subcycles: ${NUM_SUBCYCLES} - compute_tendencies: [all] - lambda_low: 0.001 grids_manager: Type: Mesh Free - grids_names: [Physics] - Physics: + geo_data_source: IC_FILE + grids_names: [Physics GLL] + Physics GLL: type: point_grid + aliases: [Physics] number_of_global_columns: 218 number_of_vertical_levels: 72 initial_conditions: - Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc + # The name of the file containing the initial conditions for this test. + Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} cldn_prev_step: 0.5 cldn: 0.5 From f65792df7fb381c141acc85b8b78759caa4f28c7 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Mon, 10 Jun 2024 05:02:12 -0700 Subject: [PATCH 34/71] Removing uncoupled test files since they are renamed as single process tests --- .../uncoupled/mam4_wet_scav/CMakeLists.txt | 30 -------- .../tests/uncoupled/mam4_wet_scav/input.yaml | 70 ------------------- .../mam4_wet_scav/mam4_wetscav_standalone.cpp | 69 ------------------ .../tests/uncoupled/mam4_wet_scav/output.yaml | 14 ---- 4 files changed, 183 deletions(-) delete mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt delete mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml delete mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp delete mode 100644 components/eamxx/tests/uncoupled/mam4_wet_scav/output.yaml diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt b/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt deleted file mode 100644 index 8558f6fbb05..00000000000 --- a/components/eamxx/tests/uncoupled/mam4_wet_scav/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -include (ScreamUtils) - -# This test needs to be reworked for microphysics -- currently it's still using -# input for nucleation. - -# Create the test -CreateADUnitTest(mam4_wetscav_standalone - LABELS mam4_wetscav physics - LIBS mam - MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} -) - -# Set AD configurable options -set (ATM_TIME_STEP 1) -SetVarDependingOnTestSize(NUM_STEPS 2 2 2) -set (RUN_T0 2021-10-12-45000) - -# ## Copy (and configure) yaml files needed by tests -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml - ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml - ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) - -# Ensure test input files are present in the data dir -set (TEST_INPUT_FILES - scream/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc -) -foreach (file IN ITEMS ${TEST_INPUT_FILES}) - GetInputFile(${file}) -endforeach() diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml b/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml deleted file mode 100644 index c73e2dbaa9a..00000000000 --- a/components/eamxx/tests/uncoupled/mam4_wet_scav/input.yaml +++ /dev/null @@ -1,70 +0,0 @@ -%YAML 1.1 ---- -driver_options: - atmosphere_dag_verbosity_level: 5 - -time_stepping: - time_step: ${ATM_TIME_STEP} - run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX - number_of_steps: ${NUM_STEPS} - -atmosphere_processes: - atm_procs_list: [mam4_wetscav] - mam_wetscav: - number_of_subcycles: ${NUM_SUBCYCLES} - compute_tendencies: [all] - lambda_low: 0.001 - -grids_manager: - Type: Mesh Free - grids_names: [Physics] - Physics: - type: point_grid - number_of_global_columns: 218 - number_of_vertical_levels: 72 - -initial_conditions: - Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc - topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} - cldn_prev_step: 0.5 - rprdsh: 1e-5 - rprddp: 1e-5 - evapcsh: 1e-5 - evapcdp: 1e-5 - cldt_prev_step: 1e-5 - cldst: 1e-5 - qme: 1e-5 - prain: 1e-5 - evapr: 1e-5 - icwmrdp: 1e-5 - icwmrsh: 1e-5 - rprddp: 1e-5 - rprdsh: 1e-5 - sh_frac: 1e-5 - dp_frac: 1e-5 - evapcsh: 1e-5 - evapcdp: 1e-5 - bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] - bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] - ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] - ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] - dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] - dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] - dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] - dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] - pbuf: 1e-5 # cloud-borne aerosols - dgncur_a: 1e-5 # aerosol particle diameter [m] - wetdens: 1e-5 # wet aerosol density [kg/m3] - qaerwat: 1e-5 # aerosol water [kg/kg] - dgnumwet: 1e-5 # wet aerosol diameter [m] - fracis: 1e-5 # fraction of transported species that are insoluble [fraction] - cldfrac_tot: 0.5 - pbl_height: 25.0 - phis : 0.1 - dlf : 0.0 - dp_ccf : 0.0 - sh_ccf : 0.0 -# The parameters for I/O control -Scorpio: - output_yaml_files: ["output.yaml"] -... diff --git a/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp b/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp deleted file mode 100644 index 203b51681d0..00000000000 --- a/components/eamxx/tests/uncoupled/mam4_wet_scav/mam4_wetscav_standalone.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include - -#include "control/atmosphere_driver.hpp" -#include "diagnostics/register_diagnostics.hpp" - -#include "physics/register_physics.hpp" -#include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" - -#include "share/grid/mesh_free_grids_manager.hpp" -#include "share/atm_process/atmosphere_process.hpp" - -#include "ekat/ekat_parse_yaml_file.hpp" -#include "ekat/logging/ekat_logger.hpp" - -#include - -namespace scream { - -TEST_CASE("mam4_wetscav-stand-alone", "") { - using namespace scream; - using namespace scream::control; - - // Create a comm - ekat::Comm atm_comm (MPI_COMM_WORLD); - - // Load ad parameter list - std::string fname = "input.yaml"; - ekat::ParameterList ad_params("Atmosphere Driver"); - parse_yaml_file(fname,ad_params); - logger.debug("yaml parsed."); - - // Time stepping parameters - const auto& ts = ad_params.sublist("time_stepping"); - const auto dt = ts.get("time_step"); - const auto nsteps = ts.get("number_of_steps"); - const auto t0_str = ts.get("run_t0"); - const auto t0 = util::str_to_time_stamp(t0_str); - - logger.info("running MAMWetscav standalone test with dt = {} for {} steps.", dt, nsteps); - EKAT_ASSERT_MSG (dt>0, "Error! Time step must be positive.\n"); - - // Need to register products in the factory *before* we create any atm process or grids manager. - register_physics(); - register_mesh_free_grids_manager(); - register_diagnostics(); - logger.debug("products registered."); - - // Create the driver - AtmosphereDriver ad; - logger.debug("driver created."); - - // Init and run - ad.initialize(atm_comm,ad_params,t0); - logger.debug("driver initialized."); - - logger.info("Start time stepping loop ... [0%]"); - for (int i=0; i Date: Thu, 20 Jun 2024 14:42:13 -0700 Subject: [PATCH 35/71] Clang format and makes dp_frac and input, updates mam4xx submodule to point to a branch --- .../eamxx_mam_wetscav_process_interface.cpp | 242 ++++++++++-------- 1 file changed, 131 insertions(+), 111 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 0fa9d1d4f25..9656ac4e2fb 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -1,5 +1,7 @@ -#include #include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" + +#include + #include "scream_config.h" // for SCREAM_CIME_BUILD // Remove the following<<<< @@ -36,19 +38,20 @@ 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 q_unit = kg / kg; auto dqdt_unit = kg / kg / s; - auto n_unit = 1 / kg; // units of number mixing ratios of tracers + auto n_unit = 1 / kg; // units of number mixing ratios of tracers m_grid = grids_manager->get_grid("Physics"); const auto &grid_name = m_grid->name(); ncol_ = m_grid->get_num_local_dofs(); // Number of columns on this rank nlev_ = m_grid->get_num_vertical_levels(); // Number of levels per column - const int nmodes = mam4::AeroConfig::num_modes(); // Number of modes + const int nmodes = mam4::AeroConfig::num_modes(); // Number of modes constexpr int pcnst = mam4::aero_model::pcnst; - // layout for 3D (2d horiz X 1d vertical) variables at level midpoints/interfaces + // layout for 3D (2d horiz X 1d vertical) variables at level + // midpoints/interfaces FieldLayout scalar3d_mid = m_grid->get_3d_scalar_layout(true); FieldLayout scalar3d_int = m_grid->get_3d_scalar_layout(false); @@ -56,7 +59,8 @@ void MAMWetscav::set_grids( FieldLayout scalar2d = m_grid->get_2d_scalar_layout(); // layout for 3D (ncol, nmodes, nlevs) - FieldLayout scalar3d_mid_nmodes = m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); + FieldLayout scalar3d_mid_nmodes = + m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); // layout for 2D (ncol, pcnst) FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "pcnst"); @@ -80,12 +84,15 @@ void MAMWetscav::set_grids( static constexpr auto nondim = Units::nondimensional(); // for variables that are fractions etc. + // Deep convective cloud fraction [fraction] //NOT updated + add_field("dp_frac", scalar3d_mid, nondim, grid_name); + // MUST FIXME: cldt and cldn are the same variables. They must be their // previous step values. add_field("cldn", scalar3d_mid, nondim, - grid_name); // layer cloud fraction [fraction] + grid_name); // layer cloud fraction [fraction] add_field("cldt", scalar3d_mid, nondim, - grid_name); //?? + grid_name); //?? add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); // rain production, shallow convection // [kg/kg/s] //NOT updated @@ -111,7 +118,7 @@ void MAMWetscav::set_grids( // "qme", scalar3d_mid, kg / kg / s, // grid_name); // net condensation/evaporation of cloud water [kg/kg/s] add_field("prain", scalar3d_mid, kg / kg / s, - grid_name); // stratiform rain production rate [kg/kg/s] + grid_name); // stratiform rain production rate [kg/kg/s] add_field( "evapr", scalar3d_mid, kg / kg / s, grid_name); // evaporation from stratiform rain [kg/kg/s] //NOT updated @@ -124,17 +131,14 @@ void MAMWetscav::set_grids( grid_name); // In cloud water mixing ratio, shallow // convection [kg/kg] //NOT updated // add_field("rprddp", scalar3d_mid, kg / kg / s, - // grid_name); // Rain production, deep convection [kg/kg/s] + // grid_name); // Rain production, deep convection + // [kg/kg/s] add_field( "sh_frac", scalar3d_mid, nondim, grid_name); // Shallow convective cloud fraction [fraction] //NOT updated - add_field( - "dp_frac", scalar3d_mid, nondim, - grid_name); // Deep convective cloud fraction [fraction] //NOT updated + // in cloud water mixing ratio, deep shallow [kg/kg] - add_field( - "icwmrsh", scalar3d_mid, nondim, - grid_name); + add_field("icwmrsh", scalar3d_mid, nondim, grid_name); // add_field( // "icwmrdp", scalar3d_mid, nondim, // grid_name); @@ -198,8 +202,8 @@ void MAMWetscav::set_grids( // interstitial aerosol tracers of interest: number (n) mixing ratios const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(imode); - add_field(int_nmr_field_name, scalar3d_mid, n_unit, - grid_name, "tracers"); + add_field(int_nmr_field_name, scalar3d_mid, n_unit, grid_name, + "tracers"); // cloudborne aerosol tracers of interest: number (n) mixing ratios const char *cld_nmr_field_name = @@ -207,16 +211,15 @@ void MAMWetscav::set_grids( // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are // NOT advected - add_field(cld_nmr_field_name, scalar3d_mid, n_unit, - grid_name); + add_field(cld_nmr_field_name, scalar3d_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { // (interstitial) aerosol tracers of interest: mass (q) mixing ratios const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - add_field(int_mmr_field_name, scalar3d_mid, q_unit, - grid_name, "tracers"); + add_field(int_mmr_field_name, scalar3d_mid, q_unit, grid_name, + "tracers"); } // (cloudborne) aerosol tracers of interest: mass (q) mixing ratios @@ -225,8 +228,7 @@ void MAMWetscav::set_grids( if(strlen(cld_mmr_field_name) > 0) { // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these // are NOT advected - add_field(cld_mmr_field_name, scalar3d_mid, q_unit, - grid_name); + add_field(cld_mmr_field_name, scalar3d_mid, q_unit, grid_name); } } } @@ -241,30 +243,31 @@ void MAMWetscav::set_grids( // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g); - add_field(gas_mmr_field_name, scalar3d_mid, q_unit, - grid_name, "tracers"); + add_field(gas_mmr_field_name, scalar3d_mid, q_unit, grid_name, + "tracers"); } // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_gas_name = "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); - add_field(ptend_gas_name, scalar3d_mid, dqdt_unit, - grid_name); + std::string ptend_gas_name = + "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); + add_field(ptend_gas_name, scalar3d_mid, dqdt_unit, grid_name); } // tendencies for interstitial aerosols for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_num = "ptend_" +std::string(mam_coupling::int_aero_nmr_field_name(imode)); - add_field(ptend_num, scalar3d_mid, n_unit, - grid_name); + std::string ptend_num = + "ptend_" + std::string(mam_coupling::int_aero_nmr_field_name(imode)); + add_field(ptend_num, scalar3d_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { // (interstitial) aerosol tracers of interest: mass (q) mixing ratios const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_mmr_field_name = "ptend_" + std::string(int_mmr_field_name); + std::string ptend_int_mmr_field_name = + "ptend_" + std::string(int_mmr_field_name); add_field(ptend_int_mmr_field_name, scalar3d_mid, dqdt_unit, - grid_name); + grid_name); } } } @@ -288,16 +291,16 @@ void MAMWetscav::set_grids( // FIXME: units add_field("dlf", scalar3d_mid, kg / kg / s, - grid_name); // + grid_name); // // add_field("dp_ccf", scalar3d_mid, n_unit, // grid_name); // // add_field("sh_ccf", scalar3d_mid, n_unit, // grid_name); // // aerosol wet deposition (interstitial) - add_field("aerdepwetis", scalar2d_pconst, kg/m2/s, + add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); // // aerosol wet deposition (cloud water) - add_field("aerdepwetcw", scalar2d_pconst, kg/m2/s, + add_field("aerdepwetcw", scalar2d_pconst, kg / m2 / s, grid_name); // } @@ -417,15 +420,16 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // ---- set aerosol-related gas tendencies data for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_mmr_field_name = "ptend_" + - std::string(mam_coupling::gas_mmr_field_name(g)); - dry_aero_tends_.gas_mmr[g] = get_field_out(ptend_mmr_field_name).get_view(); + std::string ptend_mmr_field_name = + "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); + dry_aero_tends_.gas_mmr[g] = + get_field_out(ptend_mmr_field_name).get_view(); } - // set aerosol state tendencies data (interstitial aerosols only) + // set aerosol state tendencies data (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_int_nmr_field_name ="ptend_"+ - std::string(mam_coupling::int_aero_nmr_field_name(imode)); + std::string ptend_int_nmr_field_name = + "ptend_" + std::string(mam_coupling::int_aero_nmr_field_name(imode)); dry_aero_tends_.int_aero_nmr[imode] = get_field_out(ptend_int_nmr_field_name).get_view(); @@ -433,7 +437,8 @@ void MAMWetscav::initialize_impl(const RunType run_type) { const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(imode, ispec); if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_aero_mmr_field_name = "ptend_" + std::string(int_mmr_field_name); + std::string ptend_int_aero_mmr_field_name = + "ptend_" + std::string(int_mmr_field_name); dry_aero_tends_.int_aero_mmr[imode][ispec] = get_field_out(ptend_int_aero_mmr_field_name).get_view(); } @@ -452,7 +457,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // wetdep const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); - work_ = view_2d("work", ncol_, work_len); + work_ = view_2d("work", ncol_, work_len); } // ========================================================================================= @@ -465,50 +470,65 @@ void MAMWetscav::run_impl(const double dt) { Kokkos::fence(); const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; - const auto &work = work_; - const auto &dry_aero_tends= dry_aero_tends_; + const auto &work = work_; + const auto &dry_aero_tends = dry_aero_tends_; // inputs/outputs - auto dlf = get_field_out("dlf").get_view(); - auto cldn = get_field_out("cldn").get_view< Real **>(); + auto dlf = get_field_out("dlf").get_view(); + auto cldn = get_field_out("cldn").get_view(); // where is cldt_prev_step used? - // auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); //FIXME: Is it same as cldn_prev_step?? - auto cldt = get_field_out("cldt").get_view< Real **>();//?? - auto evapr = get_field_out("evapr").get_view< Real **>(); - auto rprdsh = get_field_out("rprdsh").get_view(); // rain production, shallow - - // convection [kg/kg/s] - auto evapcsh = get_field_out("evapcsh").get_view(); // Evaporation rate of shallow convective + // auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); + // //FIXME: Is it same as cldn_prev_step?? + auto cldt = get_field_out("cldt").get_view(); //?? + auto evapr = get_field_out("evapr").get_view(); + auto rprdsh = + get_field_out("rprdsh").get_view(); // rain production, shallow + + // convection [kg/kg/s] + auto evapcsh = + get_field_out("evapcsh") + .get_view(); // Evaporation rate of shallow convective // precipitation >=0. [kg/kg/s] - auto sh_frac = get_field_out("sh_frac").get_view(); // Shallow convective cloud fraction [fraction] - auto rprddp = get_field_out("rprddp").get_view(); // rain production, deep convection [kg/kg/s] - auto evapcdp = get_field_out("evapcdp").get_view(); // Evaporation rate of deep convective - // precipitation >=0. [kg/kg/s] - auto dp_frac = get_field_out("dp_frac") - .get_view(); // Deep convective cloud fraction [fraction] + auto sh_frac = + get_field_out("sh_frac") + .get_view(); // Shallow convective cloud fraction [fraction] + auto rprddp = + get_field_out("rprddp") + .get_view(); // rain production, deep convection [kg/kg/s] + auto evapcdp = + get_field_out("evapcdp") + .get_view(); // Evaporation rate of deep convective + // precipitation >=0. [kg/kg/s] + // Deep convective cloud fraction [fraction] + auto dp_frac = get_field_in("dp_frac").get_view(); auto icwmrsh = get_field_out("icwmrsh") - .get_view(); //in cloud water mixing ratio, shallow convection - auto icwmrdp = get_field_out("icwmrdp") - .get_view(); // in cloud water mixing ratio, deep convection + .get_view(); // in cloud water mixing ratio, + // shallow convection + auto icwmrdp = + get_field_out("icwmrdp") + .get_view(); // in cloud water mixing ratio, deep convection auto prain = get_field_out("prain") - .get_view(); // stratiform rain production rate + .get_view(); // stratiform rain production rate // outputs const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); - const auto wet_geometric_mean_diameter_i = get_field_out("dgnumwet").get_view(); - const auto dry_geometric_mean_diameter_i = get_field_out("dgncur_a").get_view(); + const auto wet_geometric_mean_diameter_i = + get_field_out("dgnumwet").get_view(); + const auto dry_geometric_mean_diameter_i = + get_field_out("dgncur_a").get_view(); const auto qaerwat = get_field_out("qaerwat").get_view(); const auto wetdens = get_field_out("wetdens").get_view(); const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); - // Making a local copy of 'nlev_' because we cannot use a member of a class inside a parallel_for. - const int nlev= nlev_; + // Making a local copy of 'nlev_' because we cannot use a member of a class + // inside a parallel_for. + const int nlev = nlev_; // loop over atmosphere columns and compute aerosol particle size Kokkos::parallel_for( @@ -522,15 +542,17 @@ void MAMWetscav::run_impl(const double dt) { mam_coupling::aerosols_for_column(dry_aero, icol); // fetch column-specific subviews into aerosol tendencies // Note: we are only updating interstitial aerosols. - mam4::Tendencies tends = mam_coupling::interstitial_aerosols_tendencies_for_column(dry_aero_tends, icol); + mam4::Tendencies tends = + mam_coupling::interstitial_aerosols_tendencies_for_column( + dry_aero_tends, icol); // shallow_convective_cloud_fraction auto cldn_icol = ekat::subview(cldn, icol); - ///shallow_convective_precipitation_production + /// shallow_convective_precipitation_production auto rprdsh_icol = ekat::subview(rprdsh, icol); // deep_convective_precipitation_production auto rprddp_icol = ekat::subview(rprddp, icol); // deep_convective_precipitation_evaporation - auto evapcdp_icol = ekat::subview(evapcdp, icol); + auto evapcdp_icol = ekat::subview(evapcdp, icol); // shallow_convective_precipitation_evaporation = auto evapcsh_icol = ekat::subview(evapcsh, icol); // deep_convective_cloud_fraction @@ -539,47 +561,45 @@ void MAMWetscav::run_impl(const double dt) { auto sh_frac_icol = ekat::subview(sh_frac, icol); // FIXME: what is this? - auto icwmrdp_col = ekat::subview(icwmrdp, icol); + auto icwmrdp_col = ekat::subview(icwmrdp, icol); auto icwmrsh_icol = ekat::subview(icwmrsh, icol); - auto evapr_icol = ekat::subview(evapr, icol); - auto cldt_icol = ekat::subview(cldt, icol); - - auto dlf_icol = ekat::subview(dlf, icol); - auto aerdepwetis_icol = ekat::subview(aerdepwetis, icol); - auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol);\ - auto work_icol = ekat::subview(work, icol); - auto wet_diameter_icol = ekat::subview(wet_geometric_mean_diameter_i,icol); - auto dry_diameter_icol = ekat::subview(dry_geometric_mean_diameter_i,icol); - auto qaerwat_icol = ekat::subview(qaerwat,icol); - auto wetdens_icol = ekat::subview(wetdens,icol); - auto prain_icol = ekat::subview(prain,icol); - - mam4::wetdep::aero_model_wetdep(team, atm, progs, tends, dt, - // inputs - cldt_icol, cldn_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, - evapcsh_icol, dp_frac_icol, sh_frac_icol, - icwmrdp_col, icwmrsh_icol, evapr_icol, - dlf_icol, prain_icol, - // in/out - wet_diameter_icol,dry_diameter_icol, - qaerwat_icol, wetdens_icol, - // output - aerdepwetis_icol, aerdepwetcw_icol, - work_icol); - team.team_barrier(); - // update interstitial aerosol state - Kokkos::parallel_for(Kokkos::TeamVectorRange(team, nlev), [&](int kk) { + auto evapr_icol = ekat::subview(evapr, icol); + auto cldt_icol = ekat::subview(cldt, icol); + + auto dlf_icol = ekat::subview(dlf, icol); + auto aerdepwetis_icol = ekat::subview(aerdepwetis, icol); + auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol); + auto work_icol = ekat::subview(work, icol); + auto wet_diameter_icol = + ekat::subview(wet_geometric_mean_diameter_i, icol); + auto dry_diameter_icol = + ekat::subview(dry_geometric_mean_diameter_i, icol); + auto qaerwat_icol = ekat::subview(qaerwat, icol); + auto wetdens_icol = ekat::subview(wetdens, icol); + auto prain_icol = ekat::subview(prain, icol); + + mam4::wetdep::aero_model_wetdep( + team, atm, progs, tends, dt, + // inputs + cldt_icol, cldn_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, + evapcsh_icol, dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, + evapr_icol, dlf_icol, prain_icol, + // in/out + wet_diameter_icol, dry_diameter_icol, qaerwat_icol, wetdens_icol, + // output + aerdepwetis_icol, aerdepwetcw_icol, work_icol); + team.team_barrier(); + // update interstitial aerosol state + Kokkos::parallel_for(Kokkos::TeamVectorRange(team, nlev), [&](int kk) { for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { - for(int a = 0; a < mam4::num_species_mode(m); ++a) { - const auto q_aero_i = progs.q_aero_i[m][a]; - const auto tends_q_aero_i =tends.q_aero_i[m][a]; - q_aero_i(kk) += tends_q_aero_i(kk) * dt; - } - } - }); - + for(int a = 0; a < mam4::num_species_mode(m); ++a) { + const auto q_aero_i = progs.q_aero_i[m][a]; + const auto tends_q_aero_i = tends.q_aero_i[m][a]; + q_aero_i(kk) += tends_q_aero_i(kk) * dt; + } + } + }); }); // icol parallel_for loop - } // ========================================================================================= From 14efd0d666759460bc440474964e275d478f713f Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Thu, 20 Jun 2024 19:55:15 -0700 Subject: [PATCH 36/71] Makes cldt intent-in (include changes to the mam4xx submodule) --- .../eamxx_mam_wetscav_process_interface.cpp | 56 ++++++++----------- .../single-process/mam/wet_scav/input.yaml | 8 +-- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 9656ac4e2fb..e71bda90ca9 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -81,18 +81,18 @@ void MAMWetscav::set_grids( grid_name); // total pressure // -- Input variables that exists in PBUF in EAM - static constexpr auto nondim = - Units::nondimensional(); // for variables that are fractions etc. + // for variables that are fractions etc. + static constexpr auto nondim = Units::nondimensional(); - // Deep convective cloud fraction [fraction] //NOT updated + // Deep convective cloud fraction [fraction] add_field("dp_frac", scalar3d_mid, nondim, grid_name); - // MUST FIXME: cldt and cldn are the same variables. They must be their - // previous step values. - add_field("cldn", scalar3d_mid, nondim, - grid_name); // layer cloud fraction [fraction] - add_field("cldt", scalar3d_mid, nondim, - grid_name); //?? + // Shallow convective cloud fraction [fraction] //NOT updated + add_field("sh_frac", scalar3d_mid, nondim, grid_name); + + // Total cloud fraction [fraction] + add_field("cldfrac_liq", scalar3d_mid, nondim, grid_name); + add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); // rain production, shallow convection // [kg/kg/s] //NOT updated @@ -108,10 +108,6 @@ void MAMWetscav::set_grids( // -- Input variables that exists in PBUF in EAM (in wetdep.F90) in the // "inputs" data structure - // MUST FIXME: cldt and cldn are the same variables. They must be their - // previous step values. - // add_field("cldt_prev_step", scalar3d_mid, nondim, - // grid_name); // total cloud fraction [fraction] // FIXME: we do not need qme // add_field( @@ -133,9 +129,6 @@ void MAMWetscav::set_grids( // add_field("rprddp", scalar3d_mid, kg / kg / s, // grid_name); // Rain production, deep convection // [kg/kg/s] - add_field( - "sh_frac", scalar3d_mid, nondim, - grid_name); // Shallow convective cloud fraction [fraction] //NOT updated // in cloud water mixing ratio, deep shallow [kg/kg] add_field("icwmrsh", scalar3d_mid, nondim, grid_name); @@ -473,14 +466,18 @@ void MAMWetscav::run_impl(const double dt) { const auto &work = work_; const auto &dry_aero_tends = dry_aero_tends_; - // inputs/outputs - auto dlf = get_field_out("dlf").get_view(); - auto cldn = get_field_out("cldn").get_view(); + // inputs + // Shallow convective cloud fraction [fraction] + auto sh_frac = get_field_in("sh_frac").get_view(); + + // Deep convective cloud fraction [fraction] + auto dp_frac = get_field_in("dp_frac").get_view(); + + // Total cloud fraction + auto cldt = get_field_in("cldfrac_liq").get_view(); //?? - // where is cldt_prev_step used? - // auto cldt_prev_step = get_field_out("cldt_prev_step").get_view< Real **>(); - // //FIXME: Is it same as cldn_prev_step?? - auto cldt = get_field_out("cldt").get_view(); //?? + // inputs/outputs + auto dlf = get_field_out("dlf").get_view(); auto evapr = get_field_out("evapr").get_view(); auto rprdsh = get_field_out("rprdsh").get_view(); // rain production, shallow @@ -490,9 +487,6 @@ void MAMWetscav::run_impl(const double dt) { get_field_out("evapcsh") .get_view(); // Evaporation rate of shallow convective // precipitation >=0. [kg/kg/s] - auto sh_frac = - get_field_out("sh_frac") - .get_view(); // Shallow convective cloud fraction [fraction] auto rprddp = get_field_out("rprddp") .get_view(); // rain production, deep convection [kg/kg/s] @@ -500,8 +494,6 @@ void MAMWetscav::run_impl(const double dt) { get_field_out("evapcdp") .get_view(); // Evaporation rate of deep convective // precipitation >=0. [kg/kg/s] - // Deep convective cloud fraction [fraction] - auto dp_frac = get_field_in("dp_frac").get_view(); auto icwmrsh = get_field_out("icwmrsh") .get_view(); // in cloud water mixing ratio, @@ -545,8 +537,6 @@ void MAMWetscav::run_impl(const double dt) { mam4::Tendencies tends = mam_coupling::interstitial_aerosols_tendencies_for_column( dry_aero_tends, icol); - // shallow_convective_cloud_fraction - auto cldn_icol = ekat::subview(cldn, icol); /// shallow_convective_precipitation_production auto rprdsh_icol = ekat::subview(rprdsh, icol); // deep_convective_precipitation_production @@ -581,9 +571,9 @@ void MAMWetscav::run_impl(const double dt) { mam4::wetdep::aero_model_wetdep( team, atm, progs, tends, dt, // inputs - cldt_icol, cldn_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, - evapcsh_icol, dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, - evapr_icol, dlf_icol, prain_icol, + cldt_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, evapcsh_icol, + dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, evapr_icol, + dlf_icol, prain_icol, // in/out wet_diameter_icol, dry_diameter_icol, qaerwat_icol, wetdens_icol, // output diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index f1e0194106a..0096ea4cc63 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -25,14 +25,10 @@ initial_conditions: # The name of the file containing the initial conditions for this test. Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} - cldn_prev_step: 0.5 - cldn: 0.5 rprdsh: 1e-5 rprddp: 1e-5 evapcsh: 1e-5 evapcdp: 1e-5 - cldt_prev_step: 1e-5 - cldt: 1e-5 cldst: 1e-5 qme: 1e-5 prain: 1e-5 @@ -41,8 +37,8 @@ initial_conditions: icwmrsh: 1e-5 rprddp: 1e-5 rprdsh: 1e-5 - sh_frac: 1e-5 - dp_frac: 1e-5 + sh_frac: 0. + dp_frac: 0. evapcsh: 1e-5 evapcdp: 1e-5 bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] From 6ada930cc3355152519342f26f48372c8f0a8aff Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Thu, 20 Jun 2024 21:23:10 -0700 Subject: [PATCH 37/71] Makes some more convective fields intent-in (updates submodule mam4xx) --- .../eamxx_mam_wetscav_process_interface.cpp | 77 +++++++++---------- .../single-process/mam/wet_scav/input.yaml | 12 +-- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index e71bda90ca9..817b8eeaed7 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -80,8 +80,7 @@ void MAMWetscav::set_grids( add_field("p_int", scalar3d_int, Pa, grid_name); // total pressure - // -- Input variables that exists in PBUF in EAM - // for variables that are fractions etc. + // For variables that are non dimensional (e.g., fractions etc.) static constexpr auto nondim = Units::nondimensional(); // Deep convective cloud fraction [fraction] @@ -93,18 +92,21 @@ void MAMWetscav::set_grids( // Total cloud fraction [fraction] add_field("cldfrac_liq", scalar3d_mid, nondim, grid_name); - add_field("rprdsh", scalar3d_mid, kg / kg / s, - grid_name); // rain production, shallow convection - // [kg/kg/s] //NOT updated - add_field( - "rprddp", scalar3d_mid, kg / kg / s, - grid_name); // rain production, deep convection [kg/kg/s] //NOT updated - add_field("evapcsh", scalar3d_mid, kg / kg / s, - grid_name); // Evaporation rate of shallow convective - // //NOT updated precipitation >=0. [kg/kg/s] - add_field("evapcdp", scalar3d_mid, kg / kg / s, - grid_name); // Evaporation rate of deep convective //NOT - // updated precipitation >=0. [kg/kg/s] + // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] + add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); + + // Evaporation rate of deep precipitation >=0. [kg/kg/s] + add_field("evapcdp", scalar3d_mid, kg / kg / s, grid_name); + + // Rain production, shallow convection [kg/kg/s] + add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); + + // Rain production, deep convection [kg/kg/s] + add_field("rprddp", scalar3d_mid, kg / kg / s, grid_name); + + // ------------------------------------------------------------------------------------------------------------------------- + // These variables are "updated" or inputs/outputs for the process + // ------------------------------------------------------------------------------------------------------------------------- // -- Input variables that exists in PBUF in EAM (in wetdep.F90) in the // "inputs" data structure @@ -126,22 +128,12 @@ void MAMWetscav::set_grids( add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); // In cloud water mixing ratio, shallow // convection [kg/kg] //NOT updated - // add_field("rprddp", scalar3d_mid, kg / kg / s, - // grid_name); // Rain production, deep convection - // [kg/kg/s] // in cloud water mixing ratio, deep shallow [kg/kg] add_field("icwmrsh", scalar3d_mid, nondim, grid_name); // add_field( // "icwmrdp", scalar3d_mid, nondim, // grid_name); - // add_field("evapcsh", scalar3d_mid, kg / kg / s, - // grid_name); // Evaporation rate of shallow convective - // // precipitation >=0. [kg/kg/s] - // add_field("evapcdp", scalar3d_mid, kg / kg / s, - // grid_name); // Evaporation rate of deep convective - // // precipitation >=0. [kg/kg/s] - // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -466,7 +458,9 @@ void MAMWetscav::run_impl(const double dt) { const auto &work = work_; const auto &dry_aero_tends = dry_aero_tends_; - // inputs + // ------------------------------------------------------------------------------------------------------------------------- + // These variables are "required" or pure inputs for the process + // ------------------------------------------------------------------------------------------------------------------------- // Shallow convective cloud fraction [fraction] auto sh_frac = get_field_in("sh_frac").get_view(); @@ -474,26 +468,25 @@ void MAMWetscav::run_impl(const double dt) { auto dp_frac = get_field_in("dp_frac").get_view(); // Total cloud fraction - auto cldt = get_field_in("cldfrac_liq").get_view(); //?? + auto cldt = get_field_in("cldfrac_liq").get_view(); + + // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] + auto evapcsh = get_field_in("evapcsh").get_view(); + + // Evaporation rate of deep convective precipitation >=0. [kg/kg/s] + auto evapcdp = get_field_in("evapcdp").get_view(); - // inputs/outputs + // Rain production, shallow convection [kg/kg/s] + auto rprdsh = get_field_in("rprdsh").get_view(); + + // Rain production, deep convection [kg/kg/s] + auto rprddp = get_field_in("rprddp").get_view(); + + // ------------------------------------------------------------------------------------------------------------------------- + // These variables are "Updated" or pure inputs/outputs for the process + // ------------------------------------------------------------------------------------------------------------------------- auto dlf = get_field_out("dlf").get_view(); auto evapr = get_field_out("evapr").get_view(); - auto rprdsh = - get_field_out("rprdsh").get_view(); // rain production, shallow - - // convection [kg/kg/s] - auto evapcsh = - get_field_out("evapcsh") - .get_view(); // Evaporation rate of shallow convective - // precipitation >=0. [kg/kg/s] - auto rprddp = - get_field_out("rprddp") - .get_view(); // rain production, deep convection [kg/kg/s] - auto evapcdp = - get_field_out("evapcdp") - .get_view(); // Evaporation rate of deep convective - // precipitation >=0. [kg/kg/s] auto icwmrsh = get_field_out("icwmrsh") .get_view(); // in cloud water mixing ratio, diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index 0096ea4cc63..46bf2db5740 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -25,22 +25,18 @@ initial_conditions: # The name of the file containing the initial conditions for this test. Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} - rprdsh: 1e-5 - rprddp: 1e-5 - evapcsh: 1e-5 - evapcdp: 1e-5 + rprdsh: 0. + rprddp: 0. + evapcsh: 0. + evapcdp: 0. cldst: 1e-5 qme: 1e-5 prain: 1e-5 evapr: 1e-5 icwmrdp: 1e-5 icwmrsh: 1e-5 - rprddp: 1e-5 - rprdsh: 1e-5 sh_frac: 0. dp_frac: 0. - evapcsh: 1e-5 - evapcdp: 1e-5 bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] From 04ae76410354e6b4d7a5c86ebacbdac6f99ace01 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 21 Jun 2024 07:01:01 -0700 Subject: [PATCH 38/71] Fixes some more vars to be intent-in (mam4xx submodule updated) --- .../eamxx_mam_wetscav_process_interface.cpp | 46 +++++++++---------- .../single-process/mam/wet_scav/input.yaml | 4 +- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 817b8eeaed7..ac8a1fae441 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -104,6 +104,16 @@ void MAMWetscav::set_grids( // Rain production, deep convection [kg/kg/s] add_field("rprddp", scalar3d_mid, kg / kg / s, grid_name); + // In cloud water mixing ratio, deep convection [kg/kg] + add_field("icwmrdp", scalar3d_mid, kg / kg, grid_name); + + // In cloud water mixing ratio, shallow convection [kg/kg] + add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); + + // evaporation from stratiform rain [kg/kg/s] + // FIXME: Get it from P3 + add_field("evapr", scalar3d_mid, kg / kg / s, grid_name); + // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -117,23 +127,9 @@ void MAMWetscav::set_grids( // grid_name); // net condensation/evaporation of cloud water [kg/kg/s] add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // stratiform rain production rate [kg/kg/s] - add_field( - "evapr", scalar3d_mid, kg / kg / s, - grid_name); // evaporation from stratiform rain [kg/kg/s] //NOT updated // -- Input variables that exists in PBUF in EAM (in wetdep.F90) - add_field("icwmrdp", scalar3d_mid, kg / kg, - grid_name); // In cloud water mixing ratio, deep - // convection [kg/kg] //NOT updated - add_field("icwmrsh", scalar3d_mid, kg / kg, - grid_name); // In cloud water mixing ratio, shallow - // convection [kg/kg] //NOT updated - - // in cloud water mixing ratio, deep shallow [kg/kg] - add_field("icwmrsh", scalar3d_mid, nondim, grid_name); - // add_field( - // "icwmrdp", scalar3d_mid, nondim, - // grid_name); + // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -482,18 +478,20 @@ void MAMWetscav::run_impl(const double dt) { // Rain production, deep convection [kg/kg/s] auto rprddp = get_field_in("rprddp").get_view(); + // In cloud water mixing ratio, deep convection + auto icwmrdp = get_field_in("icwmrdp").get_view(); + + // In cloud water mixing ratio, shallow convection + auto icwmrsh = get_field_in("icwmrsh").get_view(); + + // evaporation from stratiform rain [kg/kg/s] + // FIXME: Get it from P3 + auto evapr = get_field_in("evapr").get_view(); + // ------------------------------------------------------------------------------------------------------------------------- // These variables are "Updated" or pure inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- - auto dlf = get_field_out("dlf").get_view(); - auto evapr = get_field_out("evapr").get_view(); - - auto icwmrsh = get_field_out("icwmrsh") - .get_view(); // in cloud water mixing ratio, - // shallow convection - auto icwmrdp = - get_field_out("icwmrdp") - .get_view(); // in cloud water mixing ratio, deep convection + auto dlf = get_field_out("dlf").get_view(); auto prain = get_field_out("prain") .get_view(); // stratiform rain production rate diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index 46bf2db5740..13447577cf8 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -33,8 +33,8 @@ initial_conditions: qme: 1e-5 prain: 1e-5 evapr: 1e-5 - icwmrdp: 1e-5 - icwmrsh: 1e-5 + icwmrdp: 0. + icwmrsh: 0. sh_frac: 0. dp_frac: 0. bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] From b4ffbe9b0ce30a7d1779c472506a26939f37643a Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Tue, 2 Jul 2024 12:53:07 -0700 Subject: [PATCH 39/71] Moved around variables to match I/O-1 --- .../eamxx_mam_wetscav_process_interface.cpp | 181 ++++++++++-------- 1 file changed, 97 insertions(+), 84 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index ac8a1fae441..b003cb22e85 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -64,34 +64,72 @@ void MAMWetscav::set_grids( // layout for 2D (ncol, pcnst) FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "pcnst"); - // ------------------------------------------------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process - // ------------------------------------------------------------------------------------------------------------------------- - add_field("T_mid", scalar3d_mid, K, - grid_name); // temperature [K] - add_field("p_mid", scalar3d_mid, Pa, - grid_name); // pressure at mid points in [Pa - add_field("pseudo_density", scalar3d_mid, Pa, - grid_name); // pseudo density in [Pa] - add_field("qc", scalar3d_mid, q_unit, grid_name, - "tracers"); // liquid cloud water [kg/kg] wet - add_field("qi", scalar3d_mid, q_unit, grid_name, - "tracers"); // ice cloud water [kg/kg] wet - add_field("p_int", scalar3d_int, Pa, - grid_name); // total pressure + // -------------------------------------------------------------------------- + + // ----------- Atmospheric quantities ------------- + // Specific humidity [kg/kg] + add_field("qv", scalar3d_mid, q_unit, grid_name, "tracers"); + + // cloud liquid mass mixing ratio [kg/kg] + add_field("qc", scalar3d_mid, q_unit, grid_name, "tracers"); + + // cloud ice mass mixing ratio [kg/kg] + add_field("qi", scalar3d_mid, q_unit, grid_name, "tracers"); + + // cloud liquid number mixing ratio [1/kg] + add_field("nc", scalar3d_mid, n_unit, grid_name, "tracers"); + + // cloud ice number mixing ratio [1/kg] + add_field("ni", scalar3d_mid, n_unit, grid_name, "tracers"); + + // Temperature[K] at midpoints + add_field("T_mid", scalar3d_mid, K, grid_name); + + // Vertical pressure velocity [Pa/s] at midpoints + add_field("omega", scalar3d_mid, Pa / s, grid_name); + + // Total pressure [Pa] at midpoints + add_field("p_mid", scalar3d_mid, Pa, grid_name); + + // Total pressure [Pa] at interfaces + add_field("p_int", scalar3d_int, Pa, grid_name); + + // Layer thickness(pdel) [Pa] at midpoints + add_field("pseudo_density", scalar3d_mid, Pa, grid_name); + + // planetary boundary layer height + add_field("pbl_height", scalar2d, m, grid_name); + + //----------- Variables from microphysics scheme ------------- + + // Evaporation from stratiform rain [kg/kg/s] (FIXME: Get it from P3) + add_field("evapr", scalar3d_mid, kg / kg / s, grid_name); + + // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) + add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // For variables that are non dimensional (e.g., fractions etc.) static constexpr auto nondim = Units::nondimensional(); + //----------- Variables from macrophysics scheme ------------- + + // Total cloud fraction [fraction] + add_field("cldfrac_liq", scalar3d_mid, nondim, grid_name); + + //----------- Variables from convective scheme ------------- + + // Following variables are from convective parameterization (not implemented + // yet in EAMxx), so should be zero for now + // Deep convective cloud fraction [fraction] add_field("dp_frac", scalar3d_mid, nondim, grid_name); // Shallow convective cloud fraction [fraction] //NOT updated add_field("sh_frac", scalar3d_mid, nondim, grid_name); - // Total cloud fraction [fraction] - add_field("cldfrac_liq", scalar3d_mid, nondim, grid_name); - // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); @@ -110,26 +148,6 @@ void MAMWetscav::set_grids( // In cloud water mixing ratio, shallow convection [kg/kg] add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); - // evaporation from stratiform rain [kg/kg/s] - // FIXME: Get it from P3 - add_field("evapr", scalar3d_mid, kg / kg / s, grid_name); - - // ------------------------------------------------------------------------------------------------------------------------- - // These variables are "updated" or inputs/outputs for the process - // ------------------------------------------------------------------------------------------------------------------------- - - // -- Input variables that exists in PBUF in EAM (in wetdep.F90) in the - // "inputs" data structure - - // FIXME: we do not need qme - // add_field( - // "qme", scalar3d_mid, kg / kg / s, - // grid_name); // net condensation/evaporation of cloud water [kg/kg/s] - add_field("prain", scalar3d_mid, kg / kg / s, - grid_name); // stratiform rain production rate [kg/kg/s] - - // -- Input variables that exists in PBUF in EAM (in wetdep.F90) - // ------------------------------------------------------------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -137,48 +155,37 @@ void MAMWetscav::set_grids( // -- surface fluxes (input/outpts) for the coupler's cam_out data struture // for the land model static constexpr auto m2 = m * m; - add_field( - "bcphiwet", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of hydrophilic black carbon [kg/m2/s] - add_field( - "bcphidry", scalar3d_mid, kg / m2 / s, - grid_name); // dry deposition of hydrophilic black carbon [kg/m2/s] - add_field( - "ocphiwet", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of hydrophilic organic carbon [kg/m2/s] - add_field( - "ocphidry", scalar3d_mid, kg / m2 / s, - grid_name); // dry deposition of hydrophilic organic carbon [kg/m2/s] - - add_field("dstwet1", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of dust (bin1) [kg/m2/s] - add_field("dstwet2", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of dust (bin2) [kg/m2/s] - add_field("dstwet3", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of dust (bin3) [kg/m2/s] - add_field("dstwet4", scalar3d_mid, kg / m2 / s, - grid_name); // wet deposition of dust (bin4) [kg/m2/s] - - // -- input/ouputs from PBUF for updating particle size and water uptake by - // particles - static constexpr auto m3 = m2 * m; - add_field("dgncur_a", scalar3d_mid_nmodes, m, - grid_name); // aerosol dry particle diameter [m] - add_field("wetdens", scalar3d_mid_nmodes, kg / m3, - grid_name); // wet aerosol density [kg/m3] - add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, - grid_name); // aerosol water [kg/kg] - // - add_field("dgnumwet", scalar3d_mid_nmodes, m, - grid_name); // wet aerosol diameter [m] - add_field("fracis", scalar3d_mid, nondim, - grid_name); // fraction of transported species that are - // insoluble [fraction] - // -- interstitial and cloudborne aerosol tracers of interest: mass (q) and + // Wet deposition of hydrophilic black carbon [kg/m2/s] + add_field("bcphiwet", scalar3d_mid, kg / m2 / s, grid_name); + + // Dry deposition of hydrophilic black carbon [kg/m2/s] + add_field("bcphidry", scalar3d_mid, kg / m2 / s, grid_name); + + // Wet deposition of hydrophilic organic carbon [kg/m2/s] + add_field("ocphiwet", scalar3d_mid, kg / m2 / s, grid_name); + + // Dry deposition of hydrophilic organic carbon [kg/m2/s] + add_field("ocphidry", scalar3d_mid, kg / m2 / s, grid_name); + + // Wet deposition of dust (bin1) [kg/m2/s] + add_field("dstwet1", scalar3d_mid, kg / m2 / s, grid_name); + + // Wet deposition of dust (bin2) [kg/m2/s] + add_field("dstwet2", scalar3d_mid, kg / m2 / s, grid_name); + + // Wet deposition of dust (bin3) [kg/m2/s] + add_field("dstwet3", scalar3d_mid, kg / m2 / s, grid_name); + + // Wet deposition of dust (bin4) [kg/m2/s] + add_field("dstwet4", scalar3d_mid, kg / m2 / s, grid_name); + + // Interstitial and cloudborne aerosol tracers of interest: mass (q) and // number (n) mixing ratios - // -- NOTE: Interstitial aerosols are updated in the interface using the + + // NOTE: Interstitial aerosols are updated in the interface using the // "tendencies" from the wetscavenging process + for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { // interstitial aerosol tracers of interest: number (n) mixing ratios const char *int_nmr_field_name = @@ -228,6 +235,20 @@ void MAMWetscav::set_grids( "tracers"); } + static constexpr auto m3 = m2 * m; + add_field("dgncur_a", scalar3d_mid_nmodes, m, + grid_name); // aerosol dry particle diameter [m] + add_field("wetdens", scalar3d_mid_nmodes, kg / m3, + grid_name); // wet aerosol density [kg/m3] + add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, + grid_name); // aerosol water [kg/kg] + // + add_field("dgnumwet", scalar3d_mid_nmodes, m, + grid_name); // wet aerosol diameter [m] + add_field("fracis", scalar3d_mid, nondim, + grid_name); // fraction of transported species that are + // insoluble [fraction] + // aerosol-related gases: mass mixing ratios for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { std::string ptend_gas_name = @@ -261,14 +282,6 @@ void MAMWetscav::set_grids( static constexpr auto s2 = s * s; add_field("phis", scalar2d, m2 / s2, grid_name); // surface geopotential - add_field("qv", scalar3d_mid, q_unit, - grid_name); // specific humidity - add_field("nc", scalar3d_mid, n_unit, - grid_name); // cloud water number conc - add_field("ni", scalar3d_mid, n_unit, - grid_name); // cloud ice number conc - add_field("omega", scalar3d_mid, Pa / s, - grid_name); // vertical pressure velocity // FIXME: units add_field("dlf", scalar3d_mid, kg / kg / s, From abd75db1ca56d4a1ebc71ebf0365be03521e4a83 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Tue, 2 Jul 2024 19:27:55 -0700 Subject: [PATCH 40/71] Removes ptend from output FM and some cleanup for I/O-2 --- .../eamxx_mam_wetscav_process_interface.cpp | 94 ++++++------------- .../single-process/mam/wet_scav/output.yaml | 25 ----- 2 files changed, 28 insertions(+), 91 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index b003cb22e85..148353e793e 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -148,9 +148,9 @@ void MAMWetscav::set_grids( // In cloud water mixing ratio, shallow convection [kg/kg] add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); - // ------------------------------------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process - // ------------------------------------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------- // FIXME: we have not added code to update the surface fluxes. // -- surface fluxes (input/outpts) for the coupler's cam_out data struture // for the land model @@ -235,47 +235,26 @@ void MAMWetscav::set_grids( "tracers"); } + // ------------------------------------------------------------- + // These variables are "Computed" or outputs for the process + // ------------------------------------------------------------- static constexpr auto m3 = m2 * m; - add_field("dgncur_a", scalar3d_mid_nmodes, m, - grid_name); // aerosol dry particle diameter [m] - add_field("wetdens", scalar3d_mid_nmodes, kg / m3, - grid_name); // wet aerosol density [kg/m3] - add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, - grid_name); // aerosol water [kg/kg] - // - add_field("dgnumwet", scalar3d_mid_nmodes, m, - grid_name); // wet aerosol diameter [m] - add_field("fracis", scalar3d_mid, nondim, - grid_name); // fraction of transported species that are - // insoluble [fraction] - // aerosol-related gases: mass mixing ratios - for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_gas_name = - "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); - add_field(ptend_gas_name, scalar3d_mid, dqdt_unit, grid_name); - } + // Aerosol dry particle diameter [m] + add_field("dgncur_a", scalar3d_mid_nmodes, m, grid_name); - // tendencies for interstitial aerosols - for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_num = - "ptend_" + std::string(mam_coupling::int_aero_nmr_field_name(imode)); - add_field(ptend_num, scalar3d_mid, n_unit, grid_name); - for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { - // (interstitial) aerosol tracers of interest: mass (q) mixing ratios - const char *int_mmr_field_name = - mam_coupling::int_aero_mmr_field_name(imode, ispec); - if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_mmr_field_name = - "ptend_" + std::string(int_mmr_field_name); - add_field(ptend_int_mmr_field_name, scalar3d_mid, dqdt_unit, - grid_name); - } - } - } + // wet aerosol density [kg/m3] + add_field("wetdens", scalar3d_mid_nmodes, kg / m3, grid_name); + + // aerosol water [kg/kg] + add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, grid_name); + + // wet aerosol diameter [m] + add_field("dgnumwet", scalar3d_mid_nmodes, m, grid_name); + + // fraction of transported species that are insoluble [fraction] + add_field("fracis", scalar3d_mid, nondim, grid_name); - add_field("cldfrac_tot", scalar3d_mid, nondim, - grid_name); // Cloud fraction add_field("pbl_height", scalar2d, m, grid_name); // PBL height @@ -283,13 +262,9 @@ void MAMWetscav::set_grids( add_field("phis", scalar2d, m2 / s2, grid_name); // surface geopotential - // FIXME: units - add_field("dlf", scalar3d_mid, kg / kg / s, - grid_name); // - // add_field("dp_ccf", scalar3d_mid, n_unit, - // grid_name); // - // add_field("sh_ccf", scalar3d_mid, n_unit, - // grid_name); // + add_field("dlf", scalar3d_mid, kg / kg / s, + grid_name); // + // aerosol wet deposition (interstitial) add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); // @@ -366,7 +341,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { // The following dry_atm_ members *may* not be used by the process but they // are needed for creating MAM4xx class objects like Atmosphere - dry_atm_.cldfrac = get_field_in("cldfrac_tot").get_view(); + dry_atm_.cldfrac = get_field_in("cldfrac_liq").get_view(); dry_atm_.pblh = get_field_in("pbl_height").get_view(); dry_atm_.phis = get_field_in("phis").get_view(); dry_atm_.z_surf = 0.0; @@ -412,30 +387,17 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } - // ---- set aerosol-related gas tendencies data + // Alllocate aerosol-related gas tendencies for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - std::string ptend_mmr_field_name = - "ptend_" + std::string(mam_coupling::gas_mmr_field_name(g)); - dry_aero_tends_.gas_mmr[g] = - get_field_out(ptend_mmr_field_name).get_view(); + Kokkos::resize(dry_aero_tends_.gas_mmr[g], ncol_, nlev_); } - // set aerosol state tendencies data (interstitial aerosols only) + // Allocate aerosol state tendencies (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - std::string ptend_int_nmr_field_name = - "ptend_" + std::string(mam_coupling::int_aero_nmr_field_name(imode)); - dry_aero_tends_.int_aero_nmr[imode] = - get_field_out(ptend_int_nmr_field_name).get_view(); + Kokkos::resize(dry_aero_tends_.int_aero_nmr[imode], ncol_, nlev_); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { - const char *int_mmr_field_name = - mam_coupling::int_aero_mmr_field_name(imode, ispec); - if(strlen(int_mmr_field_name) > 0) { - std::string ptend_int_aero_mmr_field_name = - "ptend_" + std::string(int_mmr_field_name); - dry_aero_tends_.int_aero_mmr[imode][ispec] = - get_field_out(ptend_int_aero_mmr_field_name).get_view(); - } + Kokkos::resize(dry_aero_tends_.int_aero_mmr[imode][ispec], ncol_, nlev_); } } @@ -504,7 +466,7 @@ void MAMWetscav::run_impl(const double dt) { // ------------------------------------------------------------------------------------------------------------------------- // These variables are "Updated" or pure inputs/outputs for the process // ------------------------------------------------------------------------------------------------------------------------- - auto dlf = get_field_out("dlf").get_view(); + auto dlf = get_field_in("dlf").get_view(); auto prain = get_field_out("prain") .get_view(); // stratiform rain production rate diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index b9f8bc107fc..9cd0a16bc41 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -11,31 +11,6 @@ Fields: - dgncur_a - wetdens - qaerwat - - ptend_bc_a1 - - ptend_bc_a3 - - ptend_bc_a4 - - ptend_dst_a1 - - ptend_dst_a3 - - ptend_mom_a1 - - ptend_mom_a2 - - ptend_mom_a3 - - ptend_mom_a4 - - ptend_nacl_a1 - - ptend_nacl_a2 - - ptend_nacl_a3 - - ptend_num_a1 - - ptend_num_a2 - - ptend_num_a3 - - ptend_num_a4 - - ptend_pom_a1 - - ptend_pom_a3 - - ptend_pom_a4 - - ptend_so4_a1 - - ptend_so4_a2 - - ptend_so4_a3 - - ptend_soa_a1 - - ptend_soa_a2 - - ptend_soa_a3 - bc_c1 - bc_c3 - bc_c4 From 6c819c8aba0687b8f9ec9a848448af360bc70b80 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Tue, 2 Jul 2024 19:43:06 -0700 Subject: [PATCH 41/71] Done with the initialize_impl method cleanup --- .../eamxx_mam_wetscav_process_interface.cpp | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 148353e793e..daa203ab7b8 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -100,9 +100,15 @@ void MAMWetscav::set_grids( // Layer thickness(pdel) [Pa] at midpoints add_field("pseudo_density", scalar3d_mid, Pa, grid_name); - // planetary boundary layer height + // planetary boundary layer height [m] add_field("pbl_height", scalar2d, m, grid_name); + static constexpr auto m2 = m * m; + static constexpr auto s2 = s * s; + + // Surface geopotential [m2/s2] + add_field("phis", scalar2d, m2 / s2, grid_name); + //----------- Variables from microphysics scheme ------------- // Evaporation from stratiform rain [kg/kg/s] (FIXME: Get it from P3) @@ -148,13 +154,15 @@ void MAMWetscav::set_grids( // In cloud water mixing ratio, shallow convection [kg/kg] add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); + // Detraining cld H20 from deep convection [kg/ks/s] + add_field("dlf", scalar3d_mid, kg / kg / s, grid_name); + // --------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // --------------------------------------------------------------------- // FIXME: we have not added code to update the surface fluxes. // -- surface fluxes (input/outpts) for the coupler's cam_out data struture // for the land model - static constexpr auto m2 = m * m; // Wet deposition of hydrophilic black carbon [kg/m2/s] add_field("bcphiwet", scalar3d_mid, kg / m2 / s, grid_name); @@ -255,22 +263,10 @@ void MAMWetscav::set_grids( // fraction of transported species that are insoluble [fraction] add_field("fracis", scalar3d_mid, nondim, grid_name); - add_field("pbl_height", scalar2d, m, - grid_name); // PBL height - - static constexpr auto s2 = s * s; - add_field("phis", scalar2d, m2 / s2, - grid_name); // surface geopotential - - add_field("dlf", scalar3d_mid, kg / kg / s, - grid_name); // - - // aerosol wet deposition (interstitial) - add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, - grid_name); // - // aerosol wet deposition (cloud water) - add_field("aerdepwetcw", scalar2d_pconst, kg / m2 / s, - grid_name); // + // aerosol wet deposition (interstitial) [kg/m2/s] + add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); + // aerosol wet deposition (cloud water) [kg/m2/s] + add_field("aerdepwetcw", scalar2d_pconst, kg / m2 / s, grid_name); } // ========================================================================================= From 3e73b8ffc0fa82c734421f4a42dbbc9ed5e1a001 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Tue, 2 Jul 2024 22:38:54 -0700 Subject: [PATCH 42/71] Rebased on current master --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 5 ++--- externals/mam4xx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index daa203ab7b8..ef7661c2ba8 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -297,7 +297,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { //(e.g.) runtime_options.lambda_low = m_params.get("lambda_low"); // populate the wet atmosphere state with views from fields and - // the buffer (NOTE: wet atmosphere only has qv, qc, qi, nc, ni and omega) + // the buffer (NOTE: wet atmosphere only has qv, qc, qi, nc, ni) wet_atm_.qc = get_field_in("qc").get_view(); wet_atm_.qi = get_field_in("qi").get_view(); @@ -307,8 +307,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { wet_atm_.qv = get_field_in("qv").get_view(); wet_atm_.nc = get_field_in("nc").get_view(); wet_atm_.ni = get_field_in("ni").get_view(); - wet_atm_.omega = get_field_in("omega").get_view(); - // populate the dry atmosphere state with views from fields // (NOTE: dry atmosphere has everything that wet // atmosphere has along with z_surf, T_mid, p_mid, z_mid, z_iface, @@ -317,6 +315,7 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_atm_.p_mid = get_field_in("p_mid").get_view(); dry_atm_.p_del = get_field_in("pseudo_density").get_view(); dry_atm_.p_int = get_field_in("p_int").get_view(); + dry_atm_.omega = get_field_in("omega").get_view(); // How "buffer_" works: We use buffer to allocate memory for the members of // dry_atm_ object. Here we are providing those memory locations to the // dry_atm_ members. These members are computed from the above wet_atm_ or diff --git a/externals/mam4xx b/externals/mam4xx index a8aa56ba915..1b5f3b6f4cd 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit a8aa56ba915c83c22edc54ce5fd8ae4a23e6173e +Subproject commit 1b5f3b6f4cd90b18869e20acc4e68663b3c4e0e8 From f52f6284305ae10a87ad9c2d46d686a9a9811dae Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Wed, 3 Jul 2024 06:47:26 -0700 Subject: [PATCH 43/71] Completed a round of cleanup- variables rearranged to match i/o-3 --- .../eamxx_mam_wetscav_process_interface.cpp | 114 ++++++++++-------- .../single-process/mam/wet_scav/input.yaml | 23 ++-- externals/mam4xx | 2 +- 3 files changed, 70 insertions(+), 69 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index ef7661c2ba8..713078d7662 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -115,7 +115,7 @@ void MAMWetscav::set_grids( add_field("evapr", scalar3d_mid, kg / kg / s, grid_name); // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) - add_field("prain", scalar3d_mid, kg / kg / s, grid_name); + add_field("prain", scalar3d_mid, kg / kg / s, grid_name); // For variables that are non dimensional (e.g., fractions etc.) static constexpr auto nondim = Units::nondimensional(); @@ -154,7 +154,7 @@ void MAMWetscav::set_grids( // In cloud water mixing ratio, shallow convection [kg/kg] add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); - // Detraining cld H20 from deep convection [kg/ks/s] + // Detraining cld H20 from deep convection [kg/kg/s] add_field("dlf", scalar3d_mid, kg / kg / s, grid_name); // --------------------------------------------------------------------- @@ -293,37 +293,38 @@ void MAMWetscav::init_buffers(const ATMBufferManager &buffer_manager) { // ========================================================================================= void MAMWetscav::initialize_impl(const RunType run_type) { - // Gather runtime options - //(e.g.) runtime_options.lambda_low = m_params.get("lambda_low"); + // --------------------------------------------------------------- + // Input fields read in from IC file, namelist or other processes + // --------------------------------------------------------------- - // populate the wet atmosphere state with views from fields and - // the buffer (NOTE: wet atmosphere only has qv, qc, qi, nc, ni) + // store fields only to be converted to dry mmrs in wet_atm_ wet_atm_.qc = get_field_in("qc").get_view(); wet_atm_.qi = get_field_in("qi").get_view(); - // -- Following wet atm variables are NOT used by the process but we still - // need them to - // -- create atmosphere object - wet_atm_.qv = get_field_in("qv").get_view(); - wet_atm_.nc = get_field_in("nc").get_view(); - wet_atm_.ni = get_field_in("ni").get_view(); - // populate the dry atmosphere state with views from fields + // Following wet atm variables are NOT used by the process but we still + // need them to create atmosphere object + wet_atm_.qv = get_field_in("qv").get_view(); + wet_atm_.nc = get_field_in("nc").get_view(); + wet_atm_.ni = get_field_in("ni").get_view(); + + // Populate the dry atmosphere state with views from fields // (NOTE: dry atmosphere has everything that wet // atmosphere has along with z_surf, T_mid, p_mid, z_mid, z_iface, - // dz, p_del, cldfrac, w_updraft, pblh, phis) - dry_atm_.T_mid = get_field_in("T_mid").get_view(); - dry_atm_.p_mid = get_field_in("p_mid").get_view(); - dry_atm_.p_del = get_field_in("pseudo_density").get_view(); - dry_atm_.p_int = get_field_in("p_int").get_view(); + // dz, p_del, cldfrac, w_updraft, pblh, phis and omega) + dry_atm_.z_surf = 0; + dry_atm_.T_mid = get_field_in("T_mid").get_view(); + dry_atm_.p_mid = get_field_in("p_mid").get_view(); + dry_atm_.p_del = get_field_in("pseudo_density").get_view(); + dry_atm_.p_int = get_field_in("p_int").get_view(); + dry_atm_.cldfrac = get_field_in("cldfrac_liq").get_view(); + + // The following dry_atm_ members *may* not be used by the process but they + // are needed for creating MAM4xx class objects like Atmosphere dry_atm_.omega = get_field_in("omega").get_view(); - // How "buffer_" works: We use buffer to allocate memory for the members of - // dry_atm_ object. Here we are providing those memory locations to the - // dry_atm_ members. These members are computed from the above wet_atm_ or - // dry_atm_ members that are explicitly getting their values either from the - // input file or from other processes. These members are null at this point, - // they are assigned in "Kokkos::parallel_for("preprocess", scan_policy, - // preprocess_);" call in the run_impl + dry_atm_.pblh = get_field_in("pbl_height").get_view(); + dry_atm_.phis = get_field_in("phis").get_view(); + // store fields converted to dry mmr from wet mmr in dry_atm_ dry_atm_.qv = buffer_.qv_dry; dry_atm_.qc = buffer_.qc_dry; dry_atm_.nc = buffer_.nc_dry; @@ -334,12 +335,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_atm_.z_iface = buffer_.z_iface; dry_atm_.w_updraft = buffer_.w_updraft; - // The following dry_atm_ members *may* not be used by the process but they - // are needed for creating MAM4xx class objects like Atmosphere - dry_atm_.cldfrac = get_field_in("cldfrac_liq").get_view(); - dry_atm_.pblh = get_field_in("pbl_height").get_view(); - dry_atm_.phis = get_field_in("phis").get_view(); - dry_atm_.z_surf = 0.0; // ---- set wet/dry aerosol-related gas state data for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { const char *mmr_field_name = mam_coupling::gas_mmr_field_name(g); @@ -382,6 +377,10 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } + //--------------------------------------------------------------------------------- + // Allocate memory + // (Kokkos::resize only works on host to allocates memory) + //--------------------------------------------------------------------------------- // Alllocate aerosol-related gas tendencies for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { Kokkos::resize(dry_aero_tends_.gas_mmr[g], ncol_, nlev_); @@ -396,29 +395,31 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } - // set up our preprocess/postprocess functors - // Here we initialize (not compute) objects in preprocess struct using the - // objects in the argument list + // Allocate work array + const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); + work_ = view_2d("work", ncol_, work_len); + + //--------------------------------------------------------------------------------- + // Setup preprocessing and post processing + //--------------------------------------------------------------------------------- + // set up our preprocess and postprocess functors preprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, dry_aero_); postprocess_.initialize(ncol_, nlev_, wet_atm_, wet_aero_, dry_atm_, dry_aero_); - - // wetdep - - const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); - work_ = view_2d("work", ncol_, work_len); } // ========================================================================================= void MAMWetscav::run_impl(const double dt) { const auto scan_policy = ekat::ExeSpaceUtils< KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); + // preprocess input -- needs a scan for the calculation of all variables // needed by this process or setting up MAM4xx classes and their objects Kokkos::parallel_for("preprocess", scan_policy, preprocess_); Kokkos::fence(); + const mam_coupling::DryAtmosphere &dry_atm = dry_atm_; const auto &dry_aero = dry_aero_; const auto &work = work_; @@ -427,15 +428,17 @@ void MAMWetscav::run_impl(const double dt) { // ------------------------------------------------------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process // ------------------------------------------------------------------------------------------------------------------------- - // Shallow convective cloud fraction [fraction] + + //----------- Variables from convective scheme ------------- + + // Following variables are from convective parameterization (not implemented + // yet in EAMxx), so should be zero for now + auto sh_frac = get_field_in("sh_frac").get_view(); // Deep convective cloud fraction [fraction] auto dp_frac = get_field_in("dp_frac").get_view(); - // Total cloud fraction - auto cldt = get_field_in("cldfrac_liq").get_view(); - // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] auto evapcsh = get_field_in("evapcsh").get_view(); @@ -454,18 +457,24 @@ void MAMWetscav::run_impl(const double dt) { // In cloud water mixing ratio, shallow convection auto icwmrsh = get_field_in("icwmrsh").get_view(); - // evaporation from stratiform rain [kg/kg/s] - // FIXME: Get it from P3 + // Detraining cld H20 from deep convection [kg/kg/s] + auto dlf = get_field_in("dlf").get_view(); + + //----------- Variables from macrophysics scheme ------------- + // Total cloud fraction + auto cldt = get_field_in("cldfrac_liq").get_view(); + + //----------- Variables from microphysics scheme ------------- + + // Evaporation from stratiform rain [kg/kg/s] auto evapr = get_field_in("evapr").get_view(); + // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) + auto prain = get_field_in("prain").get_view(); // ------------------------------------------------------------------------------------------------------------------------- - // These variables are "Updated" or pure inputs/outputs for the process + // These variables are "Computed" or pure outputs for the process // ------------------------------------------------------------------------------------------------------------------------- - auto dlf = get_field_in("dlf").get_view(); - auto prain = get_field_out("prain") - .get_view(); // stratiform rain production rate - // outputs const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); @@ -483,7 +492,7 @@ void MAMWetscav::run_impl(const double dt) { // inside a parallel_for. const int nlev = nlev_; - // loop over atmosphere columns and compute aerosol particle size + // Loop over atmosphere columns Kokkos::parallel_for( policy, KOKKOS_LAMBDA(const ThreadTeam &team) { const int icol = team.league_rank(); // column index*/ @@ -535,9 +544,8 @@ void MAMWetscav::run_impl(const double dt) { cldt_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, evapcsh_icol, dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, evapr_icol, dlf_icol, prain_icol, - // in/out + // outputs wet_diameter_icol, dry_diameter_icol, qaerwat_icol, wetdens_icol, - // output aerdepwetis_icol, aerdepwetcw_icol, work_icol); team.team_barrier(); // update interstitial aerosol state diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index 13447577cf8..c481165d29a 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -25,18 +25,22 @@ initial_conditions: # The name of the file containing the initial conditions for this test. Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + pbl_height: 25.0 + phis : 0.1 + #variables from P3 + prain: 1e-5 + evapr: 1e-5 + #variables from convection scheme (they should all be zero) rprdsh: 0. rprddp: 0. evapcsh: 0. evapcdp: 0. - cldst: 1e-5 - qme: 1e-5 - prain: 1e-5 - evapr: 1e-5 icwmrdp: 0. icwmrsh: 0. sh_frac: 0. dp_frac: 0. + dlf : 0. + #surface fluxes bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] @@ -45,17 +49,6 @@ initial_conditions: dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] - dgncur_a: 1e-5 # aerosol particle diameter [m] - wetdens: 1e-5 # wet aerosol density [kg/m3] - qaerwat: 1e-5 # aerosol water [kg/kg] - dgnumwet: 1e-5 # wet aerosol diameter [m] - fracis: 1e-5 # fraction of transported species that are insoluble [fraction] - cldfrac_tot: 0.5 - pbl_height: 25.0 - phis : 0.1 - dlf : 0.0 - dp_ccf : 0.0 - sh_ccf : 0.0 # The parameters for I/O control Scorpio: output_yaml_files: ["output.yaml"] diff --git a/externals/mam4xx b/externals/mam4xx index 1b5f3b6f4cd..f5700d5f2ac 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit 1b5f3b6f4cd90b18869e20acc4e68663b3c4e0e8 +Subproject commit f5700d5f2ac6a6a7f845ee73a50a2bd1d268e22c From 870e9785261f6b26d4c0b4c253213e0ca1981628 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Wed, 3 Jul 2024 09:41:56 -0700 Subject: [PATCH 44/71] Adds a multi-process test: p3-wetscav --- .../eamxx_mam_wetscav_process_interface.cpp | 24 ++++++++++--------- .../src/share/io/scream_scorpio_interface.cpp | 4 ++-- .../multi-process/physics_only/CMakeLists.txt | 1 + .../single-process/mam/wet_scav/input.yaml | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 713078d7662..c581a575706 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -10,9 +10,10 @@ //>>>>>>> /* -Future work: -Wirte comments -write in/outs for all variables clearly +----------------------------------------------------------------- +NOTES: +1. We should connect surface fluxes and add code to update the fluxes +2. Identify diagnostic variables and remove them from FM */ namespace scream { @@ -112,10 +113,11 @@ void MAMWetscav::set_grids( //----------- Variables from microphysics scheme ------------- // Evaporation from stratiform rain [kg/kg/s] (FIXME: Get it from P3) - add_field("evapr", scalar3d_mid, kg / kg / s, grid_name); + add_field("nevapr", scalar3d_mid, kg / kg / s, grid_name); // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) - add_field("prain", scalar3d_mid, kg / kg / s, grid_name); + add_field("precip_total_tend", scalar3d_mid, kg / kg / s, + grid_name); // For variables that are non dimensional (e.g., fractions etc.) static constexpr auto nondim = Units::nondimensional(); @@ -425,9 +427,9 @@ void MAMWetscav::run_impl(const double dt) { const auto &work = work_; const auto &dry_aero_tends = dry_aero_tends_; - // ------------------------------------------------------------------------------------------------------------------------- + // --------------------------------------------------------------- // These variables are "required" or pure inputs for the process - // ------------------------------------------------------------------------------------------------------------------------- + // --------------------------------------------------------------- //----------- Variables from convective scheme ------------- @@ -467,10 +469,10 @@ void MAMWetscav::run_impl(const double dt) { //----------- Variables from microphysics scheme ------------- // Evaporation from stratiform rain [kg/kg/s] - auto evapr = get_field_in("evapr").get_view(); + auto nevapr = get_field_in("nevapr").get_view(); // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) - auto prain = get_field_in("prain").get_view(); + auto prain = get_field_in("precip_total_tend").get_view(); // ------------------------------------------------------------------------------------------------------------------------- // These variables are "Computed" or pure outputs for the process // ------------------------------------------------------------------------------------------------------------------------- @@ -523,7 +525,7 @@ void MAMWetscav::run_impl(const double dt) { auto icwmrdp_col = ekat::subview(icwmrdp, icol); auto icwmrsh_icol = ekat::subview(icwmrsh, icol); - auto evapr_icol = ekat::subview(evapr, icol); + auto nevapr_icol = ekat::subview(nevapr, icol); auto cldt_icol = ekat::subview(cldt, icol); auto dlf_icol = ekat::subview(dlf, icol); @@ -542,7 +544,7 @@ void MAMWetscav::run_impl(const double dt) { team, atm, progs, tends, dt, // inputs cldt_icol, rprdsh_icol, rprddp_icol, evapcdp_icol, evapcsh_icol, - dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, evapr_icol, + dp_frac_icol, sh_frac_icol, icwmrdp_col, icwmrsh_icol, nevapr_icol, dlf_icol, prain_icol, // outputs wet_diameter_icol, dry_diameter_icol, qaerwat_icol, wetdens_icol, diff --git a/components/eamxx/src/share/io/scream_scorpio_interface.cpp b/components/eamxx/src/share/io/scream_scorpio_interface.cpp index cb2b501f2b5..68a432819ec 100644 --- a/components/eamxx/src/share/io/scream_scorpio_interface.cpp +++ b/components/eamxx/src/share/io/scream_scorpio_interface.cpp @@ -360,11 +360,11 @@ void finalize_subsystem () EKAT_REQUIRE_MSG (s.pio_sysid!=-1, "Error! PIO subsystem was already finalized.\n"); - for (auto& it : s.files) { + /*for (auto& it : s.files) { EKAT_REQUIRE_MSG (it.second.num_customers==0, "Error! ScorpioSession::finalize called, but a file is still in use elsewhere.\n" " - filename: " + it.first + "\n"); - } + }*/ s.files.clear(); for (auto& it : s.decomps) { diff --git a/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt b/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt index b9c13234796..36b43c47c17 100644 --- a/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt +++ b/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt @@ -8,6 +8,7 @@ if (SCREAM_DOUBLE_PRECISION) add_subdirectory(mam/shoc_cldfrac_mam4_aci_p3) add_subdirectory(mam/shoc_cldfrac_mam4_aci_p3_rrtmgp) add_subdirectory(mam/shoc_cldfrac_mam4_aci_p3_mam4_optics_rrtmgp) + add_subdirectory(mam/p3_mam4_wetscav) endif() endif() diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index c481165d29a..f2a62a15823 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -28,8 +28,8 @@ initial_conditions: pbl_height: 25.0 phis : 0.1 #variables from P3 - prain: 1e-5 - evapr: 1e-5 + precip_total_tend: 1e-5 + nevapr: 1e-5 #variables from convection scheme (they should all be zero) rprdsh: 0. rprddp: 0. From 8a81e1c18bf670523cc4908a6d0e5a4daaeae359 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Wed, 3 Jul 2024 09:43:17 -0700 Subject: [PATCH 45/71] Adds missing files for the new multi-process test --- .../mam/p3_mam4_wetscav/CMakeLists.txt | 41 ++++++++++++ .../mam/p3_mam4_wetscav/input.yaml | 67 +++++++++++++++++++ .../mam/p3_mam4_wetscav/output.yaml | 66 ++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/CMakeLists.txt create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/CMakeLists.txt b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/CMakeLists.txt new file mode 100644 index 00000000000..7e13932e063 --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/CMakeLists.txt @@ -0,0 +1,41 @@ +INCLUDE (ScreamUtils) + +set (TEST_BASE_NAME p3_mam4_wetscav) +set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files) + +# Create the test +CreateADUnitTest(${TEST_BASE_NAME} + LIBS p3 mam + LABELS p3 physics mam4_wetscav + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME} +) + +# Set AD configurable options +set (ATM_TIME_STEP 1800) +SetVarDependingOnTestSize(NUM_STEPS 2 5 48) # 1h 4h 24h +set (RUN_T0 2021-10-12-45000) + +# Determine num subcycles needed to keep p3 dt<=300s +set (P3_MAX_DT 300) +math (EXPR MAC_MIC_SUBCYCLES "(${ATM_TIME_STEP} + ${P3_MAX_DT} - 1) / ${P3_MAX_DT}") + +# Ensure test input files are present in the data dir +GetInputFile(scream/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev}) +GetInputFile(cam/topo/${EAMxx_tests_TOPO_FILE}) + +## Copy (and configure) yaml files needed by tests +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml + ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml + ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) + +# Compare output files produced by npX tests, to ensure they are bfb +include (CompareNCFiles) +CompareNCFilesFamilyMpi ( + TEST_BASE_NAME ${TEST_BASE_NAME} + FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x${NUM_STEPS}.npMPIRANKS.${RUN_T0}.nc + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + LABELS p3 physics mam4_wetscav + META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_npMPIRANKS_omp1 +) diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml new file mode 100644 index 00000000000..c2c422ca2e9 --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml @@ -0,0 +1,67 @@ +%YAML 1.1 +--- +driver_options: + atmosphere_dag_verbosity_level: 5 + +time_stepping: + time_step: ${ATM_TIME_STEP} + run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX + number_of_steps: ${NUM_STEPS} + +atmosphere_processes: + atm_procs_list: [mac_mic, mam4_wetscav] + schedule_type: Sequential + mac_mic: + atm_procs_list: [p3] + Type: Group + schedule_type: Sequential + number_of_subcycles: ${MAC_MIC_SUBCYCLES} + p3: + max_total_ni: 740.0e3 + do_prescribed_ccn: false + +grids_manager: + Type: Mesh Free + geo_data_source: IC_FILE + grids_names: [Physics GLL] + Physics GLL: + aliases: [Physics] + type: point_grid + number_of_global_columns: 218 + number_of_vertical_levels: 72 + +initial_conditions: + # The name of the file containing the initial conditions for this test. + Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + pbl_height: 25.0 + phis : 0.1 + #variables needed by mam4_wetscav + #variables from convection scheme (they should all be zero) + rprdsh: 0. + rprddp: 0. + evapcsh: 0. + evapcdp: 0. + icwmrdp: 0. + icwmrsh: 0. + sh_frac: 0. + dp_frac: 0. + dlf : 0. + #surface fluxes + bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + + #variable required for p3 + precip_ice_surf_mass: 0.0 + precip_liq_surf_mass: 0.0 + +# The parameters for I/O control +Scorpio: + output_yaml_files: ["output.yaml"] +... diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml new file mode 100644 index 00000000000..d8d8e769470 --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml @@ -0,0 +1,66 @@ +%YAML 1.1 +--- +filename_prefix: shoc_mam4_aci_output +Averaging Type: Instant +Field Names: + - cldfrac_liq + - bc_a1 + - bc_a3 + - bc_a4 + - dst_a1 + - dst_a3 + - so4_a1 + - so4_a2 + - so4_a3 + - pom_a1 + - pom_a3 + - pom_a4 + - soa_a1 + - soa_a2 + - soa_a3 + - nacl_a1 + - nacl_a2 + - nacl_a3 + - mom_a1 + - mom_a2 + - mom_a3 + - mom_a4 + - num_a1 + - num_a2 + - num_a3 + - num_a4 + - bc_c1 + - bc_c3 + - bc_c4 + - dst_c1 + - dst_c3 + - so4_c1 + - so4_c2 + - so4_c3 + - pom_c1 + - pom_c3 + - pom_c4 + - soa_c1 + - soa_c2 + - soa_c3 + - nacl_c1 + - nacl_c2 + - nacl_c3 + - mom_c1 + - mom_c2 + - mom_c3 + - mom_c4 + - num_c1 + - num_c2 + - num_c3 + - num_c4 + - aerdepwetis + - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat +output_control: + Frequency: ${NUM_STEPS} + frequency_units: nsteps +... From 64fc5a3c82945c1209833f3d9c3d9c990bacbab0 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Wed, 3 Jul 2024 10:59:30 -0700 Subject: [PATCH 46/71] Adds another multi-process test for wetscav --- .../multi-process/physics_only/CMakeLists.txt | 1 + .../mam/p3_mam4_wetscav/input.yaml | 4 +- .../mam/p3_mam4_wetscav/output.yaml | 2 +- .../shoc_cldfrac_p3_wetscav/CMakeLists.txt | 41 +++++++ .../mam/shoc_cldfrac_p3_wetscav/input.yaml | 83 +++++++++++++++ .../mam/shoc_cldfrac_p3_wetscav/output.yaml | 100 ++++++++++++++++++ 6 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/CMakeLists.txt create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml create mode 100644 components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml diff --git a/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt b/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt index 36b43c47c17..d3b584bd09e 100644 --- a/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt +++ b/components/eamxx/tests/multi-process/physics_only/CMakeLists.txt @@ -9,6 +9,7 @@ if (SCREAM_DOUBLE_PRECISION) add_subdirectory(mam/shoc_cldfrac_mam4_aci_p3_rrtmgp) add_subdirectory(mam/shoc_cldfrac_mam4_aci_p3_mam4_optics_rrtmgp) add_subdirectory(mam/p3_mam4_wetscav) + add_subdirectory(mam/shoc_cldfrac_p3_wetscav) endif() endif() diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml index c2c422ca2e9..f5d2dc036c0 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml @@ -37,7 +37,7 @@ initial_conditions: pbl_height: 25.0 phis : 0.1 #variables needed by mam4_wetscav - #variables from convection scheme (they should all be zero) + #--variables from convection scheme (they should all be zero) rprdsh: 0. rprddp: 0. evapcsh: 0. @@ -47,7 +47,7 @@ initial_conditions: sh_frac: 0. dp_frac: 0. dlf : 0. - #surface fluxes + #--surface fluxes bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml index d8d8e769470..c26db8eb681 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml @@ -1,6 +1,6 @@ %YAML 1.1 --- -filename_prefix: shoc_mam4_aci_output +filename_prefix: p3_mam4_wetscav_output Averaging Type: Instant Field Names: - cldfrac_liq diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/CMakeLists.txt b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/CMakeLists.txt new file mode 100644 index 00000000000..b5a6be819ce --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/CMakeLists.txt @@ -0,0 +1,41 @@ +INCLUDE (ScreamUtils) + +set (TEST_BASE_NAME shoc_cldfrac_p3_wetscav) +set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files) + +# Create the test +CreateADUnitTest(${TEST_BASE_NAME} + LIBS shoc cld_fraction p3 mam + LABELS shoc cld p3 physics mam4_wetscav + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME} +) + +# Set AD configurable options +set (ATM_TIME_STEP 1800) +SetVarDependingOnTestSize(NUM_STEPS 2 5 48) # 1h 4h 24h +set (RUN_T0 2021-10-12-45000) + +# Determine num subcycles needed to keep shoc dt<=300s +set (SHOC_MAX_DT 300) +math (EXPR MAC_MIC_SUBCYCLES "(${ATM_TIME_STEP} + ${SHOC_MAX_DT} - 1) / ${SHOC_MAX_DT}") + +# Ensure test input files are present in the data dir +GetInputFile(scream/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev}) +GetInputFile(cam/topo/${EAMxx_tests_TOPO_FILE}) + +## Copy (and configure) yaml files needed by tests +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml + ${CMAKE_CURRENT_BINARY_DIR}/input.yaml) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/output.yaml + ${CMAKE_CURRENT_BINARY_DIR}/output.yaml) + +# Compare output files produced by npX tests, to ensure they are bfb +include (CompareNCFiles) +CompareNCFilesFamilyMpi ( + TEST_BASE_NAME ${TEST_BASE_NAME} + FILE_META_NAME ${TEST_BASE_NAME}_output.INSTANT.nsteps_x${NUM_STEPS}.npMPIRANKS.${RUN_T0}.nc + MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END} + LABELS shoc cld p3 physics PEM mam4_wetscav + META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_npMPIRANKS_omp1 +) diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml new file mode 100644 index 00000000000..f5f491a3380 --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml @@ -0,0 +1,83 @@ +%YAML 1.1 +--- +driver_options: + atmosphere_dag_verbosity_level: 5 + +time_stepping: + time_step: ${ATM_TIME_STEP} + run_t0: ${RUN_T0} # YYYY-MM-DD-XXXXX + number_of_steps: ${NUM_STEPS} + +atmosphere_processes: + atm_procs_list: [mac_mic, mam4_wetscav] + schedule_type: Sequential + mac_mic: + atm_procs_list: [shoc,CldFraction,p3] + Type: Group + schedule_type: Sequential + number_of_subcycles: ${MAC_MIC_SUBCYCLES} + p3: + max_total_ni: 740.0e3 + do_prescribed_ccn: false + shoc: + lambda_low: 0.001 + lambda_high: 0.04 + lambda_slope: 2.65 + lambda_thresh: 0.02 + thl2tune: 1.0 + qw2tune: 1.0 + qwthl2tune: 1.0 + w2tune: 1.0 + length_fac: 0.5 + c_diag_3rd_mom: 7.0 + Ckh: 0.1 + Ckm: 0.1 +grids_manager: + Type: Mesh Free + geo_data_source: IC_FILE + grids_names: [Physics GLL] + Physics GLL: + aliases: [Physics] + type: point_grid + number_of_global_columns: 218 + number_of_vertical_levels: 72 + +initial_conditions: + # The name of the file containing the initial conditions for this test. + Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_MAM4xx_72lev} + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} + pbl_height: 25.0 + phis : 0.1 + #variables needed by mam4_wetscav + #--variables from convection scheme (they should all be zero) + rprdsh: 0. + rprddp: 0. + evapcsh: 0. + evapcdp: 0. + icwmrdp: 0. + icwmrsh: 0. + sh_frac: 0. + dp_frac: 0. + dlf : 0. + #--surface fluxes + bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + + #variable required for shoc + surf_sens_flux: 0.0 + surf_evap: 0.0 + + #variable required for p3 + precip_ice_surf_mass: 0.0 + precip_liq_surf_mass: 0.0 + +# The parameters for I/O control +Scorpio: + output_yaml_files: ["output.yaml"] +... diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml new file mode 100644 index 00000000000..8f7d04661aa --- /dev/null +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml @@ -0,0 +1,100 @@ +%YAML 1.1 +--- +filename_prefix: shoc_cldfrac_p3_mam4_wetscav_output +Averaging Type: Instant +Field Names: + # SHOC + - cldfrac_liq + - eddy_diff_mom + - horiz_winds + - sgs_buoy_flux + - tke + - inv_qc_relvar + - pbl_height + # CLD + - cldfrac_ice + - cldfrac_tot + # P3 + - bm + - nc + - ni + - nr + - qi + - qm + - qr + - T_prev_micro_step + - qv_prev_micro_step + - eff_radius_qc + - eff_radius_qi + - eff_radius_qr + - micro_liq_ice_exchange + - micro_vap_ice_exchange + - micro_vap_liq_exchange + - precip_ice_surf_mass + - precip_liq_surf_mass + - rainfrac + # SHOC + P3 + - qc + - qv + # wetscav + - T_mid + - bc_a1 + - bc_a3 + - bc_a4 + - dst_a1 + - dst_a3 + - so4_a1 + - so4_a2 + - so4_a3 + - pom_a1 + - pom_a3 + - pom_a4 + - soa_a1 + - soa_a2 + - soa_a3 + - nacl_a1 + - nacl_a2 + - nacl_a3 + - mom_a1 + - mom_a2 + - mom_a3 + - mom_a4 + - num_a1 + - num_a2 + - num_a3 + - num_a4 + - bc_c1 + - bc_c3 + - bc_c4 + - dst_c1 + - dst_c3 + - so4_c1 + - so4_c2 + - so4_c3 + - pom_c1 + - pom_c3 + - pom_c4 + - soa_c1 + - soa_c2 + - soa_c3 + - nacl_c1 + - nacl_c2 + - nacl_c3 + - mom_c1 + - mom_c2 + - mom_c3 + - mom_c4 + - num_c1 + - num_c2 + - num_c3 + - num_c4 + - aerdepwetis + - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat +output_control: + Frequency: ${NUM_STEPS} + frequency_units: nsteps +... From 0ec3227dd7312ab040502093ce698e0a760e92c9 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Thu, 4 Jul 2024 23:50:24 -0700 Subject: [PATCH 47/71] updated submodule to a newer version --- externals/mam4xx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/mam4xx b/externals/mam4xx index f5700d5f2ac..e949c1cb50b 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit f5700d5f2ac6a6a7f845ee73a50a2bd1d268e22c +Subproject commit e949c1cb50b16eeafe0161caafc4c044171b7975 From d00cd5035485018a0d07cf69554b9be7945d85fc Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 00:43:26 -0700 Subject: [PATCH 48/71] Cleans wetscav hpp file and minor changes to the cpp file --- .../eamxx_mam_wetscav_process_interface.cpp | 19 +--- .../eamxx_mam_wetscav_process_interface.hpp | 101 +++++++++--------- 2 files changed, 52 insertions(+), 68 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index c581a575706..1dc6265942c 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -1,19 +1,11 @@ #include "physics/mam/eamxx_mam_wetscav_process_interface.hpp" -#include - -#include "scream_config.h" // for SCREAM_CIME_BUILD - -// Remove the following<<<< -#include -#include -//>>>>>>> - /* ----------------------------------------------------------------- NOTES: 1. We should connect surface fluxes and add code to update the fluxes 2. Identify diagnostic variables and remove them from FM +3. Add assert statements to check output ranges */ namespace scream { @@ -27,12 +19,9 @@ MAMWetscav::MAMWetscav(const ekat::Comm &comm, */ } -AtmosphereProcessType MAMWetscav::type() const { - return AtmosphereProcessType::Physics; -} - -std::string MAMWetscav::name() const { return "mam4_wetscav"; } -// ========================================================================================= +// ================================================================ +// SET_GRIDS +// ================================================================ void MAMWetscav::set_grids( const std::shared_ptr grids_manager) { using namespace ekat::units; diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index 6f15752953c..ea2de868108 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -10,7 +10,6 @@ // For component name #include -#include #ifndef KOKKOS_ENABLE_CUDA #define protected_except_cuda public #define private_except_cuda public @@ -30,28 +29,21 @@ namespace scream { */ class MAMWetscav : public scream::AtmosphereProcess { - - using KT = ekat::KokkosTypes; - using view_1d = typename KT::template view_1d; + using KT = ekat::KokkosTypes; using view_2d = typename KT::template view_2d; - using view_3d = typename KT::template view_3d; - - using const_view_2d = typename KT::template view_2d; - using const_view_1d = typename KT::template view_1d; // remove it if possible - // a thread team dispatched to a single vertical column using ThreadTeam = mam4::ThreadTeam; public: - // Constructors + // Constructor MAMWetscav(const ekat::Comm &comm, const ekat::ParameterList ¶ms); // The type of subcomponent - AtmosphereProcessType - type() const override; + AtmosphereProcessType type() const { return AtmosphereProcessType::Physics; } + // The name of the subcomponent - std::string name() const override; + std::string name() const { return "mam4_wetscav"; } // Set the grid and input output variables void set_grids( @@ -70,7 +62,6 @@ class MAMWetscav : public scream::AtmosphereProcess { // Finalize void finalize_impl(){/*Do nothing*/}; - // Atmosphere processes often have a pre-processing step that constructs // required variables from the set of fields stored in the field manager. // This functor implements this step, which is called during run_impl. @@ -79,10 +70,10 @@ class MAMWetscav : public scream::AtmosphereProcess { // on host: initializes preprocess functor with necessary state data void initialize(const int ncol_in, const int nlev_in, - const mam_coupling::WetAtmosphere& wet_atm_in, - const mam_coupling::AerosolState& wet_aero_in, - const mam_coupling::DryAtmosphere& dry_atm_in, - const mam_coupling::AerosolState& dry_aero_in) { + const mam_coupling::WetAtmosphere &wet_atm_in, + const mam_coupling::AerosolState &wet_aero_in, + const mam_coupling::DryAtmosphere &dry_atm_in, + const mam_coupling::AerosolState &dry_aero_in) { ncol_pre_ = ncol_in; nlev_pre_ = nlev_in; wet_atm_pre_ = wet_atm_in; @@ -92,26 +83,29 @@ class MAMWetscav : public scream::AtmosphereProcess { } KOKKOS_INLINE_FUNCTION - void operator()(const Kokkos::TeamPolicy::member_type& team) const { - const int i = team.league_rank(); // column index + void operator()( + const Kokkos::TeamPolicy::member_type &team) const { + const int i = team.league_rank(); // column index // first, compute dry fields compute_dry_mixing_ratios(team, wet_atm_pre_, dry_atm_pre_, i); - compute_dry_mixing_ratios(team, wet_atm_pre_, wet_aero_pre_, dry_aero_pre_, i); + compute_dry_mixing_ratios(team, wet_atm_pre_, wet_aero_pre_, + dry_aero_pre_, i); team.team_barrier(); // second, we can use dry fields to compute dz, zmin, zint compute_vertical_layer_heights(team, dry_atm_pre_, i); compute_updraft_velocities(team, wet_atm_pre_, dry_atm_pre_, i); - team.team_barrier(); // allows kernels below to use layer heights - } // operator() + // allows kernels below to use layer heights operator() + team.team_barrier(); + } - // number of horizontal columns and vertical levels + // Number of horizontal columns and vertical levels int ncol_pre_, nlev_pre_; - // local atmospheric and aerosol state data + // Local atmospheric and aerosol state data mam_coupling::WetAtmosphere wet_atm_pre_; mam_coupling::DryAtmosphere dry_atm_pre_; - mam_coupling::AerosolState wet_aero_pre_, dry_aero_pre_; - }; // MAMWetscav::Preprocess + mam_coupling::AerosolState wet_aero_pre_, dry_aero_pre_; + }; // MAMWetscav::Preprocess // Postprocessing functor struct Postprocess { @@ -119,24 +113,26 @@ class MAMWetscav : public scream::AtmosphereProcess { // on host: initializes postprocess functor with necessary state data void initialize(const int ncol, const int nlev, - const mam_coupling::WetAtmosphere& wet_atm, - const mam_coupling::AerosolState& wet_aero, - const mam_coupling::DryAtmosphere& dry_atm, - const mam_coupling::AerosolState& dry_aero) { - ncol_post_ = ncol; - nlev_post_ = nlev; - wet_atm_post_ = wet_atm; + const mam_coupling::WetAtmosphere &wet_atm, + const mam_coupling::AerosolState &wet_aero, + const mam_coupling::DryAtmosphere &dry_atm, + const mam_coupling::AerosolState &dry_aero) { + ncol_post_ = ncol; + nlev_post_ = nlev; + wet_atm_post_ = wet_atm; wet_aero_post_ = wet_aero; - dry_atm_post_ = dry_atm; + dry_atm_post_ = dry_atm; dry_aero_post_ = dry_aero; } KOKKOS_INLINE_FUNCTION - void operator()(const Kokkos::TeamPolicy::member_type& team) const { - const int i = team.league_rank(); // column index - compute_wet_mixing_ratios(team, dry_atm_post_, dry_aero_post_, wet_aero_post_, i); + void operator()( + const Kokkos::TeamPolicy::member_type &team) const { + const int i = team.league_rank(); // column index + compute_wet_mixing_ratios(team, dry_atm_post_, dry_aero_post_, + wet_aero_post_, i); team.team_barrier(); - } // operator() + } // operator() // number of horizontal columns and vertical levels int ncol_post_, nlev_post_; @@ -144,33 +140,32 @@ class MAMWetscav : public scream::AtmosphereProcess { // local atmospheric and aerosol state data mam_coupling::WetAtmosphere wet_atm_post_; mam_coupling::DryAtmosphere dry_atm_post_; - mam_coupling::AerosolState wet_aero_post_, dry_aero_post_; - }; // MAMWetscav::Postprocess - - - /* ----------------------------------------------- - * Local variables - * ------------------------------------------------ - */ + mam_coupling::AerosolState wet_aero_post_, dry_aero_post_; + }; // MAMWetscav::Postprocess + private: + // ----------------------------------------------- + // Local variables + // ------------------------------------------------ // pre- and postprocessing scratch pads (for wet <-> dry conversions) Preprocess preprocess_; Postprocess postprocess_; - // Number of horizontal columns and vertical levels int ncol_, nlev_; - //Number of aerosol modes + // Number of aerosol modes static constexpr int ntot_amode_ = mam4::AeroConfig::num_modes(); - // atmospheric variables + // Atmospheric variables mam_coupling::WetAtmosphere wet_atm_; mam_coupling::DryAtmosphere dry_atm_; - // wet dep + + // Work arrays view_2d work_; - // aerosol states - mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_; + + // Aerosol states + mam_coupling::AerosolState wet_aero_, dry_aero_, dry_aero_tends_; mam_coupling::Buffer buffer_; From dd7e21b66f666f06b679d974247a3578b1e72e82 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 01:32:23 -0700 Subject: [PATCH 49/71] Adds descriptive var names; removes conv vars from FM; fixes input and namelist yaml files with new var names --- .../cime_config/namelist_defaults_scream.xml | 37 ++---- .../eamxx_mam_wetscav_process_interface.cpp | 115 +++++++----------- .../eamxx_mam_wetscav_process_interface.hpp | 6 +- .../input.yaml | 47 ++----- .../mam/p3_mam4_wetscav/input.yaml | 26 ++-- .../mam/shoc_cldfrac_p3_wetscav/input.yaml | 26 ++-- .../single-process/mam/wet_scav/input.yaml | 26 ++-- 7 files changed, 94 insertions(+), 189 deletions(-) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 79fcc64f384..0cd7f023bf1 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -561,35 +561,14 @@ be lost if SCREAM_HACK_XML is not enabled. 0.0 0.0 0.0 - 0.5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 0.5 - 0.0 - 0.0 - 0.0 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 1dc6265942c..768a1b827a4 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -53,7 +53,8 @@ void MAMWetscav::set_grids( m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); // layout for 2D (ncol, pcnst) - FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "pcnst"); + FieldLayout scalar2d_pconst = + m_grid->get_2d_vector_layout(pcnst, "num_phys_constants"); // -------------------------------------------------------------------------- // These variables are "required" or pure inputs for the process @@ -101,10 +102,10 @@ void MAMWetscav::set_grids( //----------- Variables from microphysics scheme ------------- - // Evaporation from stratiform rain [kg/kg/s] (FIXME: Get it from P3) + // Evaporation from stratiform rain [kg/kg/s] add_field("nevapr", scalar3d_mid, kg / kg / s, grid_name); - // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) + // Stratiform rain production rate [kg/kg/s] add_field("precip_total_tend", scalar3d_mid, kg / kg / s, grid_name); @@ -116,38 +117,6 @@ void MAMWetscav::set_grids( // Total cloud fraction [fraction] add_field("cldfrac_liq", scalar3d_mid, nondim, grid_name); - //----------- Variables from convective scheme ------------- - - // Following variables are from convective parameterization (not implemented - // yet in EAMxx), so should be zero for now - - // Deep convective cloud fraction [fraction] - add_field("dp_frac", scalar3d_mid, nondim, grid_name); - - // Shallow convective cloud fraction [fraction] //NOT updated - add_field("sh_frac", scalar3d_mid, nondim, grid_name); - - // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] - add_field("evapcsh", scalar3d_mid, kg / kg / s, grid_name); - - // Evaporation rate of deep precipitation >=0. [kg/kg/s] - add_field("evapcdp", scalar3d_mid, kg / kg / s, grid_name); - - // Rain production, shallow convection [kg/kg/s] - add_field("rprdsh", scalar3d_mid, kg / kg / s, grid_name); - - // Rain production, deep convection [kg/kg/s] - add_field("rprddp", scalar3d_mid, kg / kg / s, grid_name); - - // In cloud water mixing ratio, deep convection [kg/kg] - add_field("icwmrdp", scalar3d_mid, kg / kg, grid_name); - - // In cloud water mixing ratio, shallow convection [kg/kg] - add_field("icwmrsh", scalar3d_mid, kg / kg, grid_name); - - // Detraining cld H20 from deep convection [kg/kg/s] - add_field("dlf", scalar3d_mid, kg / kg / s, grid_name); - // --------------------------------------------------------------------- // These variables are "updated" or inputs/outputs for the process // --------------------------------------------------------------------- @@ -156,28 +125,32 @@ void MAMWetscav::set_grids( // for the land model // Wet deposition of hydrophilic black carbon [kg/m2/s] - add_field("bcphiwet", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_hydrophilic_bc", scalar3d_mid, kg / m2 / s, + grid_name); // Dry deposition of hydrophilic black carbon [kg/m2/s] - add_field("bcphidry", scalar3d_mid, kg / m2 / s, grid_name); + add_field("drydep_hydrophilic_bc", scalar3d_mid, kg / m2 / s, + grid_name); // Wet deposition of hydrophilic organic carbon [kg/m2/s] - add_field("ocphiwet", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_hydrophilic_oc", scalar3d_mid, kg / m2 / s, + grid_name); // Dry deposition of hydrophilic organic carbon [kg/m2/s] - add_field("ocphidry", scalar3d_mid, kg / m2 / s, grid_name); + add_field("drydep_hydrophilic_oc", scalar3d_mid, kg / m2 / s, + grid_name); // Wet deposition of dust (bin1) [kg/m2/s] - add_field("dstwet1", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_dust_bin1", scalar3d_mid, kg / m2 / s, grid_name); // Wet deposition of dust (bin2) [kg/m2/s] - add_field("dstwet2", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_dust_bin2", scalar3d_mid, kg / m2 / s, grid_name); // Wet deposition of dust (bin3) [kg/m2/s] - add_field("dstwet3", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_dust_bin3", scalar3d_mid, kg / m2 / s, grid_name); // Wet deposition of dust (bin4) [kg/m2/s] - add_field("dstwet4", scalar3d_mid, kg / m2 / s, grid_name); + add_field("wetdep_dust_bin4", scalar3d_mid, kg / m2 / s, grid_name); // Interstitial and cloudborne aerosol tracers of interest: mass (q) and // number (n) mixing ratios @@ -193,11 +166,11 @@ void MAMWetscav::set_grids( "tracers"); // cloudborne aerosol tracers of interest: number (n) mixing ratios + // Note: Do *not* add cld borne aerosols to the "tracer" group as these are + // not advected const char *cld_nmr_field_name = mam_coupling::cld_aero_nmr_field_name(imode); - // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are - // NOT advected add_field(cld_nmr_field_name, scalar3d_mid, n_unit, grid_name); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { @@ -210,6 +183,8 @@ void MAMWetscav::set_grids( } // (cloudborne) aerosol tracers of interest: mass (q) mixing ratios + // Note: Do *not* add cld borne aerosols to the "tracer" group as these + // are not advected const char *cld_mmr_field_name = mam_coupling::cld_aero_mmr_field_name(imode, ispec); if(strlen(cld_mmr_field_name) > 0) { @@ -220,10 +195,6 @@ void MAMWetscav::set_grids( } } - // Tracers group -- do we need this in addition to the tracers above? In any - // case, this call should be idempotent, so it can't hurt. - add_group("tracers", grid_name, 1, Bundling::Required); - // The following fields are not needed by this process but we define them so // that we can create MAM4xx class objects like atmosphere, prognostics etc. @@ -260,14 +231,9 @@ void MAMWetscav::set_grids( add_field("aerdepwetcw", scalar2d_pconst, kg / m2 / s, grid_name); } -// ========================================================================================= -// 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 MAMWetscav::requested_buffer_size_in_bytes() const { - return mam_coupling::buffer_size(ncol_, nlev_); -} - -// ========================================================================================= +// ================================================================ +// INIT_BUFFERS +// ================================================================ // ON HOST, initializeŃ• the Buffer type with sufficient memory to store // intermediate (dry) quantities on the given number of columns with the given // number of vertical levels. Returns the number of bytes allocated. @@ -282,7 +248,9 @@ void MAMWetscav::init_buffers(const ATMBufferManager &buffer_manager) { "Error! Used memory != requested memory for MAMWetscav."); } -// ========================================================================================= +// ================================================================ +// INITIALIZE_IMPL +// ================================================================ void MAMWetscav::initialize_impl(const RunType run_type) { // --------------------------------------------------------------- // Input fields read in from IC file, namelist or other processes @@ -401,7 +369,9 @@ void MAMWetscav::initialize_impl(const RunType run_type) { dry_aero_); } -// ========================================================================================= +// ================================================================ +// RUN_IMPL +// ================================================================ void MAMWetscav::run_impl(const double dt) { const auto scan_policy = ekat::ExeSpaceUtils< KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_); @@ -425,31 +395,40 @@ void MAMWetscav::run_impl(const double dt) { // Following variables are from convective parameterization (not implemented // yet in EAMxx), so should be zero for now - auto sh_frac = get_field_in("sh_frac").get_view(); + auto sh_frac = view_2d("sh_frac", ncol_, nlev_); + Kokkos::deep_copy(sh_frac, 0); // Deep convective cloud fraction [fraction] - auto dp_frac = get_field_in("dp_frac").get_view(); + auto dp_frac = view_2d("dp_frac", ncol_, nlev_); + Kokkos::deep_copy(dp_frac, 0); // Evaporation rate of shallow convective precipitation >=0. [kg/kg/s] - auto evapcsh = get_field_in("evapcsh").get_view(); + auto evapcsh = view_2d("evapcsh", ncol_, nlev_); + Kokkos::deep_copy(evapcsh, 0); // Evaporation rate of deep convective precipitation >=0. [kg/kg/s] - auto evapcdp = get_field_in("evapcdp").get_view(); + auto evapcdp = view_2d("evapcdp", ncol_, nlev_); + Kokkos::deep_copy(evapcdp, 0); // Rain production, shallow convection [kg/kg/s] - auto rprdsh = get_field_in("rprdsh").get_view(); + auto rprdsh = view_2d("rprdsh", ncol_, nlev_); + Kokkos::deep_copy(rprdsh, 0); // Rain production, deep convection [kg/kg/s] - auto rprddp = get_field_in("rprddp").get_view(); + auto rprddp = view_2d("rprddp", ncol_, nlev_); + Kokkos::deep_copy(rprddp, 0); // In cloud water mixing ratio, deep convection - auto icwmrdp = get_field_in("icwmrdp").get_view(); + auto icwmrdp = view_2d("icwmrdp", ncol_, nlev_); + Kokkos::deep_copy(icwmrdp, 0); // In cloud water mixing ratio, shallow convection - auto icwmrsh = get_field_in("icwmrsh").get_view(); + auto icwmrsh = view_2d("icwmrsh", ncol_, nlev_); + Kokkos::deep_copy(icwmrsh, 0); // Detraining cld H20 from deep convection [kg/kg/s] - auto dlf = get_field_in("dlf").get_view(); + auto dlf = view_2d("dlf", ncol_, nlev_); + Kokkos::deep_copy(dlf, 0); //----------- Variables from macrophysics scheme ------------- // Total cloud fraction diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index ea2de868108..8bd81115d8a 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -50,7 +50,11 @@ class MAMWetscav : public scream::AtmosphereProcess { const std::shared_ptr grids_manager) override; // management of common atm process memory - size_t requested_buffer_size_in_bytes() const override; + // 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 { + return mam_coupling::buffer_size(ncol_, nlev_); + } void init_buffers(const ATMBufferManager &buffer_manager) override; // Initialize variables diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml index bfbec956d85..fc15d9ce252 100644 --- a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml @@ -11,45 +11,18 @@ time_stepping: initial_conditions: Filename: ${SCREAM_DATA_DIR}/init/scream_unit_tests_aerosol_optics_ne2np4L72_20220822.nc topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} - surf_evap: 0.0 - surf_sens_flux: 0.0 - precip_liq_surf_mass: 0.0 - precip_ice_surf_mass: 0.0 - cldn: 0.5 - rprdsh: 1e-5 - rprddp: 1e-5 - evapcsh: 1e-5 - evapcdp: 1e-5 - cldt: 1e-5 - prain: 1e-5 - evapr: 1e-5 - icwmrdp: 1e-5 - icwmrsh: 1e-5 - rprddp: 1e-5 - rprdsh: 1e-5 - sh_frac: 1e-5 - dp_frac: 1e-5 - evapcsh: 1e-5 - evapcdp: 1e-5 - bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] - bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] - ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] - ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] - dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] - dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] - dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] - dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] - dgncur_a: 1e-5 # aerosol particle diameter [m] - wetdens: 1e-5 # wet aerosol density [kg/m3] - qaerwat: 1e-5 # aerosol water [kg/kg] - dgnumwet: 1e-5 # wet aerosol diameter [m] - fracis: 1e-5 # fraction of transported species that are insoluble [fraction] - cldfrac_tot: 0.5 pbl_height: 25.0 phis : 0.1 - dlf : 0.0 - dp_ccf : 0.0 - sh_ccf : 0.0 + #variables needed by mam4_wetscav + #--surface fluxes + wetdep_hydrophilic_bc: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + drydep_hydrophilic_bc: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + wetdep_hydrophilic_oc: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + drydep_hydrophilic_oc: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + wetdep_dust_bin1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + wetdep_dust_bin2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + wetdep_dust_bin3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + wetdep_dust_bin4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] atmosphere_processes: atm_procs_list: [homme,physics] diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml index f5d2dc036c0..f0d9b7c89a3 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/input.yaml @@ -37,25 +37,15 @@ initial_conditions: pbl_height: 25.0 phis : 0.1 #variables needed by mam4_wetscav - #--variables from convection scheme (they should all be zero) - rprdsh: 0. - rprddp: 0. - evapcsh: 0. - evapcdp: 0. - icwmrdp: 0. - icwmrsh: 0. - sh_frac: 0. - dp_frac: 0. - dlf : 0. #--surface fluxes - bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] - bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] - ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] - ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] - dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] - dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] - dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] - dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + wetdep_hydrophilic_bc: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + drydep_hydrophilic_bc: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + wetdep_hydrophilic_oc: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + drydep_hydrophilic_oc: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + wetdep_dust_bin1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + wetdep_dust_bin2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + wetdep_dust_bin3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + wetdep_dust_bin4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] #variable required for p3 precip_ice_surf_mass: 0.0 diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml index f5f491a3380..804939a2205 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/input.yaml @@ -49,25 +49,15 @@ initial_conditions: pbl_height: 25.0 phis : 0.1 #variables needed by mam4_wetscav - #--variables from convection scheme (they should all be zero) - rprdsh: 0. - rprddp: 0. - evapcsh: 0. - evapcdp: 0. - icwmrdp: 0. - icwmrsh: 0. - sh_frac: 0. - dp_frac: 0. - dlf : 0. #--surface fluxes - bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] - bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] - ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] - ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] - dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] - dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] - dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] - dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + wetdep_hydrophilic_bc: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + drydep_hydrophilic_bc: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + wetdep_hydrophilic_oc: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + drydep_hydrophilic_oc: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + wetdep_dust_bin1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + wetdep_dust_bin2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + wetdep_dust_bin3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + wetdep_dust_bin4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] #variable required for shoc surf_sens_flux: 0.0 diff --git a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml index f2a62a15823..d1fd9f3659d 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/input.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/input.yaml @@ -30,25 +30,15 @@ initial_conditions: #variables from P3 precip_total_tend: 1e-5 nevapr: 1e-5 - #variables from convection scheme (they should all be zero) - rprdsh: 0. - rprddp: 0. - evapcsh: 0. - evapcdp: 0. - icwmrdp: 0. - icwmrsh: 0. - sh_frac: 0. - dp_frac: 0. - dlf : 0. #surface fluxes - bcphiwet: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] - bcphidry: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] - ocphiwet: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] - ocphidry: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] - dstwet1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] - dstwet2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] - dstwet3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] - dstwet4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] + wetdep_hydrophilic_bc: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] + drydep_hydrophilic_bc: 1e-5 # dry deposition of hydrophilic black carbon [kg/m2/s] + wetdep_hydrophilic_oc: 1e-5 # wet deposition of hydrophilic organic carbon [kg/m2/s] + drydep_hydrophilic_oc: 1e-5 # dry deposition of hydrophilic organic carbon [kg/m2/s] + wetdep_dust_bin1: 1e-5 # wet deposition of dust (bin1) [kg/m2/s] + wetdep_dust_bin2: 1e-5 # wet deposition of dust (bin2) [kg/m2/s] + wetdep_dust_bin3: 1e-5 # wet deposition of dust (bin3) [kg/m2/s] + wetdep_dust_bin4: 1e-5 # wet deposition of dust (bin4) [kg/m2/s] # The parameters for I/O control Scorpio: output_yaml_files: ["output.yaml"] From e6610dd5e5a4fdc657c7f39da0543f5e66b00778 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 01:42:56 -0700 Subject: [PATCH 50/71] Adds const for input vars, removes scorpio temp change --- .../eamxx_mam_wetscav_process_interface.cpp | 39 +++++++++---------- .../mam/impl/compute_particle_size.cpp | 9 ----- .../src/share/io/scream_scorpio_interface.cpp | 4 +- 3 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 components/eamxx/src/physics/mam/impl/compute_particle_size.cpp diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 768a1b827a4..8d4b6cda29c 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -439,11 +439,11 @@ void MAMWetscav::run_impl(const double dt) { // Evaporation from stratiform rain [kg/kg/s] auto nevapr = get_field_in("nevapr").get_view(); - // Stratiform rain production rate [kg/kg/s] (FIXME: Get it from P3) + // Stratiform rain production rate [kg/kg/s] auto prain = get_field_in("precip_total_tend").get_view(); - // ------------------------------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------ // These variables are "Computed" or pure outputs for the process - // ------------------------------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------ const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); @@ -465,9 +465,9 @@ void MAMWetscav::run_impl(const double dt) { // Loop over atmosphere columns Kokkos::parallel_for( policy, KOKKOS_LAMBDA(const ThreadTeam &team) { - const int icol = team.league_rank(); // column index*/ + const int icol = team.league_rank(); // column index - auto atm = mam_coupling::atmosphere_for_column(dry_atm, icol); + const auto atm = mam_coupling::atmosphere_for_column(dry_atm, icol); // set surface state data // fetch column-specific subviews into aerosol prognostics mam4::Prognostics progs = @@ -478,25 +478,24 @@ void MAMWetscav::run_impl(const double dt) { mam_coupling::interstitial_aerosols_tendencies_for_column( dry_aero_tends, icol); /// shallow_convective_precipitation_production - auto rprdsh_icol = ekat::subview(rprdsh, icol); + const auto rprdsh_icol = ekat::subview(rprdsh, icol); // deep_convective_precipitation_production - auto rprddp_icol = ekat::subview(rprddp, icol); + const auto rprddp_icol = ekat::subview(rprddp, icol); // deep_convective_precipitation_evaporation - auto evapcdp_icol = ekat::subview(evapcdp, icol); + const auto evapcdp_icol = ekat::subview(evapcdp, icol); // shallow_convective_precipitation_evaporation = - auto evapcsh_icol = ekat::subview(evapcsh, icol); + const auto evapcsh_icol = ekat::subview(evapcsh, icol); // deep_convective_cloud_fraction - auto dp_frac_icol = ekat::subview(dp_frac, icol); + const auto dp_frac_icol = ekat::subview(dp_frac, icol); // shallow_convective_cloud_fraction = - auto sh_frac_icol = ekat::subview(sh_frac, icol); - // FIXME: what is this? + const auto sh_frac_icol = ekat::subview(sh_frac, icol); - auto icwmrdp_col = ekat::subview(icwmrdp, icol); - auto icwmrsh_icol = ekat::subview(icwmrsh, icol); - auto nevapr_icol = ekat::subview(nevapr, icol); - auto cldt_icol = ekat::subview(cldt, icol); + const auto icwmrdp_col = ekat::subview(icwmrdp, icol); + const auto icwmrsh_icol = ekat::subview(icwmrsh, icol); + const auto nevapr_icol = ekat::subview(nevapr, icol); + const auto cldt_icol = ekat::subview(cldt, icol); - auto dlf_icol = ekat::subview(dlf, icol); + const auto dlf_icol = ekat::subview(dlf, icol); auto aerdepwetis_icol = ekat::subview(aerdepwetis, icol); auto aerdepwetcw_icol = ekat::subview(aerdepwetcw, icol); auto work_icol = ekat::subview(work, icol); @@ -504,9 +503,9 @@ void MAMWetscav::run_impl(const double dt) { ekat::subview(wet_geometric_mean_diameter_i, icol); auto dry_diameter_icol = ekat::subview(dry_geometric_mean_diameter_i, icol); - auto qaerwat_icol = ekat::subview(qaerwat, icol); - auto wetdens_icol = ekat::subview(wetdens, icol); - auto prain_icol = ekat::subview(prain, icol); + auto qaerwat_icol = ekat::subview(qaerwat, icol); + auto wetdens_icol = ekat::subview(wetdens, icol); + const auto prain_icol = ekat::subview(prain, icol); mam4::wetdep::aero_model_wetdep( team, atm, progs, tends, dt, diff --git a/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp b/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp deleted file mode 100644 index 06a4c4cb3be..00000000000 --- a/components/eamxx/src/physics/mam/impl/compute_particle_size.cpp +++ /dev/null @@ -1,9 +0,0 @@ -namespace scream::impl { - -/*KOKKOS_INLINE_FUNCTION -void compute_particle_size(int icol, int nlev_, //in - view_1d& state_q, view_1d& qqcw) { - -}*/ - -} // namespace scream::impl diff --git a/components/eamxx/src/share/io/scream_scorpio_interface.cpp b/components/eamxx/src/share/io/scream_scorpio_interface.cpp index 68a432819ec..cb2b501f2b5 100644 --- a/components/eamxx/src/share/io/scream_scorpio_interface.cpp +++ b/components/eamxx/src/share/io/scream_scorpio_interface.cpp @@ -360,11 +360,11 @@ void finalize_subsystem () EKAT_REQUIRE_MSG (s.pio_sysid!=-1, "Error! PIO subsystem was already finalized.\n"); - /*for (auto& it : s.files) { + for (auto& it : s.files) { EKAT_REQUIRE_MSG (it.second.num_customers==0, "Error! ScorpioSession::finalize called, but a file is still in use elsewhere.\n" " - filename: " + it.first + "\n"); - }*/ + } s.files.clear(); for (auto& it : s.decomps) { From 8c7d2a7ca862d7ff08d0cc9fbeea5f4923a4fb21 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 01:48:38 -0700 Subject: [PATCH 51/71] Cleans up namelist xml file and removes double ICs --- .../cime_config/namelist_defaults_scream.xml | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/components/eamxx/cime_config/namelist_defaults_scream.xml b/components/eamxx/cime_config/namelist_defaults_scream.xml index 0cd7f023bf1..fb4dc5913d0 100644 --- a/components/eamxx/cime_config/namelist_defaults_scream.xml +++ b/components/eamxx/cime_config/namelist_defaults_scream.xml @@ -494,7 +494,7 @@ be lost if SCREAM_HACK_XML is not enabled. 0.0,0.0 2.6e-08 - 0.0 + 0.0 0.0 0.0 0.0 @@ -519,6 +519,15 @@ be lost if SCREAM_HACK_XML is not enabled. 0.0 0.0 0.0 + + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 + 1e-5 0.0 @@ -534,41 +543,6 @@ be lost if SCREAM_HACK_XML is not enabled. 0 0.001 900.0 - - - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 - 1e-5 From 83a85eb310647d09c9de458ab5c0f2077e57ea7d Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 02:00:46 -0700 Subject: [PATCH 52/71] Removes a left over comment --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 8d4b6cda29c..c748432af13 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -188,8 +188,6 @@ void MAMWetscav::set_grids( const char *cld_mmr_field_name = mam_coupling::cld_aero_mmr_field_name(imode, ispec); if(strlen(cld_mmr_field_name) > 0) { - // NOTE: DO NOT add cld borne aerosols to the "tracer" group as these - // are NOT advected add_field(cld_mmr_field_name, scalar3d_mid, q_unit, grid_name); } } From 140ee78b4495a2c08a22c7379454e08ec605802f Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 12:55:33 -0700 Subject: [PATCH 53/71] Minor change in comments --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index c748432af13..1a0d4b7412b 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -211,21 +211,22 @@ void MAMWetscav::set_grids( // Aerosol dry particle diameter [m] add_field("dgncur_a", scalar3d_mid_nmodes, m, grid_name); - // wet aerosol density [kg/m3] + // Wet aerosol density [kg/m3] add_field("wetdens", scalar3d_mid_nmodes, kg / m3, grid_name); - // aerosol water [kg/kg] + // Aerosol water [kg/kg] add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, grid_name); - // wet aerosol diameter [m] + // Wet aerosol diameter [m] add_field("dgnumwet", scalar3d_mid_nmodes, m, grid_name); - // fraction of transported species that are insoluble [fraction] + // Fraction of transported species that are insoluble [fraction] add_field("fracis", scalar3d_mid, nondim, grid_name); - // aerosol wet deposition (interstitial) [kg/m2/s] + // Aerosol wet deposition (interstitial) [kg/m2/s] add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); - // aerosol wet deposition (cloud water) [kg/m2/s] + + // Aerosol wet deposition (cloud water) [kg/m2/s] add_field("aerdepwetcw", scalar2d_pconst, kg / m2 / s, grid_name); } From aed9ffcc67688ad812873b0afaa72b5ded9965aa Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Fri, 5 Jul 2024 14:01:58 -0600 Subject: [PATCH 54/71] wet_scav - Removing Kokkos::resize. --- .../physics/mam/eamxx_mam_wetscav_process_interface.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 1a0d4b7412b..bef4d6c7463 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -337,19 +337,18 @@ void MAMWetscav::initialize_impl(const RunType run_type) { //--------------------------------------------------------------------------------- // Allocate memory - // (Kokkos::resize only works on host to allocates memory) //--------------------------------------------------------------------------------- // Alllocate aerosol-related gas tendencies for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - Kokkos::resize(dry_aero_tends_.gas_mmr[g], ncol_, nlev_); + dry_aero_tends_.gas_mmr[g] = view_2d("gas_mmr",ncol_, nlev_); } // Allocate aerosol state tendencies (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - Kokkos::resize(dry_aero_tends_.int_aero_nmr[imode], ncol_, nlev_); + dry_aero_tends_.int_aero_nmr[imode] = view_2d("int_aero_nmr",ncol_, nlev_); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { - Kokkos::resize(dry_aero_tends_.int_aero_mmr[imode][ispec], ncol_, nlev_); + dry_aero_tends_.int_aero_mmr[imode][ispec] = view_2d("int_aero_mmr",ncol_, nlev_); } } From 019a54cc36a99d55e1657c6c7cb2ac8b0502b2db Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 16:31:13 -0700 Subject: [PATCH 55/71] Fixes some test fails: remove old output varnames, fixed output nc file name --- .../eamxx_mam_wetscav_process_interface.cpp | 7 +++--- .../input.yaml | 4 +++ .../output.yaml | 25 ------------------- .../mam/shoc_cldfrac_p3_wetscav/output.yaml | 2 +- externals/mam4xx | 2 +- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index bef4d6c7463..20672e61f0f 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -340,15 +340,16 @@ void MAMWetscav::initialize_impl(const RunType run_type) { //--------------------------------------------------------------------------------- // Alllocate aerosol-related gas tendencies for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) { - dry_aero_tends_.gas_mmr[g] = view_2d("gas_mmr",ncol_, nlev_); + dry_aero_tends_.gas_mmr[g] = view_2d("gas_mmr", ncol_, nlev_); } // Allocate aerosol state tendencies (interstitial aerosols only) for(int imode = 0; imode < mam_coupling::num_aero_modes(); ++imode) { - dry_aero_tends_.int_aero_nmr[imode] = view_2d("int_aero_nmr",ncol_, nlev_); + dry_aero_tends_.int_aero_nmr[imode] = view_2d("int_aero_nmr", ncol_, nlev_); for(int ispec = 0; ispec < mam_coupling::num_aero_species(); ++ispec) { - dry_aero_tends_.int_aero_mmr[imode][ispec] = view_2d("int_aero_mmr",ncol_, nlev_); + dry_aero_tends_.int_aero_mmr[imode][ispec] = + view_2d("int_aero_mmr", ncol_, nlev_); } } diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml index fc15d9ce252..c9b493a2958 100644 --- a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/input.yaml @@ -13,6 +13,10 @@ initial_conditions: topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} pbl_height: 25.0 phis : 0.1 + surf_evap: 0.0 + surf_sens_flux: 0.0 + precip_liq_surf_mass: 0.0 + precip_ice_surf_mass: 0.0 #variables needed by mam4_wetscav #--surface fluxes wetdep_hydrophilic_bc: 1e-5 # wet deposition of hydrophilic black carbon [kg/m2/s] diff --git a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml index f85225d1274..afe8437a2cf 100644 --- a/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/dynamics_physics/mam/homme_shoc_cld_spa_p3_rrtmgp_mam4_wetscav/output.yaml @@ -107,31 +107,6 @@ Fields: - dgncur_a - wetdens - qaerwat - - ptend_bc_a1 - - ptend_bc_a3 - - ptend_bc_a4 - - ptend_dst_a1 - - ptend_dst_a3 - - ptend_mom_a1 - - ptend_mom_a2 - - ptend_mom_a3 - - ptend_mom_a4 - - ptend_nacl_a1 - - ptend_nacl_a2 - - ptend_nacl_a3 - - ptend_num_a1 - - ptend_num_a2 - - ptend_num_a3 - - ptend_num_a4 - - ptend_pom_a1 - - ptend_pom_a3 - - ptend_pom_a4 - - ptend_so4_a1 - - ptend_so4_a2 - - ptend_so4_a3 - - ptend_soa_a1 - - ptend_soa_a2 - - ptend_soa_a3 - bc_c1 - bc_c3 - bc_c4 diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml index 8f7d04661aa..1ae53e6c1c3 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml @@ -1,6 +1,6 @@ %YAML 1.1 --- -filename_prefix: shoc_cldfrac_p3_mam4_wetscav_output +filename_prefix: shoc_cldfrac_p3_wetscav_output Averaging Type: Instant Field Names: # SHOC diff --git a/externals/mam4xx b/externals/mam4xx index e949c1cb50b..cafdbc1b881 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit e949c1cb50b16eeafe0161caafc4c044171b7975 +Subproject commit cafdbc1b88134038aff12c1cb00110c6397a4544 From fe66519678d9b1e718e493948d624e9983a5e71c Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 16:36:26 -0700 Subject: [PATCH 56/71] Adds TODO to a comment as some editors can highlight these comments --- components/eamxx/src/share/io/scream_scorpio_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/eamxx/src/share/io/scream_scorpio_interface.cpp b/components/eamxx/src/share/io/scream_scorpio_interface.cpp index cb2b501f2b5..68a432819ec 100644 --- a/components/eamxx/src/share/io/scream_scorpio_interface.cpp +++ b/components/eamxx/src/share/io/scream_scorpio_interface.cpp @@ -360,11 +360,11 @@ void finalize_subsystem () EKAT_REQUIRE_MSG (s.pio_sysid!=-1, "Error! PIO subsystem was already finalized.\n"); - for (auto& it : s.files) { + /*for (auto& it : s.files) { EKAT_REQUIRE_MSG (it.second.num_customers==0, "Error! ScorpioSession::finalize called, but a file is still in use elsewhere.\n" " - filename: " + it.first + "\n"); - } + }*/ s.files.clear(); for (auto& it : s.decomps) { From af58453c13ea3ea0426d57f8a2844fcd3ba1dc44 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 16:49:32 -0700 Subject: [PATCH 57/71] Fixes previous commit: Adds a TODO comment here --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 2 +- components/eamxx/src/share/io/scream_scorpio_interface.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 20672e61f0f..c6153794257 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -391,7 +391,7 @@ void MAMWetscav::run_impl(const double dt) { //----------- Variables from convective scheme ------------- - // Following variables are from convective parameterization (not implemented + // 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_); diff --git a/components/eamxx/src/share/io/scream_scorpio_interface.cpp b/components/eamxx/src/share/io/scream_scorpio_interface.cpp index 68a432819ec..cb2b501f2b5 100644 --- a/components/eamxx/src/share/io/scream_scorpio_interface.cpp +++ b/components/eamxx/src/share/io/scream_scorpio_interface.cpp @@ -360,11 +360,11 @@ void finalize_subsystem () EKAT_REQUIRE_MSG (s.pio_sysid!=-1, "Error! PIO subsystem was already finalized.\n"); - /*for (auto& it : s.files) { + for (auto& it : s.files) { EKAT_REQUIRE_MSG (it.second.num_customers==0, "Error! ScorpioSession::finalize called, but a file is still in use elsewhere.\n" " - filename: " + it.first + "\n"); - }*/ + } s.files.clear(); for (auto& it : s.decomps) { From 4d3b7bc26ccf11cfda080c80a1464cc65cb3d184 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 18:01:22 -0700 Subject: [PATCH 58/71] Adds a new function to add additional tracers for MAM4xx --- .../testmods_dirs/scream/mam4xx/aci/shell_commands | 8 +++++--- .../scream/mam4xx/optics/shell_commands | 9 +++++---- .../scream/mam4xx/wetscav/shell_commands | 12 ++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/aci/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/aci/shell_commands index 68eaf51698b..658c94a3cf6 100644 --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/aci/shell_commands +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/aci/shell_commands @@ -1,7 +1,9 @@ -#Default scream has 10 tracers, MAM4xx adds another 31 making a total of 41 tracer -#Set total number of tracers to 41. We are using append here as last entry wins while parsing xml options -./xmlchange --append SCREAM_CMAKE_OPTIONS="SCREAM_NUM_TRACERS 41" +#------------------------------------------------------ +# MAM4xx adds additionaltracers to the simulation +# Increase number of tracers for MAM4xx simulations +#------------------------------------------------------ +$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh #modify initial condition file to get aerosol species ICs $CIMEROOT/../components/eamxx/scripts/atmchange initial_conditions::Filename='$DIN_LOC_ROOT/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc' -b diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/optics/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/optics/shell_commands index 1c22bd9ee45..224c1658610 100644 --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/optics/shell_commands +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/optics/shell_commands @@ -1,7 +1,8 @@ - -#Default scream has 10 tracers, MAM4xx adds another 31 making a total of 41 tracer -#Set total number of tracers to 41. We are using append here as last entry wins while parsing xml options -./xmlchange --append SCREAM_CMAKE_OPTIONS="SCREAM_NUM_TRACERS 41" +#------------------------------------------------------ +# MAM4xx adds additionaltracers to the simulation +# Increase number of tracers for MAM4xx simulations +#------------------------------------------------------ +$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh $CIMEROOT/../components/eamxx/scripts/atmchange initial_conditions::Filename='$DIN_LOC_ROOT/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc' -b $CIMEROOT/../components/eamxx/scripts/atmchange physics::atm_procs_list="mac_aero_mic,mam4_optics,rrtmgp" -b diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands index f0e96c41398..97f442f88d8 100644 --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands @@ -1,7 +1,11 @@ +#------------------------------------------------------ +# MAM4xx adds additionaltracers to the simulation +# Increase number of tracers for MAM4xx simulations +#------------------------------------------------------ +$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -#Default scream has 10 tracers, MAM4xx adds another 31 making a total of 41 tracer -#Set total number of tracers to 41. We are using append here as last entry wins while parsing xml options -./xmlchange --append SCREAM_CMAKE_OPTIONS="SCREAM_NUM_TRACERS 41" - +#------------------------------------------------------ +#Update IC file and add wetscav process +#------------------------------------------------------ $CIMEROOT/../components/eamxx/scripts/atmchange initial_conditions::Filename='$DIN_LOC_ROOT/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc' -b $CIMEROOT/../components/eamxx/scripts/atmchange physics::atm_procs_list="mac_aero_mic,mam4_wetscav,rrtmgp" -b From 6de6c33682b86c3d4caae1a2ac6a18879e4b53fc Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 5 Jul 2024 18:02:08 -0700 Subject: [PATCH 59/71] Adds the new script for computing number of tracers --- .../scream/mam4xx/update_eamxx_num_tracers.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh new file mode 100644 index 00000000000..930af526eb8 --- /dev/null +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh @@ -0,0 +1,22 @@ +#------------------------------------------------------ +# MAM4xx adds additionaltracers to the simulation +# Increase number of tracers for MAM4xx simulations +#------------------------------------------------------ + +# Additional MAM4xx tracers (MAM4xx adds 31 tracers) +ADDITIONAL_MAM4xx_TRACERS=31 + +# Original CMAKE options in env_build.xml +orig_cmake_opt=`./xmlquery --value SCREAM_CMAKE_OPTIONS` + +# Extract the number of tracers +orig_tracer_num=$(echo $orig_cmake_opt | grep -oP 'SCREAM_NUM_TRACERS \K[0-9]+') + +# Update number of tracers +new_tracer_num=$((orig_tracer_num + ADDITIONAL_MAM4xx_TRACERS)) + +# Form the new CMake options string by replacing the original number with the new number +new_cmake_opt=$(echo $orig_cmake_opt | sed "s/SCREAM_NUM_TRACERS $orig_tracer_num/SCREAM_NUM_TRACERS $new_tracer_num/") + +# Update cmake options string +./xmlchange SCREAM_CMAKE_OPTIONS="$new_cmake_opt" \ No newline at end of file From 54f71108424698eb2d78d89a88c4119ce30c69a2 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Sat, 6 Jul 2024 20:56:14 -0700 Subject: [PATCH 60/71] Fixes script to update tracer number in scream cmake options --- .../testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh | 6 ++++-- .../testmods_dirs/scream/mam4xx/wetscav/shell_commands | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh old mode 100644 new mode 100755 index 930af526eb8..c533123847e --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh @@ -1,5 +1,7 @@ +#!/bin/sh + #------------------------------------------------------ -# MAM4xx adds additionaltracers to the simulation +# MAM4xx adds additional tracers to the simulation # Increase number of tracers for MAM4xx simulations #------------------------------------------------------ @@ -19,4 +21,4 @@ new_tracer_num=$((orig_tracer_num + ADDITIONAL_MAM4xx_TRACERS)) new_cmake_opt=$(echo $orig_cmake_opt | sed "s/SCREAM_NUM_TRACERS $orig_tracer_num/SCREAM_NUM_TRACERS $new_tracer_num/") # Update cmake options string -./xmlchange SCREAM_CMAKE_OPTIONS="$new_cmake_opt" \ No newline at end of file +`./xmlchange SCREAM_CMAKE_OPTIONS="$new_cmake_opt"` diff --git a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands index 97f442f88d8..7b5b9a87650 100644 --- a/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands +++ b/components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/wetscav/shell_commands @@ -1,8 +1,10 @@ +#!/bin/sh #------------------------------------------------------ # MAM4xx adds additionaltracers to the simulation # Increase number of tracers for MAM4xx simulations #------------------------------------------------------ -$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh + +$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -b #------------------------------------------------------ #Update IC file and add wetscav process From b00a709d4a9da196e40c19dac0349854521cc70a Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 12 Jul 2024 10:37:48 -0700 Subject: [PATCH 61/71] Adds missing call to update the state (int and cldbrn aerosols) --- .../physics/mam/eamxx_mam_wetscav_process_interface.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index c6153794257..c62dcd073b0 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -391,8 +391,8 @@ void MAMWetscav::run_impl(const double dt) { //----------- Variables from convective scheme ------------- - // TODO: Following variables are from convective parameterization (not implemented - // yet in EAMxx), so should be zero for now + // 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); @@ -527,6 +527,11 @@ void MAMWetscav::run_impl(const double dt) { } }); }); // icol parallel_for loop + + // call post processing to convert dry mixing ratios to wet mixing ratios + // and update the state + Kokkos::parallel_for("postprocess", scan_policy, postprocess_); + Kokkos::fence(); // wait before returning to calling function } // ========================================================================================= From 4734cac912b4f51fb25f04957400299df8c47187 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 12 Jul 2024 11:30:04 -0700 Subject: [PATCH 62/71] Updates number mixing ratios for state --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index c62dcd073b0..4f1af79a057 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -519,6 +519,9 @@ void MAMWetscav::run_impl(const double dt) { // update interstitial aerosol state Kokkos::parallel_for(Kokkos::TeamVectorRange(team, nlev), [&](int kk) { for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { + const auto n_mode_i = progs.n_mode_i[m]; + const auto tends_n_mode_i = tends.n_mode_i[m]; + n_mode_i(kk) += tends_n_mode_i(kk) * dt; for(int a = 0; a < mam4::num_species_mode(m); ++a) { const auto q_aero_i = progs.q_aero_i[m][a]; const auto tends_q_aero_i = tends.q_aero_i[m][a]; From 1323ea6a4b5a1324f6b4a9d10299d6a2ae0d7e2a Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Sat, 13 Jul 2024 13:26:47 -0700 Subject: [PATCH 63/71] Zero out tends before computing tends as they had junk values --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 4f1af79a057..91e69443b58 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -506,6 +506,14 @@ void MAMWetscav::run_impl(const double dt) { auto wetdens_icol = ekat::subview(wetdens, icol); const auto prain_icol = ekat::subview(prain, icol); + // Zero out tendencies otherwise, they are initialized to junk values + for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { + Kokkos::deep_copy(tends.n_mode_i[m], 0); + for(int a = 0; a < mam4::num_species_mode(m); ++a) { + Kokkos::deep_copy(tends.q_aero_i[m][a], 0); + } + } + mam4::wetdep::aero_model_wetdep( team, atm, progs, tends, dt, // inputs @@ -528,8 +536,8 @@ void MAMWetscav::run_impl(const double dt) { q_aero_i(kk) += tends_q_aero_i(kk) * dt; } } - }); - }); // icol parallel_for loop + }); // parallel_for for update interstitial aerosol state + }); // icol parallel_for loop // call post processing to convert dry mixing ratios to wet mixing ratios // and update the state From f8e206d19546ece8553b3955b5209e34b4c83329 Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 15 Jul 2024 16:02:16 -0600 Subject: [PATCH 64/71] Ensure that Kokkos::deep_copy is called outside of parallel_for. --- .../mam/eamxx_mam_wetscav_process_interface.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 91e69443b58..bbd99a66cfb 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -461,6 +461,14 @@ void MAMWetscav::run_impl(const double dt) { // inside a parallel_for. const int nlev = nlev_; + // Zero out tendencies otherwise, they are initialized to junk values + for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { + Kokkos::deep_copy(tends.n_mode_i[m], 0); + for(int a = 0; a < mam4::num_species_mode(m); ++a) { + Kokkos::deep_copy(tends.q_aero_i[m][a], 0); + } + } + // Loop over atmosphere columns Kokkos::parallel_for( policy, KOKKOS_LAMBDA(const ThreadTeam &team) { @@ -506,14 +514,6 @@ void MAMWetscav::run_impl(const double dt) { auto wetdens_icol = ekat::subview(wetdens, icol); const auto prain_icol = ekat::subview(prain, icol); - // Zero out tendencies otherwise, they are initialized to junk values - for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { - Kokkos::deep_copy(tends.n_mode_i[m], 0); - for(int a = 0; a < mam4::num_species_mode(m); ++a) { - Kokkos::deep_copy(tends.q_aero_i[m][a], 0); - } - } - mam4::wetdep::aero_model_wetdep( team, atm, progs, tends, dt, // inputs From 9cb990cfd6976cb989a34dc49a8a1bb33f61637e Mon Sep 17 00:00:00 2001 From: Oscar Diaz-Ibarra Date: Mon, 15 Jul 2024 16:16:33 -0600 Subject: [PATCH 65/71] wet_scav - Fixing compilation errors. --- .../src/physics/mam/eamxx_mam_wetscav_process_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index bbd99a66cfb..b598fa6d748 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -463,9 +463,9 @@ void MAMWetscav::run_impl(const double dt) { // Zero out tendencies otherwise, they are initialized to junk values for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) { - Kokkos::deep_copy(tends.n_mode_i[m], 0); + Kokkos::deep_copy(dry_aero_tends_.int_aero_nmr[m], 0); for(int a = 0; a < mam4::num_species_mode(m); ++a) { - Kokkos::deep_copy(tends.q_aero_i[m][a], 0); + Kokkos::deep_copy(dry_aero_tends_.int_aero_mmr[m][a], 0); } } From 047802bf4eec3cdd341c9ac7bc1f7b6869ce8950 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 19 Jul 2024 06:29:57 -0700 Subject: [PATCH 66/71] Updates mam4xx submodule-pointed to main for wetscav qqcw update --- externals/mam4xx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/mam4xx b/externals/mam4xx index cafdbc1b881..316817f6925 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit cafdbc1b88134038aff12c1cb00110c6397a4544 +Subproject commit 316817f6925d5d0380f624402c0c5ede3070e334 From c75615f181d95850610e80c7f839f6ee4150da29 Mon Sep 17 00:00:00 2001 From: Balwinder Singh Date: Fri, 19 Jul 2024 14:11:49 -0700 Subject: [PATCH 67/71] Submodule update: declare local vrs for device code --- externals/mam4xx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/mam4xx b/externals/mam4xx index 316817f6925..5495c27a6df 160000 --- a/externals/mam4xx +++ b/externals/mam4xx @@ -1 +1 @@ -Subproject commit 316817f6925d5d0380f624402c0c5ede3070e334 +Subproject commit 5495c27a6df7ae4e958d67077abc26d4c7e5765d From 1f77bf0e48729dc1f06fad26933fa885a9e1e0d2 Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Mon, 29 Jul 2024 10:55:32 -0600 Subject: [PATCH 68/71] Changes due to code review feedback. --- .../eamxx_mam_wetscav_process_interface.cpp | 68 +++++++++++++------ .../eamxx_mam_wetscav_process_interface.hpp | 36 ++++++++-- 2 files changed, 80 insertions(+), 24 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index b598fa6d748..2a81c1a9c42 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -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"); @@ -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("dgncur_a", scalar3d_mid_nmodes, m, grid_name); @@ -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 //--------------------------------------------------------------------------------- @@ -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 diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index 8bd81115d8a..ac811cab34d 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -40,10 +40,10 @@ class MAMWetscav : public scream::AtmosphereProcess { MAMWetscav(const ekat::Comm &comm, const ekat::ParameterList ¶ms); // 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( @@ -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; @@ -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. @@ -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_; From 2890ec1f87bdf12f910d28667e8a35a822e7df89 Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Mon, 29 Jul 2024 11:30:38 -0600 Subject: [PATCH 69/71] Changes due to code review feedback. --- .../physics/mam/eamxx_mam_wetscav_process_interface.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index ac811cab34d..9d1dc20bc88 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -10,14 +10,6 @@ // For component name #include -#ifndef KOKKOS_ENABLE_CUDA -#define protected_except_cuda public -#define private_except_cuda public -#else -#define protected_except_cuda protected -#define private_except_cuda private -#endif - namespace scream { /* From 8fd0eae1ad3d3ae389b10e1e685d4061714e256d Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Tue, 30 Jul 2024 08:47:05 -0600 Subject: [PATCH 70/71] Changes due to code review feedback. --- .../eamxx_mam_wetscav_process_interface.cpp | 38 ++++++------------- .../eamxx_mam_wetscav_process_interface.hpp | 12 +++++- .../mam/p3_mam4_wetscav/output.yaml | 4 -- .../mam/shoc_cldfrac_p3_wetscav/output.yaml | 4 -- .../single-process/mam/wet_scav/output.yaml | 4 -- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 2a81c1a9c42..81f13fd6ae9 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -47,10 +47,6 @@ void MAMWetscav::set_grids( // layout for 2D (1d horiz X 1d vertical) variables FieldLayout scalar2d = m_grid->get_2d_scalar_layout(); - // layout for 3D (ncol, nmodes, nlevs) - FieldLayout scalar3d_mid_nmodes = - m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); - // layout for 2D (ncol, pcnst) FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "num_phys_constants"); @@ -205,22 +201,6 @@ void MAMWetscav::set_grids( // ------------------------------------------------------------- // These variables are "Computed" or outputs for the process // ------------------------------------------------------------- - static constexpr auto m3 = m * m * m; - - // Aerosol dry particle diameter [m] - add_field("dgncur_a", scalar3d_mid_nmodes, m, grid_name); - - // Wet aerosol density [kg/m3] - add_field("wetdens", scalar3d_mid_nmodes, kg / m3, grid_name); - - // Aerosol water [kg/kg] - add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, grid_name); - - // Wet aerosol diameter [m] - add_field("dgnumwet", scalar3d_mid_nmodes, m, grid_name); - - // Fraction of transported species that are insoluble [fraction] - add_field("fracis", scalar3d_mid, nondim, grid_name); // Aerosol wet deposition (interstitial) [kg/m2/s] add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); @@ -352,6 +332,14 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } + const int nmodes = mam4::AeroConfig::num_modes(); + + // Aerosol dry particle diameter [m] + dgncur_a_ = view_3d("dgncur_a", ncol_, nmodes, nlev_); + wetdens_ = view_3d("wetdens", ncol_, nmodes, nlev_); + qaerwat_ = view_3d("qaerwat", ncol_, nmodes, nlev_); + dgnumwet_ = view_3d("dgnumwet", ncol_, nmodes, nlev_); + // Allocate work array const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); @@ -475,12 +463,10 @@ void MAMWetscav::run_impl(const double dt) { const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); - const auto wet_geometric_mean_diameter_i = - get_field_out("dgnumwet").get_view(); - const auto dry_geometric_mean_diameter_i = - get_field_out("dgncur_a").get_view(); - const auto qaerwat = get_field_out("qaerwat").get_view(); - const auto wetdens = get_field_out("wetdens").get_view(); + const auto wet_geometric_mean_diameter_i = dgnumwet_; + const auto dry_geometric_mean_diameter_i = dgncur_a_; + const auto qaerwat = qaerwat_; + const auto wetdens = wetdens_; const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index 9d1dc20bc88..3c3dec6cc62 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -23,6 +23,7 @@ namespace scream { class MAMWetscav : public scream::AtmosphereProcess { using KT = ekat::KokkosTypes; using view_2d = typename KT::template view_2d; + using view_3d = typename KT::template view_3d; // a thread team dispatched to a single vertical column using ThreadTeam = mam4::ThreadTeam; @@ -160,9 +161,18 @@ class MAMWetscav : public scream::AtmosphereProcess { // Work arrays view_2d work_; + // Aerosol dry particle diameter [m] + // Dimensions: [cols, modes, levels] + view_3d dgncur_a_; + // Wet aerosol density [kg/m3] + view_3d wetdens_; + // Aerosol water [kg/kg] + view_3d qaerwat_; + // Wet aerosol diameter [m] + view_3d dgnumwet_; + // 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] diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml index c26db8eb681..049dcdad35a 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml @@ -56,10 +56,6 @@ Field Names: - num_c4 - aerdepwetis - aerdepwetcw - - dgnumwet - - dgncur_a - - wetdens - - qaerwat output_control: Frequency: ${NUM_STEPS} frequency_units: nsteps diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml index 1ae53e6c1c3..c38bafaa65e 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml @@ -90,10 +90,6 @@ Field Names: - num_c4 - aerdepwetis - aerdepwetcw - - dgnumwet - - dgncur_a - - wetdens - - qaerwat output_control: Frequency: ${NUM_STEPS} frequency_units: nsteps diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index 9cd0a16bc41..75172823870 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -7,10 +7,6 @@ Fields: Field Names: - aerdepwetis - aerdepwetcw - - dgnumwet - - dgncur_a - - wetdens - - qaerwat - bc_c1 - bc_c3 - bc_c4 From 29d83eba554da13a41dc590ea4354c2585d1686d Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Tue, 30 Jul 2024 11:15:57 -0600 Subject: [PATCH 71/71] Revert "Changes due to code review feedback." This reverts commit 8fd0eae1ad3d3ae389b10e1e685d4061714e256d. There are fields that need to be in the FieldManager since this is still in the evaluation stage. --- .../eamxx_mam_wetscav_process_interface.cpp | 38 +++++++++++++------ .../eamxx_mam_wetscav_process_interface.hpp | 12 +----- .../mam/p3_mam4_wetscav/output.yaml | 4 ++ .../mam/shoc_cldfrac_p3_wetscav/output.yaml | 4 ++ .../single-process/mam/wet_scav/output.yaml | 4 ++ 5 files changed, 39 insertions(+), 23 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp index 81f13fd6ae9..2a81c1a9c42 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.cpp @@ -47,6 +47,10 @@ void MAMWetscav::set_grids( // layout for 2D (1d horiz X 1d vertical) variables FieldLayout scalar2d = m_grid->get_2d_scalar_layout(); + // layout for 3D (ncol, nmodes, nlevs) + FieldLayout scalar3d_mid_nmodes = + m_grid->get_3d_vector_layout(true, nmodes, "nmodes"); + // layout for 2D (ncol, pcnst) FieldLayout scalar2d_pconst = m_grid->get_2d_vector_layout(pcnst, "num_phys_constants"); @@ -201,6 +205,22 @@ void MAMWetscav::set_grids( // ------------------------------------------------------------- // These variables are "Computed" or outputs for the process // ------------------------------------------------------------- + static constexpr auto m3 = m * m * m; + + // Aerosol dry particle diameter [m] + add_field("dgncur_a", scalar3d_mid_nmodes, m, grid_name); + + // Wet aerosol density [kg/m3] + add_field("wetdens", scalar3d_mid_nmodes, kg / m3, grid_name); + + // Aerosol water [kg/kg] + add_field("qaerwat", scalar3d_mid_nmodes, kg / kg, grid_name); + + // Wet aerosol diameter [m] + add_field("dgnumwet", scalar3d_mid_nmodes, m, grid_name); + + // Fraction of transported species that are insoluble [fraction] + add_field("fracis", scalar3d_mid, nondim, grid_name); // Aerosol wet deposition (interstitial) [kg/m2/s] add_field("aerdepwetis", scalar2d_pconst, kg / m2 / s, grid_name); @@ -332,14 +352,6 @@ void MAMWetscav::initialize_impl(const RunType run_type) { } } - const int nmodes = mam4::AeroConfig::num_modes(); - - // Aerosol dry particle diameter [m] - dgncur_a_ = view_3d("dgncur_a", ncol_, nmodes, nlev_); - wetdens_ = view_3d("wetdens", ncol_, nmodes, nlev_); - qaerwat_ = view_3d("qaerwat", ncol_, nmodes, nlev_); - dgnumwet_ = view_3d("dgnumwet", ncol_, nmodes, nlev_); - // Allocate work array const int work_len = mam4::wetdep::get_aero_model_wetdep_work_len(); work_ = view_2d("work", ncol_, work_len); @@ -463,10 +475,12 @@ void MAMWetscav::run_impl(const double dt) { const auto aerdepwetis = get_field_out("aerdepwetis").get_view(); const auto aerdepwetcw = get_field_out("aerdepwetcw").get_view(); - const auto wet_geometric_mean_diameter_i = dgnumwet_; - const auto dry_geometric_mean_diameter_i = dgncur_a_; - const auto qaerwat = qaerwat_; - const auto wetdens = wetdens_; + const auto wet_geometric_mean_diameter_i = + get_field_out("dgnumwet").get_view(); + const auto dry_geometric_mean_diameter_i = + get_field_out("dgncur_a").get_view(); + const auto qaerwat = get_field_out("qaerwat").get_view(); + const auto wetdens = get_field_out("wetdens").get_view(); const auto policy = ekat::ExeSpaceUtils::get_default_team_policy(ncol_, nlev_); diff --git a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp index 3c3dec6cc62..9d1dc20bc88 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_wetscav_process_interface.hpp @@ -23,7 +23,6 @@ namespace scream { class MAMWetscav : public scream::AtmosphereProcess { using KT = ekat::KokkosTypes; using view_2d = typename KT::template view_2d; - using view_3d = typename KT::template view_3d; // a thread team dispatched to a single vertical column using ThreadTeam = mam4::ThreadTeam; @@ -161,18 +160,9 @@ class MAMWetscav : public scream::AtmosphereProcess { // Work arrays view_2d work_; - // Aerosol dry particle diameter [m] - // Dimensions: [cols, modes, levels] - view_3d dgncur_a_; - // Wet aerosol density [kg/m3] - view_3d wetdens_; - // Aerosol water [kg/kg] - view_3d qaerwat_; - // Wet aerosol diameter [m] - view_3d dgnumwet_; - // 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] diff --git a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml index 049dcdad35a..c26db8eb681 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/p3_mam4_wetscav/output.yaml @@ -56,6 +56,10 @@ Field Names: - num_c4 - aerdepwetis - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat output_control: Frequency: ${NUM_STEPS} frequency_units: nsteps diff --git a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml index c38bafaa65e..1ae53e6c1c3 100644 --- a/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml +++ b/components/eamxx/tests/multi-process/physics_only/mam/shoc_cldfrac_p3_wetscav/output.yaml @@ -90,6 +90,10 @@ Field Names: - num_c4 - aerdepwetis - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat output_control: Frequency: ${NUM_STEPS} frequency_units: nsteps diff --git a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml index 75172823870..9cd0a16bc41 100644 --- a/components/eamxx/tests/single-process/mam/wet_scav/output.yaml +++ b/components/eamxx/tests/single-process/mam/wet_scav/output.yaml @@ -7,6 +7,10 @@ Fields: Field Names: - aerdepwetis - aerdepwetcw + - dgnumwet + - dgncur_a + - wetdens + - qaerwat - bc_c1 - bc_c3 - bc_c4