Skip to content

Commit 77a52f2

Browse files
Adds mapping files for finer resolutions
1 parent 10d3cbc commit 77a52f2

File tree

3 files changed

+54
-44
lines changed

3 files changed

+54
-44
lines changed

components/eamxx/cime_config/namelist_defaults_scream.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ be lost if SCREAM_HACK_XML is not enabled.
296296
<mam4_num_a2_verti_emiss_file_name hgrid="ne4np4.pg2" type="file" doc="vertical emissions for num_a2">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_num_a2_elev_1x1_2010_clim_ne4pg2_c20241008.nc</mam4_num_a2_verti_emiss_file_name>
297297
<mam4_num_a4_verti_emiss_file_name hgrid="ne4np4.pg2" type="file" doc="vertical emissions for num_a4">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_num_a4_elev_1x1_2010_clim_ne4pg2_c20241008.nc</mam4_num_a4_verti_emiss_file_name>
298298
<mam4_soag_verti_emiss_file_name hgrid="ne4np4.pg2" type="file" doc="vertical emissions for soag">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_soag_elev_1x1_2010_clim_ne4pg2_c20241008.nc</mam4_soag_verti_emiss_file_name>
299+
300+
<!-- Mapping Files for finer resolutions -->
301+
<aero_microphys_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."/>
302+
<aero_microphys_remap_file hgrid="ne120np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne120pg2_20231201.nc</aero_microphys_remap_file>
303+
<aero_microphys_remap_file hgrid="ne256np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne256pg2_20231201.nc</aero_microphys_remap_file>
304+
<aero_microphys_remap_file hgrid="ne512np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne512pg2_20231201.nc</aero_microphys_remap_file>
305+
<aero_microphys_remap_file hgrid="ne1024np4.pg2">${DIN_LOC_ROOT}/atm/scream/maps/map_ne30pg2_to_ne1024pg2_20231201.nc</aero_microphys_remap_file>
306+
299307
</mam4_aero_microphys>
300308

301309
<!-- MAM4xx-Optics -->

