Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8590674
Rename the LEV scream tag from 'Lev' to 'altitude' in the source grid…
odiazib Nov 4, 2024
f1c9a39
Removing unnecessary if statement.
odiazib Nov 4, 2024
23fd730
Fix bug by using target grid instead of source grid.
odiazib Nov 4, 2024
e0a1f20
Remove overload of create_tracer_data_reader. Pass tracer file type t…
odiazib Nov 7, 2024
fa86f7a
EAMxx: Adds a SMS ne30 test that uses ne4 emission file
singhbalwinder Nov 9, 2024
9f6e83e
EAMxx:Modified folder name nad uses alias for atmchange
singhbalwinder Nov 9, 2024
c07bc72
EAMxx:Adds an alias and upload the mapping file ne4->ne30
singhbalwinder Nov 10, 2024
e3f6717
EAMxx: Adds remap test to nightlies
singhbalwinder Nov 10, 2024
2508f47
EAMxx: Removes init file from mam4xx test as it is now picked automat…
singhbalwinder Nov 10, 2024
806a6f1
EAMxx: Fix a comment in the shell script
singhbalwinder Nov 10, 2024
9788c57
EAMxx: Fixes a comment in the microphysics testmod file
singhbalwinder Nov 10, 2024
97b2dd7
EAMxx: Fixes a comment in the newly added test
singhbalwinder Nov 10, 2024
37ae73a
EMAxx - Update comment in enum TracerFileType to avoid confusion.
odiazib Nov 11, 2024
342958c
EAMxx - Rename enum VERT_EMISSION to ELEVATED_EMISSIONS.
odiazib Nov 11, 2024
3eb6d04
EAMxx - Rename variables: 'elevated_' prefix replaces 'vert_'.
odiazib Nov 11, 2024
a596e6b
EAMxx - Rename tag names: 'elevated' replaces 'verti'
odiazib Nov 11, 2024
589742d
EAMxx - Replace 'verti' with 'elevated' in tag names; add missing lines.
odiazib Nov 11, 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
1 change: 1 addition & 0 deletions cime_config/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@
"SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-aci",
"SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-wetscav",
"SMS_D_Ln5.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.scream-mam4xx-drydep",
"SMS_D_Ln5.ne30pg2_oECv3.F2010-SCREAMv1-MPASSI.scream-mam4xx-remap_emiss_ne4_ne30"
)
},

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 microphysics 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_aero_microphys" -b


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#!/bin/sh
#------------------------------------------------------
# MAM4xx adds additionaltracers to the simulation
# Increase number of tracers for MAM4xx simulations
#------------------------------------------------------

$CIMEROOT/../components/eamxx/cime_config/testdefs/testmods_dirs/scream/mam4xx/update_eamxx_num_tracers.sh -b

#------------------------------------------------------
# Add aerosol microphysics process, force ne4pg2
# emission files and provide a ne4pg2->ne30pg2 mapping
# file
#------------------------------------------------------
alias ATMCHANGE='$CIMEROOT/../components/eamxx/scripts/atmchange'

ATMCHANGE physics::atm_procs_list="mac_aero_mic,rrtmgp,mam4_aero_microphys" -b

ATMCHANGE mam4_aero_microphys::mam4_so2_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_so2_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_so4_a1_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_so4_a1_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_so4_a2_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_so4_a2_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_pom_a4_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_pom_a4_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_bc_a4_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_bc_a4_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_num_a1_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_num_a1_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_num_a2_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_num_a2_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_num_a4_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_num_a4_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::mam4_soag_verti_emiss_file_name='${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne4pg2/elevated/cmip6_mam4_soag_elev_1x1_2010_clim_ne4pg2_c20241008.nc' -b
ATMCHANGE mam4_aero_microphys::aero_microphys_remap_file='${DIN_LOC_ROOT}/atm/scream/maps/map_ne4pg2_to_ne30pg2_nco_c20241108.nc' -b


Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void MAMMicrophysics::set_grids(
LinozHorizInterp_, linoz_file_name_);

