@@ -605,14 +605,26 @@ Engine &IO::Open(const std::string &name, const Mode mode, helper::Comm comm, co
605605 if (engineTypeLC == " filestream" )
606606 {
607607 // FileStream streams BP4/BP5 file output only (not DAOS, timeseries,
608- // etc.). A not-yet-created stream is normal, so BPVersionLocal returns
609- // '4' for a missing path and the engine waits rather than erroring.
610- char version = ' 4' ;
611- if (comm.Rank () == 0 )
608+ // etc.). The choice is mode-dependent: when writing a new file we
609+ // produce the latest streamable format (BP5) and do not query the
610+ // filesystem for a version (there is nothing to conform to). When
611+ // reading, or appending to, an existing stream we conform to the
612+ // file's version; a not-yet-created stream is normal, so
613+ // BPVersionLocal returns '4' for a missing path and the engine waits
614+ // rather than erroring.
615+ if (mode_to_use == Mode::Write)
612616 {
613- version = helper::BPVersionLocal (name);
617+ engineTypeLC = " bp5" ;
618+ }
619+ else
620+ {
621+ char version = ' 4' ;
622+ if (comm.Rank () == 0 )
623+ {
624+ version = helper::BPVersionLocal (name);
625+ }
626+ engineTypeLC = std::string (" bp" ) + comm.BroadcastValue (version);
614627 }
615- engineTypeLC = std::string (" bp" ) + comm.BroadcastValue (version);
616628 }
617629 else if (helper::EndsWith (name, " .h5" , false ))
618630 {
@@ -626,8 +638,11 @@ Engine &IO::Open(const std::string &name, const Mode mode, helper::Comm comm, co
626638 {
627639 engineTypeLC = " timeseries" ;
628640 }
629- else if ((mode_to_use == Mode::Read) || (mode_to_use == Mode::ReadRandomAccess))
641+ else if ((mode_to_use == Mode::Read) || (mode_to_use == Mode::ReadRandomAccess) ||
642+ (mode_to_use == Mode::Append))
630643 {
644+ // Read and Append both conform to the on-disk file's version; only a
645+ // fresh Write (the final else) chooses the latest format outright.
631646 auto it = m_Parameters.find (" TarInfo" );
632647 if (it != m_Parameters.end ())
633648 {
@@ -676,18 +691,30 @@ Engine &IO::Open(const std::string &name, const Mode mode, helper::Comm comm, co
676691 comm.BroadcastVector (selected);
677692 if (selected.empty ())
678693 {
679- // Built identically on every rank from 'name', so all ranks
680- // throw together without broadcasting the message.
681- std::string err = " Cannot determine the engine for reading \" " + name +
682- " \" : nothing exists at that location." ;
683- if (mode_to_use == Mode::Read)
694+ // Nothing on disk. Appending to a not-yet-created file creates
695+ // it in the latest format; reading is an error.
696+ if (mode_to_use == Mode::Append)
684697 {
685- err += " If it is a stream that has not been created yet, select "
686- " the engine explicitly with IO::SetEngine()." ;
698+ engineTypeLC = " bp5" ;
687699 }
688- helper::Throw<std::runtime_error>(" Core" , " IO" , " Open" , err);
700+ else
701+ {
702+ // Built identically on every rank from 'name', so all ranks
703+ // throw together without broadcasting the message.
704+ std::string err = " Cannot determine the engine for reading \" " + name +
705+ " \" : nothing exists at that location." ;
706+ if (mode_to_use == Mode::Read)
707+ {
708+ err += " If it is a stream that has not been created yet, select "
709+ " the engine explicitly with IO::SetEngine()." ;
710+ }
711+ helper::Throw<std::runtime_error>(" Core" , " IO" , " Open" , err);
712+ }
713+ }
714+ else
715+ {
716+ engineTypeLC.assign (selected.begin (), selected.end ());
689717 }
690- engineTypeLC.assign (selected.begin (), selected.end ());
691718 }
692719 }
693720 else
0 commit comments