Skip to content

Commit 808f706

Browse files
committed
Read stuff back again
1 parent 03a67b1 commit 808f706

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

src/Iteration.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ Iteration::flush()
288288
if( !meshes.empty() || s->containsAttribute("meshesPath") )
289289
{
290290
if( !s->containsAttribute("meshesPath") )
291+
{
291292
s->setMeshesPath("meshes/");
292-
s->flushMeshesPath();
293+
s->flushMeshesPath();
294+
}
293295
meshes.flush(s->meshesPath());
294296
for( auto& m : meshes )
295297
m.second.flush(m.first);
@@ -298,8 +300,10 @@ Iteration::flush()
298300
if( !particles.empty() || s->containsAttribute("particlesPath") )
299301
{
300302
if( !s->containsAttribute("particlesPath") )
303+
{
301304
s->setParticlesPath("particles/");
302-
s->flushParticlesPath();
305+
s->flushParticlesPath();
306+
}
303307
particles.flush(s->particlesPath());
304308
for( auto& species : particles )
305309
species.second.flush(species.first);

src/Series.cpp

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,15 @@ Series::readFileBased( )
824824
<< "time series with fileBased iteration "
825825
"encoding. Loaded file is groupBased.\n";
826826
}
827+
else if( encoding == "stepBased" )
828+
{
829+
// @todo should we throw? test this path
830+
*m_iterationEncoding = IterationEncoding::stepBased;
831+
std::cerr << "Series constructor called with iteration "
832+
"regex '%T' suggests loading a "
833+
<< "time series with fileBased iteration "
834+
"encoding. Loaded file is stepBased.\n";
835+
}
827836
else
828837
throw std::runtime_error(
829838
"Unknown iterationEncoding: " + encoding );
@@ -901,6 +910,8 @@ Series::readGroupBased( bool do_init )
901910
std::string encoding = Attribute(*aRead.resource).get< std::string >();
902911
if( encoding == "groupBased" )
903912
*m_iterationEncoding = IterationEncoding::groupBased;
913+
else if( encoding == "stepBased" )
914+
*m_iterationEncoding = IterationEncoding::stepBased;
904915
else if( encoding == "fileBased" )
905916
{
906917
*m_iterationEncoding = IterationEncoding::fileBased;
@@ -1018,22 +1029,43 @@ Series::read()
10181029
readAttributes();
10191030
iterations.readAttributes();
10201031

1021-
// @todo change this for stepBased
10221032
/* obtain all paths inside the basepath (i.e. all iterations) */
1023-
Parameter< Operation::LIST_PATHS > pList;
1024-
IOHandler->enqueue(IOTask(&iterations, pList));
1025-
IOHandler->flush();
1026-
1027-
for( auto const& it : *pList.paths )
1033+
switch(*m_iterationEncoding)
10281034
{
1029-
Iteration& i = iterations[std::stoull(it)];
1030-
if ( i.closedByWriter( ) )
1035+
using IE = IterationEncoding;
1036+
case IE::groupBased:
1037+
case IE::fileBased:
10311038
{
1032-
continue;
1039+
Parameter< Operation::LIST_PATHS > pList;
1040+
IOHandler->enqueue(IOTask(&iterations, pList));
1041+
IOHandler->flush();
1042+
1043+
for( auto const& it : *pList.paths )
1044+
{
1045+
Iteration& i = iterations[std::stoull(it)];
1046+
if ( i.closedByWriter( ) )
1047+
{
1048+
continue;
1049+
}
1050+
pOpen.path = it;
1051+
IOHandler->enqueue(IOTask(&i, pOpen));
1052+
i.read();
1053+
}
1054+
}
1055+
break;
1056+
case IE::stepBased:
1057+
{
1058+
Parameter< Operation::READ_ATT > aRead;
1059+
aRead.name = "iterationIndex";
1060+
IOHandler->enqueue( IOTask( &iterations, aRead ) );
1061+
IOHandler->flush();
1062+
uint64_t index = Attribute( *aRead.resource ).get< uint64_t >();
1063+
Iteration & i = iterations[ index ];
1064+
pOpen.path = "currentIteration";
1065+
IOHandler->enqueue( IOTask( &i, pOpen ) );
1066+
i.read();
10331067
}
1034-
pOpen.path = it;
1035-
IOHandler->enqueue(IOTask(&i, pOpen));
1036-
i.read();
1068+
break;
10371069
}
10381070
}
10391071

@@ -1438,7 +1470,7 @@ WriteIterations::operator[]( key_type && key )
14381470
res.beginStep();
14391471
res.setStepStatus( StepStatus::DuringStep );
14401472
}
1441-
res.setAttribute( "iterationIndex", key );
1473+
shared->iterations.setAttribute( "iterationIndex", key );
14421474
return res;
14431475
}
14441476
} // namespace openPMD

test/SerialIOTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,8 +3173,7 @@ stepBasedSeries( std::string const & file )
31733173
}
31743174
}
31753175

3176-
#if 0
3177-
Series readSeries( file, Access::READ_ONLY );
3176+
Series readSeries( file, Access::READ_ONLY, config );
31783177

31793178
size_t last_iteration_index = 0;
31803179
for( auto iteration : readSeries.readIterations() )
@@ -3191,7 +3190,6 @@ stepBasedSeries( std::string const & file )
31913190
last_iteration_index = iteration.iterationIndex;
31923191
}
31933192
REQUIRE( last_iteration_index == 9 );
3194-
#endif
31953193
}
31963194

31973195
TEST_CASE( "stepBasedSeries", "[serial][adios2]" )

0 commit comments

Comments
 (0)