@@ -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
0 commit comments