Two writers in one I/O
Created by: germasch
The last commit of PR #1312 adds the following test:
auto writer = this->m_Io.Open(filename, adios2::Mode::Write);
auto writer2 = this->m_Io.Open("multi_put2writers2.bp", adios2::Mode::Write);
auto var = this->m_Io.template DefineVariable<T>("var", this->m_Shape);
MyData<T> myData(this->m_Selections);
for (int b = 0; b < myData.NBlocks(); ++b)
{
this->PopulateBlock(myData, b);
var.SetSelection(myData.Selection(b));
writer.Put(var, &myData[b][0], TypeParam::PutMode);
writer2.Put(var, &myData[b][0], TypeParam::PutMode);
}
writer2.Close();
writer.Close();
The test is commented out in the PR because it produces invalid output.
Now, I know this use case is somewhat far-fetched. However:
- Multiple engines per I/O are supported by the API, so I suppose if you let the app use adios2 this way, it should work correctly.
- The test writes the same data into two files, which is not a realistic use case. However, in one of my apps, I calculate moments of the particle distribution. I write them into one output file as a snapshot just for the current time step, but I also calculate an average of the past n timesteps and write those smoothed moments into a separate file, so this pattern actually occurs in real life.