Skip to content

Commit

Permalink
Add sanity check in MMPLD writer for running on little endian system
Browse files Browse the repository at this point in the history
The MMPLD file format (version 1.2) is little endian only. The MMPLD writer
uses simple byte writes without conversions so we have to make sure that
we are running on a little endian system.

Signed-off-by: Christoph Niethammer <[email protected]>
  • Loading branch information
cniethammer committed Dec 8, 2023
1 parent cab9130 commit 88516aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/io/MmpldWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <endian.h>
#endif


#include <fstream>
#include <sstream>
#include <vector>
Expand All @@ -27,8 +26,9 @@
#include "particleContainer/ParticleContainer.h"
#include "parallel/DomainDecompBase.h"
#include "Simulation.h"
#include "utils/Logger.h"
#include "utils/FileUtils.h"
#include "utils/Logger.h"
#include "utils/mardyn_assert.h"


// default version to use for mmpld format writing. possible values: 100 or 102
Expand Down Expand Up @@ -142,6 +142,11 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig)
void MmpldWriter::init(ParticleContainer *particleContainer,
DomainDecompBase *domainDecomp, Domain *domain)
{
if ( (htole32(1) != 1) || (htole64(1.0) != 1.0) ) {
Log::global_log->error() << "[MMPLD Writer] The MMPLD Writer currently only supports running on little endian systems." << std::endl;
mardyn_exit(1);
}

// only executed once
this->PrepareWriteControl();

Expand Down

0 comments on commit 88516aa

Please sign in to comment.