Skip to content

Commit

Permalink
Merge pull request #3050 from eagles-project/singhbalwinder/read-frac…
Browse files Browse the repository at this point in the history
…-land-use-file

Adds capability to read fractional land use file in MAM4 dry deposition
  • Loading branch information
bartgol authored Oct 25, 2024
2 parents 0bf8e42 + 0b91276 commit 7945125
Show file tree
Hide file tree
Showing 18 changed files with 322 additions and 74 deletions.
37 changes: 27 additions & 10 deletions components/eamxx/cime_config/namelist_defaults_scream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ be lost if SCREAM_HACK_XML is not enabled.
<selector name="hgrid" case_env="ATM_GRID"/>
<selector name="dyn" case_env="CAM_TARGET"/>
<selector name="nlev" case_env="SCREAM_CMAKE_OPTIONS" regex=".*SCREAM_NUM_VERTICAL_LEV ([0-9]+).*"/>
<selector name="ntracers" case_env="SCREAM_CMAKE_OPTIONS" regex=".*SCREAM_NUM_TRACERS ([0-9]+).*"/>

</selectors>

<!-- List of scream grids for a given compset. I/O can only happen on these grids -->
Expand Down Expand Up @@ -250,7 +252,17 @@ be lost if SCREAM_HACK_XML is not enabled.
</mam4_aci>

<!-- MAM4xx-Dry Deposition -->
<mam4_drydep inherit="atm_proc_base" />
<mam4_drydep inherit="atm_proc_base">
<fractional_land_use_file type="file" doc="File containing Fractional land use data for drydep">${DIN_LOC_ROOT}/atm/scream/mam4xx/drydep/ne30pg2/atmsrf_ne30pg2_c20241017.nc</fractional_land_use_file>
<fractional_land_use_file hgrid="ne4np4.pg2" type="file" doc="File containing Fractional land use data for drydep">${DIN_LOC_ROOT}/atm/scream/mam4xx/drydep/ne4pg2/atmsrf_ne4pg2_c20241017.nc</fractional_land_use_file>

<!-- Mapping Files for finer resolutions -->
<drydep_remap_file type="file" doc="File containing mapping data from the grid of frac land use files to the model grid. Unused if the grid is the same."/>
<drydep_remap_file hgrid="ne120np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne120pg2_20231201.nc</drydep_remap_file>
<drydep_remap_file hgrid="ne256np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne256pg2_20231201.nc</drydep_remap_file>
<drydep_remap_file hgrid="ne512np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne512pg2_20231201.nc</drydep_remap_file>
<drydep_remap_file hgrid="ne1024np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne1024pg2_20231201.nc</drydep_remap_file>
</mam4_drydep>

<!-- CLD fraction -->
<cldFraction inherit="atm_proc_base"/>
Expand Down Expand Up @@ -278,15 +290,6 @@ be lost if SCREAM_HACK_XML is not enabled.
<!-- MAM4xx-Surface-Emissions -->
<mam4_srf_online_emiss inherit="atm_proc_base">

<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>
<!-- For all other grids -->
<srf_emis_specifier_for_DMS type="file" doc="File containing surface emissions data for DMS">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/surface/DMSflux.2010.ne30pg2_conserv.POPmonthlyClimFromACES4BGC_c20240816.nc</srf_emis_specifier_for_DMS>
<srf_emis_specifier_for_SO2 type="file" doc="File containing surface emissions data for SO2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/surface/cmip6_mam4_so2_surf_ne30pg2_2010_clim_c20240816.nc</srf_emis_specifier_for_SO2>
Expand All @@ -297,6 +300,18 @@ be lost if SCREAM_HACK_XML is not enabled.
<srf_emis_specifier_for_pom_a4 type="file" doc="File containing surface emissions data for pom_a4">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/surface/cmip6_mam4_pom_a4_surf_ne30pg2_2010_clim_c20240816.nc</srf_emis_specifier_for_pom_a4>
<srf_emis_specifier_for_so4_a1 type="file" doc="File containing surface emissions data for so4_a1">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/surface/cmip6_mam4_so4_a1_surf_ne30pg2_2010_clim_c20240816.nc</srf_emis_specifier_for_so4_a1>
<srf_emis_specifier_for_so4_a2 type="file" doc="File containing surface emissions data for so4_a2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/surface/cmip6_mam4_so4_a2_surf_ne30pg2_2010_clim_c20240816.nc</srf_emis_specifier_for_so4_a2>

<!-- For ne4pg2 grid -->
<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>


