Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,19 @@ void ADIOS2IOHandlerImpl::createFile(
VERIFY(success, "[ADIOS2] Could not create directory.");
}

// enforce opening the file
// lazy opening is deathly in parallel situations
auto &fileData =
getFileData(shared_name, IfFileNotOpen::CreateImplicitly);

// only emplace the file into our structures after it has been
// successfully opened. otherwise, errors will lead to undefined state.

associateWithFile(writable, shared_name);
this->m_dirty.emplace(shared_name);

writable->written = true;
writable->abstractFilePosition = std::make_shared<ADIOS2FilePosition>();
// enforce opening the file
// lazy opening is deathly in parallel situations
auto &fileData =
getFileData(shared_name, IfFileNotOpen::CreateImplicitly);

if (!printedWarningsAlready.noGroupBased &&
m_writeAttributesFromThisRank &&
Expand Down Expand Up @@ -1028,14 +1032,8 @@ void ADIOS2IOHandlerImpl::openFile(
}

std::string name = parameters.name + fileSuffix();

auto file = std::get<PE_InvalidatableFile>(getPossiblyExisting(name));

associateWithFile(writable, file);

writable->written = true;
writable->abstractFilePosition = std::make_shared<ADIOS2FilePosition>();

auto how_to_open = [&]() {
switch (parameters.reopen)
{
Expand All @@ -1050,8 +1048,18 @@ void ADIOS2IOHandlerImpl::openFile(
}();

// enforce opening the file
// lazy opening is deathly in parallel situations
// lazy opening is deadly in parallel situations
auto &fileData = getFileData(file, how_to_open);

// the following calls present the new file to the IO handler's data
// structures. do this only after the file has been successfully open, to
// avoid invalid state.

associateWithFile(writable, file);

writable->written = true;
writable->abstractFilePosition = std::make_shared<ADIOS2FilePosition>();

*parameters.out_parsePreference = fileData.parsePreference;
m_dirty.emplace(std::move(file));
}
Expand Down
Loading