Skip to content

Commit 9f5cbc1

Browse files
committed
Fix bug when opening a filebased series as groupbased
In that case, we must not attempt to piece back together the filename by filebased methods, but instead directly use the filename specified by the user.
1 parent 42e2a58 commit 9f5cbc1

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

include/openPMD/Series.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class SeriesData : public AttributableData
8686

8787
OPENPMD_private :
8888
auxiliary::Option< WriteIterations > m_writeIterations;
89+
auxiliary::Option< std::string > m_overrideFilebasedFilename;
8990
std::string m_name;
9091
std::string m_filenamePrefix;
9192
std::string m_filenamePostfix;

src/Series.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,12 @@ SeriesImpl::readGroupBased( bool do_init )
913913
series.m_iterationEncoding = IterationEncoding::fileBased;
914914
std::cerr << "Series constructor called with explicit iteration suggests loading a "
915915
<< "single file with groupBased iteration encoding. Loaded file is fileBased.\n";
916+
/*
917+
* We'll want the openPMD API to continue series.m_name to open
918+
* the file instead of piecing the name together via
919+
* prefix-padding-postfix things.
920+
*/
921+
series.m_overrideFilebasedFilename = series.m_name;
916922
} else
917923
throw std::runtime_error("Unknown iterationEncoding: " + encoding);
918924
setAttribute("iterationEncoding", encoding);
@@ -1065,6 +1071,10 @@ std::string
10651071
SeriesImpl::iterationFilename( uint64_t i )
10661072
{
10671073
auto & series = get();
1074+
if( series.m_overrideFilebasedFilename.has_value() )
1075+
{
1076+
return series.m_overrideFilebasedFilename.get();
1077+
}
10681078
std::stringstream iteration( "" );
10691079
iteration << std::setw( series.m_filenamePadding )
10701080
<< std::setfill( '0' ) << i;

0 commit comments

Comments
 (0)