Skip to content

Commit

Permalink
Add error check for non-homogeneous datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jan 14, 2025
1 parent e5918c7 commit d5ca329
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,29 @@ namespace detail
file, ADIOS2IOHandlerImpl::IfFileNotOpen::ThrowError);
auto &IO = fileData.m_IO;
adios2::Variable<T> var = IO.InquireVariable<T>(varName);

if (fileData.stepSelection().has_value())
{
auto file_steps = fileData.getEngine().Steps();
auto var_steps = var.Steps();
if (file_steps != var_steps)
{
throw error::OperationUnsupportedInBackend(
"ADIOS2",
&R"(
The opened file contains different data per step.
When using variable-based encoding, such files must be opened in linear read
mode, since random-access mode cannot easily associate variable steps
to iterations under these circumstances (yet).
If random-access read mode is required, file-based iteration encoding is more
useful for such data in ADIOS2. You may use the openpmd-pipe command line tool
for converting from variable-based to file-based iteration encoding.
ERROR: Variable ')"[1] + varName +
"' has " + std::to_string(var_steps) +
" step(s), but the file has " +
std::to_string(file_steps) + " step(s).");
}
}
if (stepSelection.has_value())
{
var.SetStepSelection({*stepSelection, 1});
Expand Down

0 comments on commit d5ca329

Please sign in to comment.