@@ -363,9 +363,9 @@ size_t ADIOS2File::currentStep()
363363 {
364364 return *step_selection;
365365 }
366- else if (nonpersistentEngine (m_impl-> m_engineType ) )
366+ else if (m_mode == adios2::Mode::ReadRandomAccess )
367367 {
368- return m_currentStep ;
368+ return 0 ;
369369 }
370370 else
371371 {
@@ -381,28 +381,12 @@ void ADIOS2File::setStepSelection(std::optional<size_t> step)
381381 " ADIOS2 backend: Cannot only use random-access step selections "
382382 " when reading without streaming mode." );
383383 }
384- if (!step.has_value ())
385- {
386- m_currentStep = 0 ;
387- useStepSelection = false ;
388- }
389- else
390- {
391- m_currentStep = *step;
392- useStepSelection = true ;
393- }
384+ m_stepSelection = step;
394385}
395386
396- std::optional<size_t > ADIOS2File::stepSelection () const
387+ std::optional<size_t > const & ADIOS2File::stepSelection () const
397388{
398- if (useStepSelection)
399- {
400- return {m_currentStep};
401- }
402- else
403- {
404- return std::nullopt ;
405- }
389+ return m_stepSelection;
406390}
407391
408392void ADIOS2File::configure_IO_Read ()
@@ -1172,7 +1156,6 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
11721156 }
11731157 engine.EndStep ();
11741158 engine.BeginStep ();
1175- // ++m_currentStep; // think we should keep this as the logical step
11761159 m_uniquePtrPuts.clear ();
11771160 uncommittedAttributes.clear ();
11781161 m_updateSpans.clear ();
@@ -1257,14 +1240,14 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12571240 uncommittedAttributes.clear ();
12581241 m_updateSpans.clear ();
12591242 streamStatus = StreamStatus::OutsideOfStep;
1260- ++m_currentStep;
12611243 return AdvanceStatus::OK;
12621244 }
12631245 case AdvanceMode::BEGINSTEP: {
12641246 adios2::StepStatus adiosStatus{};
1247+ auto &engine = getEngine ();
12651248
12661249 auto check_bp5 = [&]() -> bool {
1267- std::string engineType = getEngine () .Type ();
1250+ std::string engineType = engine .Type ();
12681251 std::transform (
12691252 engineType.begin (),
12701253 engineType.end (),
@@ -1273,7 +1256,7 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12731256 return engineType == " bp5writer" ;
12741257 };
12751258
1276- if (this -> m_currentStep == 0 )
1259+ if (engine. CurrentStep () == 0 )
12771260 {
12781261 int max_steps_from_env =
12791262 auxiliary::getEnvNum (" OPENPMD_BP5_GROUPENCODING_MAX_STEPS" , -1 );
@@ -1293,7 +1276,7 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12931276 if (this ->m_impl ->m_handler ->m_encoding ==
12941277 IterationEncoding::groupBased &&
12951278 this ->m_max_steps_bp5 .has_value () &&
1296- this -> m_currentStep >= *this ->m_max_steps_bp5 &&
1279+ engine. CurrentStep () >= *this ->m_max_steps_bp5 &&
12971280 (this ->m_mode == adios2::Mode::Write ||
12981281 this ->m_mode == adios2::Mode::Append) &&
12991282 check_bp5 ())
@@ -1329,7 +1312,7 @@ Be aware of the performance implications described above.)");
13291312
13301313 if (streamStatus != StreamStatus::DuringStep)
13311314 {
1332- adiosStatus = getEngine () .BeginStep ();
1315+ adiosStatus = engine .BeginStep ();
13331316 }
13341317 else
13351318 {
@@ -1403,7 +1386,7 @@ ADIOS2File::availableVariablesPrefixed(std::string const &prefix)
14031386ADIOS2File::AttributeMap_t const &ADIOS2File::availableVariables ()
14041387{
14051388 return m_variables.availableVariables (
1406- currentStep (), useStepSelection , m_IO);
1389+ currentStep (), stepSelection (). has_value () , m_IO);
14071390}
14081391
14091392void ADIOS2File::markActive (Writable *writable)
0 commit comments