<!-- 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 @@ -490,9 +505,11 @@ be lost if SCREAM_HACK_XML is not enabled.
<initial_conditions>
<Filename type="file">UNSET</Filename>
<Filename hgrid="ne4np4" nlev="72">${DIN_LOC_ROOT}/atm/scream/init/screami_ne4np4L72_20220823.nc</Filename>
<Filename hgrid="ne4np4" nlev="72" ntracers="41">${DIN_LOC_ROOT}/atm/scream/init/screami_mam4xx_ne4np4L72_c20240208.nc</Filename>
<Filename hgrid="ne4np4" nlev="128">${DIN_LOC_ROOT}/atm/scream/init/screami_ne4np4L128_20241022.nc</Filename>
<Filename hgrid="ne30np4" nlev="72">${DIN_LOC_ROOT}/atm/scream/init/screami_ne30np4L72_20220823.nc</Filename>
<Filename hgrid="ne30np4" nlev="128">${DIN_LOC_ROOT}/atm/scream/init/screami_ne30np4L128_20221004.nc</Filename>
<Filename hgrid="ne30np4" nlev="72" ntracers="41">${DIN_LOC_ROOT}/atm/scream/init/screami_mam_ne30np4L72_c20240623.nc</Filename>
<Filename hgrid="ne120np4" nlev="72">${DIN_LOC_ROOT}/atm/scream/init/screami_ne120np4L72_20220823.nc</Filename>
<Filename hgrid="ne120np4" nlev="128">${DIN_LOC_ROOT}/atm/scream/init/screami_ne120np4L128_20230215.nc</Filename>
<Filename hgrid="ne256np4">${DIN_LOC_ROOT}/atm/scream/init/screami_ne256np4L128_ifs-20200120_20220914.nc</Filename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#------------------------------------------------------
$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

# Add spa as RRTMG needs spa
$CIMEROOT/../components/eamxx/scripts/atmchange physics::atm_procs_list="mac_aero_mic,spa,rrtmgp" -b

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -b

#------------------------------------------------------
#Update IC file and add drydep process
# Add drydep 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,rrtmgp,mam4_drydep" -b


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#------------------------------------------------------
$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


Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -b

#------------------------------------------------------
#Update IC file and add the processes
# Add the processes
#------------------------------------------------------
$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="mam4_constituent_fluxes,mac_aero_mic,rrtmgp,mam4_srf_online_emiss" -b


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -b

