Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Interface and Validation Testing for MAM4xx Online Emissions #3083

Merged
merged 41 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9673d6b
emissions interface--running and calling mam4xx. next diagnose error
mjschmidt271 Sep 10, 2024
c3f2ebf
cleanup to fix warnings and change path to emissions input files
mjschmidt271 Oct 9, 2024
749f207
got online emis. interface working
mjschmidt271 Oct 15, 2024
484d2c1
online emissions interface appears to be working
mjschmidt271 Oct 16, 2024
829c560
bump mam4xx submodule, add comments to srf_online_emis_interface
mjschmidt271 Oct 16, 2024
b2dbb85
update mam4xx to main
mjschmidt271 Oct 17, 2024
24d3e11
comment out error-inducing code in mam4_amicphys.cpp and small reorg …
mjschmidt271 Oct 21, 2024
405ce81
Adds sst variable from the ocean model in EAMxx via coupler
singhbalwinder Oct 26, 2024
e38b45b
Adds dstfluxes (4 values per col) from coupler to eamxx
singhbalwinder Oct 26, 2024
13f6cfc
Adds all input variables for online emissions into the interface cpp
singhbalwinder Oct 28, 2024
52afd72
Commits changes in submodule MAM4xx
singhbalwinder Oct 28, 2024
16a1217
EAMxx:Adds soil erodibility file read and sent to online emission read
singhbalwinder Oct 29, 2024
52f32c0
Changes needed to start validatioon with EAM
singhbalwinder Oct 29, 2024
dd258df
EAMxx: dust emissions matches EAMvs grdi cell
singhbalwinder Oct 30, 2024
9e0ad96
EAMxx:calculate_seasalt_numflux_in_bins validated
singhbalwinder Oct 30, 2024
a7d47e9
EAMxx: marine_organic_emis validated with hardwired file read mom
singhbalwinder Oct 30, 2024
0594667
EAMxx: Partial implementation of marine orgaics file read
singhbalwinder Oct 31, 2024
2f0d6c8
EAMxx:Reading and interpolation of mariane organic file works, not te…
singhbalwinder Oct 31, 2024
82e843b
EAMxx: Connects marine organics emiss with MAM4xx codes
singhbalwinder Oct 31, 2024
5d8341f
EAMxx:Fixes units for marine organic emissions
singhbalwinder Oct 31, 2024
c681f07
EAMxx: Adds logic to zero out constituent fluxes, cleanup
singhbalwinder Oct 31, 2024
a150d9d
EAMxx: Reverts input yaml and CMake, changes cons fluxes to updated
singhbalwinder Oct 31, 2024
f0a33da
EAMxx: Some fixes after rebase
singhbalwinder Oct 31, 2024
80a57f0
EAMxx:Adds loop to update file read for marine organics, cleanup
singhbalwinder Oct 31, 2024
15f44fd
fixup! EAMxx: Some fixes after rebase
mjschmidt271 Oct 31, 2024
bdd475f
EAMxx:Fixes file path and specify vector components for dust flux
singhbalwinder Nov 1, 2024
4e120c7
EAMxx: MAM4xx submodule pointing to main that include GPU fixes
singhbalwinder Nov 4, 2024
7b8f7fd
EAMxx: Some codes re-arranged after rebase
singhbalwinder Nov 4, 2024
4195b41
EAMxx:Removes accidently added file
singhbalwinder Nov 4, 2024
e715b8b
update mam4xx submodule to fix gpu compilation error
mjschmidt271 Nov 5, 2024
cc63e5d
EAMxx: Fixes a gpu bug requiring a particular format for dstflx
singhbalwinder Nov 5, 2024
40a6190
EAMxx: Clang format
singhbalwinder Nov 5, 2024
f3a29b1
EAMxx: Fixed some comments paths and other minor cleanup
singhbalwinder Nov 5, 2024
8d4ca76
EAMxx: Moves online emiss and constituent init to a new function hpp …
singhbalwinder Nov 5, 2024
a20712c
fix cuda compile warnings
mjschmidt271 Nov 5, 2024
a40341e
EAMxx:Inits constituent fluxes to zero
singhbalwinder Nov 13, 2024
df4f13c
Revert "EAMxx: Clang format"
mjschmidt271 Nov 15, 2024
60a90e9
ff mam4xx to current main
mjschmidt271 Nov 15, 2024
c8c4d65
EAMxx: Remove all diffs from microphysics cpp file
singhbalwinder Nov 15, 2024
e02b76c
EAMxx: Adds missing namelist entries for multi process test
singhbalwinder Nov 16, 2024
71e4bc5
EAMxx: Moves fences into the interface and remove extra comments
singhbalwinder Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions components/eamxx/cime_config/namelist_defaults_scream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,11 @@ be lost if SCREAM_HACK_XML is not enabled.
<srf_emis_specifier_for_so4_a1 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for so4_a1">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_so4_a1_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_so4_a1>
<srf_emis_specifier_for_so4_a2 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for so4_a2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_so4_a2_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_so4_a2>

