diff --git a/components/eamxx/src/physics/mam/eamxx_mam_aci_process_interface.cpp b/components/eamxx/src/physics/mam/eamxx_mam_aci_process_interface.cpp index 25274567902..8f9552537ab 100644 --- a/components/eamxx/src/physics/mam/eamxx_mam_aci_process_interface.cpp +++ b/components/eamxx/src/physics/mam/eamxx_mam_aci_process_interface.cpp @@ -301,6 +301,7 @@ void MAMAci::initialize_impl(const RunType run_type) { wet_atm_.ni = get_field_in("ni").get_view(); // store rest fo the atm fields in dry_atm_in + 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_int = get_field_in("p_int").get_view(); 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 6ae36835302..7ea2adfddb6 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 @@ -306,6 +306,12 @@ void MAMMicrophysics::run_impl(const double dt) { // allocation perspective auto o3_col_dens = buffer_.scratch[8]; + const_view_1d &col_latitudes = col_latitudes_; + mam_coupling::DryAtmosphere &dry_atm = dry_atm_; + mam_coupling::AerosolState &dry_aero = dry_aero_; + mam4::mo_photo::PhotoTableData &photo_table = photo_table_; + const int nlev = nlev_; + const Config &config = config_; // FIXME: read relevant linoz climatology data from file(s) based on time // FIXME: read relevant chlorine loading data from file based on time @@ -314,21 +320,21 @@ void MAMMicrophysics::run_impl(const double dt) { Kokkos::parallel_for(policy, KOKKOS_LAMBDA(const ThreadTeam& team) { const int icol = team.league_rank(); // column index - Real col_lat = col_latitudes_(icol); // column latitude (degrees?) + Real col_lat = col_latitudes(icol); // column latitude (degrees?) // fetch column-specific atmosphere state data - auto atm = mam_coupling::atmosphere_for_column(dry_atm_, icol); - auto z_iface = ekat::subview(dry_atm_.z_iface, icol); - Real phis = dry_atm_.phis(icol); + auto atm = mam_coupling::atmosphere_for_column(dry_atm, icol); + auto z_iface = ekat::subview(dry_atm.z_iface, icol); + Real phis = dry_atm.phis(icol); // set surface state data haero::Surface sfc{}; // fetch column-specific subviews into aerosol prognostics - mam4::Prognostics progs = mam_coupling::interstitial_aerosols_for_column(dry_aero_, icol); + mam4::Prognostics progs = mam_coupling::interstitial_aerosols_for_column(dry_aero, icol); // set up diagnostics - mam4::Diagnostics diags(nlev_); + mam4::Diagnostics diags(nlev); // calculate o3 column densities (first component of col_dens in Fortran code) auto o3_col_dens_i = ekat::subview(o3_col_dens, icol); @@ -347,7 +353,7 @@ void MAMMicrophysics::run_impl(const double dt) { mam4::ColumnView lwc; // FIXME: liquid water cloud content: where do we get this? mam4::mo_photo::table_photo(photo_rates, atm.pressure, atm.hydrostatic_dp, atm.temperature, o3_col_dens_i, zenith_angle, surf_albedo, lwc, - atm.cloud_fraction, esfact, photo_table_, photo_work_arrays); + atm.cloud_fraction, esfact, photo_table, photo_work_arrays); // compute external forcings at time t(n+1) [molecules/cm^3/s] constexpr int extcnt = mam4::gas_chemistry::extcnt; @@ -356,7 +362,7 @@ void MAMMicrophysics::run_impl(const double dt) { mam4::mo_setext::extfrc_set(forcings, extfrc); // compute aerosol microphysics on each vertical level within this column - Kokkos::parallel_for(Kokkos::TeamThreadRange(team, nlev_), [&](const int k) { + Kokkos::parallel_for(Kokkos::TeamThreadRange(team, nlev), [&](const int k) { constexpr int num_modes = mam4::AeroConfig::num_modes(); constexpr int gas_pcnst = mam_coupling::gas_pcnst(); @@ -429,7 +435,7 @@ void MAMMicrophysics::run_impl(const double dt) { constexpr int indexm = 0; // FIXME: index of xhnm in invariants array (??) Real cldnum = 0.0; // FIXME: droplet number concentration: where do we get this? setsox_single_level(loffset, dt, pmid, pdel, temp, mbar, lwc(k), - cldfrac, cldnum, invariants[indexm], config_.setsox, vmrcw, vmr); + cldfrac, cldnum, invariants[indexm], config.setsox, vmrcw, vmr); // calculate aerosol water content using water uptake treatment // * dry and wet diameters [m] @@ -442,7 +448,7 @@ void MAMMicrophysics::run_impl(const double dt) { impl::compute_water_content(progs, k, qv, temp, pmid, dgncur_a, dgncur_awet, wetdens, qaerwat); // do aerosol microphysics (gas-aerosol exchange, nucleation, coagulation) - impl::modal_aero_amicphys_intr(config_.amicphys, step_, dt, t, pmid, pdel, + impl::modal_aero_amicphys_intr(config.amicphys, step_, dt, t, pmid, pdel, zm, pblh, qv, cldfrac, vmr, vmrcw, vmr_pregaschem, vmr_precldchem, vmrcw_precldchem, vmr_tendbb, vmrcw_tendbb, dgncur_a, dgncur_awet, @@ -467,15 +473,15 @@ void MAMMicrophysics::run_impl(const double dt) { linoz_o3_clim(icol, k), linoz_t_clim(icol, k), linoz_o3col_clim(icol, k), linoz_PmL_clim(icol, k), linoz_dPmL_dO3(icol, k), linoz_dPmL_dT(icol, k), linoz_dPmL_dO3col(icol, k), linoz_cariolle_psc(icol, k), - chlorine_loading, config_.linoz.psc_T, vmr[o3_ndx], + chlorine_loading, config.linoz.psc_T, vmr[o3_ndx], do3_linoz, do3_linoz_psc, ss_o3, o3col_du_diag, o3clim_linoz_diag, zenith_angle_degrees); // update source terms above the ozone decay threshold - if (k > nlev_ - config_.linoz.o3_lbl - 1) { + if (k > nlev - config.linoz.o3_lbl - 1) { Real do3_mass; // diagnostic, not needed - mam4::lin_strat_chem::lin_strat_sfcsink_kk(dt, pdel, vmr[o3_ndx], config_.linoz.o3_sfc, - config_.linoz.o3_tau, do3_mass); + mam4::lin_strat_chem::lin_strat_sfcsink_kk(dt, pdel, vmr[o3_ndx], config.linoz.o3_sfc, + config.linoz.o3_tau, do3_mass); } // ... check for negative values and reset to zero diff --git a/components/eamxx/src/physics/mam/mam_coupling.hpp b/components/eamxx/src/physics/mam/mam_coupling.hpp index ed156a9de89..3a001146882 100644 --- a/components/eamxx/src/physics/mam/mam_coupling.hpp +++ b/components/eamxx/src/physics/mam/mam_coupling.hpp @@ -726,7 +726,7 @@ void compute_wet_mixing_ratios(const Team& team, // Scream (or EAMxx) can sometimes extend views beyond model levels (nlev) as it uses // "packs". Following function copies a 2d view till model levels -KOKKOS_INLINE_FUNCTION +inline void copy_view_lev_slice(haero::ThreadTeamPolicy team_policy, //inputs const_view_2d &inp_view, //input view to copy const int dim, //dimension till view should be copied