Unfriendly error message when removing `.bp` file from directory context.
Created by: NAThompson
I have the following code:
#include <iostream>
#include <vector>
#include <string>
#include <adios2.h>
int main(int argc, char** argv) {
if (argc <= 1) {
std::cerr << "Usage: ./profile_memory foo.bp [variablename]\n";
return 1;
}
const std::size_t Nx = 10;
std::vector<double> myFloats(Nx, std::numeric_limits<double>::quiet_NaN());
adios2::ADIOS adios(adios2::DebugON);
adios2::IO bpIO = adios.DeclareIO("ReadBP");
adios2::Engine bpReader = bpIO.Open(std::string(argv[1]), adios2::Mode::Read);
std::string variable_name = "T";
if (argc == 3) {
variable_name = argv[2];
}
adios2::Variable<double> bpFloats = bpIO.InquireVariable<double>(variable_name);
if (bpFloats)
{
bpReader.Get<double>(bpFloats, myFloats, adios2::Mode::Sync);
}
else
{
std::cerr << "Could not find " << variable_name << " in file " << argv[1] << "\n";
std::cerr << "Try ./profile_memory file.bp variable_name\n";
return 1;
}
std::cout << "Floats = {";
for (auto x : myFloats) {
std::cout << x << ", ";
}
std::cout << "}\n";
bpReader.Close();
return 0;
}
(Full working example here.)
Now, if I copy ADIOS2/bindings/Matlab/test/heat.bp
into my local directory, and run
$ ./profile_memory heat.bp
I get the error message:
./profile_memory heat.bp
libc++abi.dylib: terminating with uncaught exception of type std::__1::ios_base::failure: ERROR: couldn't open file heat.bp.dir/heat.bp.0, check permissions or path existence, in call to POSIX open
: unspecified iostream_category error
[1] 24585 abort ./profile_memory heat.bp
I was unaware before hitting this that the .bp
file is dependent on context; namely, I can't move a .bp
around without potentially breaking it. Without this knowledge, the error message is not understandable. Can it be made more user-friendly?
For example:
.bp files do not exist independently of their directory context. Did you move the .bp file from the directory of its creation?