Skip to content

Commit

Permalink
Fix ADIOS1 constant scalar detection
Browse files Browse the repository at this point in the history
As empty groups can not be stored in ADIOS, we have to work around this
by detecting whether an attribute is at a location that is NOT a
variable.
  • Loading branch information
C0nsultant committed Sep 19, 2018
1 parent a0906c2 commit 6dc6f9f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/IO/ADIOS/CommonADIOS1IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ CommonADIOS1IOHandlerImpl::listPaths(Writable* writable,
std::string name = concrete_bp1_file_position(writable);

std::unordered_set< std::string > paths;
std::unordered_set< std::string > variables;
for( int i = 0; i < f->nvars; ++i )
{
char* str = f->var_namelist[i];
Expand All @@ -1351,6 +1352,7 @@ CommonADIOS1IOHandlerImpl::listPaths(Writable* writable,
{
/* remove the writable's path from the name */
s = auxiliary::replace_first(s, name, "");
variables.emplace(s);
if( std::any_of(s.begin(), s.end(), [](char c) { return c == '/'; }) )
{
/* there are more path levels after the current writable */
Expand All @@ -1367,13 +1369,18 @@ CommonADIOS1IOHandlerImpl::listPaths(Writable* writable,
{
/* remove the writable's path from the name */
s = auxiliary::replace_first(s, name, "");
/* remove the attribute name */
s = s.substr(0, s.find_last_of('/'));
if( std::any_of(s.begin(), s.end(), [](char c) { return c == '/'; }) )
{
/* this is an attribute of the writable */
s = s.substr(0, s.find_first_of('/'));
paths.emplace(s);
/* remove the attribute name */
s = s.substr(0, s.find_last_of('/'));
if( !std::any_of(variables.begin(),
variables.end(),
[&s](std::string const& var){ return auxiliary::starts_with(var, s); }))
{
/* this is either a group or a constant scalar */
s = s.substr(0, s.find_first_of('/'));
paths.emplace(s);
}
}
}
}
Expand Down

0 comments on commit 6dc6f9f

Please sign in to comment.