Skip to content

Commit

Permalink
EAMxx: fix handling of ranks in filename
Browse files Browse the repository at this point in the history
Do not expose option in YAML files anymore. Instead:
- for standalone: always add ranks to filename
- for CIME tests: never add ranks to filename
  • Loading branch information
bartgol committed Oct 1, 2024
1 parent f8705df commit 51b4bf2
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions components/eamxx/src/share/io/scream_io_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "share/io/scream_scorpio_interface.hpp"
#include "share/util/scream_utils.hpp"
#include "share/scream_config.hpp"

#include <fstream>
#include <regex>
Expand Down Expand Up @@ -35,6 +36,9 @@ std::string find_filename_in_rpointer (
" - filename prefix: " + filename_prefix + "\n");
pattern_str += e2str(avg_type) + "." + control.frequency_units + "_x" + std::to_string(control.frequency);
}
if (is_scream_standalone()) {
pattern_str += ".np" + std::to_string(comm.size());
}
pattern_str += "." + run_t0.to_string() + ".nc";
std::regex pattern (pattern_str);

Expand Down
13 changes: 4 additions & 9 deletions components/eamxx/src/share/io/scream_output_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,10 @@ compute_filename (const IOFileSpecs& file_specs,
filename += "." + e2str(m_avg_type);
filename += "." + control.frequency_units+ "_x" + std::to_string(control.frequency);

// Optionally, add number of mpi ranks (useful mostly in unit tests, to run multiple MPI configs in parallel)
if (m_params.get<bool>("MPI Ranks in Filename")) {
// For standalone EAMxx, we may have 2+ versions of the same test running with two
// different choices of ranks. To avoid name clashing for the output files,
// add the comm size to the output file name.
if (is_scream_standalone()) {
filename += ".np" + std::to_string(m_io_comm.size());
}

Expand Down Expand Up @@ -667,7 +669,6 @@ set_params (const ekat::ParameterList& params,
m_filename_prefix = m_params.get<std::string>("filename_prefix");

// Hard code some parameters in case we access them later
m_params.set("MPI Ranks in Filename",false);
m_params.set<std::string>("Floating Point Precision","real");
} else {
auto avg_type = m_params.get<std::string>("Averaging Type");
Expand Down Expand Up @@ -703,12 +704,6 @@ set_params (const ekat::ParameterList& params,
"Error! Invalid/unsupported value for 'Floating Point Precision'.\n"
" - input value: " + prec + "\n"
" - supported values: float, single, double, real\n");

// If not set, hard code to false for CIME cases, and true for standalone,
// since standalone may be running multiple versions of the same test at once
if (not m_params.isParameter("MPI Ranks in Filename")) {
m_params.set("MPI Ranks in Filename",is_scream_standalone());
}
}

// Output control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,4 @@ Fields:
output_control:
Frequency: ${NUM_STEPS}
frequency_units: nsteps
MPI Ranks in Filename: true
...
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@ Fields:
output_control:
Frequency: ${NUM_STEPS}
frequency_units: nsteps
MPI Ranks in Filename: true
...
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ Field Names:
output_control:
Frequency: ${NUM_STEPS}
frequency_units: nsteps
MPI Ranks in Filename: true
...
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ CreateUnitTest(create_vert_remap_and_weights "create_vert_remap_and_weights.cpp"
# Run a test to setup nudging source data:
set (NUM_STEPS 5)
set (POSTFIX source_data)
set (ADD_RANKS false)
set (ATM_TIME_STEP 300)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_source_data.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_source_data.yaml)
Expand All @@ -36,7 +35,6 @@ CreateUnitTestFromExec (shoc_p3_source shoc_p3_nudging
set (NUM_STEPS 5)
set (ATM_TIME_STEP 300)
set (POSTFIX nudged)
set (ADD_RANKS true)
set (VERT_TYPE TIME_DEPENDENT_3D_PROFILE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_nudging.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_nudging.yaml)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
filename_prefix: shoc_p3_${POSTFIX}_nudged
Averaging Type: Instant
Max Snapshots Per File: 2
MPI Ranks in Filename: ${ADD_RANKS}
Field Names:
- p_mid
- T_mid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ filename_prefix: shoc_p3_${POSTFIX}_nudged_remapped
Averaging Type: Instant
Max Snapshots Per File: 2
vertical_remap_file: vertical_remap.nc
MPI Ranks in Filename: ${ADD_RANKS}
Field Names:
- T_mid
- qv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ Fields:
output_control:
Frequency: 2
frequency_units: nsteps
MPI Ranks in Filename: true
...

0 comments on commit 51b4bf2

Please sign in to comment.