<soil_erodibility_file type="file" doc="File containing soil erodibility">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/dst_ne30pg2_c20241028.nc</soil_erodibility_file>
<soil_erodibility_file hgrid="ne4np4.pg2" type="file" doc="File containing soil erodibility">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/dst_ne4pg2_c20241028.nc</soil_erodibility_file>

<!-- For ne4pg2 grid -->
singhbalwinder marked this conversation as resolved.
Show resolved Hide resolved
<srf_emis_specifier_for_DMS hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for DMS">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/DMSflux.2010.ne4pg2_conserv.POPmonthlyClimFromACES4BGC_c20240814.nc</srf_emis_specifier_for_DMS>
<srf_emis_specifier_for_SO2 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for SO2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_so2_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_SO2>
<srf_emis_specifier_for_bc_a4 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for bc_a4">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_bc_a4_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_bc_a4>
<srf_emis_specifier_for_num_a1 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for num_a1">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_num_a1_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_num_a1>
<srf_emis_specifier_for_num_a2 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for num_a2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_num_a2_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_num_a2>
<srf_emis_specifier_for_num_a4 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for num_a4">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_num_a4_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_num_a4>
<srf_emis_specifier_for_pom_a4 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for pom_a4">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_pom_a4_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_pom_a4>
<srf_emis_specifier_for_so4_a1 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for so4_a1">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_so4_a1_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_so4_a1>
<srf_emis_specifier_for_so4_a2 hgrid="ne4np4.pg2" type="file" doc="File containing surface emissions data for so4_a2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/surface/cmip6_mam4_so4_a2_surf_ne4pg2_2010_clim_c20240815.nc</srf_emis_specifier_for_so4_a2>
<marine_organics_file type="file" doc="File containing marine organics emissions">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/monthly_macromolecules_0.1deg_bilinear_year01_merge_ne30pg2_c20241030.nc</marine_organics_file>
<marine_organics_file hgrid="ne4np4.pg2" type="file" doc="File containing marine organics emissions">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/monthly_macromolecules_0.1deg_bilinear_year01_merge_ne4pg2_c20241030.nc</marine_organics_file>

