@@ -903,19 +903,31 @@ ADIOS2IOHandlerImpl::availableChunks(
903903 switchType ( datatype, rbi, parameters, ba.m_IO , engine, varName );
904904}
905905
906- adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode ( )
906+ adios2::Mode
907+ ADIOS2IOHandlerImpl::adios2AccessMode ( std::string const & fullPath )
907908{
908- switch ( m_handler->m_backendAccess )
909+ switch ( m_handler->m_backendAccess )
909910 {
910911 case Access::CREATE:
911912 return adios2::Mode::Write;
912913 case Access::READ_ONLY:
913914 return adios2::Mode::Read;
914915 case Access::READ_WRITE:
915- std::cerr << " ADIOS2 does currently not yet implement ReadWrite "
916- " (Append) mode. "
917- << " Replacing with Read mode." << std::endl;
918- return adios2::Mode::Read;
916+ if ( auxiliary::directory_exists ( fullPath ) ||
917+ auxiliary::file_exists ( fullPath ) )
918+ {
919+ std::cerr << " ADIOS2 does currently not yet implement ReadWrite "
920+ " (Append) mode. "
921+ << " Replacing with Read mode." << std::endl;
922+ return adios2::Mode::Read;
923+ }
924+ else
925+ {
926+ std::cerr << " ADIOS2 does currently not yet implement ReadWrite "
927+ " (Append) mode. "
928+ << " Replacing with Write mode." << std::endl;
929+ return adios2::Mode::Write;
930+ }
919931 default :
920932 return adios2::Mode::Undefined;
921933 }
@@ -2047,13 +2059,12 @@ namespace detail
20472059 }
20482060
20492061 BufferedActions::BufferedActions (
2050- ADIOS2IOHandlerImpl & impl,
2051- InvalidatableFile file )
2062+ ADIOS2IOHandlerImpl & impl, InvalidatableFile file )
20522063 : m_file( impl.fullPath( std::move( file ) ) )
20532064 , m_IOName( std::to_string( impl.nameCounter++ ) )
20542065 , m_ADIOS( impl.m_ADIOS )
20552066 , m_IO( impl.m_ADIOS.DeclareIO( m_IOName ) )
2056- , m_mode( impl.adios2AccessMode() )
2067+ , m_mode( impl.adios2AccessMode( m_file ) )
20572068 , m_writeDataset( &impl )
20582069 , m_readDataset( &impl )
20592070 , m_attributeReader()
0 commit comments