File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -2538,17 +2538,42 @@ namespace detail
2538
2538
{
2539
2539
if (!m_engine)
2540
2540
{
2541
+ auto tempMode = m_mode;
2541
2542
switch (m_mode)
2542
2543
{
2543
2544
case adios2::Mode::Append:
2545
+ #ifdef _WIN32
2546
+ /*
2547
+ * On Windows, ADIOS2 Append mode only works with existing files.
2548
+ * So, we first check for file existence and switch to create mode
2549
+ * if it does not exist.
2550
+ */
2551
+ {
2552
+ try
2553
+ {
2554
+ adios2::Engine checkExists = m_IO.Open (m_file, adios2::Mode::Read);
2555
+ if (!checkExists)
2556
+ {
2557
+ tempMode = adios2::Mode::Write;
2558
+ } else
2559
+ {
2560
+ checkExists.Close ();
2561
+ }
2562
+ } catch (...)
2563
+ {
2564
+ tempMode = adios2::Mode::Write;
2565
+ }
2566
+ }
2567
+ [[fallthrough]];
2568
+ #endif
2544
2569
case adios2::Mode::Write: {
2545
2570
// usesSteps attribute only written upon ::advance()
2546
2571
// this makes sure that the attribute is only put in case
2547
2572
// the streaming API was used.
2548
2573
m_IO.DefineAttribute <ADIOS2Schema::schema_t >(
2549
2574
ADIOS2Defaults::str_adios2Schema, m_impl->m_schema );
2550
2575
m_engine = std::make_optional (
2551
- adios2::Engine (m_IO.Open (m_file, m_mode )));
2576
+ adios2::Engine (m_IO.Open (m_file, tempMode )));
2552
2577
break ;
2553
2578
}
2554
2579
case adios2::Mode::Read: {
You can’t perform that action at this time.
0 commit comments