components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,14 @@ void MAMMicrophysics::set_grids(
202202
// from a file and configuring the necessary parameters for the Linoz model.
203203
{
204204
linoz_file_name_ = m_params.get<std::string>("mam4_linoz_file_name");
205-
std::string linoz_map_file = "";
206-
std::vector<std::string> var_names{"o3_clim", "o3col_clim", "t_clim",
207-
"PmL_clim", "dPmL_dO3", "dPmL_dT",
208-
"dPmL_dO3col", "cariolle_pscs"};
205+
const std::string linoz_map_file =
206+
m_params.get<std::string>("aero_microphys_remap_file", "");
207+
const std::vector<std::string> var_names{
208+
"o3_clim", "o3col_clim", "t_clim", "PmL_clim",
209+
"dPmL_dO3", "dPmL_dT", "dPmL_dO3col", "cariolle_pscs"};
209210

210211
// in format YYYYMMDD
211-
int linoz_cyclical_ymd = m_params.get<int>("mam4_linoz_ymd");
212+
const int linoz_cyclical_ymd = m_params.get<int>("mam4_linoz_ymd");
212213
scream::mam_coupling::setup_tracer_data(linoz_data_, linoz_file_name_,
213214
linoz_cyclical_ymd);
214215
LinozHorizInterp_ = scream::mam_coupling::create_horiz_remapper(
@@ -245,12 +246,13 @@ void MAMMicrophysics::set_grids(
245246

246247
{
247248
oxid_file_name_ = m_params.get<std::string>("mam4_oxid_file_name");
248-
std::string oxid_map_file = "";
249+
const std::string oxid_map_file =
250+
m_params.get<std::string>("aero_microphys_remap_file", "");
249251
// NOTE: order matches mam4xx:
250-
std::vector<std::string> var_names{"O3", "OH", "NO3", "HO2"};
252+
const std::vector<std::string> var_names{"O3", "OH", "NO3", "HO2"};
251253

252-
// //in format YYYYMMDD
253-
int oxid_ymd = m_params.get<int>("mam4_oxid_ymd");
254+
// in format YYYYMMDD
255+
const int oxid_ymd = m_params.get<int>("mam4_oxid_ymd");
254256
scream::mam_coupling::setup_tracer_data(tracer_data_, oxid_file_name_,
255257
oxid_ymd);
256258
TracerHorizInterp_ = scream::mam_coupling::create_horiz_remapper(
@@ -280,15 +282,15 @@ void MAMMicrophysics::set_grids(
280282
} // oxid file reader
281283

282284
{
283-
// FIXME: I will need to add this file per forcing file.
284-
std::string extfrc_map_file = "";
285+
const std::string extfrc_map_file =
286+
m_params.get<std::string>("aero_microphys_remap_file", "");
285287
// NOTE: order of forcing species is important.
286288
// extfrc_lst(: 9) = {'SO2 ','so4_a1 ','so4_a2
287289
// ','pom_a4 ','bc_a4 ', 'num_a1 ','num_a2
288290
// ','num_a4 ','SOAG ' }
289291
// This order corresponds to files in namelist e3smv2
290-
extfrc_lst_ = {"so2", "so4_a1", "so4_a2", "pom_a4", "bc_a4",
291-
"num_a1", "num_a2", "num_a4", "soag"};
292+
extfrc_lst_ = {"so2", "so4_a1", "so4_a2", "pom_a4", "bc_a4",
293+
"num_a1", "num_a2", "num_a4", "soag"};
292294

293295
for(const auto &var_name : extfrc_lst_) {
294296
std::string item_name = "mam4_" + var_name + "_verti_emiss_file_name";
@@ -330,11 +332,10 @@ void MAMMicrophysics::set_grids(
330332
} // var_name vert emissions
331333
int i = 0;
332334
int offset_emis_ver = 0;
333-
for(const auto &var_name : extfrc_lst_)
334-
{
335+
for(const auto &var_name : extfrc_lst_) {
335336
const auto file_name = vert_emis_file_name_[var_name];
336337
const auto var_names = vert_emis_var_names_[var_name];
337-
const int nvars = static_cast<int>(var_names.size());
338+
const int nvars = static_cast<int>(var_names.size());
338339

339340
forcings_[i].nsectors = nvars;
340341
// I am assuming the order of species in extfrc_lst_.
@@ -358,10 +359,10 @@ void MAMMicrophysics::set_grids(
358359
++i;
359360
} // end i
360361
EKAT_REQUIRE_MSG(
361-
offset_emis_ver <= int(mam_coupling::MAX_NUM_VERT_EMISSION_FIELDS),
362-
"Error! Number of fields is bigger than "
363-
"MAX_NUM_VERT_EMISSION_FIELDS. Increase the "
364-
"MAX_NUM_VERT_EMISSION_FIELDS in tracer_reader_utils.hpp \n");
362+
offset_emis_ver <= int(mam_coupling::MAX_NUM_VERT_EMISSION_FIELDS),
363+
"Error! Number of fields is bigger than "
364+
"MAX_NUM_VERT_EMISSION_FIELDS. Increase the "
365+
"MAX_NUM_VERT_EMISSION_FIELDS in tracer_reader_utils.hpp \n");
365366

366367
#if defined(ENABLE_OUTPUT_TRACER_FIELDS)
367368
FieldLayout scalar3d_mid_emis_ver = grid_->get_3d_vector_layout(
@@ -394,12 +395,14 @@ size_t MAMMicrophysics::requested_buffer_size_in_bytes() const {
394395
void MAMMicrophysics::init_buffers(const ATMBufferManager &buffer_manager) {
395396
size_t used_mem =
396397
mam_coupling::init_buffer(buffer_manager, ncol_, nlev_, buffer_);
397-
EKAT_REQUIRE_MSG(
398-
used_mem == requested_buffer_size_in_bytes(),
399-
"Error! Used memory != requested memory for MAMMicrophysics."
400-
" Used memory: " << std::to_string(used_mem) << "."
401-
" Requested memory: " << std::to_string(requested_buffer_size_in_bytes()) << ". \n"
402-
);
398+
EKAT_REQUIRE_MSG(used_mem == requested_buffer_size_in_bytes(),
399+
"Error! Used memory != requested memory for MAMMicrophysics."
400+
" Used memory: "
401+
<< std::to_string(used_mem)
402+
<< "."
403+
" Requested memory: "
404+
<< std::to_string(requested_buffer_size_in_bytes())
405+
<< ". \n");
403406
}
404407

405408
// ================================================================
@@ -555,7 +558,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
555558
scream::mam_coupling::update_tracer_data_from_file(
556559
TracerDataReader_, curr_month, *TracerHorizInterp_, tracer_data_);
557560

558-
for (int i = 0; i < static_cast<int>(extfrc_lst_.size()); ++i) {
561+
for(int i = 0; i < static_cast<int>(extfrc_lst_.size()); ++i) {
559562
scream::mam_coupling::update_tracer_data_from_file(
560563
VertEmissionsDataReader_[i], curr_month, *VertEmissionsHorizInterp_[i],
561564
vert_emis_data_[i]);
@@ -723,14 +726,14 @@ void MAMMicrophysics::run_impl(const double dt) {
723726
// Note: We are following the RRTMGP EAMxx interface to compute the zenith
724727
// angle. This operation is performed on the host because the routine
725728
// shr_orb_cosz_c2f has not been ported to C++.
726-
auto ts2 = timestamp();
729+
auto ts2 = timestamp();
727730
auto orbital_year = m_orbital_year;
728731
// Note: We need double precision because
729732
// shr_orb_params_c2f and shr_orb_decl_c2f only support double precision.
730733
double obliqr, lambm0, mvelpp;
731-
double eccen = m_orbital_eccen;
732-
double obliq = m_orbital_obliq;
733-
double mvelp = m_orbital_mvelp;
734+
double eccen = m_orbital_eccen;
735+
double obliq = m_orbital_obliq;
736+
double mvelp = m_orbital_mvelp;
734737
// Use the orbital parameters to calculate the solar declination and
735738
// eccentricity factor
736739
double delta, eccf;

components/eamxx/src/physics/mam/impl/tracer_reader_utils.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ inline void compute_p_src_zonal_files(const view_1d &levs,
3939
"Error: p_src has a different number of levels than the source data. \n");
4040
Kokkos::parallel_for(
4141
"pressure_computation",
42-
Kokkos::MDRangePolicy<Kokkos::Rank<2> >({0, 0},
43-
{ncol, nlevs_data}),
42+
Kokkos::MDRangePolicy<Kokkos::Rank<2> >({0, 0}, {ncol, nlevs_data}),
4443
KOKKOS_LAMBDA(const int icol, const int kk) {
45-
// mbar->pascals
46-
// FIXME: Does EAMxx have a better method to
47-
// convert units?"
48-
p_src(icol, kk) = levs(kk) * 100;
44+
// mbar->pascals
45+
// FIXME: Does EAMxx have a better method to
46+
// convert units?"
47+
p_src(icol, kk) = levs(kk) * 100;
4948
});
5049
Kokkos::fence();
5150
}
@@ -649,11 +648,11 @@ inline void perform_vertical_interpolation(const const_view_1d &altitude_int,
649648
EKAT_REQUIRE_MSG(
650649
input.file_type == VERT_EMISSION,
651650
"Error! vertical interpolation only with altitude variable. \n");
652-
const int ncols = input.ncol_;
653-
const int num_vars = input.nvars_;
654-
const int num_vertical_lev_target = output[0].extent(1);
655-
const int num_vert_packs = num_vertical_lev_target;
656-
const int outer_iters = ncols * num_vars;
651+
const int ncols = input.ncol_;
652+
const int num_vars = input.nvars_;
653+
const int num_vertical_lev_target = output[0].extent(1);
654+
const int num_vert_packs = num_vertical_lev_target;
655+
const int outer_iters = ncols * num_vars;
657656
const auto policy_interp =
658657
ESU::get_default_team_policy(outer_iters, num_vert_packs);
659658
// FIXME: Get m2km from emaxx.
@@ -681,8 +680,8 @@ inline void perform_vertical_interpolation(const const_view_1d &altitude_int,
681680
trg_x[pverp - i - 1] = m2km * zi(icol, i);
682681
}
683682
team.team_barrier();
684-
mam4::vertical_interpolation::rebin(team, nsrc, num_vertical_lev_target, src_x, trg_x, src,
685-
trg);
683+
mam4::vertical_interpolation::rebin(team, nsrc, num_vertical_lev_target,
684+
src_x, trg_x, src, trg);
686685
});
687686
}
688687

0 commit comments

Comments
 (0)