@@ -3709,8 +3709,10 @@ serial_iterator( std::string const & file )
37093709 Series readSeries ( file, Access::READ_ONLY );
37103710
37113711 size_t last_iteration_index = 0 ;
3712+ size_t numberOfIterations = 0 ;
37123713 for ( auto iteration : readSeries.readIterations () )
37133714 {
3715+ ++numberOfIterations;
37143716 auto E_x = iteration.meshes [ " E" ][ " x" ];
37153717 REQUIRE ( E_x.getDimensionality () == 1 );
37163718 REQUIRE ( E_x.getExtent ()[ 0 ] == extent );
@@ -3723,6 +3725,7 @@ serial_iterator( std::string const & file )
37233725 last_iteration_index = iteration.iterationIndex ;
37243726 }
37253727 REQUIRE ( last_iteration_index == 9 );
3728+ REQUIRE ( numberOfIterations == 10 );
37263729}
37273730
37283731TEST_CASE ( " serial_iterator" , " [serial][adios2]" )
@@ -4873,11 +4876,12 @@ TEST_CASE( "deferred_parsing", "[serial]" )
48734876 }
48744877}
48754878
4876- // @todo merge this back with the chaotic_stream test of PR #949
4877- // (bug noticed while working on that branch)
4878- void no_explicit_flush ( std::string filename )
4879+ void chaotic_stream ( std::string filename, bool variableBased )
48794880{
4880- std::vector< uint64_t > sampleData{ 5 , 9 , 1 , 3 , 4 , 6 , 7 , 8 , 2 , 0 };
4881+ /*
4882+ * We will write iterations in the following order.
4883+ */
4884+ std::vector< uint64_t > iterations{ 5 , 9 , 1 , 3 , 4 , 6 , 7 , 8 , 2 , 0 };
48814885 std::string jsonConfig = R"(
48824886{
48834887 "adios2": {
@@ -4889,16 +4893,31 @@ void no_explicit_flush( std::string filename )
48894893 }
48904894})" ;
48914895
4896+ bool weirdOrderWhenReading{};
4897+
48924898 {
48934899 Series series ( filename, Access::CREATE, jsonConfig );
4894- for ( uint64_t currentIteration = 0 ; currentIteration < 10 ;
4895- ++currentIteration )
4900+ /*
4901+ * When using ADIOS2 steps, iterations are read not by logical order
4902+ * (iteration index), but by order of writing.
4903+ */
4904+ weirdOrderWhenReading = series.backend () == " ADIOS2" &&
4905+ series.iterationEncoding () != IterationEncoding::fileBased;
4906+ if ( variableBased )
4907+ {
4908+ if ( series.backend () != " ADIOS2" )
4909+ {
4910+ return ;
4911+ }
4912+ series.setIterationEncoding ( IterationEncoding::variableBased );
4913+ }
4914+ for ( auto currentIteration : iterations )
48964915 {
48974916 auto dataset =
48984917 series.writeIterations ()[ currentIteration ]
48994918 .meshes [ " iterationOrder" ][ MeshRecordComponent::SCALAR ];
49004919 dataset.resetDataset ( { determineDatatype< uint64_t >(), { 10 } } );
4901- dataset.storeChunk ( sampleData , { 0 }, { 10 } );
4920+ dataset.storeChunk ( iterations , { 0 }, { 10 } );
49024921 // series.writeIterations()[ currentIteration ].close();
49034922 }
49044923 }
@@ -4908,19 +4927,27 @@ void no_explicit_flush( std::string filename )
49084927 size_t index = 0 ;
49094928 for ( auto iteration : series.readIterations () )
49104929 {
4911- REQUIRE ( iteration.iterationIndex == index );
4930+ if ( weirdOrderWhenReading )
4931+ {
4932+ REQUIRE ( iteration.iterationIndex == iterations[ index ] );
4933+ }
4934+ else
4935+ {
4936+ REQUIRE ( iteration.iterationIndex == index );
4937+ }
49124938 ++index;
49134939 }
4914- REQUIRE ( index == 10 );
4940+ REQUIRE ( index == iterations. size () );
49154941 }
49164942}
49174943
4918- TEST_CASE ( " no_explicit_flush " , " [serial]" )
4944+ TEST_CASE ( " chaotic_stream " , " [serial]" )
49194945{
49204946 for ( auto const & t : testedFileExtensions () )
49214947 {
4922- no_explicit_flush ( " ../samples/no_explicit_flush_filebased_%T." + t );
4923- no_explicit_flush ( " ../samples/no_explicit_flush." + t );
4948+ chaotic_stream ( " ../samples/chaotic_stream_filebased_%T." + t, false );
4949+ chaotic_stream ( " ../samples/chaotic_stream." + t, false );
4950+ chaotic_stream ( " ../samples/chaotic_stream_vbased." + t, true );
49244951 }
49254952}
49264953
0 commit comments