Skip to content

Commit

Permalink
Use own flag for the warning
Browse files Browse the repository at this point in the history
Previously implementation did not work: ornladios/ADIOS2#4466
  • Loading branch information
franzpoeschel committed Feb 14, 2025
1 parent 56b453f commit e9ee667
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
2 changes: 2 additions & 0 deletions include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ namespace adios_defaults
constexpr const_str str_usesteps = "usesteps";
constexpr const_str str_flushtarget = "preferred_flush_target";
constexpr const_str str_usesstepsAttribute = "__openPMD_internal/useSteps";
constexpr const_str str_useModifiableAttributes =
"__openPMD_internal/useModifiableAttributes";
constexpr const_str str_adios2Schema =
"__openPMD_internal/openPMD2_adios2_schema";
constexpr const_str str_isBoolean = "__is_boolean__";
Expand Down
7 changes: 7 additions & 0 deletions src/IO/ADIOS/ADIOS2File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "openPMD/IO/ADIOS/ADIOS2File.hpp"
#include "openPMD/Error.hpp"
#include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp"
#include "openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
#include "openPMD/IO/AbstractIOHandler.hpp"
#include "openPMD/IterationEncoding.hpp"
Expand Down Expand Up @@ -500,6 +501,12 @@ void ADIOS2File::configure_IO()
? ADIOS2IOHandlerImpl::ModifiableAttributes::Yes
: ADIOS2IOHandlerImpl::ModifiableAttributes::No;
}
m_IO.DefineAttribute<bool_representation>(
adios_defaults::str_useModifiableAttributes,
m_impl->m_modifiableAttributes ==
ADIOS2IOHandlerImpl::ModifiableAttributes::No
? 0
: 1);
#else
if (!m_impl->m_useGroupTable.has_value())
{
Expand Down
41 changes: 17 additions & 24 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1541,37 +1541,30 @@ namespace
}
static constexpr char const *errorMsg = "DistributeToAllRanks";
};
#endif

void warn_ignored_modifiable_attributes(
adios2::IO &IO, std::string const &exempt_this_from_warnings)
void warn_ignored_modifiable_attributes(adios2::IO &IO)
{
auto all_attributes = IO.AvailableAttributes();
std::deque<std::string> modifiable_attributes;
for (auto const &[identifier, params] : all_attributes)
{
if (params.at("Modifiable") == "1")
{
modifiable_attributes.emplace_back(identifier);
}
}
if (modifiable_attributes.size() > 1 ||
(modifiable_attributes.size() == 1 &&
*modifiable_attributes.begin() != exempt_this_from_warnings))
{
std::cerr << &R"(
Warning: Random-access for variable-encoding in ADIOS2 is currently
auto modifiable_flag = IO.InquireAttribute<detail::bool_representation>(
adios_defaults::str_useModifiableAttributes);
auto print_warning = [](std::string const &note) {
std::cerr << "Warning: " << note << R"(
Random-access for variable-encoding in ADIOS2 is currently
experimental. Support for modifiable attributes is currently not implemented
yet, meaning that attributes such as /data/time will show useless values.
Use Access::READ_LINEAR to retrieve those values if needed.
The following modifiable attributes have been found:
)"[1];
for (auto const &identifier : modifiable_attributes)
{
std::cerr << '\t' << identifier << '\n';
}
)";
};
if (!modifiable_flag)
{
print_warning("File might be using modifiable attributes.");
}
else if (modifiable_flag.Data().at(0) != 0)
{
print_warning("File uses modifiable attributes.");
}
}
#endif
} // namespace

void ADIOS2IOHandlerImpl::readAttributeAllsteps(
Expand All @@ -1589,7 +1582,7 @@ void ADIOS2IOHandlerImpl::readAttributeAllsteps(
IO.SetParameter("StreamReader", "ON"); // this be for BP4
auto engine = IO.Open(fullPath(*file), adios2::Mode::Read);
auto status = engine.BeginStep();
warn_ignored_modifiable_attributes(IO, name);
warn_ignored_modifiable_attributes(IO);
auto type = detail::attributeInfo(IO, name, /* verbose = */ true);
switchType<ReadAttributeAllsteps>(
type, IO, engine, name, status, *param.resource);
Expand Down
4 changes: 2 additions & 2 deletions src/binding/python/openpmd_api/pipe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def run(self):
if not HAVE_MPI or (args.mpi is None and self.comm.size == 1):
print("Opening data source")
sys.stdout.flush()
inseries = io.Series(self.infile, io.Access.read_linear,
inseries = io.Series(self.infile, io.Access.read_random_access,
self.inconfig)
print("Opening data sink")
sys.stdout.flush()
Expand All @@ -193,7 +193,7 @@ def run(self):
else:
print("Opening data source on rank {}.".format(self.comm.rank))
sys.stdout.flush()
inseries = io.Series(self.infile, io.Access.read_linear, self.comm,
inseries = io.Series(self.infile, io.Access.read_random_access, self.comm,
self.inconfig)
print("Opening data sink on rank {}.".format(self.comm.rank))
sys.stdout.flush()
Expand Down

0 comments on commit e9ee667

Please sign in to comment.