#------------------------------------------------------
#Update IC file and add wetscav process
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void compute_tendencies(
const MAMDryDep::const_view_1d ocnfrac,
const MAMDryDep::const_view_1d friction_velocity,
const MAMDryDep::const_view_1d aerodynamical_resistance,
MAMDryDep::view_3d qtracers, MAMDryDep::view_2d fraction_landuse_,
const MAMDryDep::const_view_2d fraction_landuse_,
const MAMDryDep::const_view_3d dgncur_awet_,
const MAMDryDep::const_view_3d wet_dens_,
const mam_coupling::DryAtmosphere dry_atm,
Expand All @@ -35,7 +35,7 @@ void compute_tendencies(
// work arrays
MAMDryDep::view_2d rho_, MAMDryDep::view_4d vlc_dry_,
MAMDryDep::view_3d vlc_trb_, MAMDryDep::view_4d vlc_grv_,
MAMDryDep::view_3d dqdt_tmp_) {
MAMDryDep::view_3d dqdt_tmp_, MAMDryDep::view_3d qtracers) {
static constexpr int num_aero_modes = mam_coupling::num_aero_modes();
const auto policy =
ekat::ExeSpaceUtils<MAMDryDep::KT::ExeSpace>::get_default_team_policy(
Expand Down Expand Up @@ -86,7 +86,7 @@ void compute_tendencies(
static constexpr int n_land_type = MAMDryDep::n_land_type;
Real fraction_landuse[n_land_type];
for(int i = 0; i < n_land_type; ++i) {
fraction_landuse[i] = fraction_landuse_(i, icol);
fraction_landuse[i] = fraction_landuse_(icol, i);
}

static constexpr int nmodes = mam4::AeroConfig::num_modes();
Expand Down Expand Up @@ -181,24 +181,6 @@ void update_cloudborne_mmrs(const MAMDryDep::view_3d qqcw, const double dt,
}
} // Update cloud borne aerosols ends

// FIXME: remove the following function after implementing file read for landuse
void populated_fraction_landuse(MAMDryDep::view_2d flu, const int ncol) {
Kokkos::parallel_for(
"populated_fraction_landuse", 1, KOKKOS_LAMBDA(int) {
static constexpr int n_land_type = MAMDryDep::n_land_type;
const Real temp[n_land_type] = {
0.28044346587077795E-003, 0.26634987180780171E-001,
0.16803558403621365E-001, 0.18076055155371872E-001,
0.00000000000000000E+000, 0.00000000000000000E+000,
0.91803784897907303E+000, 0.17186036997038400E-002,
0.00000000000000000E+000, 0.00000000000000000E+000,
0.18448503115578840E-001};
for(int i = 0; i < n_land_type; ++i)
for(int j = 0; j < ncol; ++j) flu(i, j) = temp[i];
});
Kokkos::fence();
}

} // namespace
} // namespace scream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
// Drydep functions are stored in the following hpp file
#include <physics/mam/eamxx_mam_dry_deposition_functions.hpp>

/*
-----------------------------------------------------------------
NOTES:
1. Add a CIME test and multi-process tests
2. Ensure that the submodule for MAM4xx is the main branch
3. Read file for fractional landuse
-----------------------------------------------------------------
*/
// For reading fractional land use file
#include <physics/mam/readfiles/fractional_land_use.hpp>

namespace scream {

using FracLandUseFunc = frac_landuse::fracLandUseFunctions<Real, DefaultDevice>;

MAMDryDep::MAMDryDep(const ekat::Comm &comm, const ekat::ParameterList &params)
: AtmosphereProcess(comm, params) {
/* Anything that can be initialized without grid information can be
Expand Down Expand Up @@ -56,7 +53,8 @@ void MAMDryDep::set_grids(
// Layout for 4D (2d horiz X 1d vertical x number of modes) variables
// at mid points
const int num_aero_modes = mam_coupling::num_aero_modes();
const FieldLayout vector3d_mid = grid_->get_3d_vector_layout(true, num_aero_modes, "num_modes");
const FieldLayout vector3d_mid =
grid_->get_3d_vector_layout(true, num_aero_modes, "num_modes");

using namespace ekat::units;

Expand Down Expand Up @@ -199,6 +197,27 @@ void MAMDryDep::set_grids(
// surface deposition flux of interstitial aerosols, [kg/m2/s] or [1/m2/s]
add_field<Computed>("deposition_flux_of_interstitial_aerosols",
vector2d_pcnst, 1 / m2 / s, grid_name);

// -------------------------------------------------------------
// setup to enable reading fractional land use file
// -------------------------------------------------------------

const auto mapping_file = m_params.get<std::string>("drydep_remap_file", "");
const std::string frac_landuse_data_file =
m_params.get<std::string>("fractional_land_use_file");

// Field to be read from file
const std::string field_name = "fraction_landuse";

// Dimensions of the filed
const std::string dim_name1 = "ncol";
const std::string dim_name2 = "class";

// initialize the file read
FracLandUseFunc::init_frac_landuse_file_read(
ncol_, field_name, dim_name1, dim_name2, grid_, frac_landuse_data_file,
mapping_file, horizInterp_, dataReader_); // output

} // set_grids

// ================================================================
Expand Down Expand Up @@ -345,10 +364,14 @@ void MAMDryDep::initialize_impl(const RunType run_type) {
// Work array to hold tendency for 1 species [kg/kg/s] or [1/kg/s]
dqdt_tmp_ = view_3d("dqdt_tmp_", pcnst, ncol_, nlev_);

static constexpr int n_land_type = mam4::DryDeposition::n_land_type;
// FIXME: This should come from a file reading
// The fraction of land use for the column. [non-dimentional]
fraction_landuse_ = view_2d("fraction_landuse_", n_land_type, ncol_);
//-----------------------------------------------------------------
// Read fractional land use data
//-----------------------------------------------------------------
// This data is time-independent, we read all data here for the
// entire simulation
FracLandUseFunc::update_frac_land_use_data_from_file(
dataReader_, *horizInterp_,
frac_landuse_); // output

//-----------------------------------------------------------------
// Setup preprocessing and post processing
Expand Down Expand Up @@ -403,21 +426,20 @@ void MAMDryDep::run_impl(const double dt) {
auto aerdepdryis_ = get_field_out("deposition_flux_of_interstitial_aerosols")
.get_view<Real **>();

// FIXME: remove it if it read from a file
populated_fraction_landuse(fraction_landuse_, ncol_);

//--------------------------------------------------------------------
// Call drydeposition and get tendencies
//--------------------------------------------------------------------
compute_tendencies(ncol_, nlev_, dt, obukhov_length_,
surface_friction_velocty_, land_fraction_, ice_fraction_,
ocean_fraction_, friction_velocity_,
aerodynamical_resistance_, qtracers_, fraction_landuse_,
dgncur_awet_, wet_dens_, dry_atm_, dry_aero_,
aerodynamical_resistance_, frac_landuse_, dgncur_awet_,
wet_dens_, dry_atm_, dry_aero_,
// Inouts-outputs
qqcw_,
// Outputs
ptend_q_, aerdepdrycw_, aerdepdryis_,
// work arrays
rho_, vlc_dry_, vlc_trb_, vlc_grv_, dqdt_tmp_);
rho_, vlc_dry_, vlc_trb_, vlc_grv_, dqdt_tmp_, qtracers_);
Kokkos::fence();

// Update the interstitial aerosols using ptend.
Expand Down
Loading

0 comments on commit 7945125

Please sign in to comment.