<!-- Mapping Files for finer resolutions -->
<srf_remap_file type="file" doc="File containing mapping data from the grid of emission files to the model grid. Unused if the grid is the same."/>
Expand Down Expand Up @@ -639,6 +633,7 @@ be lost if SCREAM_HACK_XML is not enabled.
<dgnum type="array(real)" doc="Dry aerosol particles diameters (one per mode) [m]">1.37146e-07 ,3.45899e-08 ,1.00000e-06 ,9.99601e-08</dgnum>
<dgnumwet type="array(real)" doc="Wet aerosol particles diameter [m]">1.37452e-07 ,3.46684e-08 ,1.00900e-06 ,9.99601e-08</dgnumwet>
<wetdens type="array(real)" doc="Wet density of interstitial aerosol [kg/m3]">5.08262e-12 ,1.54035e-13 ,3.09018e-13 ,9.14710e-22</wetdens>
<constituent_fluxes type="real">0.0</constituent_fluxes>
<bc_c1 type="real">0.0</bc_c1>
<bc_c3 type="real">0.0</bc_c3>
<bc_c4 type="real">0.0</bc_c4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,41 @@ void SurfaceCouplingImporter::set_grids(const std::shared_ptr<const GridsManager

// The units of mixing ratio Q are technically non-dimensional.
// Nevertheless, for output reasons, we like to see 'kg/kg'.
auto nondim = Units::nondimensional();
Units m2 (m*m,"m2");
constexpr auto nondim = Units::nondimensional();
constexpr auto m2 = pow(m, 2);

// Define the different field layouts that will be used for this process
using namespace ShortFieldTagsNames;

FieldLayout scalar2d_layout { {COL }, {m_num_cols } };
FieldLayout vector2d_layout { {COL, CMP}, {m_num_cols, 2} };

add_field<Computed>("sfc_alb_dir_vis", scalar2d_layout, nondim, grid_name);
add_field<Computed>("sfc_alb_dir_nir", scalar2d_layout, nondim, grid_name);
add_field<Computed>("sfc_alb_dif_vis", scalar2d_layout, nondim, grid_name);
add_field<Computed>("sfc_alb_dif_nir", scalar2d_layout, nondim, grid_name);
add_field<Computed>("surf_lw_flux_up", scalar2d_layout, W/m2, grid_name);
add_field<Computed>("surf_sens_flux", scalar2d_layout, W/m2, grid_name);
add_field<Computed>("surf_evap", scalar2d_layout, kg/m2/s, grid_name);
add_field<Computed>("surf_mom_flux", vector2d_layout, N/m2, grid_name);
add_field<Computed>("surf_radiative_T", scalar2d_layout, K, grid_name);
add_field<Computed>("T_2m", scalar2d_layout, K, grid_name);
add_field<Computed>("qv_2m", scalar2d_layout, kg/kg, grid_name);
add_field<Computed>("wind_speed_10m", scalar2d_layout, m/s, grid_name);
add_field<Computed>("snow_depth_land", scalar2d_layout, m, grid_name);
add_field<Computed>("ocnfrac", scalar2d_layout, nondim, grid_name);
add_field<Computed>("landfrac", scalar2d_layout, nondim, grid_name);
add_field<Computed>("icefrac", scalar2d_layout, nondim, grid_name);
const FieldLayout scalar2d = m_grid->get_2d_scalar_layout();
const FieldLayout vector2d = m_grid->get_2d_vector_layout(2);
const FieldLayout vector4d = m_grid->get_2d_vector_layout(4);

add_field<Computed>("sfc_alb_dir_vis", scalar2d, nondim, grid_name);
add_field<Computed>("sfc_alb_dir_nir", scalar2d, nondim, grid_name);
add_field<Computed>("sfc_alb_dif_vis", scalar2d, nondim, grid_name);
add_field<Computed>("sfc_alb_dif_nir", scalar2d, nondim, grid_name);
add_field<Computed>("surf_lw_flux_up", scalar2d, W/m2, grid_name);
add_field<Computed>("surf_sens_flux", scalar2d, W/m2, grid_name);
add_field<Computed>("surf_evap", scalar2d, kg/m2/s, grid_name);
add_field<Computed>("surf_mom_flux", vector2d, N/m2, grid_name);
add_field<Computed>("surf_radiative_T", scalar2d, K, grid_name);
add_field<Computed>("T_2m", scalar2d, K, grid_name);
add_field<Computed>("qv_2m", scalar2d, kg/kg, grid_name);
add_field<Computed>("wind_speed_10m", scalar2d, m/s, grid_name);
add_field<Computed>("snow_depth_land", scalar2d, m, grid_name);
add_field<Computed>("ocnfrac", scalar2d, nondim, grid_name);
add_field<Computed>("landfrac", scalar2d, nondim, grid_name);
add_field<Computed>("icefrac", scalar2d, nondim, grid_name);
// Friction velocity [m/s]
add_field<Computed>("fv", scalar2d_layout, m/s, grid_name);
add_field<Computed>("fv", scalar2d, m/s, grid_name);
// Aerodynamical resistance
add_field<Computed>("ram1", scalar2d_layout, s/m, grid_name);
add_field<Computed>("ram1", scalar2d, s/m, grid_name);
// Sea surface temperature [K]
add_field<Computed>("sst", scalar2d, K, grid_name);
//dust fluxes [kg/m^2/s]: Four flux values for eacch column
add_field<Computed>("dstflx", vector4d, kg/m2/s, grid_name);

}
// =========================================================================================
void SurfaceCouplingImporter::setup_surface_coupling_data(const SCDataManager &sc_data_manager)
Expand Down
20 changes: 19 additions & 1 deletion components/eamxx/src/mct_coupling/scream_cpl_indices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module scream_cpl_indices
private

! Focus only on the ones that scream imports/exports (subsets of x2a and a2x)
integer, parameter, public :: num_scream_imports = 19
integer, parameter, public :: num_scream_imports = 24
integer, parameter, public :: num_scream_exports = 17
integer, public :: num_cpl_imports, num_cpl_exports, import_field_size, export_field_size

Expand Down Expand Up @@ -92,6 +92,11 @@ subroutine scream_set_cpl_indices (x2a, a2x)
import_field_names(17) = 'icefrac'
import_field_names(18) = 'fv'
import_field_names(19) = 'ram1'
import_field_names(20) = 'sst'
import_field_names(21) = 'dstflx'
import_field_names(22) = 'dstflx'
import_field_names(23) = 'dstflx'
import_field_names(24) = 'dstflx'