// linoz reader
const auto io_grid_linoz = LinozHorizInterp_->get_src_grid();
const auto io_grid_linoz = LinozHorizInterp_->get_tgt_grid();
const int num_cols_io_linoz =
io_grid_linoz->get_num_local_dofs(); // Number of columns on this rank
const int num_levs_io_linoz =
Expand Down Expand Up @@ -233,7 +233,7 @@ void MAMMicrophysics::set_grids(
TracerHorizInterp_, oxid_file_name_);

const int nvars = int(var_names.size());
const auto io_grid = TracerHorizInterp_->get_src_grid();
const auto io_grid = TracerHorizInterp_->get_tgt_grid();
const int num_cols_io =
io_grid->get_num_local_dofs(); // Number of columns on this rank
const int num_levs_io =
Expand Down Expand Up @@ -289,8 +289,10 @@ void MAMMicrophysics::set_grids(
verti_emiss_cyclical_ymd);
auto hor_rem = scream::mam_coupling::create_horiz_remapper(
grid_, file_name, extfrc_map_file, var_names, data_tracer);

auto file_reader =
scream::mam_coupling::create_tracer_data_reader(hor_rem, file_name);
scream::mam_coupling::create_tracer_data_reader(hor_rem, file_name,
data_tracer.file_type);
VertEmissionsHorizInterp_.push_back(hor_rem);
VertEmissionsDataReader_.push_back(file_reader);
vert_emis_data_.push_back(data_tracer);
Expand All @@ -306,7 +308,7 @@ void MAMMicrophysics::set_grids(
// I am assuming the order of species in extfrc_lst_.
// Indexing in mam4xx is fortran.
forcings_[i].frc_ndx = i + 1;
const auto io_grid_emis = VertEmissionsHorizInterp_[i]->get_src_grid();
const auto io_grid_emis = VertEmissionsHorizInterp_[i]->get_tgt_grid();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add a test

Copy link
Contributor Author

@odiazib odiazib Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To create a test, I will need to have a map file. Is it possible to include this test in a future PR? Note that the evaluation team is running additional cases that allow us to catch issues.

const int num_cols_io_emis =
io_grid_emis->get_num_local_dofs(); // Number of columns on this rank
const int num_levs_io_emis =
Expand Down
39 changes: 29 additions & 10 deletions components/eamxx/src/physics/mam/readfiles/tracer_reader_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ struct ForcingHelper {
};

enum TracerFileType {
// file with PS ncol, lev, and time
// file with ncol, lev, ilev, time and has P0 and PS as variables
// example: oxidants
FORMULA_PS,
// nc zonal file from ncremap
ZONAL,
// vertical emission files
// example: linoz
ZONAL,
// file with ncol, altitude, altitude_int, time
// example: elevated (at a height) emissions of aerosols and precursors
// NOTE: we must rename the default vertical tags when horiz remapping
// NOTE: we vert remap in a different routine in mam4xx
VERT_EMISSION,
// Placeholder for cases where no file type is applicable
NONE
};

enum TracerDataIndex { BEG = 0, END = 1, OUT = 2 };
Expand Down Expand Up @@ -381,11 +388,6 @@ inline std::shared_ptr<AbstractRemapper> create_horiz_remapper(
model_grid->clone("tracer_horiz_interp_tgt_grid", true);
horiz_interp_tgt_grid->reset_num_vertical_lev(tracer_data.nlevs_data);

if(tracer_data.file_type == VERT_EMISSION) {
horiz_interp_tgt_grid->reset_field_tag_name(LEV, "altitude");
horiz_interp_tgt_grid->reset_field_tag_name(ILEV, "altitude_int");
}

const int ncols_model = model_grid->get_num_global_dofs();
std::shared_ptr<AbstractRemapper> remapper;
if(tracer_data.ncols_data == ncols_model) {
Expand Down Expand Up @@ -438,14 +440,31 @@ inline std::shared_ptr<AbstractRemapper> create_horiz_remapper(

inline std::shared_ptr<AtmosphereInput> create_tracer_data_reader(
const std::shared_ptr<AbstractRemapper> &horiz_remapper,
const std::string &tracer_data_file) {
const std::string &tracer_data_file,
const TracerFileType file_type = NONE)
{
std::vector<Field> io_fields;
for(int i = 0; i < horiz_remapper->get_num_fields(); ++i) {
io_fields.push_back(horiz_remapper->get_src_field(i));
}
const auto io_grid = horiz_remapper->get_src_grid();
return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
if(file_type == VERT_EMISSION ){
// NOTE: If we are using a vertical emission nc file with altitude instead of lev,
// we must rename this tag.
// We need to perform a shallow clone of io_grid because tags are const in this object.
auto horiz_interp_src_grid =
io_grid->clone("tracer_horiz_interp_src_grid", true);
horiz_interp_src_grid->reset_field_tag_name(LEV, "altitude");
horiz_interp_src_grid->reset_field_tag_name(ILEV, "altitude_int");
return std::make_shared<AtmosphereInput>(tracer_data_file, horiz_interp_src_grid, io_fields,
true);
} else{
// We do not need to rename tags in or clone io_grid for other types of files.
Copy link
Contributor

@mahf708 mahf708 Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is partly the confusion and that's why I was unhappy about this PR. Your comments here don't add up to what's going on. What you should actually say is the following: "we must not rename the tags". If you rename the tags here for the zonal or formula_ps files, you will end up with errors. (You will be to rename the tags for the surface/none type though.) So, your branching logic is justified, but that wasn't clear to me (because the notes here made it sound it was just a preference; if it were just a preference, it'd simply be bad code imo --- we should only branch if we have to)

Based on the info you provided in the main post, I believe the following is the best way to describe this messy situation. Let's take your enum for illustration:

enum TracerFileType {
- // file with PS ncol, lev, and time
+ // file with ncol, lev, ilev, time and has P0 and PS as variables
+ // example: oxidants
  FORMULA_PS,
- // nc zonal file from ncremap
+ // file with ncol, lev, ilev, time
+ // example: linoz
  ZONAL,
- // vertical emission files
+ // file with ncol, altitude, altitude_int, time
+ // example: elevated (at a height) emissions of aerosols and precursors
+ // NOTE: we must rename the default vertical tags when horiz remapping
+ // NOTE: we vert remap in a different routine in mam4xx
  VERT_EMISSION,
- //
+ // file with ncol, time
+ // example: surface emissions of aerosols and precursors
  NONE
};

Note I referred to the "VERT_EMISSION" files as they are actually named "elevated" (that's in the name of the files). I think it would have been good to keep that terminology from EAM. I believe the "NONE" type includes the surface emission. In the messy namelist world of EAM, we roughly call these "ext_frc_" (VERT_) and "srf_emis_" (NONE). So, I think you should actually change the "NONE" type to something more meaningful. I would encourage you to check with people like Balwinder, Kai, and Mingxuan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mingxuanwupnnl explained very well why to use the term "external forcings" for emissions (as they are applied like forcing in the equations). I think NONE here means a tracer file with no vertical dimension (e.g., surface emissions). We can rename NONE to SURFACE, but NONE should also be fine as it would mean a tracer file with a NONE vertical extent.

Copy link
Contributor Author

@odiazib odiazib Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rename the enums. Note that we are not using the TracerFileType enum for surface emissions. The reader for surface emissions was implemented by @singhbalwinder. We worked in parallel on this, so we ended up with duplicate code. Because @bartgol is working on a general reader, it is better to just keep NONE, and I do not think we should add a reference for surface emissions. I will update the comments in this part of the code, as recommended by @mahf708.

@singhbalwinder, is this change okay: renaming VERT_EMISSION to ELEVATED_EMISSION? Or do we want to keep it as EXT_FRC?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change it to ELEVATED_EMISSIONS. I would like to keep a reference to "emissions" to be clear that these are actually emissions.

return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
true);
}


} // create_tracer_data_reader

inline void update_tracer_data_from_file(
Expand Down
Loading