Skip to content

Commit

Permalink
Merge pull request sxs-collaboration#6211 from knelli2/h5_cce_error
Browse files Browse the repository at this point in the history
Clarify error messages in H5 Cce constructor
  • Loading branch information
kidder authored Aug 14, 2024
2 parents ab8123b + c2c05f4 commit e57053b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/IO/H5/Cce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,22 @@ Cce::Cce(const bool exists, detail::OpenGroup&& group, const hid_t /*location*/,
std::array<hsize_t, 2> max_dims{};
if (2 != H5Sget_simple_extent_dims(space_id, dataset.size.data(),
max_dims.data())) {
ERROR("Invalid number of dimensions in cce file " << bondi_var
<< " on disk.");
ERROR("Invalid number of dimensions (" << max_dims << ") in cce file "
<< bondi_var << " on disk.");
}
CHECK_H5(H5Sclose(space_id), "Failed to close dataspace");

if (legend_ != read_rank1_attribute<std::string>(dataset.id, "Legend"s)) {
ERROR("l_max from cce file " << bondi_var
<< " does not match l_max in constructor");
const size_t file_l_max_plus_1 = static_cast<size_t>(
sqrt(static_cast<double>(
read_rank1_attribute<std::string>(dataset.id, "Legend"s)
.size() -
1_st) /
2.0));
ERROR("l_max (" << (file_l_max_plus_1 > 0 ? file_l_max_plus_1 - 1 : 0)
<< ") from cce file " << bondi_var
<< " does not match l_max (" << l_max_
<< ") in constructor");
}
}
} else { // file does not exist
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/IO/H5/Test_Cce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ void test_errors() {
(void)cce_file2;
}
}(),
Catch::Matchers::ContainsSubstring("l_max from cce file") and
Catch::Matchers::ContainsSubstring("l_max (4) from cce file") and
Catch::Matchers::ContainsSubstring(
"does not match l_max in constructor"));
"does not match l_max (5) in constructor"));
if (file_system::check_if_file_exists(file_name)) {
file_system::rm(file_name, true);
}
Expand Down

0 comments on commit e57053b

Please sign in to comment.