Skip to content

Commit

Permalink
Windows Workaround: Fallback to Create mode
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel authored and Pöschel committed Jul 20, 2022
1 parent f5e511f commit 1b5b053
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2538,17 +2538,42 @@ namespace detail
{
if (!m_engine)
{
auto tempMode = m_mode;
switch (m_mode)
{
case adios2::Mode::Append:
#ifdef _WIN32
/*
* On Windows, ADIOS2 Append mode only works with existing files.
* So, we first check for file existence and switch to create mode
* if it does not exist.
*/
{
try
{
adios2::Engine checkExists = m_IO.Open(m_file, adios2::Mode::Read);
if(!checkExists)
{
tempMode = adios2::Mode::Write;
} else
{
checkExists.Close();
}
} catch(...)
{
tempMode = adios2::Mode::Write;
}
}
[[fallthrough]];
#endif
case adios2::Mode::Write: {
// usesSteps attribute only written upon ::advance()
// this makes sure that the attribute is only put in case
// the streaming API was used.
m_IO.DefineAttribute<ADIOS2Schema::schema_t>(
ADIOS2Defaults::str_adios2Schema, m_impl->m_schema);
m_engine = std::make_optional(
adios2::Engine(m_IO.Open(m_file, m_mode)));
adios2::Engine(m_IO.Open(m_file, tempMode)));
break;
}
case adios2::Mode::Read: {
Expand Down

0 comments on commit 1b5b053

Please sign in to comment.