Skip to content

Commit

Permalink
Add error handling of ASCII + write/append mode with XDMFFile. Would r…
Browse files Browse the repository at this point in the history
…esolve #3316
  • Loading branch information
jorgensd committed Sep 11, 2024
1 parent 442117b commit 253774b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cpp/dolfinx/io/XDMFFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ XDMFFile::XDMFFile(MPI_Comm comm, const std::filesystem::path& filename,
}
else if (_file_mode == "w")
{
if (_encoding == Encoding::ASCII and MPI::size(_comm.comm()) > 1)
{
throw std::runtime_error(
"ASCII encoding is not supported for writing files in parallel.");
}

_xml_doc->reset();

// Add XDMF node and version attribute
Expand All @@ -84,6 +90,12 @@ XDMFFile::XDMFFile(MPI_Comm comm, const std::filesystem::path& filename,
}
else if (_file_mode == "a")
{
if (_encoding == Encoding::ASCII and MPI::size(_comm.comm()) > 1)
{
throw std::runtime_error("ASCII encoding is not supported for appending "
"to files in parallel.");
}

if (std::filesystem::exists(_filename))
{
// Load XML doc from file
Expand Down

0 comments on commit 253774b

Please sign in to comment.