File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -407,7 +407,7 @@ class ADIOS2File
407407
408408 size_t currentStep ();
409409 void setStepSelection (std::optional<size_t >);
410- [[nodiscard]] std::optional<size_t > stepSelection () const ;
410+ [[nodiscard]] std::optional<size_t > const & stepSelection () const ;
411411
412412 [[nodiscard]] detail::AdiosAttributes const &attributes () const
413413 {
@@ -431,13 +431,9 @@ class ADIOS2File
431431 std::optional<adios2::Engine> m_engine; // ! ADIOS engine
432432
433433 /*
434- * Not all engines support the CurrentStep() call, so we have to
435- * implement this manually.
436- * Note: We don't use a std::optional<size_t> here since the currentStep
437- * is always being counted.
434+ * Used for selecting steps in adios2::Mode::ReadRandomAccesss.
438435 */
439- size_t m_currentStep = 0 ;
440- bool useStepSelection = false ;
436+ std::optional<size_t > m_stepSelection;
441437 std::optional<size_t > m_max_steps_bp5 = std::make_optional<size_t >(100 );
442438
443439 /*
Original file line number Diff line number Diff line change @@ -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 ()
@@ -1402,7 +1386,7 @@ ADIOS2File::availableVariablesPrefixed(std::string const &prefix)
14021386ADIOS2File::AttributeMap_t const &ADIOS2File::availableVariables ()
14031387{
14041388 return m_variables.availableVariables (
1405- currentStep (), useStepSelection , m_IO);
1389+ currentStep (), stepSelection (). has_value () , m_IO);
14061390}
14071391
14081392void ADIOS2File::markActive (Writable *writable)
You can’t perform that action at this time.
0 commit comments