2222#include " openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
2323
2424#include " openPMD/Datatype.hpp"
25+ #include " openPMD/Error.hpp"
2526#include " openPMD/IO/ADIOS/ADIOS2FilePosition.hpp"
2627#include " openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
2728#include " openPMD/auxiliary/Environment.hpp"
@@ -292,9 +293,6 @@ void ADIOS2IOHandlerImpl::createFile(
292293 m_iterationEncoding = parameters.encoding ;
293294 associateWithFile ( writable, shared_name );
294295 this ->m_dirty .emplace ( shared_name );
295- getFileData ( shared_name, IfFileNotOpen::OpenImplicitly ).m_mode =
296- adios2::Mode::Write; // WORKAROUND
297- // ADIOS2 does not yet implement ReadWrite Mode
298296
299297 writable->written = true ;
300298 writable->abstractFilePosition =
@@ -1061,7 +1059,8 @@ void ADIOS2IOHandlerImpl::availableChunks(
10611059adios2::Mode
10621060ADIOS2IOHandlerImpl::adios2AccessMode ( std::string const & fullPath )
10631061{
1064- switch ( m_handler->m_backendAccess )
1062+ ( void )fullPath;
1063+ switch ( m_handler->m_backendAccess )
10651064 {
10661065 case Access::CREATE :
10671066 return adios2::Mode::Write;
@@ -1071,21 +1070,16 @@ ADIOS2IOHandlerImpl::adios2AccessMode( std::string const & fullPath )
10711070 if ( auxiliary::directory_exists ( fullPath ) ||
10721071 auxiliary::file_exists ( fullPath ) )
10731072 {
1074- std::cerr << " ADIOS2 does currently not yet implement ReadWrite "
1075- " (Append) mode. "
1076- << " Replacing with Read mode." << std::endl;
10771073 return adios2::Mode::Read;
10781074 }
10791075 else
10801076 {
1081- std::cerr << " ADIOS2 does currently not yet implement ReadWrite "
1082- " (Append) mode. "
1083- << " Replacing with Write mode." << std::endl;
10841077 return adios2::Mode::Write;
10851078 }
1086- default :
1087- return adios2::Mode::Undefined ;
1079+ case Access:: APPEND :
1080+ return adios2::Mode::Append ;
10881081 }
1082+ throw std::runtime_error ( " Unreachable!" );
10891083}
10901084
10911085auxiliary::TracingJSON ADIOS2IOHandlerImpl::nullvalue = nlohmann::json();
@@ -2304,6 +2298,7 @@ namespace detail
23042298 delayOpeningTheFirstStep = true ;
23052299 break ;
23062300 case adios2::Mode::Write:
2301+ case adios2::Mode::Append:
23072302 /*
23082303 * File engines, write mode:
23092304 * Default for old layout is no steps.
@@ -2463,6 +2458,7 @@ namespace detail
24632458 {
24642459 switch ( m_mode )
24652460 {
2461+ case adios2::Mode::Append:
24662462 case adios2::Mode::Write: {
24672463 // usesSteps attribute only written upon ::advance()
24682464 // this makes sure that the attribute is only put in case
@@ -2695,19 +2691,17 @@ namespace detail
26952691 []( BufferedActions & ba, adios2::Engine & eng ) {
26962692 switch ( ba.m_mode )
26972693 {
2698- case adios2::Mode::Write:
2699- eng.PerformPuts ();
2700- break ;
2701- case adios2::Mode::Read:
2702- eng.PerformGets ();
2703- break ;
2704- case adios2::Mode::Append:
2705- // TODO order?
2706- eng.PerformGets ();
2707- eng.PerformPuts ();
2708- break ;
2709- default :
2710- break ;
2694+ case adios2::Mode::Write:
2695+ case adios2::Mode::Append:
2696+ eng.PerformPuts ();
2697+ break ;
2698+ case adios2::Mode::Read:
2699+ eng.PerformGets ();
2700+ break ;
2701+ default :
2702+ throw std::runtime_error (
2703+ " [ADIOS2] Unexpected access mode." );
2704+ break ;
27112705 }
27122706 },
27132707 writeAttributes,
0 commit comments