! CPL indices
import_cpl_indices(1) = mct_avect_indexra(x2a,'Sx_avsdr')
Expand All @@ -113,10 +118,23 @@ subroutine scream_set_cpl_indices (x2a, a2x)
import_cpl_indices(17) = mct_avect_indexra(x2a,'Sf_ifrac')
import_cpl_indices(18) = mct_avect_indexra(x2a,'Sl_fv')
import_cpl_indices(19) = mct_avect_indexra(x2a,'Sl_ram1')
!sst
import_cpl_indices(20) = mct_avect_indexra(x2a,'So_t')
!dust fluxes
import_cpl_indices(21) = mct_avect_indexra(x2a,'Fall_flxdst1')
import_cpl_indices(22) = mct_avect_indexra(x2a,'Fall_flxdst2')
import_cpl_indices(23) = mct_avect_indexra(x2a,'Fall_flxdst3')
import_cpl_indices(24) = mct_avect_indexra(x2a,'Fall_flxdst4')

! Vector components
!(Faxx_taux and Faxx_tauy)
import_vector_components(11) = 0
import_vector_components(12) = 1
!(dust fluxes)
import_vector_components(21) = 0
import_vector_components(22) = 1
import_vector_components(23) = 2
import_vector_components(24) = 3

! Constant multiples
import_constant_multiple(10) = -1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#ifndef EAMXX_MAM_SRF_AND_ONLINE_EMISSIONS_FUNCTIONS_HPP
#define EAMXX_MAM_SRF_AND_ONLINE_EMISSIONS_FUNCTIONS_HPP

namespace scream {

namespace {

using KT = ekat::KokkosTypes<DefaultDevice>;
using view_1d = typename KT::template view_1d<Real>;
using view_2d = typename KT::template view_2d<Real>;
using const_view_1d = typename KT::template view_1d<const Real>;
using const_view_2d = typename KT::template view_2d<const Real>;

//-------- Inititlize gas and aerosol fluxes ------
void init_fluxes(const int &ncol,
singhbalwinder marked this conversation as resolved.
Show resolved Hide resolved
view_2d &constituent_fluxes) { // input-output

constexpr int pcnst = mam4::aero_model::pcnst;
const int gas_start_ind = mam4::utils::gasses_start_ind();

const auto policy =
ekat::ExeSpaceUtils<KT::ExeSpace>::get_default_team_policy(
ncol, pcnst - gas_start_ind);

// Parallel loop over all the columns
Kokkos::parallel_for(
policy, KOKKOS_LAMBDA(const KT::MemberType &team) {
const int icol = team.league_rank();
view_1d flux_col = ekat::subview(constituent_fluxes, icol);

// Zero out constituent fluxes only for gasses and aerosols
Kokkos::parallel_for(
Kokkos::TeamVectorRange(team, gas_start_ind, pcnst),
[&](int icnst) { flux_col(icnst) = 0; });
});
} // init_fluxes ends

//-------- compute online emissions for dust, sea salt and marine organics -----
void compute_online_dust_nacl_emiss(
const int &ncol, const int &nlev, const const_view_1d &ocnfrac,
const const_view_1d &sst, const const_view_2d &u_wind,
const const_view_2d &v_wind, const const_view_2d &dstflx,
const const_view_1d &mpoly, const const_view_1d &mprot,
const const_view_1d &mlip, const const_view_1d &soil_erodibility,
const const_view_2d &z_mid,
// output
view_2d &constituent_fluxes) {
const int surf_lev = nlev - 1; // surface level

Kokkos::parallel_for(
"online_emis_fluxes", ncol, KOKKOS_LAMBDA(int icol) {
// Input
const const_view_1d dstflx_icol = ekat::subview(dstflx, icol);

// Output
view_1d fluxes_col = ekat::subview(constituent_fluxes, icol);

// Compute online emissions
// NOTE: mam4::aero_model_emissions calculates mass and number emission
// fluxes in units of [kg/m2/s or #/m2/s] (MKS), so no need to convert
mam4::aero_model_emissions::aero_model_emissions(
sst(icol), ocnfrac(icol), u_wind(icol, surf_lev),
v_wind(icol, surf_lev), z_mid(icol, surf_lev), dstflx_icol,
soil_erodibility(icol), mpoly(icol), mprot(icol), mlip(icol),
// out
fluxes_col);
});
} // compute_online_dust_nacl_emiss ends

} // namespace
} // namespace scream

#endif // EAMXX_MAM_SRF_AND_ONLINE_EMISSIONS_FUNCTIONS_HPP
Loading
Loading