From c5b5a044d66d9dddaa6de81d62234f62a84763a2 Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Tue, 30 Sep 2025 15:46:47 -0600 Subject: [PATCH 1/2] Make the gas dry deposition flux a diagnostic output when diagnostics requested. --- ...mxx_mam_microphysics_process_interface.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp index e15f841af1bb..8fc92b362bad 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp @@ -207,6 +207,8 @@ MAMMicrophysics::set_grids(const std::shared_ptr grids_manag true, mam_coupling::gas_pcnst(), "num_gas_aerosol_constituents"); const FieldLayout vector2d_nmodes = grid_->get_2d_vector_layout(nmodes, "nmodes"); + const FieldLayout vector2d_pcnst = grid_->get_2d_vector_layout( + mam_coupling::gas_pcnst(), "num_gas_aerosol_constituents"); // Diagnostics: tendencies due to gas phase chemistry [mixed units: kg/kg/s or #/kg/s] add_field("mam4_microphysics_tendency_gas_phase_chemistry", @@ -243,6 +245,8 @@ MAMMicrophysics::set_grids(const std::shared_ptr grids_manag vector3d_num_gas_aerosol_constituents, nondim, grid_name); add_field("mam4_microphysics_tendency_renaming_cloud_borne", vector3d_num_gas_aerosol_constituents, nondim, grid_name); + constexpr auto cm2 = m*m/10000; + add_field("mam4_gas_dry_deposition_flux", vector2d_pcnst, 1/cm2/s, grid_name); } // Creating a Linoz reader and setting Linoz parameters involves reading data @@ -559,6 +563,8 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) { {"mam4_microphysics_tendency_renaming_cloud_borne", "MAM4xx microphysics tendencies due to gas aerosol exchange (renaming cloud borne) [mixed units: mol/mol/s or #/mol/s]"}, + {"mam4_gas_dry_deposition_flux", + "MAM4xx microphysics deposition flux [units: 1/cm^2/s]"}, }; // Add docstring to the fields with mixed units add_io_docstring_to_fields_with_mixed_units(mixed_units_fields); @@ -708,7 +714,7 @@ void MAMMicrophysics::run_impl(const double dt) { get_field_in("snow_depth_land").get_view(); // - dvmr/dt: Tendencies for mixing ratios [kg/kg/s] - view_2d dqdt_so4_aqueous_chemistry, dqdt_h2so4_uptake; + view_2d dqdt_so4_aqueous_chemistry, dqdt_h2so4_uptake, gas_dry_deposition_flux; view_3d gas_phase_chemistry_dvmrdt, aqueous_chemistry_dvmrdt; view_3d aqso4_incloud_mmr_tendency, aqh2so4_incloud_mmr_tendency; view_3d gas_aero_exchange_condensation, gas_aero_exchange_renaming, @@ -727,6 +733,7 @@ void MAMMicrophysics::run_impl(const double dt) { gas_aero_exchange_nucleation = get_field_out("mam4_microphysics_tendency_nucleation").get_view(); gas_aero_exchange_coagulation = get_field_out("mam4_microphysics_tendency_coagulation").get_view(); gas_aero_exchange_renaming_cloud_borne = get_field_out("mam4_microphysics_tendency_renaming_cloud_borne").get_view(); + gas_dry_deposition_flux = get_field_out("mam4_gas_dry_deposition_flux").get_view(); } @@ -988,7 +995,7 @@ void MAMMicrophysics::run_impl(const double dt) { const auto nevapr_icol = ekat::subview(nevapr, icol); const auto prain_icol = ekat::subview(prain, icol); const auto work_set_het_icol = ekat::subview(work_set_het, icol); - + view_1d diag_arrays_gas_dry_deposition_flux; mam4::MicrophysDiagnosticArrays diag_arrays; if (extra_mam4_aero_microphys_diags) { diag_arrays.dqdt_so4_aqueous_chemistry = ekat::subview(dqdt_so4_aqueous_chemistry, icol); @@ -1004,6 +1011,7 @@ void MAMMicrophysics::run_impl(const double dt) { diag_arrays.gas_aero_exchange_nucleation = ekat::subview(gas_aero_exchange_nucleation, icol); diag_arrays.gas_aero_exchange_coagulation = ekat::subview(gas_aero_exchange_coagulation, icol); diag_arrays.gas_aero_exchange_renaming_cloud_borne = ekat::subview(gas_aero_exchange_renaming_cloud_borne, icol); + diag_arrays_gas_dry_deposition_flux = ekat::subview(gas_dry_deposition_flux, icol); } // Wind speed at the surface const Real wind_speed = @@ -1047,8 +1055,8 @@ void MAMMicrophysics::run_impl(const double dt) { } } // These output values need to be put somewhere: - Real dflx_col[num_gas_aerosol_constituents] = {}; // deposition velocity [1/cm/s] - Real dvel_col[num_gas_aerosol_constituents] = {}; // deposition flux [1/cm^2/s] + Real dflx_col[num_gas_aerosol_constituents] = {}; // deposition flux [1/cm^2/s] + Real dvel_col[num_gas_aerosol_constituents] = {}; // deposition velocity [1/cm/s] // Output: values are dvel, dflx // Input/Output: progs::stateq, progs::qqcw team.team_barrier(); @@ -1075,6 +1083,11 @@ void MAMMicrophysics::run_impl(const double dt) { Kokkos::parallel_for(Kokkos::TeamVectorRange(team, offset_aerosol, pcnst), [&](int ispc) { constituent_fluxes(icol, ispc) -= dflx_col[ispc - offset_aerosol]; }); + if (diag_arrays_gas_dry_deposition_flux.size()) { + Kokkos::parallel_for(Kokkos::TeamVectorRange(team, pcnst), [&](int ispc) { + diag_arrays_gas_dry_deposition_flux[ispc] = dflx_col[ispc]; + }); + } }); // parallel_for for the column loop Kokkos::fence(); From 8a8aa6fd3345620aa92ca3a67da929764e658578 Mon Sep 17 00:00:00 2001 From: James Overfelt Date: Tue, 30 Sep 2025 16:25:53 -0600 Subject: [PATCH 2/2] Apply clang format patch. --- .../mam/eamxx_mam_microphysics_process_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp index 8fc92b362bad..c50f9ba4439b 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp @@ -207,8 +207,8 @@ MAMMicrophysics::set_grids(const std::shared_ptr grids_manag true, mam_coupling::gas_pcnst(), "num_gas_aerosol_constituents"); const FieldLayout vector2d_nmodes = grid_->get_2d_vector_layout(nmodes, "nmodes"); - const FieldLayout vector2d_pcnst = grid_->get_2d_vector_layout( - mam_coupling::gas_pcnst(), "num_gas_aerosol_constituents"); + const FieldLayout vector2d_pcnst = + grid_->get_2d_vector_layout(mam_coupling::gas_pcnst(), "num_gas_aerosol_constituents"); // Diagnostics: tendencies due to gas phase chemistry [mixed units: kg/kg/s or #/kg/s] add_field("mam4_microphysics_tendency_gas_phase_chemistry", @@ -245,8 +245,8 @@ MAMMicrophysics::set_grids(const std::shared_ptr grids_manag vector3d_num_gas_aerosol_constituents, nondim, grid_name); add_field("mam4_microphysics_tendency_renaming_cloud_borne", vector3d_num_gas_aerosol_constituents, nondim, grid_name); - constexpr auto cm2 = m*m/10000; - add_field("mam4_gas_dry_deposition_flux", vector2d_pcnst, 1/cm2/s, grid_name); + constexpr auto cm2 = m * m / 10000; + add_field("mam4_gas_dry_deposition_flux", vector2d_pcnst, 1 / cm2 / s, grid_name); } // Creating a Linoz reader and setting Linoz parameters involves reading data