Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
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, extfrc_map_file);
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
28 changes: 28 additions & 0 deletions components/eamxx/src/physics/mam/readfiles/tracer_reader_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,34 @@ inline std::shared_ptr<AtmosphereInput> create_tracer_data_reader(
true);
} // create_tracer_data_reader

inline std::shared_ptr<AtmosphereInput> create_tracer_data_reader(
const std::shared_ptr<AbstractRemapper> &horiz_remapper,
const std::string &tracer_data_file,
const TracerData &tracer_data,
const std::string &extfrc_map_file
) {
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();

// NOTE: If we are using a vertical emission NC file with altitude instead of levels,
// we must rename this tag. This is only necessary when a map file is used.
if(tracer_data.file_type == VERT_EMISSION && extfrc_map_file != ""){
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 {
return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
true);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

i still don't think you should overload, see my comments previously --- just add this stuff to the other function with some extra args

if you still want to, consider this change

Suggested change
const auto io_grid = horiz_remapper->get_src_grid();
// NOTE: If we are using a vertical emission NC file with altitude instead of levels,
// we must rename this tag. This is only necessary when a map file is used.
if(tracer_data.file_type == VERT_EMISSION && extfrc_map_file != ""){
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 {
return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
true);
}
auto io_grid = horiz_remapper->get_src_grid();
// NOTE: we must rename this tag to be consistent
io_grid->reset_field_tag_name(LEV, "altitude");
io_grid->reset_field_tag_name(ILEV, "altitude_int");
return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
true);

Even better, if you could just add this stuff in the first call as a map

inline std::shared_ptr<AtmosphereInput> create_tracer_data_reader(
    const std::shared_ptr<AbstractRemapper> &horiz_remapper,
    const std::string &tracer_data_file
    std::map<FieldTag, std::string>* some_map = nullptr) {
  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));
  }
  auto io_grid = horiz_remapper->get_src_grid();
  if (some_map) {
    for (const auto& [key, value] : *some_map) {
        io_grid->reset_field_tag_name(key, value);
    }
  }
  return std::make_shared<AtmosphereInput>(tracer_data_file, io_grid, io_fields,
                                           true);
}  // create_tracer_data_reader

I am assuming this stuff isn't happening on device, and you have to double check the code

Copy link
Contributor

Choose a reason for hiding this comment

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

He can't change the remapper src grid, since it's const. He'd have to (shallow) clone it first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, forgot that ... in the above:

-  auto io_grid = horiz_remapper->get_src_grid();
+  auto io_grid = horiz_remapper->get_src_grid().clone(...);

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.

I committed a cleaner version of this part of the code. I will clone only the source grid if the file type corresponds to a file with altitude, i.e., the VERT_EMISSION file type. I did not use a map because it would require additional changes in the interface code (I need to create a map). I deleted the overload of create_tracer_data_reader by passing the file type as input and setting the file type default to NONE.

} // create_tracer_data_reader

inline void update_tracer_data_from_file(
const std::shared_ptr<AtmosphereInput> &scorpio_reader,
const int time_index, // zero-based
Expand Down