From 7c53add783aabfe04bd5fdf21dc39dd918cb78c5 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Wed, 31 Jul 2024 16:06:11 +0200 Subject: [PATCH 01/28] Replace raw with smart pointers --- src/bhfmm/HaloBufferOverlap.h | 9 ++++----- src/ensemble/ChemicalPotential.h | 7 ++++--- src/io/ReplicaGenerator.cpp | 7 ++++--- src/io/ReplicaGenerator.h | 3 ++- src/utils/Logger.cpp | 21 +++++++++++++++------ src/utils/Logger.h | 11 ++++++----- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/bhfmm/HaloBufferOverlap.h b/src/bhfmm/HaloBufferOverlap.h index 71f21d0ca8..cde74f0de1 100644 --- a/src/bhfmm/HaloBufferOverlap.h +++ b/src/bhfmm/HaloBufferOverlap.h @@ -10,6 +10,7 @@ #include "bhfmm/utils/Vector3.h" #include #include +#include #ifdef ENABLE_MPI #include "mpi.h" @@ -92,15 +93,13 @@ _areaBuffers(areaNumber), _edgeBuffers(edgeNumber), _cornerBuffers(cornerNumber) } if(areaNumber != 0){ - - _areaRequests = new MPI_Request[_areaBuffers.size()]; -// std::cout << "areaBufferSize: "<<_areaBuffers.size() << "\n"; + std::vector _areaRequests(_areaBuffers.size()); } if(edgeNumber != 0){ - _edgeRequests = new MPI_Request[_edgeBuffers.size()]; + std::vector _edgeRequests(_edgeBuffers.size()); } if(cornerNumber != 0){ - _cornerRequests = new MPI_Request[_cornerBuffers.size()]; + std::vector _cornerRequests(_cornerBuffers.size()); } fillArraySizes(areaHaloSize,edgeHaloSize); diff --git a/src/ensemble/ChemicalPotential.h b/src/ensemble/ChemicalPotential.h index f24aaa8f16..3246226e9c 100644 --- a/src/ensemble/ChemicalPotential.h +++ b/src/ensemble/ChemicalPotential.h @@ -2,6 +2,7 @@ #pragma once #include +#include #include "utils/Random.h" #include "molecules/Molecule.h" @@ -43,9 +44,9 @@ class ChemicalPotential { #ifndef NDEBUG old.check(old.getID()); #endif - _reservoir = new Molecule(old); + _reservoir = std::make_unique(old); } - bool hasSample() { return _reservoir != NULL; } + bool hasSample() { return _reservoir != nullptr; } void setPlanckConstant(double h_in) { _h = h_in; } void submitTemperature(double T_in); @@ -128,7 +129,7 @@ class ChemicalPotential { // Using the widom method is just a way to determine the potential. This has nothing to do with actual insertions or // deletions! - Molecule* _reservoir; + std::unique_ptr _reservoir; /* Moved from LinkedCells! */ int _localInsertionsMinusDeletions; //!< balance of the grand canonical ensemble diff --git a/src/io/ReplicaGenerator.cpp b/src/io/ReplicaGenerator.cpp index 41e7737f3e..c9296390d1 100755 --- a/src/io/ReplicaGenerator.cpp +++ b/src/io/ReplicaGenerator.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Domain.h" #include "Simulation.h" @@ -117,13 +118,13 @@ void ReplicaGenerator::readReplicaPhaseSpaceData(SubDomain& subDomain, DomainDec // Select appropriate reader switch (_nMoleculeFormat) { case ICRVQD: - _moleculeDataReader = new MoleculeDataReaderICRVQD(); + _moleculeDataReader = std::make_unique(); break; case ICRV: - _moleculeDataReader = new MoleculeDataReaderICRV(); + _moleculeDataReader = std::make_unique(); break; case IRV: - _moleculeDataReader = new MoleculeDataReaderIRV(); + _moleculeDataReader = std::make_unique(); break; } diff --git a/src/io/ReplicaGenerator.h b/src/io/ReplicaGenerator.h index c1994f7a78..a849173166 100755 --- a/src/io/ReplicaGenerator.h +++ b/src/io/ReplicaGenerator.h @@ -9,6 +9,7 @@ #include #include #include +#include enum SystemTypes : uint8_t { @@ -72,7 +73,7 @@ class ReplicaGenerator : public InputBase { uint32_t _nIndexLiqBeginY; uint32_t _nIndexLiqEndY; uint32_t _nMoleculeFormat; - MoleculeDataReader* _moleculeDataReader; + std::unique_ptr _moleculeDataReader; double _dMoleculeDiameter; double _fspY[6]; // free space positions uint8_t _nSystemType; diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index fe44547c1c..7cf5b03806 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -2,13 +2,16 @@ #include "Logger.h" +#include + namespace Log { Logger *global_log; +// Write to stream Logger::Logger(logLevel level, std::ostream *os) : _log_level(level), _msg_log_level(Log::Error), - _do_output(true), _filename(""),_log_stream(os), + _do_output(true), _filename(""), _log_stream(os), logLevelNames(), _starttime(), _rank(0) { init_starting_time(); @@ -19,10 +22,10 @@ Logger::Logger(logLevel level, std::ostream *os) : *_log_stream << std::boolalpha; // Print boolean as true/false } - +// Write to file Logger::Logger(logLevel level, std::string prefix) : _log_level(level), _msg_log_level(Log::Error), - _do_output(true), _filename(""), _log_stream(0), + _do_output(true), _filename(""), _log_stream(nullptr), logLevelNames(), _starttime(), _rank(0) { init_starting_time(); @@ -35,14 +38,20 @@ Logger::Logger(logLevel level, std::string prefix) : #endif filenamestream << ".log"; _filename = filenamestream.str(); - _log_stream = new std::ofstream(_filename.c_str()); + + _log_stream = std::make_unique(_filename.c_str()); *_log_stream << std::boolalpha; // Print boolean as true/false } Logger::~Logger() { *_log_stream << std::flush; - if (_filename != "") - (static_cast (_log_stream))->close(); + if (_filename != "") { + // Convert from ostream to ofstream for closing if _log_stream is file + std::ofstream* file = dynamic_cast(_log_stream.get()); + if (file && file->is_open()) { + file->close(); + } + } } diff --git a/src/utils/Logger.h b/src/utils/Logger.h index 5cabb95f15..b4f07add04 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef USE_GETTIMEOFDAY #include @@ -92,7 +93,7 @@ class Logger { logLevel _msg_log_level; bool _do_output; std::string _filename; - std::ostream *_log_stream; + std::unique_ptr _log_stream; std::map logLevelNames; #ifdef USE_GETTIMEOFDAY timeval _starttime; @@ -115,7 +116,7 @@ class Logger { // don't allow copy-construction Logger(const Logger&) : _log_level(Log::Error), _msg_log_level(Log::Error), _do_output(true), - _filename(""), _log_stream(0), logLevelNames(), _starttime(), _rank(0) + _filename(""), _log_stream(nullptr), logLevelNames(), _starttime(), _rank(0) { } // don't allow assignment @@ -124,11 +125,11 @@ class Logger { public: /** Initializes the log level, log stream and the list of log level names. * If ENABLE_MPI is enabled by default all process perform logging output. */ - Logger(logLevel level = Log::Error, std::ostream *os = &(std::cout)); + Logger(logLevel level = Log::Error, std::ostream *os = &(std::cout)); // Write to stream - Logger(logLevel level, std::string prefix); + Logger(logLevel level, std::string prefix); // Write to file - /// Destructor flushes stream + /// Destructor flushes stream and/or closes file ~Logger(); /// General output template for variables, strings, etc. From 0808152dbd0dd57451c03aa6f3458a41ad8961d6 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Wed, 31 Jul 2024 19:25:12 +0200 Subject: [PATCH 02/28] Fixes regarding Log smart pointer --- src/MarDyn.cpp | 12 ++++------ src/utils/Logger.cpp | 15 ++---------- src/utils/Logger.h | 9 ++++---- src/utils/Testing.cpp | 7 ++++-- src/utils/Testing.h | 2 +- tools/gui/generators/MDGenerator.cpp | 23 ++++++------------- tools/gui/generators/MDGenerator.h | 8 +++---- .../generators/common/DropletPlacement.cpp | 6 ++++- .../gui/generators/common/DropletPlacement.h | 5 ++-- 9 files changed, 36 insertions(+), 51 deletions(-) diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index 9a4cf21924..d394fb31ff 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "WrapOpenMP.h" @@ -58,7 +59,7 @@ void initOptions(optparse::OptionParser *op) { /** * @brief Helper function outputting program build information to given logger */ -void program_build_info(Log::Logger *log) { +void program_build_info(std::shared_ptr log) { log->info() << "Compilation info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; @@ -81,7 +82,7 @@ void program_build_info(Log::Logger *log) { /** * @brief Helper function outputting program invocation information to given logger */ -void program_execution_info(int argc, char **argv, Log::Logger *log) { +void program_execution_info(int argc, char **argv, std::shared_ptr log) { log->info() << "Execution info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; @@ -136,7 +137,7 @@ int main(int argc, char** argv) { #endif /* Initialize the global log file */ - Log::global_log = new Log::Logger(Log::Info); + Log::global_log = std::make_shared(Log::Info); #ifdef ENABLE_MPI Log::global_log->set_mpi_output_root(0); //global_log->set_mpi_output_all(); @@ -160,8 +161,7 @@ int main(int argc, char** argv) { if( options.is_set_by_user("logfile") ) { std::string logfileNamePrefix(options.get("logfile")); Log::global_log->info() << "Using logfile with prefix " << logfileNamePrefix << std::endl; - delete Log::global_log; - Log::global_log = new Log::Logger(Log::Info, logfileNamePrefix); + Log::global_log = std::make_shared(Log::Info, logfileNamePrefix); } if( options.is_set_by_user("verbose") ) { Log::global_log->info() << "Enabling verbose log output." << std::endl; @@ -281,8 +281,6 @@ int main(int argc, char** argv) { simulation.finalize(); - delete Log::global_log; - #ifdef ENABLE_MPI MPI_Finalize(); #endif diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index 7cf5b03806..a07ae5867c 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -6,7 +6,7 @@ namespace Log { -Logger *global_log; +std::shared_ptr global_log; // Write to stream Logger::Logger(logLevel level, std::ostream *os) : @@ -39,21 +39,10 @@ Logger::Logger(logLevel level, std::string prefix) : filenamestream << ".log"; _filename = filenamestream.str(); - _log_stream = std::make_unique(_filename.c_str()); + _log_stream = std::make_shared(_filename.c_str()); *_log_stream << std::boolalpha; // Print boolean as true/false } -Logger::~Logger() { - *_log_stream << std::flush; - if (_filename != "") { - // Convert from ostream to ofstream for closing if _log_stream is file - std::ofstream* file = dynamic_cast(_log_stream.get()); - if (file && file->is_open()) { - file->close(); - } - } -} - /// allow logging only for a single process void Logger::set_mpi_output_root(int root) { diff --git a/src/utils/Logger.h b/src/utils/Logger.h index b4f07add04..2c6507fe12 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -48,11 +48,11 @@ class Logger; /** * Gobal logger variable for use in the entire program. - * Must be initialized with constructor e.g. new Log::Logger(). + * Must be initialized with constructor * Namespace visibility: * */ #ifndef LOGGER_SRC -extern Log::Logger *global_log; +extern std::shared_ptr global_log; #endif /** @@ -93,7 +93,7 @@ class Logger { logLevel _msg_log_level; bool _do_output; std::string _filename; - std::unique_ptr _log_stream; + std::shared_ptr _log_stream; std::map logLevelNames; #ifdef USE_GETTIMEOFDAY timeval _starttime; @@ -129,8 +129,7 @@ class Logger { Logger(logLevel level, std::string prefix); // Write to file - /// Destructor flushes stream and/or closes file - ~Logger(); + ~Logger() = default; /// General output template for variables, strings, etc. template diff --git a/src/utils/Testing.cpp b/src/utils/Testing.cpp index 3899af516d..9745c0178a 100644 --- a/src/utils/Testing.cpp +++ b/src/utils/Testing.cpp @@ -6,11 +6,14 @@ */ #include "utils/Testing.h" + +#include + #include "utils/Logger.h" #include "utils/FileUtils.h" #include "utils/mardyn_assert.h" -Log::Logger* test_log; +std::shared_ptr test_log; #ifdef UNIT_TESTS #ifdef USE_CPPUNIT @@ -30,7 +33,7 @@ Log::Logger* test_log; int runTests(Log::logLevel testLogLevel, std::string& testDataDirectory, const std::string& testcases) { Log::logLevel globalLogLevel = Log::global_log->get_log_level(); - test_log = new Log::Logger(testLogLevel); + test_log = std::make_shared(testLogLevel); test_log->set_do_output(Log::global_log->get_do_output()); if (testLogLevel > Log::Info) { Log::global_log->set_log_level(Log::Debug); diff --git a/src/utils/Testing.h b/src/utils/Testing.h index 1243c03528..5e02feff8d 100644 --- a/src/utils/Testing.h +++ b/src/utils/Testing.h @@ -36,7 +36,7 @@ void setTestDataDirectory(std::string& testDataDirectory); * Gobal logger variable for use in the test cases. * Is initialized in runTests(). */ -extern Log::Logger* test_log; +extern std::shared_ptr test_log; #ifdef UNIT_TESTS diff --git a/tools/gui/generators/MDGenerator.cpp b/tools/gui/generators/MDGenerator.cpp index 0e871f345a..cd6ad19a86 100644 --- a/tools/gui/generators/MDGenerator.cpp +++ b/tools/gui/generators/MDGenerator.cpp @@ -7,6 +7,8 @@ #include "MDGenerator.h" +#include + #include "parallel/DomainDecompBase.h" #include "io/CheckpointWriter.h" #include "particleContainer/LinkedCells.h" @@ -42,30 +44,19 @@ const double MDGenerator::abogadro_constant = 6.02214078e23; const double MDGenerator::boltzmann_constant_kB = 1.38065e-23; MDGenerator::MDGenerator(std::string name) : -Generator(name), _deleteLogger(true) { +Generator(name) { // initialize monolithic Mardyn's global_log and silence it... #ifndef MARDYN // if mardyn is not the main program, silence it's logger; - Log::global_log = new Log::Logger(Log::Warning, &(std::cout)); - _logger = new Log::Logger(Log::Debug, &ScenarioGeneratorApplication::getInstance()->getTextMessageStream()); + Log::global_log = std::make_shared(Log::Warning, &(std::cout)); + _logger = std::make_shared(Log::Debug, &ScenarioGeneratorApplication::getInstance()->getTextMessageStream()); #else - _logger = new Log::Logger(Log::Debug, &(std::cout)); + _logger = std::make_shared(Log::Debug, &(std::cout)); #endif } -MDGenerator::~MDGenerator() { - if (_deleteLogger) { - delete _logger; - } -} - -void MDGenerator::setLogger(Log::Logger* logger) { - if (_logger != NULL && _deleteLogger) { - delete _logger; - } - +void MDGenerator::setLogger(std::shared_ptr logger) { _logger = logger; - _deleteLogger = false; } void MDGenerator::createSampleObject() const { diff --git a/tools/gui/generators/MDGenerator.h b/tools/gui/generators/MDGenerator.h index 76a3e9f98d..ac5c0edf4f 100644 --- a/tools/gui/generators/MDGenerator.h +++ b/tools/gui/generators/MDGenerator.h @@ -18,6 +18,7 @@ #include #include #include +#include class Domain; class DomainDecompBase; @@ -72,12 +73,11 @@ class MDGenerator: public Generator, public InputBase { static const double kelvin_2_mardyn; protected: - Log::Logger* _logger; - bool _deleteLogger; + std::shared_ptr _logger; MDGenerator(std::string name); - virtual ~MDGenerator(); + virtual ~MDGenerator() {}; /** * determine the velocity according to the temperature. @@ -91,7 +91,7 @@ class MDGenerator: public Generator, public InputBase { public: - virtual void setLogger(Log::Logger* logger); + virtual void setLogger(std::shared_ptr logger); //! NOP void setPhaseSpaceFile(std::string /*filename*/) {} diff --git a/tools/gui/generators/common/DropletPlacement.cpp b/tools/gui/generators/common/DropletPlacement.cpp index fe55fb123e..ca1b7c1893 100644 --- a/tools/gui/generators/common/DropletPlacement.cpp +++ b/tools/gui/generators/common/DropletPlacement.cpp @@ -7,10 +7,14 @@ #include "DropletPlacement.h" #include +#include + +#include "utils/Logger.h" + #define SIZE 100 -DropletPlacement::DropletPlacement(double fluidVolume, double maxSphereVolume, int numSphereSizes, Log::Logger* logger) +DropletPlacement::DropletPlacement(double fluidVolume, double maxSphereVolume, int numSphereSizes, std::shared_ptr logger) : _fluidVolume(fluidVolume / 100.), _maxSphereRadius(pow((3.0*maxSphereVolume / 100.)/(4.0 * M_PI), 1.0/3.0)), _numSphereSizes(numSphereSizes), _numOccupied(0), _logger(logger) { diff --git a/tools/gui/generators/common/DropletPlacement.h b/tools/gui/generators/common/DropletPlacement.h index c65ffbd739..1caba0d6dc 100644 --- a/tools/gui/generators/common/DropletPlacement.h +++ b/tools/gui/generators/common/DropletPlacement.h @@ -10,6 +10,7 @@ #include "utils/Logger.h" #include +#include /** * Places drops of different sizes in the domain, so that a given percentage @@ -41,7 +42,7 @@ class DropletPlacement { * - each class covering the same volume in total * - the size of a sphere is determined by pow(0.9, i) * maxSphereRadius; i in [1,maxSphereSize] */ - DropletPlacement(double fluidVolume, double maxSphereVolume, int numSphereSizes, Log::Logger* logger); + DropletPlacement(double fluidVolume, double maxSphereVolume, int numSphereSizes, std::shared_ptr logger); /** * Generates droplets with sizes as specified by numSphereSizes, fluidVolume @@ -59,7 +60,7 @@ class DropletPlacement { int _numOccupied; std::vector > > _occupiedFields; - Log::Logger* _logger; + std::shared_ptr _logger; /** * Initialize vector _occupiedFields From 5c5c4ff27420146bbd6ba3fcb805418445f13df1 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:14:22 +0200 Subject: [PATCH 03/28] Revert usage of smart pointer for _log_stream --- src/utils/Logger.cpp | 7 ++++++- src/utils/Logger.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index a07ae5867c..e0e67f37ef 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -39,10 +39,15 @@ Logger::Logger(logLevel level, std::string prefix) : filenamestream << ".log"; _filename = filenamestream.str(); - _log_stream = std::make_shared(_filename.c_str()); + _log_stream = new std::ofstream(_filename.c_str()); *_log_stream << std::boolalpha; // Print boolean as true/false } +Logger::~Logger() { + *_log_stream << std::flush; + if (_filename != "") + (static_cast (_log_stream))->close(); +} /// allow logging only for a single process void Logger::set_mpi_output_root(int root) { diff --git a/src/utils/Logger.h b/src/utils/Logger.h index 2c6507fe12..b8d51ab8e3 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -93,7 +93,7 @@ class Logger { logLevel _msg_log_level; bool _do_output; std::string _filename; - std::shared_ptr _log_stream; + std::ostream *_log_stream; std::map logLevelNames; #ifdef USE_GETTIMEOFDAY timeval _starttime; @@ -129,7 +129,7 @@ class Logger { Logger(logLevel level, std::string prefix); // Write to file - ~Logger() = default; + ~Logger(); /// General output template for variables, strings, etc. template From 66688a5da3551033707147e01d7ff96762d6cc82 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Wed, 11 Sep 2024 10:41:29 +0200 Subject: [PATCH 04/28] Use custom deleter to make smart pointer for _log_stream work --- src/MarDyn.cpp | 40 ++++++++++++++++++++++------------------ src/utils/Logger.cpp | 8 +++++--- src/utils/Logger.h | 4 ++-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index d394fb31ff..15f7bdaa11 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -59,42 +59,42 @@ void initOptions(optparse::OptionParser *op) { /** * @brief Helper function outputting program build information to given logger */ -void program_build_info(std::shared_ptr log) { - log->info() << "Compilation info:" << std::endl; +void program_build_info() { + Log::global_log->info() << "Compilation info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; get_compiler_info(info_str); - log->info() << " Compiler: " << info_str << std::endl; + Log::global_log->info() << " Compiler: " << info_str << std::endl; get_compile_time(info_str); - log->info() << " Compiled on: " << info_str << std::endl; + Log::global_log->info() << " Compiled on: " << info_str << std::endl; get_precision_info(info_str); - log->info() << " Precision: " << info_str << std::endl; + Log::global_log->info() << " Precision: " << info_str << std::endl; get_intrinsics_info(info_str); - log->info() << " Intrinsics: " << info_str << std::endl; + Log::global_log->info() << " Intrinsics: " << info_str << std::endl; get_rmm_normal_info(info_str); - log->info() << " RMM/normal: " << info_str << std::endl; + Log::global_log->info() << " RMM/normal: " << info_str << std::endl; get_openmp_info(info_str); - log->info() << " OpenMP: " << info_str << std::endl; + Log::global_log->info() << " OpenMP: " << info_str << std::endl; get_mpi_info(info_str); - log->info() << " MPI: " << info_str << std::endl; + Log::global_log->info() << " MPI: " << info_str << std::endl; } /** * @brief Helper function outputting program invocation information to given logger */ -void program_execution_info(int argc, char **argv, std::shared_ptr log) { - log->info() << "Execution info:" << std::endl; +void program_execution_info(int argc, char **argv) { + Log::global_log->info() << "Execution info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; get_timestamp(info_str); - log->info() << " Started: " << info_str << std::endl; + Log::global_log->info() << " Started: " << info_str << std::endl; get_host(info_str); - log->info() << " Execution host: " << info_str << std::endl; + Log::global_log->info() << " Execution host: " << info_str << std::endl; std::stringstream arguments; for (int i = 0; i < argc; i++) { arguments << " " << argv[i]; } - log->info() << " Started with arguments: " << arguments.str() << std::endl; + Log::global_log->info() << " Started with arguments: " << arguments.str() << std::endl; #if defined(_OPENMP) int num_threads = mardyn_get_max_threads(); @@ -137,7 +137,7 @@ int main(int argc, char** argv) { #endif /* Initialize the global log file */ - Log::global_log = std::make_shared(Log::Info); + Log::global_log = std::make_unique(Log::Info); #ifdef ENABLE_MPI Log::global_log->set_mpi_output_root(0); //global_log->set_mpi_output_all(); @@ -161,7 +161,8 @@ int main(int argc, char** argv) { if( options.is_set_by_user("logfile") ) { std::string logfileNamePrefix(options.get("logfile")); Log::global_log->info() << "Using logfile with prefix " << logfileNamePrefix << std::endl; - Log::global_log = std::make_shared(Log::Info, logfileNamePrefix); + Log::global_log.reset(); + Log::global_log = std::make_unique(Log::Info, logfileNamePrefix); } if( options.is_set_by_user("verbose") ) { Log::global_log->info() << "Enabling verbose log output." << std::endl; @@ -173,8 +174,8 @@ int main(int argc, char** argv) { registerSigsegvHandler(); // from SigsegvHandler.h } #endif - program_build_info(Log::global_log); - program_execution_info(argc, argv, Log::global_log); + program_build_info(); + program_execution_info(argc, argv); /* Run built in tests and exit */ @@ -284,4 +285,7 @@ int main(int argc, char** argv) { #ifdef ENABLE_MPI MPI_Finalize(); #endif + std::cout << "testend" << std::endl; + Log::global_log.reset(); + std::cout << "testend2" << std::endl; } diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index a07ae5867c..64a1db96d0 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -6,12 +6,15 @@ namespace Log { -std::shared_ptr global_log; +std::unique_ptr global_log; // Write to stream Logger::Logger(logLevel level, std::ostream *os) : _log_level(level), _msg_log_level(Log::Error), - _do_output(true), _filename(""), _log_stream(os), + _do_output(true), _filename(""), + // std::cout is managed globally, + // so do nothing when _log_stream goes out of scope + _log_stream(os, [](std::ostream*){/* no-op deleter */}), logLevelNames(), _starttime(), _rank(0) { init_starting_time(); @@ -43,7 +46,6 @@ Logger::Logger(logLevel level, std::string prefix) : *_log_stream << std::boolalpha; // Print boolean as true/false } - /// allow logging only for a single process void Logger::set_mpi_output_root(int root) { if (_rank != root) diff --git a/src/utils/Logger.h b/src/utils/Logger.h index 2c6507fe12..aea078c90c 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -47,12 +47,12 @@ namespace Log { class Logger; /** - * Gobal logger variable for use in the entire program. + * Global logger variable for use in the entire program. * Must be initialized with constructor * Namespace visibility: * */ #ifndef LOGGER_SRC -extern std::shared_ptr global_log; +extern std::unique_ptr global_log; #endif /** From 2058a6ae03bbe2b8de71d3570a6fbf260d7cc961 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 12 Sep 2024 16:56:37 +0200 Subject: [PATCH 05/28] Apply suggestions from review --- src/MarDyn.cpp | 36 ++++++++++++++++-------------- src/utils/Logger.cpp | 2 ++ src/utils/Logger.h | 32 +++++++++++++++++++------- tools/gui/generators/MDGenerator.h | 2 +- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index 0706ad9a8d..368a343080 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -59,7 +59,7 @@ void initOptions(optparse::OptionParser *op) { /** * @brief Helper function outputting program build information to given logger */ -void program_build_info() { +void log_program_build_info() { Log::global_log->info() << "Compilation info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; @@ -82,7 +82,7 @@ void program_build_info() { /** * @brief Helper function outputting program invocation information to given logger */ -void program_execution_info(int argc, char **argv) { +void log_program_execution_info(int argc, char **argv) { Log::global_log->info() << "Execution info:" << std::endl; char info_str[MAX_INFO_STRING_LENGTH]; @@ -136,18 +136,27 @@ int main(int argc, char** argv) { MPI_Init(&argc, &argv); #endif + optparse::OptionParser op; + initOptions(&op); + optparse::Values options = op.parse_args(argc, argv); + std::vector args = op.args(); + /* Initialize the global log file */ - Log::global_log = std::make_unique(Log::Info); + if( options.is_set_by_user("logfile") ) { + // Print to file + std::string logfileNamePrefix(options.get("logfile")); + std::cout << "Using logfile with prefix " << logfileNamePrefix << std::endl; + Log::global_log = std::make_unique(Log::Info, logfileNamePrefix); + } else { + // Print to stream (default: std::cout) + Log::global_log = std::make_unique(Log::Info); + } + #ifdef ENABLE_MPI Log::global_log->set_mpi_output_root(0); //global_log->set_mpi_output_all(); #endif - optparse::OptionParser op; - initOptions(&op); - optparse::Values options = op.parse_args(argc, argv); - std::vector args = op.args(); - Log::global_log->info() << "Running ls1-MarDyn version " << MARDYN_VERSION << std::endl; #ifdef MARDYN_AUTOPAS @@ -158,12 +167,6 @@ int main(int argc, char** argv) { Log::global_log->warning() << "This ls1-MarDyn binary is a DEBUG build!" << std::endl; #endif - if( options.is_set_by_user("logfile") ) { - std::string logfileNamePrefix(options.get("logfile")); - Log::global_log->info() << "Using logfile with prefix " << logfileNamePrefix << std::endl; - Log::global_log.reset(); - Log::global_log = std::make_unique(Log::Info, logfileNamePrefix); - } if( options.is_set_by_user("verbose") ) { Log::global_log->info() << "Enabling verbose log output." << std::endl; Log::global_log->set_log_level(Log::All); @@ -174,8 +177,8 @@ int main(int argc, char** argv) { registerSigsegvHandler(); // from SigsegvHandler.h } #endif - program_build_info(); - program_execution_info(argc, argv); + log_program_build_info(); + log_program_execution_info(argc, argv); /* Run built in tests and exit */ @@ -285,5 +288,4 @@ int main(int argc, char** argv) { #ifdef ENABLE_MPI MPI_Finalize(); #endif - } diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index 64a1db96d0..6a694fd3df 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -14,6 +14,8 @@ Logger::Logger(logLevel level, std::ostream *os) : _do_output(true), _filename(""), // std::cout is managed globally, // so do nothing when _log_stream goes out of scope + // --> any passed ostream other than std::cout needs to be + // deleted manually! _log_stream(os, [](std::ostream*){/* no-op deleter */}), logLevelNames(), _starttime(), _rank(0) { diff --git a/src/utils/Logger.h b/src/utils/Logger.h index aea078c90c..5afa8b0b98 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -50,7 +50,7 @@ class Logger; * Global logger variable for use in the entire program. * Must be initialized with constructor * Namespace visibility: - * */ + */ #ifndef LOGGER_SRC extern std::unique_ptr global_log; #endif @@ -73,8 +73,12 @@ typedef enum { * * Provides easy interface to handle log messages. Initialize either with * output level and stream or output level and filename or use default constructor - * values (Error, &(std::cout)). With a given file basename and MPI Support each rank will - * create and write to his own file. + * values (Error, &(std::cout)). + * Note: Due to the default argument (std::cout), the passed ostream pointer + * will not be deleted automatically! Any passed ostream pointer other than + * std::cout must be deleted manually! + * With a given file basename and MPI Support each rank will create + * and write to its own file. * For writing log messages use fatal(), error(), warning(), info() or debug() as * with normal streams, e.g. * > log.error() << "Wrong parameter." << std::endl; @@ -123,11 +127,23 @@ class Logger { Logger& operator=(const Logger&) { return *this; } public: - /** Initializes the log level, log stream and the list of log level names. - * If ENABLE_MPI is enabled by default all process perform logging output. */ - Logger(logLevel level = Log::Error, std::ostream *os = &(std::cout)); // Write to stream - - Logger(logLevel level, std::string prefix); // Write to file + /** + * Constructor for a logger to a stream. + * + * Initializes the log level, log stream and the list of log level names. + * If ENABLE_MPI is enabled by default, all process perform logging output. + * Note: Due to the default argument (std::cout), the passed ostream pointer + * will not be deleted automatically! Any passed ostream pointer other than + * std::cout must be deleted manually! + */ + Logger(logLevel level = Log::Error, std::ostream *os = &(std::cout)); + /** + * Constructor for a logger to a file. + * + * Initializes the log level, log stream and the list of log level names. + * If ENABLE_MPI is enabled by default, all process perform logging output. + */ + Logger(logLevel level, std::string prefix); ~Logger() = default; diff --git a/tools/gui/generators/MDGenerator.h b/tools/gui/generators/MDGenerator.h index ac5c0edf4f..221a534ce6 100644 --- a/tools/gui/generators/MDGenerator.h +++ b/tools/gui/generators/MDGenerator.h @@ -77,7 +77,7 @@ class MDGenerator: public Generator, public InputBase { MDGenerator(std::string name); - virtual ~MDGenerator() {}; + virtual ~MDGenerator() = default; /** * determine the velocity according to the temperature. From 27625f5d120326447ede42fe322dcda93f1dbc39 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 12 Sep 2024 17:30:27 +0200 Subject: [PATCH 06/28] Fix to replace raw with smart pointers as suggested in review --- src/bhfmm/HaloBufferOverlap.h | 51 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/bhfmm/HaloBufferOverlap.h b/src/bhfmm/HaloBufferOverlap.h index cde74f0de1..7e300191bd 100644 --- a/src/bhfmm/HaloBufferOverlap.h +++ b/src/bhfmm/HaloBufferOverlap.h @@ -55,7 +55,9 @@ class HaloBufferOverlap { //these arrays save for every halo element the specific size -> if neighbour rank order is changed these arrays have to be changed too but nothing else std::vector _areaHaloSizes, _edgeHaloSizes; //corner Arrays are always of the same size! std::vector _areaNeighbours, _edgeNeighbours,_cornerNeighbours; - MPI_Request * _areaRequests, *_edgeRequests, *_cornerRequests; + std::vector _areaRequests; + std::vector _edgeRequests; + std::vector _cornerRequests; MPI_Comm _comm; bool _isSend; bool _doNT; @@ -75,7 +77,8 @@ class HaloBufferOverlap { template HaloBufferOverlap::HaloBufferOverlap(Vector3 areaHaloSize, Vector3 edgeHaloSize, int cornerHaloSize, MPI_Comm comm, std::vector& areaNeighbours,std::vector& edgeNeighbours,std::vector& cornerNeighbours, bool isSend, bool doNT, int areaNumber, int edgeNumber, int cornerNumber, std::vector>> allRanks, Vector3 numCellsOnGlobalLevel, bool fuseGlobalCommunication): -_areaBuffers(areaNumber), _edgeBuffers(edgeNumber), _cornerBuffers(cornerNumber), _areaHaloSize(areaHaloSize), _edgeHaloSize(edgeHaloSize), _areaNeighbours(areaNeighbours), _edgeNeighbours(edgeNeighbours), _cornerNeighbours(cornerNeighbours), _doNT(doNT), _allRanks(allRanks), _numCellsOnGlobalLevel(numCellsOnGlobalLevel), _fuseGlobalCommunication(fuseGlobalCommunication) { +_areaBuffers(areaNumber), _edgeBuffers(edgeNumber), _cornerBuffers(cornerNumber), _areaHaloSize(areaHaloSize), _edgeHaloSize(edgeHaloSize), _areaNeighbours(areaNeighbours), _edgeNeighbours(edgeNeighbours), _cornerNeighbours(cornerNeighbours), _doNT(doNT), _allRanks(allRanks), _numCellsOnGlobalLevel(numCellsOnGlobalLevel), _fuseGlobalCommunication(fuseGlobalCommunication), +_areaRequests(areaNumber), _edgeRequests(edgeNumber), _cornerRequests(cornerNumber) { _cornerHaloSize = cornerHaloSize; if(edgeNumber == 0){ @@ -92,16 +95,6 @@ _areaBuffers(areaNumber), _edgeBuffers(edgeNumber), _cornerBuffers(cornerNumber) _isGlobal = false; } - if(areaNumber != 0){ - std::vector _areaRequests(_areaBuffers.size()); - } - if(edgeNumber != 0){ - std::vector _edgeRequests(_edgeBuffers.size()); - } - if(cornerNumber != 0){ - std::vector _cornerRequests(_cornerBuffers.size()); - } - fillArraySizes(areaHaloSize,edgeHaloSize); // _cornerHaloSizes = new int[_cornerBuffers.size()]; @@ -527,13 +520,13 @@ template void HaloBufferOverlap::startCommunication(){ //outdated!!! if(not(_doNT)){ - MPI_Startall(_areaBuffers.size(), _areaRequests); - MPI_Startall(_edgeBuffers.size(), _edgeRequests); - MPI_Startall(_cornerBuffers.size(), _cornerRequests); + MPI_Startall(_areaBuffers.size(), _areaRequests.data()); + MPI_Startall(_edgeBuffers.size(), _edgeRequests.data()); + MPI_Startall(_cornerBuffers.size(), _cornerRequests.data()); } else{ - MPI_Startall(4, _areaRequests); - MPI_Startall(2, _edgeRequests); + MPI_Startall(4, _areaRequests.data()); + MPI_Startall(2, _edgeRequests.data()); } // std::cout << _areaBuffers.size() << _edgeBuffers.size() << _cornerBuffers.size() <<"\n"; } @@ -543,20 +536,20 @@ void HaloBufferOverlap::wait(){ //outdated!!! if(not(_doNT)){ MPI_Status * areaStatusArray = new MPI_Status[_areaBuffers.size()]; - MPI_Waitall(_areaBuffers.size(),_areaRequests, areaStatusArray); + MPI_Waitall(_areaBuffers.size(),_areaRequests.data(), areaStatusArray); MPI_Status * edgeStatusArray = new MPI_Status[_edgeBuffers.size()]; - MPI_Waitall(_edgeBuffers.size(),_edgeRequests, edgeStatusArray); + MPI_Waitall(_edgeBuffers.size(),_edgeRequests.data(), edgeStatusArray); MPI_Status * cornerStatusArray = new MPI_Status[_cornerBuffers.size()]; - MPI_Waitall(_cornerBuffers.size(),_cornerRequests, cornerStatusArray); + MPI_Waitall(_cornerBuffers.size(),_cornerRequests.data(), cornerStatusArray); } else{ MPI_Status * areaStatusArray = new MPI_Status[4]; - MPI_Waitall(4,_areaRequests, areaStatusArray); + MPI_Waitall(4,_areaRequests.data(), areaStatusArray); MPI_Status * edgeStatusArray = new MPI_Status[2]; - MPI_Waitall(2,_edgeRequests, edgeStatusArray); + MPI_Waitall(2,_edgeRequests.data(), edgeStatusArray); } } @@ -567,13 +560,13 @@ int HaloBufferOverlap::testIfFinished(){ if(!_isGlobal){ std::vector areaStatusArray(_areaBuffers.size()); - MPI_Testall(_areaBuffers.size(),_areaRequests, &areaFlag, areaStatusArray.data()); + MPI_Testall(_areaBuffers.size(),_areaRequests.data(), &areaFlag, areaStatusArray.data()); std::vector edgeStatusArray(_edgeBuffers.size()); - MPI_Testall(_edgeBuffers.size(),_edgeRequests, &edgeFlag, edgeStatusArray.data()); + MPI_Testall(_edgeBuffers.size(),_edgeRequests.data(), &edgeFlag, edgeStatusArray.data()); std::vector cornerStatusArray(_cornerBuffers.size()); - MPI_Testall(_cornerBuffers.size(),_cornerRequests, &cornerFlag, cornerStatusArray.data()); + MPI_Testall(_cornerBuffers.size(),_cornerRequests.data(), &cornerFlag, cornerStatusArray.data()); return areaFlag * edgeFlag * cornerFlag; } @@ -581,17 +574,17 @@ int HaloBufferOverlap::testIfFinished(){ // std::cout << _areaBuffers.size() << "\n"; if(_areaBuffers.size() == 0) return true; std::vector areaStatusArray(_areaBuffers.size()); - MPI_Testall(_areaBuffers.size(),_areaRequests, &areaFlag, areaStatusArray.data()); + MPI_Testall(_areaBuffers.size(),_areaRequests.data(), &areaFlag, areaStatusArray.data()); return areaFlag; } } else{ if(!_isGlobal){ MPI_Status areaStatusArray[4]; - MPI_Testall(4,_areaRequests, &areaFlag, areaStatusArray); + MPI_Testall(4,_areaRequests.data(), &areaFlag, areaStatusArray); MPI_Status edgeStatusArray[2]; - MPI_Testall(2,_edgeRequests, &edgeFlag, edgeStatusArray); + MPI_Testall(2,_edgeRequests.data(), &edgeFlag, edgeStatusArray); return areaFlag * edgeFlag; } else{ @@ -605,7 +598,7 @@ int HaloBufferOverlap::testIfFinished(){ } if(numRequests == 0) return true; std::vector areaStatusArray(numRequests); - MPI_Testall(numRequests,_areaRequests, &areaFlag, areaStatusArray.data()); + MPI_Testall(numRequests,_areaRequests.data(), &areaFlag, areaStatusArray.data()); // MPI_Status status; // // for(int i= 0; i Date: Thu, 19 Sep 2024 18:17:00 +0200 Subject: [PATCH 07/28] Introduce scope around simulation to cleanup simulation objects in organized manner before MPI_Finalize() is called --- src/MarDyn.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index 368a343080..64eb9eb2b4 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -136,6 +136,10 @@ int main(int argc, char** argv) { MPI_Init(&argc, &argv); #endif + // Open scope to exclude MPI_Init() and MPI_Finalize(). + // This way, all simulation objects are cleaned up before MPI finalizes. + { + optparse::OptionParser op; initOptions(&op); optparse::Values options = op.parse_args(argc, argv); @@ -285,6 +289,8 @@ int main(int argc, char** argv) { simulation.finalize(); + } // End of scope to exclude MPI_Init() and MPI_Finalize() + #ifdef ENABLE_MPI MPI_Finalize(); #endif From 5d0e0ddfb7243f90e8f03ea6537b99784ce49196 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 20 Sep 2024 14:44:35 +0200 Subject: [PATCH 08/28] Convert raw pointer to vector --- src/bhfmm/HaloBufferNoOverlap.h | 55 +++++------ src/bhfmm/HaloBufferOverlap.h | 97 +++++++++---------- .../UniformPseudoParticleContainer.cpp | 65 ++++++------- .../UniformPseudoParticleContainer.h | 14 +-- .../expansions/SolidHarmonicsExpansion.h | 6 +- src/bhfmm/pseudoParticles/SHLocalParticle.h | 6 +- .../pseudoParticles/SHMultipoleParticle.h | 6 +- 7 files changed, 113 insertions(+), 136 deletions(-) diff --git a/src/bhfmm/HaloBufferNoOverlap.h b/src/bhfmm/HaloBufferNoOverlap.h index 68af77b11b..b14f4be7e5 100644 --- a/src/bhfmm/HaloBufferNoOverlap.h +++ b/src/bhfmm/HaloBufferNoOverlap.h @@ -11,25 +11,25 @@ template class HaloBufferNoOverlap { public: HaloBufferNoOverlap(int xHaloSize, int yHaloSize, int zHaloSize); - virtual ~HaloBufferNoOverlap(); - void initOverlap(); + virtual ~HaloBufferNoOverlap() = default; + //void initNoOverlap(int xHaloSize, int yHaloSize, int zHaloSize); - T * getFrontBuffer(){ + auto getFrontBuffer(){ return _frontBuffer; } - T * getBackBuffer(){ + auto getBackBuffer(){ return _backBuffer; } - T * getTopBuffer(){ + auto getTopBuffer(){ return _topBuffer; } - T * getBottomBuffer(){ + auto getBottomBuffer(){ return _bottomBuffer; } - T * getLeftBuffer(){ + auto getLeftBuffer(){ return _leftBuffer; } - T * getRightBuffer(){ + auto getRightBuffer(){ return _rightBuffer; } int getXSize(){ @@ -44,10 +44,9 @@ template class HaloBufferNoOverlap { void clear(); private: - T* _leftBuffer, * _rightBuffer, * _topBuffer, * _bottomBuffer, * _frontBuffer, * _backBuffer; //arrays for MPI halo transfer (send) + // arrays for MPI halo transfer (send) + std::vector _leftBuffer, _rightBuffer, _topBuffer, _bottomBuffer, _frontBuffer, _backBuffer; int _xHaloSize,_yHaloSize,_zHaloSize; - - }; #include @@ -59,33 +58,23 @@ HaloBufferNoOverlap::HaloBufferNoOverlap(int xHaloSize, int yHaloSize, int zH _yHaloSize = yHaloSize; _zHaloSize = zHaloSize; - _leftBuffer = new T[_xHaloSize]; - _rightBuffer = new T[_xHaloSize]; + _leftBuffer = std::vector(_xHaloSize); + _rightBuffer = std::vector(_xHaloSize); - _bottomBuffer = new T[_yHaloSize]; - _topBuffer = new T[_yHaloSize]; + _bottomBuffer = std::vector(_yHaloSize); + _topBuffer = std::vector(_yHaloSize); - _backBuffer = new T[_zHaloSize]; - _frontBuffer = new T[_zHaloSize]; -} - -template -HaloBufferNoOverlap::~HaloBufferNoOverlap() { - delete[] _leftBuffer; - delete[] _rightBuffer; - delete[] _bottomBuffer; - delete[] _topBuffer; - delete[] _backBuffer; - delete[] _frontBuffer; + _backBuffer = std::vector(_zHaloSize); + _frontBuffer = std::vector(_zHaloSize); } template void HaloBufferNoOverlap::clear(){ - std::fill(_leftBuffer, _leftBuffer + _xHaloSize , 0.0); - std::fill(_rightBuffer, _rightBuffer + _xHaloSize , 0.0); - std::fill(_frontBuffer, _frontBuffer + _zHaloSize, 0.0); - std::fill(_backBuffer, _backBuffer + _zHaloSize, 0.0); - std::fill(_topBuffer, _topBuffer + _yHaloSize, 0.0); - std::fill(_bottomBuffer, _bottomBuffer + _yHaloSize, 0.0); + std::fill(_leftBuffer.begin(), _leftBuffer.end(), 0.0); + std::fill(_rightBuffer.begin(), _rightBuffer.end(), 0.0); + std::fill(_frontBuffer.begin(), _frontBuffer.end(), 0.0); + std::fill(_backBuffer.begin(), _backBuffer.end(), 0.0); + std::fill(_topBuffer.begin(), _topBuffer.end(), 0.0); + std::fill(_bottomBuffer.begin(), _bottomBuffer.end(), 0.0); } #endif /* HALOBUFFER_H_ */ diff --git a/src/bhfmm/HaloBufferOverlap.h b/src/bhfmm/HaloBufferOverlap.h index 7e300191bd..767391a2d0 100644 --- a/src/bhfmm/HaloBufferOverlap.h +++ b/src/bhfmm/HaloBufferOverlap.h @@ -22,7 +22,7 @@ class HaloBufferOverlap { HaloBufferOverlap(Vector3 areaHaloSize, Vector3 edgeHaloSize, int cornerHaloSize, MPI_Comm comm, std::vector& areaNeighbours,std::vector& edgeNeighbours,std::vector& cornerNeighbours, bool isSend, bool doNT, int areaNumber = 6, int edgeNumber = 12, int cornerNumber = 8 , std::vector>> allRanks = std::vector>>(0), Vector3 numCellsOnGlobalLevel = Vector3(1), bool fuseGlobalCommunication = false); - virtual ~HaloBufferOverlap(); + virtual ~HaloBufferOverlap() = default; void startCommunication(); //communicate without persistent sends and receives void communicate(bool postProcessing); @@ -30,13 +30,13 @@ class HaloBufferOverlap { void wait(); int testIfFinished(); - std::vector& getAreaBuffers(){ + auto & getAreaBuffers(){ return _areaBuffers; } - std::vector& getEdgeBuffers(){ + auto & getEdgeBuffers(){ return _edgeBuffers; } - std::vector& getCornerBuffers(){ + auto & getCornerBuffers(){ return _cornerBuffers; } @@ -49,7 +49,7 @@ class HaloBufferOverlap { void communicateLevelGlobal(int level, int globalLevel, int offset, bool backCommunication); void initCommunicationDouble(); void fillArraySizes(Vector3 areaSizes, Vector3 edgeSizes); - std::vector _areaBuffers, _edgeBuffers, _cornerBuffers; //arrays for MPI halo transfer (send) + std::vector> _areaBuffers, _edgeBuffers, _cornerBuffers; //arrays for MPI halo transfer (send) Vector3 _areaHaloSize,_edgeHaloSize; int _cornerHaloSize; //these arrays save for every halo element the specific size -> if neighbour rank order is changed these arrays have to be changed too but nothing else @@ -102,22 +102,22 @@ _areaRequests(areaNumber), _edgeRequests(edgeNumber), _cornerRequests(cornerNumb if(areaNumber != 0){ for(unsigned int i=0; i<_areaBuffers.size();i++){ if(!_isGlobal){ - _areaBuffers[i] = new T[_areaHaloSizes[i]]; + _areaBuffers[i] = std::vector(_areaHaloSizes[i]); } else{ - _areaBuffers[i] = new T[_areaHaloSizes[0]]; + _areaBuffers[i] = std::vector(_areaHaloSizes[0]); } } } if(edgeNumber != 0){ for(unsigned int i=0; i<_edgeBuffers.size();i++){ - _edgeBuffers[i] = new T[_edgeHaloSizes[i]]; + _edgeBuffers[i] = std::vector(_edgeHaloSizes[i]); } } if(cornerNumber != 0){ for(unsigned int i=0; i<_cornerBuffers.size();i++){ - _cornerBuffers[i] = new T[cornerHaloSize]; + _cornerBuffers[i] = std::vector(cornerHaloSize); } } _isSend = isSend; @@ -181,41 +181,22 @@ void HaloBufferOverlap::fillArraySizes(Vector3 areaSizes, Vector3 e // } } } -template -HaloBufferOverlap::~HaloBufferOverlap() { - - for(unsigned int i=0; i<_areaBuffers.size();i++){ -// MPI_Request_free(&_areaRequests[i]); - delete[] (_areaBuffers[i]); - } - if(!_isGlobal){ - - for(unsigned int i=0; i<_edgeBuffers.size();i++){ - // MPI_Request_free(&_edgeRequests[i]); - delete[] _edgeBuffers[i]; - } - for(unsigned int i=0; i<_cornerBuffers.size();i++){ - // MPI_Request_free(&_cornerRequests[i]); - delete[] _cornerBuffers[i]; - } - } -} template void HaloBufferOverlap::clear(){ for(unsigned int i = 0; i < _areaBuffers.size(); i++){ if(!_isGlobal){ - std::fill(_areaBuffers[i], _areaBuffers[i] + _areaHaloSizes[i] , 0.0); + std::fill(_areaBuffers[i].begin(), _areaBuffers[i].end(), 0.0); } else{ - std::fill(_areaBuffers[i], _areaBuffers[i] + _areaHaloSizes[0] , 0.0); + std::fill(_areaBuffers[i].begin(), _areaBuffers[i].end(), 0.0); } } for(unsigned int i = 0; i < _edgeBuffers.size(); i++){ - std::fill(_edgeBuffers[i], _edgeBuffers[i] + _edgeHaloSizes[i] , 0.0); + std::fill(_edgeBuffers[i].begin(), _edgeBuffers[i].end(), 0.0); } for(unsigned int i = 0; i < _cornerBuffers.size(); i++){ - std::fill(_cornerBuffers[i], _cornerBuffers[i] + _cornerHaloSize , 0.0); + std::fill(_cornerBuffers[i].begin(), _cornerBuffers[i].end(), 0.0); } } @@ -224,35 +205,35 @@ template void HaloBufferOverlap::initCommunicationDouble(){ for (unsigned int i = 0; i < _areaBuffers.size(); i++){ if(_isSend){ - MPI_Rsend_init(_areaBuffers[i], _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); + MPI_Rsend_init(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); //MPI_Rsend_init(_areaBuffers[i], _areaHaloSize, MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); } else{ //adjusts that the tag of receive corresponds to send int indexShift = (i%2 == 0)? +1: -1; - MPI_Recv_init(_areaBuffers[i], _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42 + indexShift, _comm, &_areaRequests[i]); + MPI_Recv_init(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42 + indexShift, _comm, &_areaRequests[i]); } } for (unsigned int i = 0; i < _edgeBuffers.size(); i++){ if(_isSend){ - MPI_Rsend_init(_edgeBuffers[i], _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); + MPI_Rsend_init(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); //MPI_Rsend_init(_edgeBuffers[i], _edgeHaloSize, MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); } else{ int indexShift = (i%2 == 0)? +1: -1; - MPI_Recv_init(_edgeBuffers[i], _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42 + indexShift, _comm, &_edgeRequests[i]); + MPI_Recv_init(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42 + indexShift, _comm, &_edgeRequests[i]); } } for (unsigned int i = 0; i < _cornerBuffers.size(); i++){ if(_isSend){ - MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); + MPI_Rsend_init(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); // MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); } else{ int indexShift = (i%2 == 0)? +1: -1; - MPI_Recv_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42 + indexShift, _comm, &_cornerRequests[i]); + MPI_Recv_init(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42 + indexShift, _comm, &_cornerRequests[i]); } } } @@ -275,9 +256,9 @@ void HaloBufferOverlap::communicate(bool postProcessing){ } } if(postProcessing) - MPI_Isend(_areaBuffers[i], _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[requestIndex]); + MPI_Isend(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[requestIndex]); else - MPI_Irsend(_areaBuffers[i], _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[requestIndex]); + MPI_Irsend(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[requestIndex]); requestIndex++; //MPI_Rsend_init(_areaBuffers[i], _areaHaloSize, MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); @@ -298,7 +279,7 @@ void HaloBufferOverlap::communicate(bool postProcessing){ } //adjusts that the tag of receive corresponds to send int indexShift = (i%2 == 0)? +1: -1; - MPI_Irecv(_areaBuffers[i], _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42 + indexShift, _comm, &_areaRequests[requestIndex]); + MPI_Irecv(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42 + indexShift, _comm, &_areaRequests[requestIndex]); requestIndex++; } } @@ -318,9 +299,9 @@ void HaloBufferOverlap::communicate(bool postProcessing){ } } if(postProcessing) - MPI_Isend(_edgeBuffers[i], _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[requestIndex]); + MPI_Isend(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[requestIndex]); else - MPI_Irsend(_edgeBuffers[i], _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[requestIndex]); + MPI_Irsend(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[requestIndex]); requestIndex++; //MPI_Rsend_init(_edgeBuffers[i], _edgeHaloSize, MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); @@ -339,7 +320,7 @@ void HaloBufferOverlap::communicate(bool postProcessing){ } } int indexShift = (i%2 == 0)? +1: -1; - MPI_Irecv(_edgeBuffers[i], _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42 + indexShift, _comm, &_edgeRequests[requestIndex]); + MPI_Irecv(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42 + indexShift, _comm, &_edgeRequests[requestIndex]); requestIndex++; } } @@ -347,13 +328,13 @@ void HaloBufferOverlap::communicate(bool postProcessing){ if(not(_doNT)){ for (unsigned int i = 0; i < _cornerBuffers.size(); i++){ if(_isSend){ - MPI_Irsend(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[requestIndex]); + MPI_Irsend(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[requestIndex]); requestIndex++; // MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); } else{ int indexShift = (i%2 == 0)? +1: -1; - MPI_Irecv(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42 + indexShift, _comm, &_cornerRequests[requestIndex]); + MPI_Irecv(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42 + indexShift, _comm, &_cornerRequests[requestIndex]); requestIndex++; } } @@ -473,14 +454,26 @@ void HaloBufferOverlap::communicateLevelGlobal(int level, int globalLevel, in int numCellsOnLevel = (level == globalLevel)? _numCellsOnGlobalLevel[0] * _numCellsOnGlobalLevel[1] * _numCellsOnGlobalLevel[2] : 1; if(_isSend){ if(!backCommunication){ - MPI_Irsend(_areaBuffers[8*(globalLevel-level) + 4*zOffset + 2*yOffset + xOffset], _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Irsend(_areaBuffers[8*(globalLevel-level) + 4*zOffset + 2*yOffset + xOffset].data(), + _areaHaloSizes[0], + MPI_DOUBLE, + rank, + 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), + _comm, + &_areaRequests[indexPosition + offset]); } else{ if(_fuseGlobalCommunication){ //in the back communication only 1 (or equal to the number of cells one owns on global level) cell is send instead of 8 - MPI_Isend(_areaBuffers[indexPosition + offset], _areaHaloSizes[0] / 8 * numCellsOnLevel , MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Isend(_areaBuffers[indexPosition + offset].data(), + _areaHaloSizes[0] / 8 * numCellsOnLevel , MPI_DOUBLE, rank, + 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), + _comm, &_areaRequests[indexPosition + offset]); } else{ - MPI_Isend(_areaBuffers[indexPosition + offset], _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Isend(_areaBuffers[indexPosition + offset].data(), + _areaHaloSizes[0], MPI_DOUBLE, rank, + 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), + _comm, &_areaRequests[indexPosition + offset]); } } indexPosition++; @@ -490,14 +483,14 @@ void HaloBufferOverlap::communicateLevelGlobal(int level, int globalLevel, in // std::cout << indexPosition << "\n"; // MPI_Barrier(_comm); if(!backCommunication){ - MPI_Irecv(_areaBuffers[indexPosition + offset], _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Irecv(_areaBuffers[indexPosition + offset].data(), _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); } else{ if(_fuseGlobalCommunication){ //in the back communication only 1 (or equal to the number of cells one owns on global level) cell is send instead if 8 - MPI_Irecv(_areaBuffers[indexPosition + offset], _areaHaloSizes[0] / 8 * numCellsOnLevel, MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Irecv(_areaBuffers[indexPosition + offset].data(), _areaHaloSizes[0] / 8 * numCellsOnLevel, MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); } else{ - MPI_Irecv(_areaBuffers[indexPosition + offset], _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); + MPI_Irecv(_areaBuffers[indexPosition + offset].data(), _areaHaloSizes[0], MPI_DOUBLE, rank, 1000 + zOffset * 4 + yOffset * 2 + xOffset + 8 * (globalLevel - level), _comm, &_areaRequests[indexPosition + offset]); } } indexPosition++; diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index d0a2e37c96..85820770b2 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -318,8 +318,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _globalNumCells = pow(_globalNumCellsPerDim, 3); #if defined(ENABLE_MPI) _globalLevelNumCells = pow(8,_globalLevel); - _occVector = new int[_globalLevelNumCells]; - std::fill(_occVector, _occVector + _globalLevelNumCells, 0); + _occVector = std::vector(_globalLevelNumCells, 0); #endif _coeffVectorLength = 0; _expansionSize = 0; @@ -489,8 +488,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _coeffVectorLength = _expansionSize*numCells; #endif - _coeffVector = new double[_coeffVectorLength * 2]; - std::fill(_coeffVector, _coeffVector + _coeffVectorLength * 2, 0.0); + _coeffVector = std::vector(_coeffVectorLength * 2, 0.0); Log::global_log->info() << "UniformPseudoParticleContainer: coeffVectorLength=" << _coeffVectorLength << " Size of MPI Buffers is " << (8 * (_coeffVectorLength * 2 + _globalNumCells) @@ -534,9 +532,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( UniformPseudoParticleContainer::~UniformPseudoParticleContainer() { delete _leafContainer; - delete[] _coeffVector; #if defined(ENABLE_MPI) - delete[] _occVector; if(!_overlapComm){ delete _multipoleBuffer; delete _multipoleRecBuffer; @@ -1174,7 +1170,7 @@ int UniformPseudoParticleContainer::optimizeAllReduce(/*ParticleContainer* ljCon } _coeffVectorLength = _expansionSize*numCells; - _coeffVector = new double[_coeffVectorLength * 2]; + _coeffVector = std::vector(_coeffVectorLength * 2); _leafContainer->clearParticles(); @@ -1253,21 +1249,20 @@ void UniformPseudoParticleContainer::upwardPass(P2MCellProcessor* cp) { } int cellIndex = ((coordsLevel[2]) * mpCells + coordsLevel[1]) * mpCells + coordsLevel[0]; if(!_fuseGlobalCommunication){ - double * buffer = new double[2*_expansionSize]; + auto buffer = std::vector(2*_expansionSize); MpCell & currentCell = _mpCellGlobalTop[curLevel][cellIndex]; int index = 0; currentCell.multipole.writeValuesToMPIBuffer(buffer,index); - MPI_Allreduce(MPI_IN_PLACE,buffer,2 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel]); + MPI_Allreduce(MPI_IN_PLACE,buffer.data(),2 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel]); index = 0; currentCell.multipole.readValuesFromMPIBuffer(buffer,index); - delete[] buffer; } else{ //get values of 8 values from previous level that contributed to the parent level in addition to parent value (9 values each 2 expansions) int coordsFlooredPreviousLevel[3]; for(int d = 0; d < 3; d++){ coordsFlooredPreviousLevel[d] = (((coords[d] * _numCellsOnGlobalLevel[d]) / (stride/2)) / 2) * 2; } - double * buffer = new double[18*_expansionSize]; + auto buffer = std::vector(18*_expansionSize); MpCell & currentCell = _mpCellGlobalTop[curLevel][cellIndex]; int index = 0; currentCell.multipole.writeValuesToMPIBuffer(buffer,index); @@ -1282,7 +1277,7 @@ void UniformPseudoParticleContainer::upwardPass(P2MCellProcessor* cp) { } } } - MPI_Allreduce(MPI_IN_PLACE,buffer,18 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel]); + MPI_Allreduce(MPI_IN_PLACE,buffer.data(),18 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel]); index = 0; MpCell & currentCell2 = _mpCellGlobalTop[curLevel][cellIndex]; currentCell2.multipole.readValuesFromMPIBuffer(buffer,index); @@ -1326,7 +1321,7 @@ void UniformPseudoParticleContainer::upwardPass(P2MCellProcessor* cp) { coordsFlooredLevel[d] = (((coords[d] * _numCellsOnGlobalLevel[d]) / (stride)) / 2) * 2; } - double * buffer = new double[16*_expansionSize]; + auto buffer = std::vector(16*_expansionSize); int index = 0; for(int z = 0; z < 2; z++){ for(int y = 0; y < 2; y++){ @@ -1338,7 +1333,7 @@ void UniformPseudoParticleContainer::upwardPass(P2MCellProcessor* cp) { } } } - MPI_Allreduce(MPI_IN_PLACE,buffer,16 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[_stopLevel - 1]); + MPI_Allreduce(MPI_IN_PLACE,buffer.data(),16 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[_stopLevel - 1]); index = 0; for(int z = 0; z < 2; z++){ @@ -1510,7 +1505,7 @@ void UniformPseudoParticleContainer::horizontalPass( //Fixme? special case for curlevel == 2? -> 64 cells only? unnecessary communication in this case? //possible optimization only add up values that were modified in NT method int numCells = (curLevel == 1)? 8 : 216; - double * buffer = new double[numCells * 2 * _expansionSize]; + auto buffer = std::vector(numCells * 2 * _expansionSize); int index = 0; int start, end; if(curLevel == 1){ @@ -1536,7 +1531,7 @@ void UniformPseudoParticleContainer::horizontalPass( } } } - MPI_Allreduce(MPI_IN_PLACE,buffer,numCells * 2 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel - 1]); + MPI_Allreduce(MPI_IN_PLACE,buffer.data(),numCells * 2 * _expansionSize,MPI_DOUBLE,MPI_SUM,_neighbourhoodComms[curLevel - 1]); index = 0; for(int z = start; z < end; z++){ @@ -3373,8 +3368,8 @@ void UniformPseudoParticleContainer::clear() { // clear the MPI buffers #ifdef ENABLE_MPI - std::fill(_coeffVector, _coeffVector + _coeffVectorLength*2, 0.0); - std::fill(_occVector, _occVector + _globalLevelNumCells, 0); + std::fill(_coeffVector.begin(), _coeffVector.end(), 0.0); + std::fill(_occVector.begin(), _occVector.end(), 0); #endif } @@ -3392,8 +3387,8 @@ void UniformPseudoParticleContainer::AllReduceMultipoleMoments() { _occVector[cellIndex] = currentCell.occ; } - MPI_Allreduce(MPI_IN_PLACE, _coeffVector, _coeffVectorLength*2, MPI_DOUBLE, MPI_SUM, _comm); - MPI_Allreduce(MPI_IN_PLACE, _occVector, _globalLevelNumCells, MPI_INT, MPI_SUM, _comm); + MPI_Allreduce(MPI_IN_PLACE, _coeffVector.data(), _coeffVectorLength*2, MPI_DOUBLE, MPI_SUM, _comm); + MPI_Allreduce(MPI_IN_PLACE, _occVector.data(), _globalLevelNumCells, MPI_INT, MPI_SUM, _comm); coeffIndex = 0; @@ -3405,7 +3400,7 @@ void UniformPseudoParticleContainer::AllReduceMultipoleMoments() { } - std::fill(_coeffVector, _coeffVector + _coeffVectorLength * 2, 0.0); + std::fill(_coeffVector.begin(), _coeffVector.end(), 0.0); #endif global_simulation->timers()->stop("UNIFORM_PSEUDO_PARTICLE_CONTAINER_ALL_REDUCE"); @@ -3429,7 +3424,7 @@ void UniformPseudoParticleContainer::AllReduceMultipoleMomentsLevelToTop(int num numCellsLevelTemp /= 8; } int commLevel = (_avoidAllReduce && _stopLevel <= _globalLevel)? _stopLevel: _globalLevel; - MPI_Iallreduce(MPI_IN_PLACE, _coeffVector, _coeffVectorLength*2, MPI_DOUBLE, MPI_SUM, _allReduceComms[commLevel], &_allReduceRequest); + MPI_Iallreduce(MPI_IN_PLACE, _coeffVector.data(), _coeffVectorLength*2, MPI_DOUBLE, MPI_SUM, _allReduceComms[commLevel], &_allReduceRequest); } #endif @@ -3450,7 +3445,7 @@ void UniformPseudoParticleContainer::AllReduceMultipoleMomentsSetValues(int numC } numCellsLevelTemp /= 8; } - std::fill(_coeffVector, _coeffVector + _coeffVectorLength * 2, 0.0); + std::fill(_coeffVector.begin(), _coeffVector.end(), 0.0); } #endif } @@ -3471,7 +3466,7 @@ void UniformPseudoParticleContainer::AllReduceLocalMoments(int mpCells, int _cur currentCell.local.writeValuesToMPIBuffer(_coeffVector, coeffIndex); } - MPI_Allreduce(MPI_IN_PLACE, _coeffVector, coeffIndex, MPI_DOUBLE, MPI_SUM, _comm); + MPI_Allreduce(MPI_IN_PLACE, _coeffVector.data(), coeffIndex, MPI_DOUBLE, MPI_SUM, _comm); coeffIndex = 0; @@ -3483,13 +3478,13 @@ void UniformPseudoParticleContainer::AllReduceLocalMoments(int mpCells, int _cur } - std::fill(_coeffVector, _coeffVector + _coeffVectorLength * 2, 0.0); + std::fill(_coeffVector.begin(), _coeffVector.end(), 0.0); #endif global_simulation->timers()->stop("UNIFORM_PSEUDO_PARTICLE_CONTAINER_ALL_REDUCE_ME"); } -void UniformPseudoParticleContainer::getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, double *buffer, +void UniformPseudoParticleContainer::getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector buffer, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion){ #if defined(ENABLE_MPI) int coeffIndex = 0; @@ -3526,7 +3521,7 @@ void UniformPseudoParticleContainer::getHaloValues(Vector3 localMpCellsBott #endif } -void UniformPseudoParticleContainer::setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, double *bufferRec, +void UniformPseudoParticleContainer::setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector bufferRec, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion){ #if defined(ENABLE_MPI) @@ -4319,10 +4314,10 @@ void UniformPseudoParticleContainer::communicateHalosOverlapPostProcessingStart( #endif } -void UniformPseudoParticleContainer::communicateHalosAlongAxis(double *lowerNeighbourBuffer, - double *higherNeighbourBuffer, - double *lowerNeighbourBufferRec, - double *higherNeighbourBufferRec, +void UniformPseudoParticleContainer::communicateHalosAlongAxis(std::vectorlowerNeighbourBuffer, + std::vectorhigherNeighbourBuffer, + std::vectorlowerNeighbourBufferRec, + std::vectorhigherNeighbourBufferRec, int lowerNeighbour, int higherNeighbour, int haloSize) { @@ -4331,13 +4326,13 @@ void UniformPseudoParticleContainer::communicateHalosAlongAxis(double *lowerNeig MPI_Status lowRecv,highRecv; - MPI_Isend(lowerNeighbourBuffer, haloSize, MPI_DOUBLE, lowerNeighbour, 1, + MPI_Isend(lowerNeighbourBuffer.data(), haloSize, MPI_DOUBLE, lowerNeighbour, 1, _comm, &low); - MPI_Isend(higherNeighbourBuffer, haloSize, MPI_DOUBLE, higherNeighbour, 3, + MPI_Isend(higherNeighbourBuffer.data(), haloSize, MPI_DOUBLE, higherNeighbour, 3, _comm, &high); - MPI_Recv(lowerNeighbourBufferRec, haloSize,MPI_DOUBLE, lowerNeighbour,3,_comm, &lowRecv); - MPI_Recv(higherNeighbourBufferRec, haloSize,MPI_DOUBLE, higherNeighbour,1,_comm, &highRecv); + MPI_Recv(lowerNeighbourBufferRec.data(), haloSize,MPI_DOUBLE, lowerNeighbour,3,_comm, &lowRecv); + MPI_Recv(higherNeighbourBufferRec.data(), haloSize,MPI_DOUBLE, higherNeighbour,1,_comm, &highRecv); #endif diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.h b/src/bhfmm/containers/UniformPseudoParticleContainer.h index cc4eb208ab..3632bc7506 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.h +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.h @@ -111,12 +111,12 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { int _globalNumCellsPerDim; Domain* _domain; int _globalNumCells; //total amount of cells - int* _occVector; // array for MPI allgather + std::vector _occVector; // array for MPI allgather int _coeffVectorLength; //size of MPI buffer for multipole coefficients int _expansionSize; //size of one local or multipole expansion in doubles - double* _coeffVector; // array for MPI allgather - double* _coeffVector_me; + std::vector _coeffVector; // array for MPI allgather + std::vector _coeffVector_me; #ifdef ENABLE_MPI HaloBufferNoOverlap * _multipoleRecBuffer, *_multipoleBuffer; //Buffer with use for non-overlapping communication HaloBufferOverlap * _multipoleRecBufferOverlap, * _multipoleBufferOverlap, * _multipoleBufferOverlapGlobal, * _multipoleRecBufferOverlapGlobal; //Buffers for receiving and sending of global and local tree halos @@ -199,7 +199,7 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { * @param bottomLevel: lowest level * @param buffer: buffer where values are should be stored */ - void getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, double *buffer, + void getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector buffer, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion); /** * Sets multipole or local expansion values in a defined area into a buffer for each level in local tree (e.g. halo values) @@ -211,7 +211,7 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { * @param bottomLevel: lowest level * @param buffer: buffer where values are stored in which should be written into the area */ - void setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, double *bufferRec, + void setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector bufferRec, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion); //for parallelization void communicateHalosNoOverlap(); @@ -235,8 +235,8 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { void communicateHalosX(); void communicateHalosY(); void communicateHalosZ(); - void communicateHalosAlongAxis(double * lowerNeighbourBuffer, double * higherNeighbourBuffer, - double * lowerNeighbourBufferRec, double * higherNeighbourBufferRec, + void communicateHalosAlongAxis(std::vector lowerNeighbourBuffer, std::vector higherNeighbourBuffer, + std::vector lowerNeighbourBufferRec, std::vector higherNeighbourBufferRec, int lowerNeighbour, int higherNeighbour, int haloSize ); bool _doNTLocal, _doNTGlobal; //indicate if NT method should be applied to the local tree part and/or the global tree part diff --git a/src/bhfmm/expansions/SolidHarmonicsExpansion.h b/src/bhfmm/expansions/SolidHarmonicsExpansion.h index a927d4190a..d196aa4a7d 100644 --- a/src/bhfmm/expansions/SolidHarmonicsExpansion.h +++ b/src/bhfmm/expansions/SolidHarmonicsExpansion.h @@ -318,7 +318,7 @@ class SolidHarmonicsExpansion * @param buf buffer to write to * @param position index at which next entry should be written, note that it's value is updated! */ - void writeValuesToMPIBuffer(double * buf, int& position) const { + void writeValuesToMPIBuffer(std::vector buf, int& position) const { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { buf[position++] = acc_c_C_seq(i); @@ -328,7 +328,7 @@ class SolidHarmonicsExpansion } } - void readValuesFromMPIBuffer(double * buf, int& position) { + void readValuesFromMPIBuffer(std::vector buf, int& position) { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { acc_C_seq(i) = buf[position++]; @@ -337,7 +337,7 @@ class SolidHarmonicsExpansion acc_S_seq(i) = buf[position++]; } } - void addValuesFromMPIBuffer(double * buf, int& position) { + void addValuesFromMPIBuffer(std::vector buf, int& position) { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { acc_C_seq(i) += buf[position++]; diff --git a/src/bhfmm/pseudoParticles/SHLocalParticle.h b/src/bhfmm/pseudoParticles/SHLocalParticle.h index a1a5bbece1..f6622bc033 100644 --- a/src/bhfmm/pseudoParticles/SHLocalParticle.h +++ b/src/bhfmm/pseudoParticles/SHLocalParticle.h @@ -84,14 +84,14 @@ class SHLocalParticle: public LocalParticle { return _expansionM; } - void writeValuesToMPIBuffer(double * buf, int& position) const { + void writeValuesToMPIBuffer(std::vector buf, int& position) const { _expansionM.writeValuesToMPIBuffer(buf, position); } - void readValuesFromMPIBuffer(double * buf, int& position) { + void readValuesFromMPIBuffer(std::vector buf, int& position) { _expansionM.readValuesFromMPIBuffer(buf,position); } - void addValuesFromMPIBuffer(double * buf, int& position) { + void addValuesFromMPIBuffer(std::vector buf, int& position) { _expansionM.addValuesFromMPIBuffer(buf,position); } diff --git a/src/bhfmm/pseudoParticles/SHMultipoleParticle.h b/src/bhfmm/pseudoParticles/SHMultipoleParticle.h index a7a57d6512..cdd1cd1fcd 100644 --- a/src/bhfmm/pseudoParticles/SHMultipoleParticle.h +++ b/src/bhfmm/pseudoParticles/SHMultipoleParticle.h @@ -70,15 +70,15 @@ class SHMultipoleParticle: public MultipoleParticle { return _expansionL; } - void writeValuesToMPIBuffer(double * buf, int& position) const { + void writeValuesToMPIBuffer(std::vector buf, int& position) const { _expansionL.writeValuesToMPIBuffer(buf, position); } - void readValuesFromMPIBuffer(double * buf, int& position) { + void readValuesFromMPIBuffer(std::vector buf, int& position) { _expansionL.readValuesFromMPIBuffer(buf,position); } - void addValuesFromMPIBuffer(double * buf, int& position) { + void addValuesFromMPIBuffer(std::vector buf, int& position) { _expansionL.addValuesFromMPIBuffer(buf,position); } From 8f1feef2a68fec924ba0feaea9cffe7517c4148f Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 20 Sep 2024 14:49:00 +0200 Subject: [PATCH 09/28] Remove some commented-out code --- src/bhfmm/HaloBufferNoOverlap.h | 1 - src/bhfmm/HaloBufferOverlap.h | 20 -------------------- 2 files changed, 21 deletions(-) diff --git a/src/bhfmm/HaloBufferNoOverlap.h b/src/bhfmm/HaloBufferNoOverlap.h index b14f4be7e5..3d06a3d15e 100644 --- a/src/bhfmm/HaloBufferNoOverlap.h +++ b/src/bhfmm/HaloBufferNoOverlap.h @@ -13,7 +13,6 @@ template class HaloBufferNoOverlap { HaloBufferNoOverlap(int xHaloSize, int yHaloSize, int zHaloSize); virtual ~HaloBufferNoOverlap() = default; - //void initNoOverlap(int xHaloSize, int yHaloSize, int zHaloSize); auto getFrontBuffer(){ return _frontBuffer; } diff --git a/src/bhfmm/HaloBufferOverlap.h b/src/bhfmm/HaloBufferOverlap.h index 767391a2d0..58a842e48d 100644 --- a/src/bhfmm/HaloBufferOverlap.h +++ b/src/bhfmm/HaloBufferOverlap.h @@ -97,7 +97,6 @@ _areaRequests(areaNumber), _edgeRequests(edgeNumber), _cornerRequests(cornerNumb fillArraySizes(areaHaloSize,edgeHaloSize); -// _cornerHaloSizes = new int[_cornerBuffers.size()]; _comm = comm; if(areaNumber != 0){ for(unsigned int i=0; i<_areaBuffers.size();i++){ @@ -174,12 +173,6 @@ void HaloBufferOverlap::fillArraySizes(Vector3 areaSizes, Vector3 e _edgeHaloSizes[i] = edgeSizes[2-i/4]; } } - else{ -// _edgeHaloSizes = new int[_edgeBuffers.size()]; -// for(unsigned int i = 0; i < _edgeBuffers.size(); i++){ -// _edgeHaloSizes[i] = edgeSizes[0]; -// } - } } template @@ -206,8 +199,6 @@ void HaloBufferOverlap::initCommunicationDouble(){ for (unsigned int i = 0; i < _areaBuffers.size(); i++){ if(_isSend){ MPI_Rsend_init(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); - //MPI_Rsend_init(_areaBuffers[i], _areaHaloSize, MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); - } else{ //adjusts that the tag of receive corresponds to send @@ -218,8 +209,6 @@ void HaloBufferOverlap::initCommunicationDouble(){ for (unsigned int i = 0; i < _edgeBuffers.size(); i++){ if(_isSend){ MPI_Rsend_init(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); - //MPI_Rsend_init(_edgeBuffers[i], _edgeHaloSize, MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); - } else{ int indexShift = (i%2 == 0)? +1: -1; @@ -229,7 +218,6 @@ void HaloBufferOverlap::initCommunicationDouble(){ for (unsigned int i = 0; i < _cornerBuffers.size(); i++){ if(_isSend){ MPI_Rsend_init(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); - // MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); } else{ int indexShift = (i%2 == 0)? +1: -1; @@ -261,8 +249,6 @@ void HaloBufferOverlap::communicate(bool postProcessing){ MPI_Irsend(_areaBuffers[i].data(), _areaHaloSizes[i], MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[requestIndex]); requestIndex++; - //MPI_Rsend_init(_areaBuffers[i], _areaHaloSize, MPI_DOUBLE, _areaNeighbours[i], i + 42, _comm, &_areaRequests[i]); - } else{ if(_doNT){ @@ -303,8 +289,6 @@ void HaloBufferOverlap::communicate(bool postProcessing){ else MPI_Irsend(_edgeBuffers[i].data(), _edgeHaloSizes[i], MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[requestIndex]); requestIndex++; - //MPI_Rsend_init(_edgeBuffers[i], _edgeHaloSize, MPI_DOUBLE, _edgeNeighbours[i], i + 42, _comm, &_edgeRequests[i]); - } else{ if(_doNT){ @@ -330,7 +314,6 @@ void HaloBufferOverlap::communicate(bool postProcessing){ if(_isSend){ MPI_Irsend(_cornerBuffers[i].data(), _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[requestIndex]); requestIndex++; - // MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); } else{ int indexShift = (i%2 == 0)? +1: -1; @@ -477,7 +460,6 @@ void HaloBufferOverlap::communicateLevelGlobal(int level, int globalLevel, in } } indexPosition++; - // MPI_Rsend_init(_cornerBuffers[i], _cornerHaloSize, MPI_DOUBLE, _cornerNeighbours[i], i + 42, _comm, &_cornerRequests[i]); } else{ // std::cout << indexPosition << "\n"; @@ -521,7 +503,6 @@ void HaloBufferOverlap::startCommunication(){ MPI_Startall(4, _areaRequests.data()); MPI_Startall(2, _edgeRequests.data()); } -// std::cout << _areaBuffers.size() << _edgeBuffers.size() << _cornerBuffers.size() <<"\n"; } template @@ -564,7 +545,6 @@ int HaloBufferOverlap::testIfFinished(){ return areaFlag * edgeFlag * cornerFlag; } else{ -// std::cout << _areaBuffers.size() << "\n"; if(_areaBuffers.size() == 0) return true; std::vector areaStatusArray(_areaBuffers.size()); MPI_Testall(_areaBuffers.size(),_areaRequests.data(), &areaFlag, areaStatusArray.data()); From fb3e41fd9a344e0125fe8238067ea8983a96d907 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:34:00 +0200 Subject: [PATCH 10/28] Apply code scanning fix for multiplication result converted to larger type Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/bhfmm/containers/UniformPseudoParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index 85820770b2..853d6266e0 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -1505,7 +1505,7 @@ void UniformPseudoParticleContainer::horizontalPass( //Fixme? special case for curlevel == 2? -> 64 cells only? unnecessary communication in this case? //possible optimization only add up values that were modified in NT method int numCells = (curLevel == 1)? 8 : 216; - auto buffer = std::vector(numCells * 2 * _expansionSize); + auto buffer = std::vector(static_cast(numCells) * 2 * _expansionSize); int index = 0; int start, end; if(curLevel == 1){ From f0cbed60934c14e27bf1adc235ba885ab0e0aad4 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:39:44 +0200 Subject: [PATCH 11/28] Pass by reference instead of copy Co-authored-by: FG-TUM --- .../containers/UniformPseudoParticleContainer.cpp | 12 ++++++------ .../containers/UniformPseudoParticleContainer.h | 8 ++++---- src/bhfmm/expansions/SolidHarmonicsExpansion.h | 6 +++--- src/bhfmm/pseudoParticles/SHLocalParticle.h | 6 +++--- src/bhfmm/pseudoParticles/SHMultipoleParticle.h | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index 853d6266e0..76566ef0f5 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -3484,7 +3484,7 @@ void UniformPseudoParticleContainer::AllReduceLocalMoments(int mpCells, int _cur global_simulation->timers()->stop("UNIFORM_PSEUDO_PARTICLE_CONTAINER_ALL_REDUCE_ME"); } -void UniformPseudoParticleContainer::getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector buffer, +void UniformPseudoParticleContainer::getHaloValues(const Vector3 &localMpCellsBottom,int bottomLevel, std::vector &buffer, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion){ #if defined(ENABLE_MPI) int coeffIndex = 0; @@ -3521,7 +3521,7 @@ void UniformPseudoParticleContainer::getHaloValues(Vector3 localMpCellsBott #endif } -void UniformPseudoParticleContainer::setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector bufferRec, +void UniformPseudoParticleContainer::setHaloValues(const Vector3 &localMpCellsBottom,int bottomLevel, std::vector &bufferRec, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion){ #if defined(ENABLE_MPI) @@ -4314,10 +4314,10 @@ void UniformPseudoParticleContainer::communicateHalosOverlapPostProcessingStart( #endif } -void UniformPseudoParticleContainer::communicateHalosAlongAxis(std::vectorlowerNeighbourBuffer, - std::vectorhigherNeighbourBuffer, - std::vectorlowerNeighbourBufferRec, - std::vectorhigherNeighbourBufferRec, +void UniformPseudoParticleContainer::communicateHalosAlongAxis(std::vector &lowerNeighbourBuffer, + std::vector &higherNeighbourBuffer, + std::vector &lowerNeighbourBufferRec, + std::vector &higherNeighbourBufferRec, int lowerNeighbour, int higherNeighbour, int haloSize) { diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.h b/src/bhfmm/containers/UniformPseudoParticleContainer.h index 3632bc7506..11c2cb1668 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.h +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.h @@ -199,7 +199,7 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { * @param bottomLevel: lowest level * @param buffer: buffer where values are should be stored */ - void getHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector buffer, + void getHaloValues(const Vector3 &localMpCellsBottom,int bottomLevel, std::vector &buffer, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion); /** * Sets multipole or local expansion values in a defined area into a buffer for each level in local tree (e.g. halo values) @@ -211,7 +211,7 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { * @param bottomLevel: lowest level * @param buffer: buffer where values are stored in which should be written into the area */ - void setHaloValues(Vector3 localMpCellsBottom,int bottomLevel, std::vector bufferRec, + void setHaloValues(const Vector3 &localMpCellsBottom,int bottomLevel, std::vector &bufferRec, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh, bool doLocalExpansion); //for parallelization void communicateHalosNoOverlap(); @@ -235,8 +235,8 @@ class UniformPseudoParticleContainer: public PseudoParticleContainer { void communicateHalosX(); void communicateHalosY(); void communicateHalosZ(); - void communicateHalosAlongAxis(std::vector lowerNeighbourBuffer, std::vector higherNeighbourBuffer, - std::vector lowerNeighbourBufferRec, std::vector higherNeighbourBufferRec, + void communicateHalosAlongAxis(std::vector &lowerNeighbourBuffer, std::vector &higherNeighbourBuffer, + std::vector &lowerNeighbourBufferRec, std::vector &higherNeighbourBufferRec, int lowerNeighbour, int higherNeighbour, int haloSize ); bool _doNTLocal, _doNTGlobal; //indicate if NT method should be applied to the local tree part and/or the global tree part diff --git a/src/bhfmm/expansions/SolidHarmonicsExpansion.h b/src/bhfmm/expansions/SolidHarmonicsExpansion.h index d196aa4a7d..11707a0f8d 100644 --- a/src/bhfmm/expansions/SolidHarmonicsExpansion.h +++ b/src/bhfmm/expansions/SolidHarmonicsExpansion.h @@ -318,7 +318,7 @@ class SolidHarmonicsExpansion * @param buf buffer to write to * @param position index at which next entry should be written, note that it's value is updated! */ - void writeValuesToMPIBuffer(std::vector buf, int& position) const { + void writeValuesToMPIBuffer(std::vector &buf, int& position) const { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { buf[position++] = acc_c_C_seq(i); @@ -328,7 +328,7 @@ class SolidHarmonicsExpansion } } - void readValuesFromMPIBuffer(std::vector buf, int& position) { + void readValuesFromMPIBuffer(std::vector &buf, int& position) { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { acc_C_seq(i) = buf[position++]; @@ -337,7 +337,7 @@ class SolidHarmonicsExpansion acc_S_seq(i) = buf[position++]; } } - void addValuesFromMPIBuffer(std::vector buf, int& position) { + void addValuesFromMPIBuffer(std::vector &buf, int& position) { const int end = _c.getTotalNumValues(); for (int i = 0; i < end; ++i) { acc_C_seq(i) += buf[position++]; diff --git a/src/bhfmm/pseudoParticles/SHLocalParticle.h b/src/bhfmm/pseudoParticles/SHLocalParticle.h index f6622bc033..ed2121770f 100644 --- a/src/bhfmm/pseudoParticles/SHLocalParticle.h +++ b/src/bhfmm/pseudoParticles/SHLocalParticle.h @@ -84,14 +84,14 @@ class SHLocalParticle: public LocalParticle { return _expansionM; } - void writeValuesToMPIBuffer(std::vector buf, int& position) const { + void writeValuesToMPIBuffer(std::vector &buf, int& position) const { _expansionM.writeValuesToMPIBuffer(buf, position); } - void readValuesFromMPIBuffer(std::vector buf, int& position) { + void readValuesFromMPIBuffer(std::vector &buf, int& position) { _expansionM.readValuesFromMPIBuffer(buf,position); } - void addValuesFromMPIBuffer(std::vector buf, int& position) { + void addValuesFromMPIBuffer(std::vector &buf, int& position) { _expansionM.addValuesFromMPIBuffer(buf,position); } diff --git a/src/bhfmm/pseudoParticles/SHMultipoleParticle.h b/src/bhfmm/pseudoParticles/SHMultipoleParticle.h index cdd1cd1fcd..5720c7d754 100644 --- a/src/bhfmm/pseudoParticles/SHMultipoleParticle.h +++ b/src/bhfmm/pseudoParticles/SHMultipoleParticle.h @@ -70,15 +70,15 @@ class SHMultipoleParticle: public MultipoleParticle { return _expansionL; } - void writeValuesToMPIBuffer(std::vector buf, int& position) const { + void writeValuesToMPIBuffer(std::vector &buf, int& position) const { _expansionL.writeValuesToMPIBuffer(buf, position); } - void readValuesFromMPIBuffer(std::vector buf, int& position) { + void readValuesFromMPIBuffer(std::vector &buf, int& position) { _expansionL.readValuesFromMPIBuffer(buf,position); } - void addValuesFromMPIBuffer(std::vector buf, int& position) { + void addValuesFromMPIBuffer(std::vector &buf, int& position) { _expansionL.addValuesFromMPIBuffer(buf,position); } From 21a164679a2d7c0058ccc1519b0631877ad77e2d Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Sat, 21 Sep 2024 08:10:35 +0200 Subject: [PATCH 12/28] Fix regarding buffer to return ref --- src/bhfmm/HaloBufferNoOverlap.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bhfmm/HaloBufferNoOverlap.h b/src/bhfmm/HaloBufferNoOverlap.h index 3d06a3d15e..3bdce11545 100644 --- a/src/bhfmm/HaloBufferNoOverlap.h +++ b/src/bhfmm/HaloBufferNoOverlap.h @@ -13,22 +13,22 @@ template class HaloBufferNoOverlap { HaloBufferNoOverlap(int xHaloSize, int yHaloSize, int zHaloSize); virtual ~HaloBufferNoOverlap() = default; - auto getFrontBuffer(){ + auto & getFrontBuffer(){ return _frontBuffer; } - auto getBackBuffer(){ + auto & getBackBuffer(){ return _backBuffer; } - auto getTopBuffer(){ + auto & getTopBuffer(){ return _topBuffer; } - auto getBottomBuffer(){ + auto & getBottomBuffer(){ return _bottomBuffer; } - auto getLeftBuffer(){ + auto & getLeftBuffer(){ return _leftBuffer; } - auto getRightBuffer(){ + auto & getRightBuffer(){ return _rightBuffer; } int getXSize(){ From 9a2d6c29c4296c2eafc260b729b2f44945915e4d Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Sun, 22 Sep 2024 18:44:36 +0200 Subject: [PATCH 13/28] Add exit wrapper to print function, file and line in which exit was called --- src/Domain.cpp | 4 +- src/MarDyn.cpp | 4 +- src/Simulation.cpp | 72 +++++++++---------- src/bhfmm/FastMultipoleMethod.cpp | 6 +- .../UniformPseudoParticleContainer.cpp | 6 +- ...PseudoParticleContainer_old_Wigner_cpp.txt | 10 +-- src/ensemble/CanonicalEnsemble.cpp | 2 +- src/ensemble/CavityEnsemble.cpp | 10 +-- src/ensemble/ChemicalPotential.cpp | 6 +- src/ensemble/EnsembleBase.cpp | 12 ++-- src/ensemble/GrandCanonicalEnsemble.h | 4 +- src/ensemble/PressureGradient.cpp | 2 +- src/io/ASCIIReader.cpp | 18 ++--- src/io/Adios2Reader.cpp | 6 +- src/io/Adios2Writer.cpp | 6 +- src/io/BinaryReader.cpp | 16 ++--- src/io/CavityWriter.cpp | 14 ++-- src/io/CheckpointWriter.cpp | 4 +- src/io/CommunicationPartnerWriter.cpp | 2 +- src/io/CubicGridGeneratorInternal.cpp | 8 +-- src/io/FlopRateWriter.cpp | 2 +- src/io/HaloParticleWriter.cpp | 2 +- src/io/KDTreePrinter.cpp | 2 +- src/io/MPI_IOCheckpointWriter.cpp | 2 +- src/io/MPI_IOReader.cpp | 12 ++-- src/io/Mkesfera.cpp | 2 +- src/io/MmpldWriter.cpp | 10 +-- src/io/ObjectGenerator.cpp | 8 +-- src/io/PerCellGenerator.cpp | 4 +- src/io/RDF.cpp | 2 +- src/io/ReplicaGenerator.cpp | 16 ++--- src/io/ResultWriter.cpp | 2 +- src/io/TimerWriter.cpp | 2 +- src/io/vtk/VTKGridWriter.cpp | 4 +- src/longRange/Homogeneous.cpp | 2 +- src/longRange/Planar.cpp | 8 +-- src/molecules/AutoPasSimpleMolecule.cpp | 2 +- src/molecules/Comp2Param.cpp | 2 +- src/molecules/Component.cpp | 4 +- src/molecules/MoleculeInterface.cpp | 2 +- src/molecules/mixingrules/MixingRuleBase.cpp | 4 +- src/parallel/CollectiveCommunication.h | 4 +- .../CollectiveCommunicationNonBlocking.h | 4 +- src/parallel/CommunicationPartner.cpp | 4 +- src/parallel/DomainDecompBase.cpp | 2 +- src/parallel/DomainDecompMPIBase.cpp | 4 +- src/parallel/DomainDecomposition.cpp | 6 +- src/parallel/ForceHelper.cpp | 2 +- src/parallel/GeneralDomainDecomposition.cpp | 12 ++-- src/parallel/KDDecomposition.cpp | 26 +++---- src/parallel/LoadCalc.cpp | 12 ++-- src/parallel/NeighbourCommunicationScheme.cpp | 8 +-- src/parallel/ParticleDataRMM.cpp | 2 +- .../StaticIrregDomainDecomposition.cpp | 2 +- src/particleContainer/AutoPasContainer.cpp | 4 +- .../C08CellPairTraversal.h | 2 +- .../NeutralTerritoryTraversal.h | 4 +- .../OriginalCellPairTraversal.h | 2 +- .../QuickschedTraversal.h | 2 +- .../SlicedCellPairTraversal.h | 2 +- src/particleContainer/LinkedCells.cpp | 22 +++--- src/particleContainer/TraversalTuner.h | 10 +-- .../adapter/ParticlePairs2PotForceAdapter.h | 2 +- src/plugins/COMaligner.cpp | 2 +- src/plugins/DirectedPM.cpp | 2 +- src/plugins/Dropaccelerator.cpp | 2 +- src/plugins/Dropaligner.cpp | 2 +- src/plugins/ExamplePlugin.cpp | 2 +- src/plugins/FixRegion.cpp | 2 +- src/plugins/MaxCheck.cpp | 2 +- src/plugins/Mirror.cpp | 14 ++-- src/plugins/NEMD/DensityControl.cpp | 4 +- src/plugins/NEMD/DistControl.cpp | 26 +++---- src/plugins/NEMD/MettDeamon.cpp | 34 ++++----- .../NEMD/MettDeamonFeedrateDirector.cpp | 4 +- src/plugins/NEMD/RegionSampling.cpp | 40 +++++------ src/plugins/PluginFactory.cpp | 2 +- src/plugins/SpatialProfile.cpp | 4 +- src/plugins/VectorizationTuner.cpp | 6 +- src/plugins/WallPotential.cpp | 4 +- src/thermostats/TemperatureControl.cpp | 8 +-- src/utils/OptionParser.cpp | 8 +-- src/utils/SigsegvHandler.h | 2 +- src/utils/Testing.cpp | 4 +- src/utils/generator/ReplicaFiller.cpp | 10 +-- src/utils/mardyn_assert.h | 11 ++- src/utils/xmlfile.cpp | 8 +-- 87 files changed, 326 insertions(+), 321 deletions(-) diff --git a/src/Domain.cpp b/src/Domain.cpp index e02fd03fde..771a03e34f 100644 --- a/src/Domain.cpp +++ b/src/Domain.cpp @@ -553,7 +553,7 @@ void Domain::writeCheckpointHeader(std::string filename, } } else { Log::global_log->error() << "Only LB mixing rule supported" << std::endl; - mardyn_exit(123); + MARDYN_EXIT(123); } } } @@ -711,7 +711,7 @@ void Domain::enableComponentwiseThermostat() void Domain::setComponentThermostat(int cid, int thermostat) { if ((0 > cid) || (0 >= thermostat)) { Log::global_log->error() << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl; - mardyn_exit(787); + MARDYN_EXIT(787); } this->_componentToThermostatIdMap[cid] = thermostat; this->_universalThermostatN[thermostat] = 0; diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index 9a4cf21924..dcaa224a84 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -194,7 +194,7 @@ int main(int argc, char** argv) { if(numArgs != 1) { Log::global_log->error() << "Incorrect number of arguments provided." << std::endl; op.print_usage(); - mardyn_exit(-1); + MARDYN_EXIT(-1); } /* First read the given config file if it exists, then overwrite parameters with command line arguments. */ std::string configFileName(args[0]); @@ -203,7 +203,7 @@ int main(int argc, char** argv) { simulation.readConfigFile(configFileName); } else { Log::global_log->error() << "Cannot open config file '" << configFileName << "'" << std::endl; - mardyn_exit(-2); + MARDYN_EXIT(-2); } /* processing command line arguments */ diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 8a8860e8c6..66df7634c6 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -172,14 +172,14 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { if(integratorType == "Leapfrog") { #ifdef ENABLE_REDUCED_MEMORY_MODE Log::global_log->error() << "The reduced memory mode (RMM) requires the LeapfrogRMM integrator." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); #endif _integrator = new Leapfrog(); } else if (integratorType == "LeapfrogRMM") { _integrator = new LeapfrogRMM(); } else { Log::global_log-> error() << "Unknown integrator " << integratorType << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _integrator->readXML(xmlconfig); _integrator->init(); @@ -222,7 +222,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _ensemble = new GrandCanonicalEnsemble(); } else { Log::global_log->error() << "Unknown ensemble type: " << ensembletype << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _ensemble->readXML(xmlconfig); /** @todo Here we store data in the _domain member as long as we do not use the ensemble everywhere */ @@ -235,7 +235,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Ensemble section missing." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } /* algorithm */ @@ -256,13 +256,13 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _cutoffRadius = std::max(_cutoffRadius, _LJCutoffRadius); if(_cutoffRadius <= 0) { Log::global_log->error() << "cutoff radius <= 0." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "dimensionless cutoff radius:\t" << _cutoffRadius << std::endl; xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "Cutoff section missing." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } /* electrostatics */ @@ -275,7 +275,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "Electrostatics section for reaction field setup missing." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if (xmlconfig.changecurrentnode("electrostatic[@type='FastMultipoleMethod']")) { @@ -283,7 +283,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->fatal() << "The fast multipole method is not compatible with AutoPas. Please disable the AutoPas mode (ENABLE_AUTOPAS)!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); #endif _FMM = new bhfmm::FastMultipoleMethod(); _FMM->readXML(xmlconfig); @@ -342,7 +342,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { "vs the GeneralDomainDecomposition which can lead ALL to shrink the " "domain too small." << std::endl; - mardyn_exit(512435340); + MARDYN_EXIT(512435340); } } else { Log::global_log->warning() << "Using the GeneralDomainDecomposition without AutoPas is not " @@ -358,17 +358,17 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Using skin = " << skin << " for the GeneralDomainDecomposition." << std::endl; } else { Log::global_log->error() << "Datastructure section missing" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(not xmlconfig.changecurrentnode("../parallelisation")){ Log::global_log->error() << "Could not go back to parallelisation path. Aborting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } delete _domainDecomposition; _domainDecomposition = new GeneralDomainDecomposition(getcutoffRadius() + skin, _domain, forceLatchingToLinkedCellsGrid); } else { Log::global_log->error() << "Unknown parallelisation type: " << parallelisationtype << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #else /* serial */ if(parallelisationtype != "DummyDecomposition") { @@ -376,7 +376,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { << "Executable was compiled without support for parallel execution: " << parallelisationtype << " not available. Using serial mode." << std::endl; - //mardyn_exit(1); + //MARDYN_EXIT(1); } //_domainDecomposition = new DomainDecompBase(); // already set in initialize() #endif @@ -403,7 +403,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { << "time steps for the load calculation." << std::endl; if(timerForLoadAveragingLength < 1ul) { Log::global_log->fatal() << "timerForLoadAveragingLength has to be at least 1" << std::endl; - mardyn_exit(15843); + MARDYN_EXIT(15843); } _lastTraversalTimeHistory.setCapacity(timerForLoadAveragingLength); @@ -412,7 +412,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { #ifdef ENABLE_MPI Log::global_log->error() << "Parallelisation section missing." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); #else /* serial */ // set _timerForLoad, s.t. it always exists. _timerForLoad = timers()->getTimer("SIMULATION_COMPUTATION"); @@ -430,7 +430,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->fatal() << "LinkedCells not compiled (use AutoPas instead, or compile with disabled autopas mode)!" << std::endl; - mardyn_exit(33); + MARDYN_EXIT(33); #else _moleculeContainer = new LinkedCells(); /** @todo Review if we need to know the max cutoff radius usable with any datastructure. */ @@ -439,7 +439,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { #endif } else if(datastructuretype == "AdaptiveSubCells") { Log::global_log->warning() << "AdaptiveSubCells no longer supported." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else if(datastructuretype == "AutoPas" || datastructuretype == "AutoPasContainer") { #ifdef MARDYN_AUTOPAS Log::global_log->info() << "Using AutoPas container." << std::endl; @@ -447,12 +447,12 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Setting cell cutoff radius for AutoPas container to " << _cutoffRadius << std::endl; #else Log::global_log->fatal() << "AutoPas not compiled (use LinkedCells instead, or compile with enabled autopas mode)!" << std::endl; - mardyn_exit(33); + MARDYN_EXIT(33); #endif } else { Log::global_log->error() << "Unknown data structure type: " << datastructuretype << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _moleculeContainer->readXML(xmlconfig); @@ -464,7 +464,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "Datastructure section missing" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // TODO: move parts to readXML in TemperatureControl? @@ -508,7 +508,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Instance of TemperatureControl allready exist! Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else @@ -531,7 +531,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { if( !xmlconfig.getNodeValue("@type", type) ) { Log::global_log->error() << "LongRangeCorrection: Missing type specification. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } if("planar" == type) { @@ -555,7 +555,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { Log::global_log->error() << "LongRangeCorrection: Wrong type. Expected type == homogeneous|planar|none. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } xmlconfig.changecurrentnode(".."); } else { @@ -621,7 +621,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { #endif else { Log::global_log->error() << "Unknown phase space file type" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } xmlconfig.changecurrentnode(oldpath); @@ -651,7 +651,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Unknown generator: " << generatorName << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _inputReader->readXML(xmlconfig); } @@ -686,7 +686,7 @@ void Simulation::readConfigFile(std::string filename) { } else { Log::global_log->error() << "Unknown config file extension '" << extension << "'." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } @@ -701,7 +701,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { if(inp.changecurrentnode("/mardyn") < 0) { Log::global_log->error() << "Cound not find root node /mardyn in XML input file." << std::endl; Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } std::string version("unknown"); @@ -716,7 +716,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { } // simulation-section else { Log::global_log->error() << "Simulation section missing" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } parseMiscOptions(inp); @@ -729,7 +729,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { } catch (const std::exception& e) { Log::global_log->error() << "Error in XML config. Please check your input file!" << std::endl; Log::global_log->error() << "Exception: " << e.what() << std::endl; - mardyn_exit(7); + MARDYN_EXIT(7); } #ifdef ENABLE_MPI @@ -855,7 +855,7 @@ void Simulation::prepare_start() { _longRangeCorrection->init(); } else { Log::global_log->fatal() << "No _longRangeCorrection set!" << std::endl; - mardyn_exit(93742); + MARDYN_EXIT(93742); } // longRangeCorrection is a site-wise force plugin, so we have to call it before updateForces() _longRangeCorrection->calculateLongRange(); @@ -950,7 +950,7 @@ void Simulation::preSimLoopSteps() { Log::global_log->error() << "Unexpected call to preSimLoopSteps()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } @@ -1012,7 +1012,7 @@ void Simulation::simulateOneTimestep() { Log::global_log->error() << "Unexpected call to simulateOneTimeStep()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #ifdef MAMICO_COUPLING @@ -1243,7 +1243,7 @@ void Simulation::postSimLoopSteps() { Log::global_log->error() << "Unexpected call to postSimLoopSteps()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } @@ -1308,7 +1308,7 @@ void Simulation::pluginEndStepCall(unsigned long simstep) { << _domain->getGlobalPressure() << std::endl; if (std::isnan(_domain->getGlobalCurrentTemperature()) || std::isnan(_domain->getGlobalUpot()) || std::isnan(_domain->getGlobalPressure())) { Log::global_log->error() << "NaN detected, exiting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } @@ -1378,7 +1378,7 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim auto* dd = dynamic_cast(_domainDecomposition); if (not dd) { Log::global_log->fatal() << "DomainDecompMPIBase* required for overlapping comm, but dynamic_cast failed." << std::endl; - mardyn_exit(873456); + MARDYN_EXIT(873456); } NonBlockingMPIMultiStepHandler nonBlockingMPIHandler {dd, _moleculeContainer, _domain, _cellProcessor}; @@ -1387,7 +1387,7 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim nonBlockingMPIHandler.performOverlappingTasks(forceRebalancing, etime); #else Log::global_log->fatal() << "performOverlappingDecompositionAndCellTraversalStep() called with disabled MPI." << std::endl; - mardyn_exit(873457); + MARDYN_EXIT(873457); #endif } diff --git a/src/bhfmm/FastMultipoleMethod.cpp b/src/bhfmm/FastMultipoleMethod.cpp index 3e4533219e..41ffb07d94 100644 --- a/src/bhfmm/FastMultipoleMethod.cpp +++ b/src/bhfmm/FastMultipoleMethod.cpp @@ -70,7 +70,7 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], Log::global_log->error() << "Fast Multipole Method: bad subdivision factor:" << _LJCellSubdivisionFactor << std::endl; Log::global_log->error() << "expected 1,2,4 or 8" << std::endl; - mardyn_exit(5); + MARDYN_EXIT(5); } Log::global_log->info() << "Fast Multipole Method: each LJ cell will be subdivided in " @@ -108,7 +108,7 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], // TODO: Debugging in Progress! #if defined(ENABLE_MPI) Log::global_log->error() << "MPI in combination with adaptive is not supported yet" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); #endif //int threshold = 100; _pseudoParticleContainer = new AdaptivePseudoParticleContainer( @@ -314,7 +314,7 @@ void FastMultipoleMethod::runner(int type, void *data) { #pragma omp critical { Log::global_log->error() << "Quicksched runner without FMM_FFT not implemented!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #endif /* FMM_FFT */ } diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index d0a2e37c96..69808b98b5 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -112,7 +112,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( #endif #if WIGNER == 1 //global_log->error() << "not supported yet" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); #endif #ifdef ENABLE_MPI /* @@ -176,7 +176,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _globalLevel = ceil(log2(numProcessors)/3.0); if(_globalLevel > _maxLevel){ std::cout << "too many MPI ranks \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); } //numProcessers has to be a power of 2 mardyn_assert(pow(2,log2(numProcessors)) == numProcessors); @@ -379,7 +379,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( MPI_Comm_size(_neighbourhoodComms[i], &size2); if(size2 > 8){ //neighbourhood comms need to have size 8 std::cout << "Error wrong communicator \n"; - mardyn_exit(1); + MARDYN_EXIT(1); } } #endif diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt index 1f81735625..40ec2cee30 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt +++ b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt @@ -45,7 +45,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( #endif #if WIGNER == 1 //global_log->error() << "not supported yet" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); #endif #ifdef ENABLE_MPI _timerProcessCells.set_sync(false); @@ -81,7 +81,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _globalLevel = log2(numProcessors)/3; if(_globalLevel > _maxLevel){ std::cout << "too many MPI ranks \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); } //numProcessers has to be a power of 8 mardyn_assert(log2(numProcessors) == _globalLevel * 3); @@ -778,7 +778,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2z = LoLim(2) + 2; m2z <= HiLim(2) + 2; m2z++) { if (m2z < 0 or m2z >= localMpCells) { std::cout << "Error \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); } @@ -786,7 +786,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2y = LoLim(1) + 2; m2y <= HiLim(1) + 2; m2y++) { if (m2y < 0 or m2y >= localMpCells) { std::cout << "Error \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); } @@ -794,7 +794,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2x = LoLim(0) + 2; m2x <= HiLim(0) + 2; m2x++) { if (m2x < 0 or m2x >= localMpCells) { std::cout << "Error \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); } m2v[0] = m2x; diff --git a/src/ensemble/CanonicalEnsemble.cpp b/src/ensemble/CanonicalEnsemble.cpp index c79b31be4e..da0af18555 100644 --- a/src/ensemble/CanonicalEnsemble.cpp +++ b/src/ensemble/CanonicalEnsemble.cpp @@ -196,7 +196,7 @@ void CanonicalEnsemble::readXML(XMLfileUnits& xmlconfig) { _domain = new BoxDomain(); } else { Log::global_log->error() << "Volume type not supported." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } xmlconfig.changecurrentnode("domain"); _domain->readXML(xmlconfig); diff --git a/src/ensemble/CavityEnsemble.cpp b/src/ensemble/CavityEnsemble.cpp index bd65adeade..4ac6c85462 100644 --- a/src/ensemble/CavityEnsemble.cpp +++ b/src/ensemble/CavityEnsemble.cpp @@ -96,7 +96,7 @@ void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1 Log::global_log->error() << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 << ")." << std::endl; - mardyn_exit(711); + MARDYN_EXIT(711); } this->restrictedControlVolume = true; @@ -112,19 +112,19 @@ void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1 void CavityEnsemble::init(Component *component, unsigned Nx, unsigned Ny, unsigned Nz) { if (this->ownrank < 0) { Log::global_log->error() << "\nInvalid rank " << ownrank << ".\n"; - mardyn_exit(712); + MARDYN_EXIT(712); } if (this->initialized) { Log::global_log->error() << "\nCavity ensemble initialized twice.\n"; - mardyn_exit(713); + MARDYN_EXIT(713); } if (0.0 >= this->T) { Log::global_log->error() << "\nInvalid temperature T = " << T << ".\n"; - mardyn_exit(714); + MARDYN_EXIT(714); } if (0.0 >= this->globalV) { Log::global_log->error() << "\nInvalid control volume V_ctrl = " << globalV << ".\n"; - mardyn_exit(715); + MARDYN_EXIT(715); } this->componentid = component->ID(); diff --git a/src/ensemble/ChemicalPotential.cpp b/src/ensemble/ChemicalPotential.cpp index a535104e44..05a9cb87c2 100644 --- a/src/ensemble/ChemicalPotential.cpp +++ b/src/ensemble/ChemicalPotential.cpp @@ -285,7 +285,7 @@ bool ChemicalPotential::decideDeletion(double deltaUTilde) return false; } Log::global_log->error() << "No decision is possible." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } float dec = *_remainingDecisions.begin(); _remainingDecisions.erase(_remainingDecisions.begin()); @@ -318,7 +318,7 @@ bool ChemicalPotential::decideInsertion(double deltaUTilde) return false; } Log::global_log->error() << "No decision is possible." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } double acc = _globalReducedVolume * exp(_muTilde - deltaUTilde) / (1.0 + (double) (_globalN)); @@ -376,7 +376,7 @@ void ChemicalPotential::setControlVolume(double x0, double y0, double z0, Log::global_log->error() << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 << ")." << std::endl; - mardyn_exit(611); + MARDYN_EXIT(611); } _restrictedControlVolume = true; _globalV = (x1 - x0) * (y1 - y0) * (z1 - z0); diff --git a/src/ensemble/EnsembleBase.cpp b/src/ensemble/EnsembleBase.cpp index d688d40471..ee34db1b6d 100644 --- a/src/ensemble/EnsembleBase.cpp +++ b/src/ensemble/EnsembleBase.cpp @@ -24,7 +24,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Number of components: " << numComponents << std::endl; if (numComponents == 0) { Log::global_log->fatal() << "No components found. Please verify that you have input them correctly." << std::endl; - mardyn_exit(96123); + MARDYN_EXIT(96123); } _components.resize(numComponents); XMLfile::Query::const_iterator componentIter; @@ -58,7 +58,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Unknown mixing rule " << mixingruletype << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } mixingrule->readXML(xmlconfig); @@ -69,7 +69,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { if (cid2 >= numComponents) { Log::global_log->error() << "Mixing: cid=" << cid2+1 << " is larger than number of components (" << numComponents << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _mixingrules[cid1][cid2] = mixingrule; } @@ -116,16 +116,16 @@ void Ensemble::setMixingrule(std::shared_ptr mixingrule) { // Check if cids are valid if (cid1 == cid2) { Log::global_log->error() << "Mixing setMixingrule: cids must not be the same" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if (std::min(cid1, cid2) < 0) { Log::global_log->error() << "Mixing setMixingrule: cids must not be negative" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if (std::max(cid1, cid2) >= _components.size()) { Log::global_log->error() << "Mixing setMixingrule: cids must not exceed number of components (" << _components.size() << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _mixingrules[cid1][cid2] = mixingrule; diff --git a/src/ensemble/GrandCanonicalEnsemble.h b/src/ensemble/GrandCanonicalEnsemble.h index 2249cc0de7..05e45ca440 100644 --- a/src/ensemble/GrandCanonicalEnsemble.h +++ b/src/ensemble/GrandCanonicalEnsemble.h @@ -41,7 +41,7 @@ class GrandCanonicalEnsemble : public Ensemble { // TODO: Implement STUB void readXML(XMLfileUnits& xmlconfig) override { Log::global_log->info() << "[GrandCanonicalEnsemble] readXML not implemented!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); }; unsigned long N() override { @@ -71,7 +71,7 @@ class GrandCanonicalEnsemble : public Ensemble { // TODO: Implement void updateGlobalVariable(ParticleContainer* particleContainer, GlobalVariable variable) override { Log::global_log->info() << "[GrandCanonicalEnsemble] updateGlobalVariable not implemented!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); }; /*! Runs steps formerly in initConfigXML in simulation.cpp */ diff --git a/src/ensemble/PressureGradient.cpp b/src/ensemble/PressureGradient.cpp index 029a1a9e77..83af623597 100644 --- a/src/ensemble/PressureGradient.cpp +++ b/src/ensemble/PressureGradient.cpp @@ -220,7 +220,7 @@ void PressureGradient::specifyTauPrime(double tauPrime, double dt) if(this->_universalConstantAccelerationTimesteps == 0) { Log::global_log->error() << "SEVERE ERROR: unknown UCAT!\n"; - mardyn_exit(78); + MARDYN_EXIT(78); } unsigned int vql = (unsigned int)ceil(tauPrime / (dt*this->_universalConstantAccelerationTimesteps)); std::map::iterator vqlit; diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index d0dd3cf7c1..a41ce21a59 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -57,7 +57,7 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream >> token; if(token != "mardyn") { Log::global_log->error() << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } std::string inputversion; @@ -65,12 +65,12 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { // FIXME: remove tag trunk from file specification? if(token != "trunk") { Log::global_log->error() << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(std::stoi(inputversion) < 20080701) { Log::global_log->error() << "Input version too old (" << inputversion << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -165,7 +165,7 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(numtersoff != 0) { Log::global_log->error() << "tersoff no longer supported." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -275,7 +275,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain _phaseSpaceFileStream.open(_phaseSpaceFile.c_str()); if(!_phaseSpaceFileStream.is_open()) { Log::global_log->error() << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; #ifdef ENABLE_MPI @@ -301,7 +301,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain } if((token != "NumberOfMolecules") && (token != "N")) { Log::global_log->error() << "Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _phaseSpaceFileStream >> nummolecules; #ifdef ENABLE_MPI @@ -328,7 +328,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain else if(ntypestring == "IRV") ntype = Ndatatype::IRV; else { Log::global_log->error() << "Unknown molecule format '" << ntypestring << "'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } else { _phaseSpaceFileStream.seekg(spos); @@ -389,7 +389,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain break; default: Log::global_log->error() << "[ASCIIReader.cpp] Unknown ntype" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) @@ -403,7 +403,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain << componentid << ">" << numcomponents << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/Adios2Reader.cpp b/src/io/Adios2Reader.cpp index 643fc4ba19..02b2faf3fe 100644 --- a/src/io/Adios2Reader.cpp +++ b/src/io/Adios2Reader.cpp @@ -536,19 +536,19 @@ void Adios2Reader::initAdios2() { << "[Adios2Reader] Invalid argument exception, STOPPING PROGRAM from rank" << domainDecomp.getRank() << ": " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } catch (std::ios_base::failure& e) { Log::global_log->fatal() << "[Adios2Reader] IO System base failure exception, STOPPING PROGRAM from rank " << domainDecomp.getRank() << ": " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } catch (std::exception& e) { Log::global_log->fatal() << "[Adios2Reader] Exception, STOPPING PROGRAM from rank" << domainDecomp.getRank() << ": " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "[Adios2Reader] Init complete." << std::endl; }; diff --git a/src/io/Adios2Writer.cpp b/src/io/Adios2Writer.cpp index 12cad27dca..a829f06c26 100644 --- a/src/io/Adios2Writer.cpp +++ b/src/io/Adios2Writer.cpp @@ -265,14 +265,14 @@ void Adios2Writer::initAdios2() { resetContainers(); } catch (std::invalid_argument& e) { Log::global_log->fatal() << "Invalid argument exception, STOPPING PROGRAM from rank: " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } catch (std::ios_base::failure& e) { Log::global_log->fatal() << "IO System base failure exception, STOPPING PROGRAM from rank: " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } catch (std::exception& e) { Log::global_log->fatal() << "Exception, STOPPING PROGRAM from rank: " << e.what() << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "[Adios2Writer] Init complete." << std::endl; } diff --git a/src/io/BinaryReader.cpp b/src/io/BinaryReader.cpp index 95c56fa418..1bb02f1955 100644 --- a/src/io/BinaryReader.cpp +++ b/src/io/BinaryReader.cpp @@ -78,7 +78,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(not inp.changecurrentnode("/mardyn")) { Log::global_log->error() << "Could not find root node /mardyn in XML input file." << std::endl; Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } bool bInputOk = true; @@ -96,7 +96,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(not bInputOk) { Log::global_log->error() << "Content of file: '" << _phaseSpaceHeaderFile << "' corrupted! Program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if("ICRVQD" == strMoleculeFormat) @@ -107,7 +107,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _nMoleculeFormat = ICRV; else { Log::global_log->error() << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // Set parameters of Domain and Simulation class @@ -134,7 +134,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai if(!_phaseSpaceFileStream.is_open()) { Log::global_log->error() << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; @@ -178,7 +178,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai if(_phaseSpaceFileStream.eof()) { Log::global_log->error() << "End of file was hit before all " << numMolecules << " expected molecules were read." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _phaseSpaceFileStream.read(reinterpret_cast (&id), 8); switch (_nMoleculeFormat) { @@ -221,7 +221,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai default: Log::global_log->error() << "BinaryReader: Unknown phase space format: " << _nMoleculeFormat << std::endl << "Aborting simulation." << std::endl; - mardyn_exit(12); + MARDYN_EXIT(12); } if ((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) || (z < 0.0 || z >= domain->getGlobalLength(2))) { @@ -234,12 +234,12 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai << componentid << ">" << numcomponents << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(componentid == 0) { Log::global_log->error() << "Molecule id " << id << " has componentID == 0." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/CavityWriter.cpp b/src/io/CavityWriter.cpp index 5c6d57601e..288edcad36 100644 --- a/src/io/CavityWriter.cpp +++ b/src/io/CavityWriter.cpp @@ -38,28 +38,28 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { xmlconfig.getNodeValue("maxNeighbours", _maxNeighbors); if (_maxNeighbors <= 0) { Log::global_log->error() << "[CavityWriter] Invalid number of maxNeighbors: " << _maxNeighbors << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } xmlconfig.getNodeValue("radius", _radius); if (_radius <= 0.0f) { Log::global_log->error() << "[CavityWriter] Invalid size of radius: " << _radius << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } xmlconfig.getNodeValue("Nx", _Nx); if (_Nx <= 0) { Log::global_log->error() << "[CavityWriter] Invalid number of cells Nx: " << _Nx << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } xmlconfig.getNodeValue("Ny", _Ny); if (_Ny <= 0) { Log::global_log->error() << "[CavityWriter] Invalid number of cells Ny: " << _Ny << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } xmlconfig.getNodeValue("Nz", _Nz); if (_Nz <= 0) { Log::global_log->error() << "[CavityWriter] Invalid number of cells Nz: " << _Nz << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } // Default Control Volume is entire Domain @@ -77,13 +77,13 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { if (_controlVolume[d * 2] > _controlVolume[d * 2 + 1]) { Log::global_log->error() << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound. " << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } if (_controlVolume[d * 2] < 0 || _controlVolume[d * 2 + 1] > global_simulation->getDomain()->getGlobalLength(d)) { Log::global_log->error() << "[CavityWriter] Control volume bounds may not be outside of domain boundaries. " << std::endl; - mardyn_exit(999); + MARDYN_EXIT(999); } } diff --git a/src/io/CheckpointWriter.cpp b/src/io/CheckpointWriter.cpp index 6d8c4621c7..69d2dbc632 100644 --- a/src/io/CheckpointWriter.cpp +++ b/src/io/CheckpointWriter.cpp @@ -20,7 +20,7 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string checkpointType = "unknown"; @@ -33,7 +33,7 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Unknown CheckpointWriter type '" << checkpointType << "', expected: ASCII|binary." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } _outputPrefix = "mardyn"; diff --git a/src/io/CommunicationPartnerWriter.cpp b/src/io/CommunicationPartnerWriter.cpp index 1a280316e7..08980ceb24 100644 --- a/src/io/CommunicationPartnerWriter.cpp +++ b/src/io/CommunicationPartnerWriter.cpp @@ -18,7 +18,7 @@ void CommunicationPartnerWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string HaloParticleType = "unknown"; diff --git a/src/io/CubicGridGeneratorInternal.cpp b/src/io/CubicGridGeneratorInternal.cpp index 8c3e7e85c2..720c38e0ca 100644 --- a/src/io/CubicGridGeneratorInternal.cpp +++ b/src/io/CubicGridGeneratorInternal.cpp @@ -41,7 +41,7 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { // setting both or none is not allowed! if((_numMolecules == 0 && density == -1.) || (_numMolecules != 0 && density != -1.) ){ Log::global_log->error() << "Error in CubicGridGeneratorInternal: You have to set either density or numMolecules!" << std::endl; - mardyn_exit(2341); + MARDYN_EXIT(2341); } if(density != -1.){ @@ -50,7 +50,7 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "Error in CubicGridGeneratorInternal: Density has to be positive and non-zero!" << std::endl; - mardyn_exit(2342); + MARDYN_EXIT(2342); } double vol = 1.0; for (int d = 0; d < 3; ++d) @@ -67,7 +67,7 @@ unsigned long CubicGridGeneratorInternal::readPhaseSpace(ParticleContainer *part if(_numMolecules == 0){ Log::global_log->error() << "Error in CubicGridGeneratorInternal: numMolecules is not set!" << std::endl << "Please make sure to run readXML()!" << std::endl; - mardyn_exit(2341); + MARDYN_EXIT(2341); } // create a body centered cubic layout, by creating by placing the molecules on the @@ -147,7 +147,7 @@ std::array CubicGridGeneratorInternal::determineMolsPerDimensi if (answer < 1) { Log::global_log->error() << "computed num Molecules along dimension " << d << ": " << answer << std::endl; Log::global_log->error() << "Should be larger than 1. Exiting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } ret[d] = answer; diff --git a/src/io/FlopRateWriter.cpp b/src/io/FlopRateWriter.cpp index e438a724da..e93018d1fd 100644 --- a/src/io/FlopRateWriter.cpp +++ b/src/io/FlopRateWriter.cpp @@ -36,7 +36,7 @@ void FlopRateWriter::readXML(XMLfileUnits& xmlconfig) { // TODO: if(_writeToFile) { Log::global_log->error() << "TODO: file output not yet supported." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(_writeToFile) { diff --git a/src/io/HaloParticleWriter.cpp b/src/io/HaloParticleWriter.cpp index cd6f058252..08e1e389cd 100644 --- a/src/io/HaloParticleWriter.cpp +++ b/src/io/HaloParticleWriter.cpp @@ -18,7 +18,7 @@ void HaloParticleWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string HaloParticleType = "unknown"; diff --git a/src/io/KDTreePrinter.cpp b/src/io/KDTreePrinter.cpp index 132a7e1965..714132f2f2 100644 --- a/src/io/KDTreePrinter.cpp +++ b/src/io/KDTreePrinter.cpp @@ -20,7 +20,7 @@ void KDTreePrinter::readXML(XMLfileUnits &xmlconfig) { if (_writeFrequency == 0) { Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - mardyn_exit(948947); + MARDYN_EXIT(948947); } _outputPrefix = "mardyn"; diff --git a/src/io/MPI_IOCheckpointWriter.cpp b/src/io/MPI_IOCheckpointWriter.cpp index b160edd7e5..95bbc82797 100644 --- a/src/io/MPI_IOCheckpointWriter.cpp +++ b/src/io/MPI_IOCheckpointWriter.cpp @@ -436,6 +436,6 @@ void MPI_IOCheckpointWriter::handle_error(int i) { Log::global_log->error() << "Writing of file was not successfull " << " , " << i << " , " << error_string << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); #endif } diff --git a/src/io/MPI_IOReader.cpp b/src/io/MPI_IOReader.cpp index 11a33ce58d..b40a73fe2e 100644 --- a/src/io/MPI_IOReader.cpp +++ b/src/io/MPI_IOReader.cpp @@ -59,7 +59,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream >> token; if(token != "mardyn") { Log::global_log->error() << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } std::string inputversion; @@ -67,12 +67,12 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { // FIXME: remove tag trunk from file specification? if(token != "trunk") { Log::global_log->error() << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(strtoul(inputversion.c_str(), NULL, 0) < 20080701) { Log::global_log->error() << "Input version tool old (" << inputversion << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -117,7 +117,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { || ntypestring == "IRV")) { Log::global_log->error() << "Unknown molecule format: '" << ntypestring << "'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _moleculeFormat = ntypestring; Log::global_log->info() << " molecule format: " << ntypestring << std::endl; @@ -183,7 +183,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { >> numquadrupoles >> numtersoff; if(numtersoff != 0) { Log::global_log->error() << "tersoff no longer supported." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -656,6 +656,6 @@ void MPI_IOReader::handle_error(int i) { Log::global_log->error() << "Writing of file was not successfull " << " , " << i << " , " << error_string << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); #endif } diff --git a/src/io/Mkesfera.cpp b/src/io/Mkesfera.cpp index c374fe6462..82795eb602 100755 --- a/src/io/Mkesfera.cpp +++ b/src/io/Mkesfera.cpp @@ -176,7 +176,7 @@ MkesferaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* idx[2] - startx[2] >= fl_units_local[2] or startx[0] > idx[0] or startx[1] > idx[1] or startx[2] > idx[2]) { Log::global_log->error() << "Error in calculation of start and end values! \n"; - mardyn_exit(0); + MARDYN_EXIT(0); } fill[idx[0] - startx[0]][idx[1] - startx[1]][idx[2] - startx[2]][p] = tfill; if(tfill) { diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index 72defd987a..a91dd73648 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -56,7 +56,7 @@ MmpldWriter::MmpldWriter(uint64_t startTimestep, uint64_t writeFrequency, uint64 _color_type(MMPLD_COLOR_NONE) { if (0 == _writeFrequency) { - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -89,7 +89,7 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) break; default: Log::global_log->error() << "Unsupported MMPLD version:" << _mmpldversion << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); break; } xmlconfig.getNodeValue("outputprefix", _outputPrefix); @@ -102,7 +102,7 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "[MMPLD Writer] Number of sites: " << numSites << std::endl; if(numSites < 1) { Log::global_log->fatal() << "[MMPLD Writer] No site parameters specified." << std::endl; - mardyn_exit(48973); + MARDYN_EXIT(48973); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSiteIter; @@ -144,7 +144,7 @@ void MmpldWriter::init(ParticleContainer *particleContainer, { 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); + MARDYN_EXIT(1); } // only executed once @@ -392,7 +392,7 @@ long MmpldWriter::get_data_frame_header_size() { break; default: Log::global_log->error() << "[MMPLD Writer] Unsupported MMPLD version: " << _mmpldversion << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); break; } return data_frame_header_size; diff --git a/src/io/ObjectGenerator.cpp b/src/io/ObjectGenerator.cpp index c342173c7f..9b07fd0b8c 100644 --- a/src/io/ObjectGenerator.cpp +++ b/src/io/ObjectGenerator.cpp @@ -25,14 +25,14 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { _filler = std::shared_ptr(objectFillerFactory.create(fillerType)); if(!_filler) { Log::global_log->error() << "Object filler could not be created" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->debug() << "Using object filler of type: " << _filler->getPluginName() << std::endl; _filler->readXML(xmlconfig); xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "No filler specified." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(xmlconfig.changecurrentnode("object")) { @@ -49,7 +49,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "No object specified." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if(xmlconfig.changecurrentnode("velocityAssigner")) { @@ -79,7 +79,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { _velocityAssigner = std::make_shared(0, seed); } else { Log::global_log->error() << "Unknown velocity assigner specified." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Ensemble* ensemble = _simulation.getEnsemble(); Log::global_log->info() << "Setting temperature for velocity assigner to " << ensemble->T() << std::endl; diff --git a/src/io/PerCellGenerator.cpp b/src/io/PerCellGenerator.cpp index e0631c6073..9f7a61a93e 100644 --- a/src/io/PerCellGenerator.cpp +++ b/src/io/PerCellGenerator.cpp @@ -43,7 +43,7 @@ void PerCellGenerator::readXML(XMLfileUnits &xmlconfig) { Log::global_log->info() << "numMoleculesPerCell: " << _numMoleculesPerCell << std::endl; } else { Log::global_log->error() << "Missing required field numMoleculesPerCell. Aborting!" << std::endl; - mardyn_exit(1949); + MARDYN_EXIT(1949); } xmlconfig.getNodeValue("initTemperature", _initTemperature); @@ -51,7 +51,7 @@ void PerCellGenerator::readXML(XMLfileUnits &xmlconfig) { Log::global_log->info() << "initTemperature: " << _initTemperature << std::endl; } else { Log::global_log->error() << "Missing required field initTemperature. Aborting!" << std::endl; - mardyn_exit(1949); + MARDYN_EXIT(1949); } xmlconfig.getNodeValue("generateAtLeastTwoParticles", _generateAtLeastTwoParticles); diff --git a/src/io/RDF.cpp b/src/io/RDF.cpp index 732e869024..a33004b0d6 100644 --- a/src/io/RDF.cpp +++ b/src/io/RDF.cpp @@ -34,7 +34,7 @@ RDF::RDF() : void RDF::init() { if(!_readConfig){ Log::global_log->error() << "RDF initialized without reading the configuration, exiting" << std::endl; - mardyn_exit(25); + MARDYN_EXIT(25); } _cellProcessor = new RDFCellProcessor(global_simulation->getcutoffRadius(), this); diff --git a/src/io/ReplicaGenerator.cpp b/src/io/ReplicaGenerator.cpp index 41e7737f3e..de974ed92e 100755 --- a/src/io/ReplicaGenerator.cpp +++ b/src/io/ReplicaGenerator.cpp @@ -58,7 +58,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { if(not inp.changecurrentnode("/mardyn")) { Log::global_log->error() << "Could not find root node /mardyn in XML input file." << std::endl; Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } bool bInputOk = true; @@ -82,7 +82,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { if(not bInputOk) { Log::global_log->error() << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted! Program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if("ICRVQD" == strMoleculeFormat) @@ -93,7 +93,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { _nMoleculeFormat = ICRV; else { Log::global_log->error() << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } @@ -107,7 +107,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceData(SubDomain& subDomain, DomainDec ifs.open(subDomain.strFilePathData.c_str(), std::ios::binary | std::ios::in); if(!ifs.is_open()) { Log::global_log->error() << "Could not open phaseSpaceFile " << subDomain.strFilePathData << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Reading phase space file " << subDomain.strFilePathData << std::endl; @@ -190,7 +190,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } SubDomain sd; @@ -241,7 +241,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Number of components to change: " << (uint32_t) numChanges << std::endl; if(numChanges < 1) { Log::global_log->error() << "No component change defined in XML-config file. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -264,7 +264,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Number of components to change: " << (uint32_t) numChanges << std::endl; if(numChanges < 1) { Log::global_log->error() << "No component change defined in XML-config file. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -532,7 +532,7 @@ ReplicaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* d " != " << (_numParticlesTotal - numAddedParticlesFreespaceGlobal) << " (expected). Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } global_simulation->timers()->stop("REPLICA_GENERATOR_VLE_INPUT"); diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index 543d715593..db02bf84e2 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -15,7 +15,7 @@ void ResultWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << std::endl; if (_writeFrequency <= 0) { Log::global_log->error() << "[ResultWriter] Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - mardyn_exit(123); + MARDYN_EXIT(123); } xmlconfig.getNodeValue("outputprefix", _outputPrefix); diff --git a/src/io/TimerWriter.cpp b/src/io/TimerWriter.cpp index 7521dd92c9..fe1dabcc70 100644 --- a/src/io/TimerWriter.cpp +++ b/src/io/TimerWriter.cpp @@ -35,7 +35,7 @@ void TimerWriter::readXML(XMLfileUnits& xmlconfig) { } if (_timerNames.empty()) { Log::global_log->error() << "TimerWriter: no timers given. make sure you specify them correctly." << std::endl; - mardyn_exit(242367); + MARDYN_EXIT(242367); } xmlconfig.changecurrentnode(oldpath); } diff --git a/src/io/vtk/VTKGridWriter.cpp b/src/io/vtk/VTKGridWriter.cpp index e31a1ede79..8840c90ff2 100644 --- a/src/io/vtk/VTKGridWriter.cpp +++ b/src/io/vtk/VTKGridWriter.cpp @@ -48,7 +48,7 @@ void VTKGridWriter::endStep( #ifndef NDEBUG if (container == NULL) { Log::global_log->error() << "VTKGridWriter works only with plottable LinkedCells!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #endif @@ -114,7 +114,7 @@ void VTKGridWriter::init(ParticleContainer *particleContainer, #ifndef NDEBUG if (dynamic_cast(particleContainer) == NULL) { Log::global_log->error() << "VTKGridWriter works only with LinkCells!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #endif } diff --git a/src/longRange/Homogeneous.cpp b/src/longRange/Homogeneous.cpp index 8e25bfd89a..90afb0fd71 100644 --- a/src/longRange/Homogeneous.cpp +++ b/src/longRange/Homogeneous.cpp @@ -82,7 +82,7 @@ void Homogeneous::init() { double tau2 = sqrt(xj * xj + yj * yj + zj * zj); if (tau1 + tau2 >= _cutoffLJ) { Log::global_log->error() << "Error calculating cutoff corrections, rc too small" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } double eps24; params >> eps24; diff --git a/src/longRange/Planar.cpp b/src/longRange/Planar.cpp index a75a38a8c5..3acd92b7f5 100644 --- a/src/longRange/Planar.cpp +++ b/src/longRange/Planar.cpp @@ -150,7 +150,7 @@ void Planar::init() Log::global_log->info() << "Long Range Correction: Subject registered" << std::endl; } else { Log::global_log->error() << "Long Range Correction: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } } @@ -195,12 +195,12 @@ void Planar::readXML(XMLfileUnits& xmlconfig) if(_nWriteFreqProfiles < 1) { Log::global_log->error() << "Long Range Correction: Write frequency < 1! Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } if(_nStopWritingProfiles <= _nStartWritingProfiles) { Log::global_log->error() << "Long Range Correction: Writing profiles 'stop' <= 'start'! Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } bool bInputIsValid = (bRet1 && bRet2 && bRet3); if(true == bInputIsValid) @@ -212,7 +212,7 @@ void Planar::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "Long Range Correction: Write control parameters not valid! Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } diff --git a/src/molecules/AutoPasSimpleMolecule.cpp b/src/molecules/AutoPasSimpleMolecule.cpp index 49150cd981..988bf472fc 100644 --- a/src/molecules/AutoPasSimpleMolecule.cpp +++ b/src/molecules/AutoPasSimpleMolecule.cpp @@ -20,7 +20,7 @@ AutoPasSimpleMolecule::AutoPasSimpleMolecule(unsigned long id, Component* compon } else if (_component != component and component != nullptr) { Log::global_log->warning() << "AutoPasSimpleMolecule can only handle one component" << std::endl; _component = component; - // mardyn_exit(32); + // MARDYN_EXIT(32); } } diff --git a/src/molecules/Comp2Param.cpp b/src/molecules/Comp2Param.cpp index f32bdb3042..d0427cccf8 100644 --- a/src/molecules/Comp2Param.cpp +++ b/src/molecules/Comp2Param.cpp @@ -59,7 +59,7 @@ void Comp2Param::initialize( [=](double epsi, double epsj) { return xi * sqrt(epsi * epsj); }}; // mixingEpsilon } else { Log::global_log->error() << "Mixing: Only LB rule supported" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); return {}; } }(); diff --git a/src/molecules/Component.cpp b/src/molecules/Component.cpp index fd1506a78b..f55d7b4ff5 100644 --- a/src/molecules/Component.cpp +++ b/src/molecules/Component.cpp @@ -77,10 +77,10 @@ void Component::readXML(XMLfileUnits& xmlconfig) { addQuadrupole(quadrupoleSite); } else if (siteType == "Tersoff") { Log::global_log->error() << "Tersoff no longer supported:" << siteType << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else { Log::global_log->error() << "Unknown site type:" << siteType << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // go back to initial level, to be consistent, even if no site information is found. xmlconfig.changecurrentnode(".."); diff --git a/src/molecules/MoleculeInterface.cpp b/src/molecules/MoleculeInterface.cpp index 4ba56e0dbc..09c48a4793 100644 --- a/src/molecules/MoleculeInterface.cpp +++ b/src/molecules/MoleculeInterface.cpp @@ -31,7 +31,7 @@ bool MoleculeInterface::isLessThan(const MoleculeInterface& m2) const { return false; else { Log::global_log->error() << "LinkedCells::isFirstParticle: both Particles have the same position" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } } diff --git a/src/molecules/mixingrules/MixingRuleBase.cpp b/src/molecules/mixingrules/MixingRuleBase.cpp index f66d45322d..da90c9efc5 100644 --- a/src/molecules/mixingrules/MixingRuleBase.cpp +++ b/src/molecules/mixingrules/MixingRuleBase.cpp @@ -16,10 +16,10 @@ void MixingRuleBase::readXML(const XMLfileUnits& xmlconfig) { // catch invalid inputs if (cid1 == cid2) { Log::global_log->error() << "Mixing rules: cid1 and cid2 must not be the same but are both " << cid1 << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } else if (std::min(cid1, cid2) < 0) { Log::global_log->error() << "Mixing rules: cid1 and cid2 must be greater than zero" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // Symmetry for mixing rules is assumed diff --git a/src/parallel/CollectiveCommunication.h b/src/parallel/CollectiveCommunication.h index 7c390fa0ea..1f42ce5bcc 100644 --- a/src/parallel/CollectiveCommunication.h +++ b/src/parallel/CollectiveCommunication.h @@ -171,7 +171,7 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu break; default: Log::global_log->error()<<"invalid reducetype, aborting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } MPI_CHECK( @@ -193,7 +193,7 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu break; default: Log::global_log->error()<<"invalid reducetype, aborting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } MPI_CHECK(MPI_Allreduce( MPI_IN_PLACE, &_values[i], 1, _types[i], op, _communicator )); } diff --git a/src/parallel/CollectiveCommunicationNonBlocking.h b/src/parallel/CollectiveCommunicationNonBlocking.h index d20e1818b7..774d32ccb9 100644 --- a/src/parallel/CollectiveCommunicationNonBlocking.h +++ b/src/parallel/CollectiveCommunicationNonBlocking.h @@ -41,7 +41,7 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac if (_currentKey != -1) { Log::global_log->error() << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey << " not yet finalized" << std::endl; - mardyn_exit(234); + MARDYN_EXIT(234); } _currentKey = key; @@ -59,7 +59,7 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac if (not inserted) { Log::global_log->error() << "CollectiveCommunicationNonBlocking: key " << _currentKey << " could not be inserted. Aborting!" << std::endl; - mardyn_exit(498789); + MARDYN_EXIT(498789); } } _comms.at(_currentKey).init(communicator, numValues, _currentKey); diff --git a/src/parallel/CommunicationPartner.cpp b/src/parallel/CommunicationPartner.cpp index 90d99e1ded..9d7879d601 100644 --- a/src/parallel/CommunicationPartner.cpp +++ b/src/parallel/CommunicationPartner.cpp @@ -196,7 +196,7 @@ void CommunicationPartner::initSend(ParticleContainer* moleculeContainer, const } default: Log::global_log->error() << "[CommunicationPartner] MessageType unknown!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #ifndef NDEBUG @@ -600,7 +600,7 @@ void CommunicationPartner::collectLeavingMoleculesFromInvalidParticles(std::vect auto shiftAndAdd = [domain, lowCorner, highCorner, shift, this, &numMolsAlreadyIn](Molecule& m) { if (not m.inBox(lowCorner, highCorner)) { Log::global_log->error() << "trying to remove a particle that is not in the halo region" << std::endl; - mardyn_exit(456); + MARDYN_EXIT(456); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompBase.cpp b/src/parallel/DomainDecompBase.cpp index c8bb20978f..f4f39f616a 100644 --- a/src/parallel/DomainDecompBase.cpp +++ b/src/parallel/DomainDecompBase.cpp @@ -232,7 +232,7 @@ void DomainDecompBase::handleDomainLeavingParticlesDirect(const HaloRegion& halo auto shiftAndAdd = [&moleculeContainer, haloRegion, shift](Molecule& m) { if (not m.inBox(haloRegion.rmin, haloRegion.rmax)) { Log::global_log->error() << "trying to remove a particle that is not in the halo region" << std::endl; - mardyn_exit(456); + MARDYN_EXIT(456); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index cde084769c..68c05cde96 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -151,7 +151,7 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else { Log::global_log->error() << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "Using zonal method: " << zonalMethod << std::endl; @@ -167,7 +167,7 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else { Log::global_log->error() << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } diff --git a/src/parallel/DomainDecomposition.cpp b/src/parallel/DomainDecomposition.cpp index 4aa51be05a..542046534c 100644 --- a/src/parallel/DomainDecomposition.cpp +++ b/src/parallel/DomainDecomposition.cpp @@ -28,7 +28,7 @@ void DomainDecomposition::initMPIGridDims() { Log::global_log->error() << "\tbut grid is " << _gridSize[0] << " x " << _gridSize[1] << " x " << _gridSize[2] << std::endl; Log::global_log->error() << "\tresulting in " << numProcsGridSize << " subdomains!" << std::endl; Log::global_log->error() << "\tplease check your input file!" << std::endl; - mardyn_exit(2134); + MARDYN_EXIT(2134); } } @@ -62,7 +62,7 @@ void DomainDecomposition::prepareNonBlockingStage(bool /*forceRebalancing*/, Par Log::global_log->error() << "nonblocking P2P using separate messages for leaving and halo is currently not " "supported. Please use the indirect neighbor communication scheme!" << std::endl; - mardyn_exit(235861); + MARDYN_EXIT(235861); } } @@ -75,7 +75,7 @@ void DomainDecomposition::finishNonBlockingStage(bool /*forceRebalancing*/, Part // Would first need to send leaving, then halo -> not good for overlapping! Log::global_log->error() << "nonblocking P2P using separate messages for leaving and halo is currently not supported." << std::endl; - mardyn_exit(235861); + MARDYN_EXIT(235861); } } diff --git a/src/parallel/ForceHelper.cpp b/src/parallel/ForceHelper.cpp index 86d19a8fff..227717a979 100644 --- a/src/parallel/ForceHelper.cpp +++ b/src/parallel/ForceHelper.cpp @@ -38,7 +38,7 @@ std::variant> addValuesAndGet if (not originalIter.isValid()) { // This should not happen std::cout << "Original molecule not usePreviousIterator"; - mardyn_exit(1); + MARDYN_EXIT(1); } mardyn_assert(originalIter->getID() == haloMolecule.getID()); diff --git a/src/parallel/GeneralDomainDecomposition.cpp b/src/parallel/GeneralDomainDecomposition.cpp index fbae56f0e9..7b28fb4160 100644 --- a/src/parallel/GeneralDomainDecomposition.cpp +++ b/src/parallel/GeneralDomainDecomposition.cpp @@ -59,7 +59,7 @@ void GeneralDomainDecomposition::initializeALL() { gridCoords, minimalDomainSize); #else Log::global_log->error() << "ALL load balancing library not enabled. Aborting." << std::endl; - mardyn_exit(24235); + MARDYN_EXIT(24235); #endif Log::global_log->info() << "GeneralDomainDecomposition initial box: [" << _boxMin[0] << ", " << _boxMax[0] << "] x [" << _boxMin[1] << ", " << _boxMax[1] << "] x [" << _boxMin[2] << ", " << _boxMax[2] << "]" @@ -196,7 +196,7 @@ void GeneralDomainDecomposition::migrateParticles(Domain* domain, ParticleContai << particleContainer->getBoundingBoxMax(2) << "\n" << "Particle: \n" << *iter << std::endl; - mardyn_exit(2315); + MARDYN_EXIT(2315); } } particleContainer->clear(); @@ -290,7 +290,7 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "GeneralDomainDecomposition's gridSize should have three entries if a list is given, but has " << strings.size() << "!" << std::endl; - mardyn_exit(8134); + MARDYN_EXIT(8134); } _gridSize = {std::stod(strings[0]), std::stod(strings[1]), std::stod(strings[2])}; } else { @@ -302,7 +302,7 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "GeneralDomainDecomposition's gridSize (" << gridSize << ") is smaller than the interactionLength (" << _interactionLength << "). This is forbidden, as it leads to errors! " << std::endl; - mardyn_exit(8136); + MARDYN_EXIT(8136); } } } @@ -319,12 +319,12 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->error() << "GeneralDomainDecomposition: Unknown load balancer " << loadBalancerString << ". Aborting! Please select a valid option! Valid options: ALL"; - mardyn_exit(1); + MARDYN_EXIT(1); } _loadBalancer->readXML(xmlconfig); } else { Log::global_log->error() << "loadBalancer section missing! Aborting!" << std::endl; - mardyn_exit(8466); + MARDYN_EXIT(8466); } xmlconfig.changecurrentnode(".."); } diff --git a/src/parallel/KDDecomposition.cpp b/src/parallel/KDDecomposition.cpp index e421d93dd1..c8875717a8 100644 --- a/src/parallel/KDDecomposition.cpp +++ b/src/parallel/KDDecomposition.cpp @@ -68,7 +68,7 @@ void KDDecomposition::init(Domain* domain){ Log::global_log->error() << "KDDecomposition not possible. Each process needs at least " << minCellCountPerProc << " cells." << std::endl; Log::global_log->error() << "The number of Cells is only sufficient for " << _decompTree->getNumMaxProcs() << " Procs!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } _decompTree->buildKDTree(); _ownArea = _decompTree->findAreaForProcess(_rank); @@ -104,7 +104,7 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { << std::endl; if(KDDStaticValues::minNumCellsPerDimension==0u){ Log::global_log->error() << "KDDecomposition minNumCellsPerDimension has to be bigger than zero!" << std::endl; - mardyn_exit(43); + MARDYN_EXIT(43); } xmlconfig.getNodeValue("updateFrequency", _frequency); Log::global_log->info() << "KDDecomposition update frequency: " << _frequency << std::endl; @@ -126,7 +126,7 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { } else { Log::global_log->fatal() << "Wrong deviationReductionOperation given: " << _deviationReductionOperation << ". Should be 'max' or 'sum'." << std::endl; - mardyn_exit(45681); + MARDYN_EXIT(45681); } } Log::global_log->info() << "KDDecomposition uses " << deviationReductionOperation @@ -318,7 +318,7 @@ void KDDecomposition::balanceAndExchange(double lastTraversalTime, bool forceReb if (not migrationSuccessful) { Log::global_log->error() << "A problem occurred during particle migration between old decomposition and new decomposition of the KDDecomposition." << std::endl; Log::global_log->error() << "Aborting. Please save your input files and last available checkpoint and contact TUM SCCS." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } delete _decompTree; _decompTree = newDecompRoot; @@ -555,7 +555,7 @@ bool KDDecomposition::migrateParticles(const KDNode& newRoot, const KDNode& newO void KDDecomposition::fillTimeVecs(CellProcessor **cellProc){ if(cellProc == nullptr){ Log::global_log->error() << "The cellProcessor was not yet set! Please reorder fillTimeVecs, so that there won't be a problem!"; - mardyn_exit(1); + MARDYN_EXIT(1); } auto _tunerLoadCalc = dynamic_cast(_loadCalc); if(_tunerLoadCalc){ @@ -1025,7 +1025,7 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::listerror() << "no processor speeds given" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } double optimalLoad = (_accumulatedProcessorSpeeds[node->_owningProc + node->_numProcs] - _accumulatedProcessorSpeeds[node->_owningProc]) * leftRightLoadRatio / (1. + leftRightLoadRatio); @@ -1088,7 +1088,7 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::list_child2->_numProcs <= 0 || clone->_child2->_numProcs >= node->_numProcs) ){ //continue; Log::global_log->error_always_output() << "ERROR in calculateAllPossibleSubdivisions(), part of the domain was not assigned to a proc" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } mardyn_assert( clone->_child1->isResolvable() && clone->_child2->isResolvable() ); @@ -1248,7 +1248,7 @@ void KDDecomposition::calculateCostsPar(KDNode* area, std::vectorerror() << "[KDDecomposition] zeroCounts too large!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } } @@ -1433,13 +1433,13 @@ void KDDecomposition::calcNumParticlesPerCell(ParticleContainer* moleculeContain std::vector KDDecomposition::getNeighbourRanks() { //global_log->error() << "not implemented \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); return std::vector (0); } std::vector KDDecomposition::getNeighbourRanksFullShell() { //global_log->error() << "not implemented \n"; - mardyn_exit(-1); + MARDYN_EXIT(-1); return std::vector (0); } @@ -1773,7 +1773,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN if (costsLeft[biggestDim].size()<=2){ Log::global_log->error_always_output() << "The domain is far to small!"; - mardyn_exit(1); + MARDYN_EXIT(1); } int startIndex = 1; @@ -1817,7 +1817,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN if ( (unsigned int) (optimalNode->_child1->_numProcs + optimalNode->_child2->_numProcs) > (optimalNode->_child1->getNumMaxProcs() + optimalNode->_child2->getNumMaxProcs())) { Log::global_log->error() << "Domain is not resolvable at all!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } while ( (! optimalNode->_child1->isResolvable()) && optimalNode->_child2->isResolvable()) { @@ -1845,7 +1845,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN (optimalNode->_child2->_numProcs <= 0 || optimalNode->_child2->_numProcs >= node->_numProcs) ){ //continue; Log::global_log->error_always_output() << "ERROR in calculateHeteroSubdivision(), part of the domain was not assigned to a proc" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } mardyn_assert( optimalNode->_child1->isResolvable() && optimalNode->_child2->isResolvable() ); diff --git a/src/parallel/LoadCalc.cpp b/src/parallel/LoadCalc.cpp index abe0c2dc33..e4ac51cab4 100644 --- a/src/parallel/LoadCalc.cpp +++ b/src/parallel/LoadCalc.cpp @@ -46,7 +46,7 @@ std::vector TunerLoad::readVec(std::istream& in, int& count1, int& count Log::global_log->error_always_output() << "This means the files is corrupted. Please remove it (or disallow the tuner to read from inputfiles) before restarting!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } } @@ -148,7 +148,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { if (inStr != "Vectorization Tuner File") { Log::global_log->error() << "The tunerfile is corrupted! Missing header \"Vectorization Tuner File\""; Log::global_log->error() << "Please remove it or fix it before restarting!"; - mardyn_exit(1); + MARDYN_EXIT(1); } int count1; @@ -158,7 +158,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { if (inStr != "own") { Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"own\""; Log::global_log->error() << "Please remove it or fix it before restarting!"; - mardyn_exit(1); + MARDYN_EXIT(1); } auto ownTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -166,7 +166,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { if (inStr != "face") { Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"face\""; Log::global_log->error() << "Please remove it or fix it before restarting!"; - mardyn_exit(1); + MARDYN_EXIT(1); } auto faceTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -174,7 +174,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { if (inStr != "edge") { Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"edge\""; Log::global_log->error() << "Please remove it or fix it before restarting!"; - mardyn_exit(1); + MARDYN_EXIT(1); } auto edgeTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -182,7 +182,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { if (inStr != "corner") { Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"corner\""; Log::global_log->error() << "Please remove it or fix it before restarting!"; - mardyn_exit(1); + MARDYN_EXIT(1); } auto cornerTime = readVec(stream, count1, count2); return TunerLoad { count1, count2, std::move(ownTime), std::move(faceTime), std::move(edgeTime), std::move( diff --git a/src/parallel/NeighbourCommunicationScheme.cpp b/src/parallel/NeighbourCommunicationScheme.cpp index 7eaa8e94ea..02923e0d9b 100644 --- a/src/parallel/NeighbourCommunicationScheme.cpp +++ b/src/parallel/NeighbourCommunicationScheme.cpp @@ -266,7 +266,7 @@ void DirectNeighbourCommunicationScheme::initExchangeMoleculesMPI(ParticleContai neighbour.print(ss); Log::global_log->error_always_output() << ss.str() << std::endl; } - mardyn_exit(544); + MARDYN_EXIT(544); } } @@ -396,7 +396,7 @@ void DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI(ParticleCo }); } - mardyn_exit(457); + MARDYN_EXIT(457); } } // while not allDone @@ -425,7 +425,7 @@ void NeighbourCommunicationScheme::selectNeighbours(MessageType msgType, bool im Log::global_log->error() << "WRONG type in selectNeighbours - this should not be used for push-pull-partners " "selectNeighbours method" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); break; } } @@ -594,7 +594,7 @@ void IndirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI1D(Partic for (int i = 0; i < numNeighbours; ++i) { (*_neighbours)[d][i].deadlockDiagnosticSendRecv(); } - mardyn_exit(457); + MARDYN_EXIT(457); } } // while not allDone diff --git a/src/parallel/ParticleDataRMM.cpp b/src/parallel/ParticleDataRMM.cpp index 9ab4094e93..f3560d881c 100644 --- a/src/parallel/ParticleDataRMM.cpp +++ b/src/parallel/ParticleDataRMM.cpp @@ -30,7 +30,7 @@ void ParticleDataRMM::getMPIType(MPI_Datatype &sendPartType) { types[1] = MPI_FLOAT; } else { Log::global_log->error() << "invalid size of vcp_real_calc"; - mardyn_exit(4852); + MARDYN_EXIT(4852); } //if the following statement is not true, then the 6 double values do not follow one after the other. diff --git a/src/parallel/StaticIrregDomainDecomposition.cpp b/src/parallel/StaticIrregDomainDecomposition.cpp index 16e0ac5901..c067a60181 100644 --- a/src/parallel/StaticIrregDomainDecomposition.cpp +++ b/src/parallel/StaticIrregDomainDecomposition.cpp @@ -74,7 +74,7 @@ void StaticIrregDomainDecomposition::readXML(XMLfileUnits &xmlconfig) { << " axis have a non-natural number! Only integer weights > " "0 allowed, please check XML file!" << std::endl; - mardyn_exit(5003); + MARDYN_EXIT(5003); } _subdomainWeights[i].push_back(temp); if (ss.peek() == ',' || ss.peek() == ' ') // skip commas and spaces diff --git a/src/particleContainer/AutoPasContainer.cpp b/src/particleContainer/AutoPasContainer.cpp index 0a9fa5a8c3..71a914a41f 100644 --- a/src/particleContainer/AutoPasContainer.cpp +++ b/src/particleContainer/AutoPasContainer.cpp @@ -187,7 +187,7 @@ auto parseAutoPasOption(XMLfileUnits &xmlconfig, const std::string &xmlString, Log::global_log->error() << e.what() << std::endl; Log::global_log->error() << "Possible options: " << autopas::utils::ArrayUtils::to_string(OptionType::getAllOptions()) << std::endl; - mardyn_exit(4432); + MARDYN_EXIT(4432); // dummy return return decltype(OptionType::template parseOptions(""))(); } @@ -399,7 +399,7 @@ void AutoPasContainer::update() { "Remaining invalid particles:\n" << autopas::utils::ArrayUtils::to_string(_invalidParticles, "\n", {"", ""}) << std::endl; - mardyn_exit(434); + MARDYN_EXIT(434); } _invalidParticles = _autopasContainer.updateContainer(); diff --git a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h index 0ef15dc14d..1db5cd8e33 100644 --- a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h @@ -79,7 +79,7 @@ void C08CellPairTraversal::traverseCellPairsOuter( CellProcessor& cellProcessor) { if(eighthShell){ Log::global_log->error() << "eightshell + overlapping not yet supported." << std::endl; - mardyn_exit(-2); + MARDYN_EXIT(-2); } using std::array; diff --git a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h index f4428e7c52..1603b5bc47 100644 --- a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h @@ -125,14 +125,14 @@ void NeutralTerritoryTraversal::traverseCellPairs(CellProcessor& c template void NeutralTerritoryTraversal::traverseCellPairsOuter(CellProcessor& cellProcessor) { Log::global_log->error() << "NT: overlapping Comm not implemented." << std::endl; - mardyn_exit(46); + MARDYN_EXIT(46); } template void NeutralTerritoryTraversal::traverseCellPairsInner(CellProcessor& cellProcessor, unsigned stage, unsigned stageCount) { Log::global_log->error() << "NT: overlapping Comm not implemented." << std::endl; - mardyn_exit(47); + MARDYN_EXIT(47); } template diff --git a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h index c54e9045fc..4af4e7c745 100644 --- a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h @@ -75,7 +75,7 @@ void OriginalCellPairTraversal::rebuild(std::vector } } else { Log::global_log->error() << "OriginalCellPairTraversalDat::rebuild was called with incompatible Traversal data!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } diff --git a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h index 0298d0142b..5ce1e2d341 100644 --- a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h @@ -111,7 +111,7 @@ void QuickschedTraversal::init() { Log::global_log->error() << "Blocksize is bigger than number of cells in dimension " << (char) ('x' + i) << ". (" << _taskBlocksize[i] << " > " << this->_dims[i] << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } diff --git a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h index 1d5e484710..9127d11a14 100644 --- a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h @@ -191,7 +191,7 @@ inline void SlicedCellPairTraversal::traverseCellPairsBackend( // Note: in the following we quasi-reimplement an OpenMP for-loop parallelisation with static scheduling if (not isApplicable(start, end) ) { Log::global_log->error() << "The SlicedCellPairTraversal is not applicable. Aborting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } std::array diff; diff --git a/src/particleContainer/LinkedCells.cpp b/src/particleContainer/LinkedCells.cpp index d214872be7..c44ffd32ca 100644 --- a/src/particleContainer/LinkedCells.cpp +++ b/src/particleContainer/LinkedCells.cpp @@ -95,7 +95,7 @@ LinkedCells::LinkedCells(double bBoxMin[3], double bBoxMax[3], Log::global_log->error_always_output() << "_boxWidthInNumCells: " << _boxWidthInNumCells[0] << " / " << _boxWidthInNumCells[1] << " / " << _boxWidthInNumCells[2] << std::endl; - mardyn_exit(5); + MARDYN_EXIT(5); } initializeCells(); @@ -156,7 +156,7 @@ bool LinkedCells::rebuild(double bBoxMin[3], double bBoxMax[3]) { // in each dimension at least one layer of (inner+boundary) cells necessary if (_cellsPerDimension[dim] == 2 * _haloWidthInNumCells[dim]) { Log::global_log->error_always_output() << "LinkedCells::rebuild: region too small" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } numberOfCells *= _cellsPerDimension[dim]; @@ -233,7 +233,7 @@ void LinkedCells::check_molecules_in_box() { << ") x [" << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMax[1] << ") x [" << _haloBoundingBoxMin[2] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; Log::global_log->error() << "Particles will be lost. Aborting simulation." << std::endl; - mardyn_exit(311); + MARDYN_EXIT(311); } } @@ -293,7 +293,7 @@ void LinkedCells::update() { if (numBadMolecules > 0) { Log::global_log->error() << "Found " << numBadMolecules << " outside of their correct cells. Aborting." << std::endl; - mardyn_exit(311); + MARDYN_EXIT(311); } #endif } @@ -543,7 +543,7 @@ void LinkedCells::addParticles(std::vector& particles, bool checkWheth void LinkedCells::traverseNonInnermostCells(CellProcessor& cellProcessor) { if (not _cellsValid) { Log::global_log->error() << "Cell structure in LinkedCells (traverseNonInnermostCells) invalid, call update first" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _traversalTuner->traverseCellPairsOuter(cellProcessor); @@ -552,7 +552,7 @@ void LinkedCells::traverseNonInnermostCells(CellProcessor& cellProcessor) { void LinkedCells::traversePartialInnermostCells(CellProcessor& cellProcessor, unsigned int stage, int stageCount) { if (not _cellsValid) { Log::global_log->error() << "Cell structure in LinkedCells (traversePartialInnermostCells) invalid, call update first" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _traversalTuner->traverseCellPairsInner(cellProcessor, stage, stageCount); @@ -563,7 +563,7 @@ void LinkedCells::traverseCells(CellProcessor& cellProcessor) { Log::global_log->error() << "Cell structure in LinkedCells (traversePairs) invalid, call update first" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } cellProcessor.initTraversal(); @@ -612,7 +612,7 @@ void LinkedCells::deleteOuterParticles() { Log::global_log->error() << "Cell structure in LinkedCells (deleteOuterParticles) invalid, call update first" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); }*/ const size_t numHaloCells = _haloCellIndices.size(); @@ -837,7 +837,7 @@ unsigned long int LinkedCells::getCellIndexOfMolecule(Molecule* molecule) const Log::global_log->error() << "Molecule:\n" << *molecule << std::endl; Log::global_log->error() << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; Log::global_log->error() << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #endif //this version is sensitive to roundoffs, if we have molecules (initialized) precisely at position 0.0: @@ -886,7 +886,7 @@ unsigned long int LinkedCells::getCellIndexOfPoint(const double point[3]) const Log::global_log->error() << "Point p = (" << localPoint[0] << ", " << localPoint[1] << ", " << localPoint[2] << ")" << std::endl; Log::global_log->error() << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; Log::global_log->error() << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #endif @@ -1009,7 +1009,7 @@ void LinkedCells::deleteMolecule(ParticleIterator &moleculeIter, const bool& reb Log::global_log->error_always_output() << "coordinates for atom deletion lie outside bounding box." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _cells[cellid].buildSoACaches(); } diff --git a/src/particleContainer/TraversalTuner.h b/src/particleContainer/TraversalTuner.h index b4f0f27a65..1db3367ba5 100644 --- a/src/particleContainer/TraversalTuner.h +++ b/src/particleContainer/TraversalTuner.h @@ -155,7 +155,7 @@ void TraversalTuner::findOptimalTraversal() { Log::global_log->info() << "Using QuickschedTraversal." << std::endl; #ifndef QUICKSCHED Log::global_log->error() << "MarDyn was compiled without Quicksched Support. Aborting!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); #endif } else if (dynamic_cast *>(_optimalTraversal)) Log::global_log->info() << "Using SlicedCellPairTraversal." << std::endl; @@ -165,7 +165,7 @@ void TraversalTuner::findOptimalTraversal() { if (_cellsInCutoff > _optimalTraversal->maxCellsInCutoff()) { Log::global_log->error() << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; - mardyn_exit(45); + MARDYN_EXIT(45); } } @@ -245,7 +245,7 @@ void TraversalTuner::readXML(XMLfileUnits &xmlconfig) { << " direction is <2 and thereby invalid! (" << quiData->taskBlockSize[j] << ")" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } break; @@ -307,7 +307,7 @@ void TraversalTuner::rebuild(std::vector &cells, con } break; default: Log::global_log->error() << "Unknown traversal data found in TraversalTuner._traversals!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } traversalPointerReference->rebuild(cells, dims, cellLength, cutoff, traversalData); @@ -336,7 +336,7 @@ inline void TraversalTuner::traverseCellPairs(traversalNames name, break; default: Log::global_log->error()<< "Calling traverseCellPairs(traversalName, CellProcessor&) for something else than the Sliced Traversal is disabled for now. Aborting." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); break; } } diff --git a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h index df57c1bf6d..6627e6d0d3 100644 --- a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h +++ b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h @@ -175,7 +175,7 @@ class ParticlePairs2PotForceAdapter : public ParticlePairsHandler { FluidPot(molecule1, molecule2, params, distanceVector, dummy1, dummy2, dummy3, calculateLJ); return dummy1 / 6.0 + dummy2 + dummy3; default: - mardyn_exit(666); + MARDYN_EXIT(666); } return 0.0; } diff --git a/src/plugins/COMaligner.cpp b/src/plugins/COMaligner.cpp index 48f784c59e..51f1d4e63a 100755 --- a/src/plugins/COMaligner.cpp +++ b/src/plugins/COMaligner.cpp @@ -31,7 +31,7 @@ void COMaligner::readXML(XMLfileUnits& xmlconfig){ Log::global_log -> error() << "[COMaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - mardyn_exit(1); + MARDYN_EXIT(1); return; } diff --git a/src/plugins/DirectedPM.cpp b/src/plugins/DirectedPM.cpp index 0c37d09842..b2087794a3 100644 --- a/src/plugins/DirectedPM.cpp +++ b/src/plugins/DirectedPM.cpp @@ -112,7 +112,7 @@ void DirectedPM::beforeForces(ParticleContainer* particleContainer, DomainDecomp Log::global_log->error() << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; Log::global_log->error() << "unID = " << unID << "\n"; - mardyn_exit(707); + MARDYN_EXIT(707); } // ADD VELOCITCY AND VIRIAL TO RESPECTIVE BIN _localnumberOfParticles[unID] += 1.; diff --git a/src/plugins/Dropaccelerator.cpp b/src/plugins/Dropaccelerator.cpp index e0d5d7e4ef..64ec3c87bb 100644 --- a/src/plugins/Dropaccelerator.cpp +++ b/src/plugins/Dropaccelerator.cpp @@ -35,7 +35,7 @@ void Dropaccelerator::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "[Dropaccelerator] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - mardyn_exit(1); + MARDYN_EXIT(1); return; } diff --git a/src/plugins/Dropaligner.cpp b/src/plugins/Dropaligner.cpp index 085add8594..54a1148f73 100644 --- a/src/plugins/Dropaligner.cpp +++ b/src/plugins/Dropaligner.cpp @@ -27,7 +27,7 @@ void Dropaligner::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "[Dropaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - mardyn_exit(1); + MARDYN_EXIT(1); return; } diff --git a/src/plugins/ExamplePlugin.cpp b/src/plugins/ExamplePlugin.cpp index f08e926a30..2d0d7fcc73 100644 --- a/src/plugins/ExamplePlugin.cpp +++ b/src/plugins/ExamplePlugin.cpp @@ -60,7 +60,7 @@ void ExamplePlugin::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "Valid options are: all, beforeEventNewTimestep, beforeForces, afterForces, endStep, init, finish." << std::endl; - mardyn_exit(11); + MARDYN_EXIT(11); } } diff --git a/src/plugins/FixRegion.cpp b/src/plugins/FixRegion.cpp index 1d11c42c70..5907bebf36 100644 --- a/src/plugins/FixRegion.cpp +++ b/src/plugins/FixRegion.cpp @@ -32,7 +32,7 @@ void FixRegion::init(ParticleContainer* particleContainer, DomainDecompBase* dom Log::global_log->error() << "[FixRegion] INVALID INPUT!!! DISABLED!" << std::endl; Log::global_log->error() << "[FixRegion] HALTING SIMULATION" << std::endl; // HALT SIM - mardyn_exit(1); + MARDYN_EXIT(1); return; } diff --git a/src/plugins/MaxCheck.cpp b/src/plugins/MaxCheck.cpp index f61deed1a8..f323dea434 100644 --- a/src/plugins/MaxCheck.cpp +++ b/src/plugins/MaxCheck.cpp @@ -76,7 +76,7 @@ void MaxCheck::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "[MaxCheck] Number of component targets: " << numTargets << std::endl; if (numTargets < 1) { Log::global_log->warning() << "[MaxCheck] No target parameters specified. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/Mirror.cpp b/src/plugins/Mirror.cpp index f13855e1c7..707cee3b8f 100644 --- a/src/plugins/Mirror.cpp +++ b/src/plugins/Mirror.cpp @@ -86,7 +86,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) subject->registerObserver(this); else { Log::global_log->error() << "[Mirror] Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } Log::global_log->info() << "[Mirror] Enabled at position: y = " << _position.coord << std::endl; @@ -125,14 +125,14 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if(MT_ZERO_GRADIENT == _type) { Log::global_log->error() << "[Mirror] Method 3 (MT_ZERO_GRADIENT) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } /** normal distributions */ if(MT_NORMDISTR_MB == _type) { Log::global_log->error() << "[Mirror] Method 4 (MT_NORMDISTR_MB) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } /** Meland2004 */ @@ -143,7 +143,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if(!xmlconfig.getNodeValue("meland/velo_target", _melandParams.velo_target)) { Log::global_log->error() << "[Mirror] Meland: Parameters for method 5 (MT_MELAND_2004) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - mardyn_exit(-2004); + MARDYN_EXIT(-2004); } else { Log::global_log->info() << "[Mirror] Meland: target velocity = " << _melandParams.velo_target << std::endl; @@ -169,12 +169,12 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if (not bRet) { Log::global_log->error() << "[Mirror] Ramping: Parameters for method 5 (MT_RAMPING) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else { if(_rampingParams.startStep > _rampingParams.stopStep) { Log::global_log->error() << "[Mirror] Ramping: Start > Stop. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else { Log::global_log->info() << "[Mirror] Ramping from " << _rampingParams.startStep << " to " << _rampingParams.stopStep << std::endl; @@ -186,7 +186,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) break; default: Log::global_log->error() << "[Mirror] Ramping: No proper treatment was set. Use 0 (Deletion) or 1 (Transmission). Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } Log::global_log->info() << "[Mirror] Ramping: Treatment for non-reflected particles: " << _rampingParams.treatment << " ( " << treatmentStr << " ) " << std::endl; } diff --git a/src/plugins/NEMD/DensityControl.cpp b/src/plugins/NEMD/DensityControl.cpp index 0cd8dd582c..05fe0e2685 100644 --- a/src/plugins/NEMD/DensityControl.cpp +++ b/src/plugins/NEMD/DensityControl.cpp @@ -87,7 +87,7 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << "[DensityControl] Number of component IDs specified in element ..." << " does not match the number of components in the simulation. Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // targets @@ -112,7 +112,7 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "[DensityControl] Number of component targets: " << numTargets << std::endl; if (numTargets < 1) { Log::global_log->error() << "[DensityControl] No target parameters specified. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } const std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/NEMD/DistControl.cpp b/src/plugins/NEMD/DistControl.cpp index 0dff820093..c6bfee8783 100644 --- a/src/plugins/NEMD/DistControl.cpp +++ b/src/plugins/NEMD/DistControl.cpp @@ -80,7 +80,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { Log::global_log->error() << "[DistControl] Missing attribute \"subdivision@type\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } if("number" == strSubdivisionType) { @@ -88,7 +88,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) if( !xmlconfig.getNodeValue("subdivision/number", nNumSlabs) ) { Log::global_log->error() << "[DistControl] Missing element \"subdivision/number\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else this->SetSubdivision(nNumSlabs); @@ -99,7 +99,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) if( !xmlconfig.getNodeValue("subdivision/width", dSlabWidth) ) { Log::global_log->error() << "[DistControl] Missing element \"subdivision/width\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } else this->SetSubdivision(dSlabWidth); @@ -107,7 +107,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "[DistControl] Wrong attribute \"subdivision@type\". Expected: type=\"number|width\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // init method @@ -138,7 +138,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "[DistControl] Missing elements \"init/values/left\" or \"init/values/right\" or both! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else if("file" == strInitMethodType) @@ -155,14 +155,14 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "[DistControl] Missing elements \"init/file\" or \"init/simstep\" or both! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else { Log::global_log->error() << "[DistControl] Wrong attribute \"init@type\", type = " << strInitMethodType << ", " "expected: type=\"startconfig|values|file\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // update method @@ -190,7 +190,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else if("denderiv" == strUpdateMethodType) @@ -214,14 +214,14 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else { Log::global_log->error() << "[DistControl] Wrong attribute \"method@type\", type = " << strUpdateMethodType << ", " "expected: type=\"density|denderiv\"! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -267,7 +267,7 @@ void DistControl::PrepareSubdivision() case SDOPT_UNKNOWN: default: Log::global_log->error() << "[DistControl] PrepareSubdivision(): Neither _binParams.width nor _binParams.count was set correctly! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } _binParams.invWidth = 1. / _binParams.width; @@ -703,7 +703,7 @@ void DistControl::UpdatePositionsInit(ParticleContainer* particleContainer) case DCIM_UNKNOWN: default: Log::global_log->error() << "[DistControl] Wrong Init Method! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } #ifndef NDEBUG @@ -739,7 +739,7 @@ void DistControl::UpdatePositions(const uint64_t& simstep) case DCUM_UNKNOWN: default: Log::global_log->error() << "[DistControl] UpdatePositions() Corrupted code!!! Programm exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // update positions diff --git a/src/plugins/NEMD/MettDeamon.cpp b/src/plugins/NEMD/MettDeamon.cpp index ec9ed8c18d..4ddaaa7e2f 100644 --- a/src/plugins/NEMD/MettDeamon.cpp +++ b/src/plugins/NEMD/MettDeamon.cpp @@ -417,7 +417,7 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "[MettDeamon] Number of fixed molecules components: " << numChanges << std::endl; if(numChanges < 1) { Log::global_log->error() << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -435,7 +435,7 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) } else { Log::global_log->error() << "[MettDeamon] No component changes defined in XML-config file. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -1189,7 +1189,7 @@ void MettDeamon::InsertReservoirSlab(ParticleContainer* particleContainer) _feedrate.feed.sum -= _reservoir->getBinWidth(); // reset feed sum if(not _reservoir->nextBin(_nMaxMoleculeID.global) ) { Log::global_log->error() << "[MettDeamon] Failed to activate new bin of particle Reservoir's BinQueue => Program exit." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } Log::global_log->debug() << "[" << nRank << "]: ADDED " << numAdded.local << "/" << numParticlesCurrentSlab.local << " particles (" << numAdded.local/static_cast(numParticlesCurrentSlab.local)*100 << ")%." << std::endl; // calc global values @@ -1209,7 +1209,7 @@ void MettDeamon::initRestart() if(not bRet) { Log::global_log->info() << "[MettDeamon] Failed to activate reservoir bin after restart! Program exit ... " << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } _feedrate.feed.sum = _restartInfo.dYsum; } @@ -1226,7 +1226,7 @@ void MettDeamon::readNormDistr() //check to see that the file was opened correctly: if (!ifs.vxz.is_open() || !ifs.vy.is_open() ) { std::cerr << "[MettDeamon] There was a problem opening the input file!\n"; - mardyn_exit(-1);//exit or do additional error checking + MARDYN_EXIT(-1);//exit or do additional error checking } double dVal = 0.0; @@ -1240,7 +1240,7 @@ void MettDeamon::readNormDistr() else if (MD_RIGHT_TO_LEFT == _nMovingDirection) _norm.vy.push_back( abs(dVal) * (-1.) ); else - mardyn_exit(-1); + MARDYN_EXIT(-1); } // close files ifs.vxz.close(); @@ -1309,7 +1309,7 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) } else { Log::global_log->error() << "[MettDeamon] Reservoir file type not specified or unknown. Programm exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // Possibly change component IDs @@ -1319,7 +1319,7 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) numChanges = query.card(); if(numChanges < 1) { Log::global_log->error() << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -1348,7 +1348,7 @@ void Reservoir::readParticleData(DomainDecompBase* domainDecomp, ParticleContain break; default: Log::global_log->error() << "[MettDeamon] Unknown (or ambiguous) method to read reservoir for feature MettDeamon. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } // sort particles into bins @@ -1519,7 +1519,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* ifs.open( _filepath.data.c_str() ); if (!ifs.is_open()) { Log::global_log->error() << "[MettDeamon] Could not open Mettdeamon Reservoirfile " << _filepath.data << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "[MettDeamon] Reading Mettdeamon Reservoirfile " << _filepath.data << std::endl; @@ -1548,7 +1548,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* if((token != "NumberOfMolecules") && (token != "N")) { Log::global_log->error() << "[MettDeamon] Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } ifs >> _numMoleculesRead; @@ -1568,7 +1568,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* else if (ntypestring == "IRV") ntype = IRV; else { Log::global_log->error() << "[MettDeamon] Unknown molecule format '" << ntypestring << "'" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } else { ifs.seekg(spos); @@ -1618,7 +1618,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* << componentid << ">" << numcomponents << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. @@ -1647,7 +1647,7 @@ void Reservoir::readFromFileBinaryHeader() if(not inp.changecurrentnode("/mardyn")) { Log::global_log->error() << "[MettDeamon] Could not find root node /mardyn in XML header file or file itself." << std::endl; Log::global_log->fatal() << "[MettDeamon] Not a valid MarDyn XML header file." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } bool bInputOk = true; @@ -1675,7 +1675,7 @@ void Reservoir::readFromFileBinaryHeader() if(not bInputOk) { Log::global_log->error() << "[MettDeamon] Content of file: '" << _filepath.header << "' corrupted! Program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if("ICRVQD" == strMoleculeFormat) @@ -1687,7 +1687,7 @@ void Reservoir::readFromFileBinaryHeader() else { Log::global_log->error() << "[MettDeamon] Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } @@ -1706,7 +1706,7 @@ void Reservoir::readFromFileBinary(DomainDecompBase* domainDecomp, ParticleConta ifs.open(_filepath.data.c_str(), std::ios::binary | std::ios::in); if (!ifs.is_open()) { Log::global_log->error() << "[MettDeamon] Could not open reservoir phaseSpaceFile " << _filepath.data << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "[MettDeamon] Reading phase space file " << _filepath.data << std::endl; diff --git a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp index 62a136d275..3b46c6957d 100644 --- a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp +++ b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp @@ -135,11 +135,11 @@ void MettDeamonFeedrateDirector::beforeForces( // Check if other plugins were found if(nullptr == mirror) { Log::global_log->error() << "[MettDeamonFeedrateDirector] No Mirror plugin found in plugin list. Program exit ..." << std::endl; - mardyn_exit(-2004); + MARDYN_EXIT(-2004); } if(nullptr == mettDeamon) { Log::global_log->error() << "[MettDeamonFeedrateDirector] No MettDeamon plugin found in plugin list. Program exit ..." << std::endl; - mardyn_exit(-2004); + MARDYN_EXIT(-2004); } // Get number of deleted/reflected particles from Mirror plugin diff --git a/src/plugins/NEMD/RegionSampling.cpp b/src/plugins/NEMD/RegionSampling.cpp index 26f7c94062..a1c0ef9b87 100644 --- a/src/plugins/NEMD/RegionSampling.cpp +++ b/src/plugins/NEMD/RegionSampling.cpp @@ -172,7 +172,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) else { Log::global_log->error() << "RegionSampling->region["<GetID()<<"]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -184,7 +184,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "RegionSampling->region["<GetID()-1<<"]: Number of sampling modules: " << numSamplingModules << std::endl; if(numSamplingModules < 1) { Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: No sampling module parameters specified. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } XMLfile::Query::const_iterator outputSamplingIter; @@ -220,7 +220,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<info() << "RegionSampling->region["<GetID()-1<<"]: Number of velocity discretizations: " << numDiscretizations << std::endl; if(numDiscretizations < 1) { Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: No velocity discretizations specified for VDF sampling. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } XMLfile::Query::const_iterator nodeIter; for( nodeIter = query_vd.begin(); nodeIter != query_vd.end(); nodeIter++ ) @@ -307,7 +307,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) bool bVal = xmlconfig.getNodeValue("@cid", cid); if( (cid > _numComponents) || ((not bVal) && (not _boolSingleComp)) ){ Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: VDF velocity discretization corrupted. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } if(_boolSingleComp){ @@ -334,7 +334,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]: Found " << numSubdivisions << " 'subdivision' elements, " "expected: 2. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSubdivisionIter; @@ -474,7 +474,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if(not bInputIsValid) { Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]: Wrong attribute 'sampling@type', expected type='profiles|VDF|fieldYR'! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } // for( outputSamplingIter = query.begin(); outputSamplingIter; outputSamplingIter++ ) } @@ -555,7 +555,7 @@ void SampleRegion::prepareSubdivisionFieldYR() case SDOPT_UNKNOWN: default: Log::global_log->error() << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } dWidth = (this->GetWidth(0) < this->GetWidth(2) ) ? this->GetWidth(0) : this->GetWidth(2); @@ -574,7 +574,7 @@ void SampleRegion::prepareSubdivisionFieldYR() case SDOPT_UNKNOWN: default: Log::global_log->error() << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -2048,7 +2048,7 @@ void RegionSampling::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "RegionSampling: Number of sampling regions: " << numRegions << std::endl; if(numRegions < 1) { Log::global_log->warning() << "RegionSampling: No region parameters specified. Program exit ..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputRegionIter; diff --git a/src/plugins/PluginFactory.cpp b/src/plugins/PluginFactory.cpp index 0927e4b9da..765ae121a9 100644 --- a/src/plugins/PluginFactory.cpp +++ b/src/plugins/PluginFactory.cpp @@ -194,7 +194,7 @@ long PluginFactory::enablePlugins(std::list& _plugins, } else { Log::global_log->error() << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } else if (pluginname == "DomainProfiles") { plugin = this->create("DensityProfileWriter"); diff --git a/src/plugins/SpatialProfile.cpp b/src/plugins/SpatialProfile.cpp index 07ca7397fc..136972aaed 100644 --- a/src/plugins/SpatialProfile.cpp +++ b/src/plugins/SpatialProfile.cpp @@ -46,7 +46,7 @@ void SpatialProfile::readXML(XMLfileUnits& xmlconfig) { samplInfo.cylinder = false; } else { Log::global_log->error() << "[SpatialProfile] Invalid mode. cylinder/cartesian" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } Log::global_log->info() << "[SpatialProfile] Binning units: " << samplInfo.universalProfileUnit[0] << " " @@ -404,7 +404,7 @@ long SpatialProfile::getCylUID(ParticleIterator& thismol) { Log::global_log->error() << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " << phi << ").\n\n"; Log::global_log->error() << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; Log::global_log->error() << "unID = " << unID << "\n"; - mardyn_exit(707); + MARDYN_EXIT(707); } return unID; } diff --git a/src/plugins/VectorizationTuner.cpp b/src/plugins/VectorizationTuner.cpp index 6174b59301..14e726a566 100644 --- a/src/plugins/VectorizationTuner.cpp +++ b/src/plugins/VectorizationTuner.cpp @@ -35,7 +35,7 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { vtWriter.reset(new VTWriter()); } else { Log::global_log->error() << R"(Unknown FlopRateOutputPlugin::mode. Choose "stdout" or "file".)" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _outputPrefix = "mardyn"; @@ -64,7 +64,7 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { Log::global_log->error() << R"(Unknown FlopRateOutputPlugin::moleculecntincreasetype. Choose "linear" or "exponential" or "both".)" << std::endl; - mardyn_exit(798123); + MARDYN_EXIT(798123); } Log::global_log->info() << "Molecule count increase type: " << incTypeStr << std::endl; @@ -283,7 +283,7 @@ void VectorizationTuner::tune(std::vector& componentList, TunerLoad& if(componentList.size() > 2){ Log::global_log->error_always_output() << "The tuner currently supports only two different particle types!" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } int maxMols = particleNums.at(0); diff --git a/src/plugins/WallPotential.cpp b/src/plugins/WallPotential.cpp index 2d9bda387a..b442a1c01c 100755 --- a/src/plugins/WallPotential.cpp +++ b/src/plugins/WallPotential.cpp @@ -40,7 +40,7 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { _potential = LJ9_3; // TODO: is this allowed or should simulation be halted // HALT SIM - //mardyn_exit(1); + //MARDYN_EXIT(1); } XMLfile::Query query = xmlconfig.query("component"); @@ -88,7 +88,7 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { } else{ Log::global_log -> error() << "[WallPotential] UNKNOWN WALL POTENTIAL! EXITING!" << std::endl; - mardyn_exit(11); + MARDYN_EXIT(11); } } diff --git a/src/thermostats/TemperatureControl.cpp b/src/thermostats/TemperatureControl.cpp index d6156f1e17..f80ff6455f 100644 --- a/src/thermostats/TemperatureControl.cpp +++ b/src/thermostats/TemperatureControl.cpp @@ -168,7 +168,7 @@ void ControlRegionT::readXML(XMLfileUnits& xmlconfig) { _nuDt = _nuAndersen * _timestep; } else { Log::global_log->error() << "[TemperatureControl] REGION: Invalid 'method' param: " << methods << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } Log::global_log->info() << "[TemperatureControl] REGION 'method' param: " << methods << std::endl; } @@ -192,7 +192,7 @@ void ControlRegionT::VelocityScalingInit(XMLfileUnits& xmlconfig, std::string st xmlconfig.getNodeValue("settings/numslabs", _nNumSlabs); if (_nNumSlabs < 1) { Log::global_log->fatal() << "TemperatureControl: need at least one slab! (settings/numslabs)"; - mardyn_exit(932); + MARDYN_EXIT(932); } xmlconfig.getNodeValue("settings/exponent", _dTemperatureExponent); xmlconfig.getNodeValue("settings/directions", strDirections); @@ -418,7 +418,7 @@ void ControlRegionT::ControlTemperature(Molecule* mol) { } } else { Log::global_log->error() << "[TemperatureControl] Invalid localMethod param: " << _localMethod << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } @@ -506,7 +506,7 @@ void ControlRegionT::registerAsObserver() { else { Log::global_log->error() << "TemperatureControl->region[" << this->GetID() << "]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } } } diff --git a/src/utils/OptionParser.cpp b/src/utils/OptionParser.cpp index 80e8baa9e2..920308d2c1 100644 --- a/src/utils/OptionParser.cpp +++ b/src/utils/OptionParser.cpp @@ -345,11 +345,11 @@ void OptionParser::process_opt(const Option& o, const std::string& opt, const st } else if (o.action() == "help") { print_help(); - mardyn_exit(0); + MARDYN_EXIT(0); } else if (o.action() == "version") { print_version(); - mardyn_exit(0); + MARDYN_EXIT(0); } else if (o.action() == "callback" && o.callback()) { (*o.callback())(o, opt, value, *this); @@ -437,12 +437,12 @@ void OptionParser::print_version() const { } void OptionParser::exit() const { - mardyn_exit(2); + MARDYN_EXIT(2); } void OptionParser::error(const std::string& msg) const { print_usage(std::cerr); std::cerr << prog() << ": " << _("error") << ": " << msg << std::endl; - mardyn_exit(-4); + MARDYN_EXIT(-4); } ////////// } class OptionParser ////////// diff --git a/src/utils/SigsegvHandler.h b/src/utils/SigsegvHandler.h index f6bcf7c823..0e682df7af 100644 --- a/src/utils/SigsegvHandler.h +++ b/src/utils/SigsegvHandler.h @@ -28,7 +28,7 @@ void handler(int sig) { // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, STDERR_FILENO); - mardyn_exit(1); + MARDYN_EXIT(1); } void registerSigsegvHandler() { diff --git a/src/utils/Testing.cpp b/src/utils/Testing.cpp index 3899af516d..157163dee3 100644 --- a/src/utils/Testing.cpp +++ b/src/utils/Testing.cpp @@ -94,7 +94,7 @@ utils::Test::~Test() { } void utils::Test::setTestDataDirectory(std::string& testDataDir) { if (!fileExists(testDataDir.c_str())) { test_log->error() << "Directory '" << testDataDirectory << "' for test input data does not exist!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } testDataDirectory = testDataDir; } @@ -105,7 +105,7 @@ std::string utils::Test::getTestDataFilename(const std::string& file, bool check if (!fileExists(fullPath.c_str()) and checkExistence) { test_log->error() << "File " << fullPath << " for test input data does not exist!" << std::endl; - mardyn_exit(-1); + MARDYN_EXIT(-1); } return fullPath; } diff --git a/src/utils/generator/ReplicaFiller.cpp b/src/utils/generator/ReplicaFiller.cpp index f4767918cc..d499c22713 100644 --- a/src/utils/generator/ReplicaFiller.cpp +++ b/src/utils/generator/ReplicaFiller.cpp @@ -147,18 +147,18 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { xmlconfig.getNodeValue("@type", inputPluginName); if (inputPluginName != "BinaryReader") { Log::global_log->error() << "[ReplicaFiller] ReplicaFiller only works with inputPlugins: BinaryReader at the moment" << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } setInputReader(std::make_shared()); _inputReader->readXML(xmlconfig); if (_inputReader == nullptr) { Log::global_log->error() << "[ReplicaFiller] Could not create input reader " << inputPluginName << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } xmlconfig.changecurrentnode(".."); } else { Log::global_log->error() << "[ReplicaFiller] Input reader for original not specified." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } if (xmlconfig.changecurrentnode("origin")) { Coordinate3D origin; @@ -177,7 +177,7 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { const size_t numComps = global_simulation->getEnsemble()->getComponents()->size(); if ((componentid < 1) || (componentid > numComps)) { Log::global_log->error() << "[ReplicaFiller] Specified componentid is invalid. Valid range: 1 <= componentid <= " << numComps << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } _componentid = componentid - 1; // Internally stored in array starting at index 0 _keepComponent = false; @@ -206,7 +206,7 @@ void ReplicaFiller::init() { if (numberOfParticles == 0) { Log::global_log->error_always_output() << "[ReplicaFiller] No molecules in replica, aborting! " << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } Log::global_log->info() << "[ReplicaFiller] Setting simulation time to 0.0" << std::endl; diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index fec2f2510c..207fa2f9ee 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -10,20 +10,25 @@ #include "Logger.h" -inline void mardyn_exit(int code) { +// Macro to wrap mardyn_exit and pass the caller function, file and line +#define MARDYN_EXIT(code) mardyn_exit(code, __FUNCTION__, __FILE__, __LINE__) + +inline void mardyn_exit(int code, const char* caller_function, const char* file, int line) { + std::cerr << "Exit with exit code " << code + << " called from function \"" << caller_function + << "\" in file " << file << ":" << line << std::endl; #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode MPI_Abort(MPI_COMM_WORLD, code); #else // call global abort - this stops the debugger at the right spot. - Log::global_log->error_always_output() << "Exit code would have been " << code << std::endl; ::abort(); #endif } inline void __mardyn_assert__(const char * expr, const char* file, int line) { Log::global_log->error_always_output() << "Assertion \"" << expr << "\" failed at " << file << ":" << line << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } #ifdef NDEBUG diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index c781575251..18d5d0eab5 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -195,7 +195,7 @@ bool XMLfile::initfile_local(const std::string& filepath) { if(!fstrm) { std::cerr << "ERROR opening " << filepathTrimmed << std::endl; clear(); - mardyn_exit(1); + MARDYN_EXIT(1); } std::ifstream::pos_type filesize=fstrm.tellg(); fstrm.close(); fstrm.clear(); @@ -540,7 +540,7 @@ template bool XMLfile::Node::getValue(T& value) const if (ss.str().find_first_of("-") != std::string::npos) { std::cerr << "ERROR parsing \"" << ss.str() << "\" to data type " << typeid(T).name() << " from tag \"<" << name() << ">\" in xml file" << std::endl; std::cerr << "The tag contains a negative value but an unsigned value was expected." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } ss >> value; @@ -548,7 +548,7 @@ template bool XMLfile::Node::getValue(T& value) const if (!ss.eof() || ss.fail()) { std::cerr << "ERROR parsing all chars of \"" << ss.str() << "\" from tag \"<" << name() << ">\" in xml file" << std::endl; std::cerr << "This might be the result of using a float while an integer is expected." << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } return true; } @@ -584,7 +584,7 @@ template<> bool XMLfile::Node::getValue(bool& value) const } else { std::cerr << "ERROR parsing \"" << v << "\" to boolean from tag \"" << name() << "\" in xml file." << " Valid values are: true, false, yes, no, on, off. " << std::endl; - mardyn_exit(1); + MARDYN_EXIT(1); } } return found; From d98cb7df10d942c1857f0a134a3422d9912fa1a3 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 4 Oct 2024 09:59:42 +0200 Subject: [PATCH 14/28] Prepare mardyn_exit to receive error message --- src/utils/mardyn_assert.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index 207fa2f9ee..b83db41b6f 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -8,15 +8,20 @@ #ifndef SRC_UTILS_MARDYN_ASSERT_H_ #define SRC_UTILS_MARDYN_ASSERT_H_ +#include +#include + #include "Logger.h" -// Macro to wrap mardyn_exit and pass the caller function, file and line -#define MARDYN_EXIT(code) mardyn_exit(code, __FUNCTION__, __FILE__, __LINE__) +// Macro to wrap mardyn_exit and pass the caller file and line +#define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __FILE__, __LINE__) -inline void mardyn_exit(int code, const char* caller_function, const char* file, int line) { - std::cerr << "Exit with exit code " << code - << " called from function \"" << caller_function - << "\" in file " << file << ":" << line << std::endl; +inline void mardyn_exit(const std::ostringstream & exit_message, + const char* file, const int line) { + Log::global_log->error_always_output() + << "Exit called in file `" << file << ":" << line << "`" << std::endl; + Log::global_log->error_always_output() + << exit_message << std::endl; #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode MPI_Abort(MPI_COMM_WORLD, code); @@ -27,8 +32,9 @@ inline void mardyn_exit(int code, const char* caller_function, const char* file, } inline void __mardyn_assert__(const char * expr, const char* file, int line) { - Log::global_log->error_always_output() << "Assertion \"" << expr << "\" failed at " << file << ":" << line << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Assertion \"" << expr << "\" failed at " << file << ":" << line << std::endl; + MARDYN_EXIT(error_message); } #ifdef NDEBUG From de95eaace2959318b7a9d4b3df4a3c5d44f205f5 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 4 Oct 2024 12:52:08 +0200 Subject: [PATCH 15/28] Preparations in mardyn_exit --- src/utils/mardyn_assert.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index b83db41b6f..be5007889c 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -10,6 +10,8 @@ #include #include +#include +#include #include "Logger.h" @@ -17,14 +19,15 @@ #define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __FILE__, __LINE__) inline void mardyn_exit(const std::ostringstream & exit_message, - const char* file, const int line) { - Log::global_log->error_always_output() - << "Exit called in file `" << file << ":" << line << "`" << std::endl; - Log::global_log->error_always_output() - << exit_message << std::endl; + const char* file, const int line, const int exit_code=EXIT_FAILURE) { + if (exit_code == EXIT_FAILURE) { + Log::global_log->error_always_output() + << "Exit called in file `" << file << ":" << line << "` with message:" << std::endl; + std::cerr << exit_message.str() << std::endl; + } #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode - MPI_Abort(MPI_COMM_WORLD, code); + MPI_Abort(MPI_COMM_WORLD, exit_code); #else // call global abort - this stops the debugger at the right spot. ::abort(); From 12a8e321ac3786f9e5376955c5faab898e06f066 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 4 Oct 2024 12:53:08 +0200 Subject: [PATCH 16/28] Use error messages instead of error codes --- src/Domain.cpp | 15 +- src/MarDyn.cpp | 10 +- src/Simulation.cpp | 215 +++++++++++------- src/bhfmm/FastMultipoleMethod.cpp | 17 +- .../UniformPseudoParticleContainer.cpp | 16 +- ...PseudoParticleContainer_old_Wigner_cpp.txt | 10 +- src/ensemble/CanonicalEnsemble.cpp | 5 +- src/ensemble/CavityEnsemble.cpp | 25 +- src/ensemble/ChemicalPotential.cpp | 15 +- src/ensemble/EnsembleBase.cpp | 34 +-- src/ensemble/GrandCanonicalEnsemble.h | 10 +- src/ensemble/PressureGradient.cpp | 5 +- src/io/ASCIIReader.cpp | 45 ++-- src/io/Adios2Reader.cpp | 31 ++- src/io/Adios2Writer.cpp | 37 +-- src/io/BinaryReader.cpp | 43 ++-- src/io/CavityWriter.cpp | 35 +-- src/io/CheckpointWriter.cpp | 10 +- src/io/CommunicationPartnerWriter.cpp | 5 +- src/io/CubicGridGeneratorInternal.cpp | 22 +- src/io/FlopRateWriter.cpp | 9 +- src/io/FlopRateWriter.h | 1 + src/io/HaloParticleWriter.cpp | 5 +- src/io/KDTreePrinter.cpp | 5 +- src/io/MPI_IOCheckpointWriter.cpp | 5 +- src/io/MPI_IOReader.cpp | 30 +-- src/io/Mkesfera.cpp | 5 +- src/io/MmpldWriter.cpp | 24 +- src/io/ObjectGenerator.cpp | 25 +- src/io/PerCellGenerator.cpp | 10 +- src/io/RDF.cpp | 17 +- src/io/ReplicaGenerator.cpp | 46 ++-- src/io/ResultWriter.cpp | 5 +- src/io/TimerProfiler.cpp | 6 +- src/io/TimerWriter.cpp | 5 +- src/io/vtk/VTKGridWriter.cpp | 14 +- src/io/vtk/VTKMoleculeWriter.cpp | 4 +- src/longRange/Homogeneous.cpp | 5 +- src/longRange/Planar.cpp | 20 +- src/molecules/AutoPasSimpleMolecule.cpp | 2 +- src/molecules/Comp2Param.cpp | 5 +- src/molecules/Component.cpp | 10 +- src/molecules/MoleculeInterface.cpp | 5 +- src/molecules/mixingrules/MixingRuleBase.cpp | 10 +- src/parallel/CollectiveCommunication.h | 10 +- .../CollectiveCommunicationNonBlocking.h | 10 +- src/parallel/CommunicationPartner.cpp | 10 +- src/parallel/DomainDecompBase.cpp | 5 +- src/parallel/DomainDecompMPIBase.cpp | 12 +- src/parallel/DomainDecomposition.cpp | 26 ++- src/parallel/ForceHelper.cpp | 6 +- src/parallel/GeneralDomainDecomposition.cpp | 31 ++- src/parallel/KDDecomposition.cpp | 71 +++--- src/parallel/LoadCalc.cpp | 64 +++--- src/parallel/NeighbourCommunicationScheme.cpp | 28 ++- src/parallel/ParticleDataRMM.cpp | 5 +- .../StaticIrregDomainDecomposition.cpp | 5 +- src/particleContainer/AutoPasContainer.cpp | 19 +- .../C08CellPairTraversal.h | 5 +- .../NeutralTerritoryTraversal.h | 10 +- .../OriginalCellPairTraversal.h | 5 +- .../QuickschedTraversal.h | 8 +- .../SlicedCellPairTraversal.h | 5 +- src/particleContainer/LinkedCells.cpp | 98 ++++---- src/particleContainer/TraversalTuner.h | 25 +- .../adapter/ParticlePairs2PotForceAdapter.h | 4 +- src/plugins/COMaligner.cpp | 11 +- src/plugins/DirectedPM.cpp | 15 +- src/plugins/Dropaccelerator.cpp | 7 +- src/plugins/Dropaligner.cpp | 7 +- src/plugins/ExamplePlugin.cpp | 10 +- src/plugins/FixRegion.cpp | 7 +- src/plugins/MaxCheck.cpp | 6 +- src/plugins/Mirror.cpp | 35 +-- src/plugins/NEMD/DensityControl.cpp | 10 +- src/plugins/NEMD/DistControl.cpp | 69 +++--- src/plugins/NEMD/MettDeamon.cpp | 117 ++++++---- .../NEMD/MettDeamonFeedrateDirector.cpp | 10 +- src/plugins/NEMD/RegionSampling.cpp | 110 +++++---- src/plugins/Permittivity.cpp | 7 +- src/plugins/PluginFactory.cpp | 5 +- src/plugins/SpatialProfile.cpp | 20 +- src/plugins/VectorizationTuner.cpp | 15 +- src/plugins/WallPotential.cpp | 9 +- src/plugins/profiles/ProfileBase.cpp | 7 +- src/thermostats/TemperatureControl.cpp | 20 +- src/utils/OptionParser.cpp | 16 +- src/utils/SigsegvHandler.h | 2 +- src/utils/Testing.cpp | 4 +- src/utils/generator/ReplicaFiller.cpp | 25 +- src/utils/xmlfile.cpp | 24 +- 91 files changed, 1120 insertions(+), 788 deletions(-) diff --git a/src/Domain.cpp b/src/Domain.cpp index 771a03e34f..9b5d82df56 100644 --- a/src/Domain.cpp +++ b/src/Domain.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -93,7 +94,9 @@ void Domain::readXML(XMLfileUnits& xmlconfig) { << _globalLength[2] << std::endl; } else { - Log::global_log->error() << "Unsupported volume type " << type << std::endl; + std::ostringstream error_message; + error_message << "Unsupported volume type " << type << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode(".."); } @@ -552,8 +555,9 @@ void Domain::writeCheckpointHeader(std::string filename, mixingss << "\t"; } } else { - Log::global_log->error() << "Only LB mixing rule supported" << std::endl; - MARDYN_EXIT(123); + std::ostringstream error_message; + error_message << "Only LB mixing rule supported" << std::endl; + MARDYN_EXIT(error_message); } } } @@ -710,8 +714,9 @@ void Domain::enableComponentwiseThermostat() void Domain::setComponentThermostat(int cid, int thermostat) { if ((0 > cid) || (0 >= thermostat)) { - Log::global_log->error() << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl; - MARDYN_EXIT(787); + std::ostringstream error_message; + error_message << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl; + MARDYN_EXIT(error_message); } this->_componentToThermostatIdMap[cid] = thermostat; this->_universalThermostatN[thermostat] = 0; diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index dcaa224a84..2854232198 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -192,9 +192,10 @@ int main(int argc, char** argv) { auto numArgs = args.size(); if(numArgs != 1) { - Log::global_log->error() << "Incorrect number of arguments provided." << std::endl; op.print_usage(); - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Incorrect number of arguments provided." << std::endl; + MARDYN_EXIT(error_message); } /* First read the given config file if it exists, then overwrite parameters with command line arguments. */ std::string configFileName(args[0]); @@ -202,8 +203,9 @@ int main(int argc, char** argv) { Log::global_log->info() << "Config file: " << configFileName << std::endl; simulation.readConfigFile(configFileName); } else { - Log::global_log->error() << "Cannot open config file '" << configFileName << "'" << std::endl; - MARDYN_EXIT(-2); + std::ostringstream error_message; + error_message << "Cannot open config file '" << configFileName << "'" << std::endl; + MARDYN_EXIT(error_message); } /* processing command line arguments */ diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 66df7634c6..a13ce6202c 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -72,6 +72,7 @@ #include "utils/FileUtils.h" #include "utils/Logger.h" +#include "utils/mardyn_assert.h" #include "longRange/LongRangeCorrection.h" #include "longRange/Homogeneous.h" @@ -171,21 +172,25 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Integrator type: " << integratorType << std::endl; if(integratorType == "Leapfrog") { #ifdef ENABLE_REDUCED_MEMORY_MODE - Log::global_log->error() << "The reduced memory mode (RMM) requires the LeapfrogRMM integrator." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "The reduced memory mode (RMM) requires the LeapfrogRMM integrator." << std::endl; + MARDYN_EXIT(error_message); #endif _integrator = new Leapfrog(); } else if (integratorType == "LeapfrogRMM") { _integrator = new LeapfrogRMM(); } else { - Log::global_log-> error() << "Unknown integrator " << integratorType << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown integrator " << integratorType << std::endl; + MARDYN_EXIT(error_message); } _integrator->readXML(xmlconfig); _integrator->init(); xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Integrator section missing." << std::endl; + std::ostringstream error_message; + error_message << "Integrator section missing." << std::endl; + MARDYN_EXIT(error_message); } /* run section */ @@ -205,7 +210,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Run section missing." << std::endl; + std::ostringstream error_message; + error_message << "Run section missing." << std::endl; + MARDYN_EXIT(error_message); } /* ensemble */ @@ -221,8 +228,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { /* TODO: GrandCanonical terminates as readXML is not implemented and it is not tested yet. */ _ensemble = new GrandCanonicalEnsemble(); } else { - Log::global_log->error() << "Unknown ensemble type: " << ensembletype << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown ensemble type: " << ensembletype << std::endl; + MARDYN_EXIT(error_message); } _ensemble->readXML(xmlconfig); /** @todo Here we store data in the _domain member as long as we do not use the ensemble everywhere */ @@ -234,8 +242,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Ensemble section missing." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Ensemble section missing." << std::endl; + MARDYN_EXIT(error_message); } /* algorithm */ @@ -255,14 +264,16 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { * maybe use map/list to store cutoffs for different potentials? */ _cutoffRadius = std::max(_cutoffRadius, _LJCutoffRadius); if(_cutoffRadius <= 0) { - Log::global_log->error() << "cutoff radius <= 0." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "cutoff radius <= 0." << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "dimensionless cutoff radius:\t" << _cutoffRadius << std::endl; xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Cutoff section missing." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cutoff section missing." << std::endl; + MARDYN_EXIT(error_message); } /* electrostatics */ @@ -274,16 +285,17 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _domain->setepsilonRF(epsilonRF); xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Electrostatics section for reaction field setup missing." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Electrostatics section for reaction field setup missing." << std::endl; + MARDYN_EXIT(error_message); } if (xmlconfig.changecurrentnode("electrostatic[@type='FastMultipoleMethod']")) { #ifdef MARDYN_AUTOPAS - Log::global_log->fatal() - << "The fast multipole method is not compatible with AutoPas. Please disable the AutoPas mode (ENABLE_AUTOPAS)!" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The fast multipole method is not compatible with AutoPas. " + << "Please disable the AutoPas mode (ENABLE_AUTOPAS)!" << std::endl; + MARDYN_EXIT(error_message); #endif _FMM = new bhfmm::FastMultipoleMethod(); _FMM->readXML(xmlconfig); @@ -337,12 +349,13 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { if (datastructuretype == "AutoPas" or datastructuretype == "AutoPasContainer") { // check if skin is specified if (xmlconfig.getNodeValue("skin", skin) == 0) { - Log::global_log->error() << "Skin not set in datastructure/AutoPas. " + std::ostringstream error_message; + error_message << "Skin not set in datastructure/AutoPas. " "This will lead to a different interaction length in the container " "vs the GeneralDomainDecomposition which can lead ALL to shrink the " "domain too small." << std::endl; - MARDYN_EXIT(512435340); + MARDYN_EXIT(error_message); } } else { Log::global_log->warning() << "Using the GeneralDomainDecomposition without AutoPas is not " @@ -357,18 +370,21 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } Log::global_log->info() << "Using skin = " << skin << " for the GeneralDomainDecomposition." << std::endl; } else { - Log::global_log->error() << "Datastructure section missing" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Datastructure section missing" << std::endl; + MARDYN_EXIT(error_message); } if(not xmlconfig.changecurrentnode("../parallelisation")){ - Log::global_log->error() << "Could not go back to parallelisation path. Aborting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Could not go back to parallelisation path. Aborting." << std::endl; + MARDYN_EXIT(error_message); } delete _domainDecomposition; _domainDecomposition = new GeneralDomainDecomposition(getcutoffRadius() + skin, _domain, forceLatchingToLinkedCellsGrid); } else { - Log::global_log->error() << "Unknown parallelisation type: " << parallelisationtype << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown parallelisation type: " << parallelisationtype << std::endl; + MARDYN_EXIT(error_message); } #else /* serial */ if(parallelisationtype != "DummyDecomposition") { @@ -376,7 +392,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { << "Executable was compiled without support for parallel execution: " << parallelisationtype << " not available. Using serial mode." << std::endl; - //MARDYN_EXIT(1); + //MARDYN_EXIT(error_message); } //_domainDecomposition = new DomainDecompBase(); // already set in initialize() #endif @@ -392,9 +408,10 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Using timer " << loadTimerStr << " for the load calculation." << std::endl; _timerForLoad = timers()->getTimer(loadTimerStr); if (not _timerForLoad) { - Log::global_log->error() << "'timerForLoad' set to a timer that does not exist('" << loadTimerStr + std::ostringstream error_message; + error_message << "'timerForLoad' set to a timer that does not exist('" << loadTimerStr << "')! Aborting!" << std::endl; - exit(1); + MARDYN_EXIT(error_message); } std::size_t timerForLoadAveragingLength{1ul}; @@ -402,8 +419,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Averaging over " << timerForLoadAveragingLength << "time steps for the load calculation." << std::endl; if(timerForLoadAveragingLength < 1ul) { - Log::global_log->fatal() << "timerForLoadAveragingLength has to be at least 1" << std::endl; - MARDYN_EXIT(15843); + std::ostringstream error_message; + error_message << "timerForLoadAveragingLength has to be at least 1" << std::endl; + MARDYN_EXIT(error_message); } _lastTraversalTimeHistory.setCapacity(timerForLoadAveragingLength); @@ -411,8 +429,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { #ifdef ENABLE_MPI - Log::global_log->error() << "Parallelisation section missing." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Parallelisation section missing." << std::endl; + MARDYN_EXIT(error_message); #else /* serial */ // set _timerForLoad, s.t. it always exists. _timerForLoad = timers()->getTimer("SIMULATION_COMPUTATION"); @@ -427,10 +446,11 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Datastructure type: " << datastructuretype << std::endl; if(datastructuretype == "LinkedCells") { #ifdef MARDYN_AUTOPAS - Log::global_log->fatal() + std::ostringstream error_message; + error_message << "LinkedCells not compiled (use AutoPas instead, or compile with disabled autopas mode)!" << std::endl; - MARDYN_EXIT(33); + MARDYN_EXIT(error_message); #else _moleculeContainer = new LinkedCells(); /** @todo Review if we need to know the max cutoff radius usable with any datastructure. */ @@ -438,21 +458,24 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _moleculeContainer->setCutoff(_cutoffRadius); #endif } else if(datastructuretype == "AdaptiveSubCells") { - Log::global_log->warning() << "AdaptiveSubCells no longer supported." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "AdaptiveSubCells no longer supported." << std::endl; + MARDYN_EXIT(error_message); } else if(datastructuretype == "AutoPas" || datastructuretype == "AutoPasContainer") { #ifdef MARDYN_AUTOPAS Log::global_log->info() << "Using AutoPas container." << std::endl; _moleculeContainer = new AutoPasContainer(_cutoffRadius); Log::global_log->info() << "Setting cell cutoff radius for AutoPas container to " << _cutoffRadius << std::endl; #else - Log::global_log->fatal() << "AutoPas not compiled (use LinkedCells instead, or compile with enabled autopas mode)!" << std::endl; - MARDYN_EXIT(33); + std::ostringstream error_message; + error_message << "AutoPas not compiled (use LinkedCells instead, or compile with enabled autopas mode)!" << std::endl; + MARDYN_EXIT(error_message); #endif } else { - Log::global_log->error() << "Unknown data structure type: " << datastructuretype << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown data structure type: " << datastructuretype << std::endl; + MARDYN_EXIT(error_message); } _moleculeContainer->readXML(xmlconfig); @@ -463,8 +486,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _domainDecomposition->updateSendLeavingWithCopies(sendTogether); xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "Datastructure section missing" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Datastructure section missing" << std::endl; + MARDYN_EXIT(error_message); } // TODO: move parts to readXML in TemperatureControl? @@ -506,9 +530,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _temperatureControl = new TemperatureControl(); _temperatureControl->readXML(xmlconfig); } else { - Log::global_log->error() << "Instance of TemperatureControl allready exist! Programm exit ..." - << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Instance of TemperatureControl already exist!" << std::endl; + MARDYN_EXIT(error_message); } } else @@ -530,8 +554,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { std::string type; if( !xmlconfig.getNodeValue("@type", type) ) { - Log::global_log->error() << "LongRangeCorrection: Missing type specification. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "LongRangeCorrection: Missing type specification. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } if("planar" == type) { @@ -554,8 +579,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { - Log::global_log->error() << "LongRangeCorrection: Wrong type. Expected type == homogeneous|planar|none. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "LongRangeCorrection: Wrong type. Expected type == homogeneous|planar|none. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode(".."); } else { @@ -567,7 +593,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(".."); /* algorithm section */ } else { - Log::global_log->error() << "Algorithm section missing." << std::endl; + std::ostringstream error_message; + error_message << "Algorithm section missing." << std::endl; + MARDYN_EXIT(error_message); } Log::global_log -> info() << "Registering default plugins..." << std::endl; @@ -620,8 +648,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } #endif else { - Log::global_log->error() << "Unknown phase space file type" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Unknown phase space file type" << std::endl; + MARDYN_EXIT(error_message); } } xmlconfig.changecurrentnode(oldpath); @@ -650,8 +679,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { _inputReader = new PerCellGenerator(); } else { - Log::global_log->error() << "Unknown generator: " << generatorName << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown generator: " << generatorName << std::endl; + MARDYN_EXIT(error_message); } _inputReader->readXML(xmlconfig); } @@ -685,8 +715,9 @@ void Simulation::readConfigFile(std::string filename) { initConfigXML(filename); } else { - Log::global_log->error() << "Unknown config file extension '" << extension << "'." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown config file extension '" << extension << "'." << std::endl; + MARDYN_EXIT(error_message); } } @@ -699,9 +730,10 @@ void Simulation::initConfigXML(const std::string& inputfilename) { Log::global_log->debug() << "Input XML:" << std::endl << std::string(inp) << std::endl; if(inp.changecurrentnode("/mardyn") < 0) { - Log::global_log->error() << "Cound not find root node /mardyn in XML input file." << std::endl; - Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cound not find root node /mardyn in XML input file." << std::endl; + error_message << "Not a valid MarDyn XML input file." << std::endl; + MARDYN_EXIT(error_message); } std::string version("unknown"); @@ -715,8 +747,9 @@ void Simulation::initConfigXML(const std::string& inputfilename) { inp.changecurrentnode(".."); } // simulation-section else { - Log::global_log->error() << "Simulation section missing" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Simulation section missing" << std::endl; + MARDYN_EXIT(error_message); } parseMiscOptions(inp); @@ -727,9 +760,10 @@ void Simulation::initConfigXML(const std::string& inputfilename) { } } catch (const std::exception& e) { - Log::global_log->error() << "Error in XML config. Please check your input file!" << std::endl; - Log::global_log->error() << "Exception: " << e.what() << std::endl; - MARDYN_EXIT(7); + std::ostringstream error_message; + error_message << "Error in XML config. Please check your input file!" << std::endl; + error_message << "Exception: " << e.what() << std::endl; + MARDYN_EXIT(error_message); } #ifdef ENABLE_MPI @@ -854,8 +888,9 @@ void Simulation::prepare_start() { Log::global_log->info() << "Initializing LongRangeCorrection" << std::endl; _longRangeCorrection->init(); } else { - Log::global_log->fatal() << "No _longRangeCorrection set!" << std::endl; - MARDYN_EXIT(93742); + std::ostringstream error_message; + error_message << "No _longRangeCorrection set!" << std::endl; + MARDYN_EXIT(error_message); } // longRangeCorrection is a site-wise force plugin, so we have to call it before updateForces() _longRangeCorrection->calculateLongRange(); @@ -948,9 +983,12 @@ void Simulation::preSimLoopSteps() //sanity checks if(preSimLoopStepsDone || simulationDone || postSimLoopStepsDone) { - Log::global_log->error() << "Unexpected call to preSimLoopSteps()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << - ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unexpected call to preSimLoopSteps()! " + << "Status: (pre sim loop steps done:" << preSimLoopStepsDone + << ", simulation done: " << simulationDone + << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; + MARDYN_EXIT(error_message); } @@ -1010,9 +1048,12 @@ void Simulation::simulateOneTimestep() //sanity checks if(!preSimLoopStepsDone || simulationDone || postSimLoopStepsDone) { - Log::global_log->error() << "Unexpected call to simulateOneTimeStep()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << - ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unexpected call to simulateOneTimeStep()! " + << "Status: (pre sim loop steps done:" << preSimLoopStepsDone + << ", simulation done: " << simulationDone + << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; + MARDYN_EXIT(error_message); } #ifdef MAMICO_COUPLING @@ -1241,9 +1282,12 @@ void Simulation::postSimLoopSteps() //sanity checks if(!preSimLoopStepsDone || !simulationDone || postSimLoopStepsDone) { - Log::global_log->error() << "Unexpected call to postSimLoopSteps()! Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << - ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unexpected call to postSimLoopSteps()! " + << "Status: (pre sim loop steps done:" << preSimLoopStepsDone + << ", simulation done: " << simulationDone + << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; + MARDYN_EXIT(error_message); } @@ -1307,8 +1351,9 @@ void Simulation::pluginEndStepCall(unsigned long simstep) { << _domain->getGlobalUpot() << "\tp = " << _domain->getGlobalPressure() << std::endl; if (std::isnan(_domain->getGlobalCurrentTemperature()) || std::isnan(_domain->getGlobalUpot()) || std::isnan(_domain->getGlobalPressure())) { - Log::global_log->error() << "NaN detected, exiting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "NaN detected, exiting." << std::endl; + MARDYN_EXIT(error_message); } } @@ -1377,8 +1422,9 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim #ifdef ENABLE_MPI auto* dd = dynamic_cast(_domainDecomposition); if (not dd) { - Log::global_log->fatal() << "DomainDecompMPIBase* required for overlapping comm, but dynamic_cast failed." << std::endl; - MARDYN_EXIT(873456); + std::ostringstream error_message; + error_message << "DomainDecompMPIBase* required for overlapping comm, but dynamic_cast failed." << std::endl; + MARDYN_EXIT(error_message); } NonBlockingMPIMultiStepHandler nonBlockingMPIHandler {dd, _moleculeContainer, _domain, _cellProcessor}; @@ -1386,8 +1432,9 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim nonBlockingMPIHandler.performOverlappingTasks(forceRebalancing, etime); #else - Log::global_log->fatal() << "performOverlappingDecompositionAndCellTraversalStep() called with disabled MPI." << std::endl; - MARDYN_EXIT(873457); + std::ostringstream error_message; + error_message << "performOverlappingDecompositionAndCellTraversalStep() called with disabled MPI." << std::endl; + MARDYN_EXIT(error_message); #endif } diff --git a/src/bhfmm/FastMultipoleMethod.cpp b/src/bhfmm/FastMultipoleMethod.cpp index 41ffb07d94..5d2c60fa1c 100644 --- a/src/bhfmm/FastMultipoleMethod.cpp +++ b/src/bhfmm/FastMultipoleMethod.cpp @@ -67,10 +67,11 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], and _LJCellSubdivisionFactor != 2 and _LJCellSubdivisionFactor != 4 and _LJCellSubdivisionFactor != 8) { - Log::global_log->error() << "Fast Multipole Method: bad subdivision factor:" + std::ostringstream error_message; + error_message << "Fast Multipole Method: bad subdivision factor:" << _LJCellSubdivisionFactor << std::endl; - Log::global_log->error() << "expected 1,2,4 or 8" << std::endl; - MARDYN_EXIT(5); + error_message << "expected 1,2,4 or 8" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Fast Multipole Method: each LJ cell will be subdivided in " @@ -107,8 +108,9 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], } else { // TODO: Debugging in Progress! #if defined(ENABLE_MPI) - Log::global_log->error() << "MPI in combination with adaptive is not supported yet" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "MPI in combination with adaptive is not supported yet" << std::endl; + MARDYN_EXIT(error_message); #endif //int threshold = 100; _pseudoParticleContainer = new AdaptivePseudoParticleContainer( @@ -313,8 +315,9 @@ void FastMultipoleMethod::runner(int type, void *data) { #else #pragma omp critical { - Log::global_log->error() << "Quicksched runner without FMM_FFT not implemented!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Quicksched runner without FMM_FFT not implemented!" << std::endl; + MARDYN_EXIT(error_message); } #endif /* FMM_FFT */ } diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index 69808b98b5..5947762c51 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -14,6 +14,7 @@ #include "bhfmm/HaloBufferNoOverlap.h" #include "bhfmm/HaloBufferOverlap.h" #include +#include #include #include #ifdef _OPENMP @@ -111,8 +112,9 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _comm = domainDecomp.getCommunicator(); #endif #if WIGNER == 1 - //global_log->error() << "not supported yet" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "WIGNER not supported yet" << std::endl; + MARDYN_EXIT(error_message); #endif #ifdef ENABLE_MPI /* @@ -175,8 +177,9 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( MPI_Comm_size(_comm,&numProcessors); _globalLevel = ceil(log2(numProcessors)/3.0); if(_globalLevel > _maxLevel){ - std::cout << "too many MPI ranks \n"; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Too many MPI ranks" << std::endl; + MARDYN_EXIT(error_message); } //numProcessers has to be a power of 2 mardyn_assert(pow(2,log2(numProcessors)) == numProcessors); @@ -378,8 +381,9 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( int size2; MPI_Comm_size(_neighbourhoodComms[i], &size2); if(size2 > 8){ //neighbourhood comms need to have size 8 - std::cout << "Error wrong communicator \n"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Error wrong communicator" << std::endl; + MARDYN_EXIT(error_message); } } #endif diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt index 40ec2cee30..3932c08184 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt +++ b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt @@ -45,7 +45,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( #endif #if WIGNER == 1 //global_log->error() << "not supported yet" << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); #endif #ifdef ENABLE_MPI _timerProcessCells.set_sync(false); @@ -81,7 +81,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _globalLevel = log2(numProcessors)/3; if(_globalLevel > _maxLevel){ std::cout << "too many MPI ranks \n"; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } //numProcessers has to be a power of 8 mardyn_assert(log2(numProcessors) == _globalLevel * 3); @@ -778,7 +778,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2z = LoLim(2) + 2; m2z <= HiLim(2) + 2; m2z++) { if (m2z < 0 or m2z >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } @@ -786,7 +786,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2y = LoLim(1) + 2; m2y <= HiLim(1) + 2; m2y++) { if (m2y < 0 or m2y >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } @@ -794,7 +794,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2x = LoLim(0) + 2; m2x <= HiLim(0) + 2; m2x++) { if (m2x < 0 or m2x >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } m2v[0] = m2x; diff --git a/src/ensemble/CanonicalEnsemble.cpp b/src/ensemble/CanonicalEnsemble.cpp index da0af18555..441006ff06 100644 --- a/src/ensemble/CanonicalEnsemble.cpp +++ b/src/ensemble/CanonicalEnsemble.cpp @@ -195,8 +195,9 @@ void CanonicalEnsemble::readXML(XMLfileUnits& xmlconfig) { if("box" == domaintype) { _domain = new BoxDomain(); } else { - Log::global_log->error() << "Volume type not supported." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Volume type not supported." << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode("domain"); _domain->readXML(xmlconfig); diff --git a/src/ensemble/CavityEnsemble.cpp b/src/ensemble/CavityEnsemble.cpp index 4ac6c85462..e62a3ed9f7 100644 --- a/src/ensemble/CavityEnsemble.cpp +++ b/src/ensemble/CavityEnsemble.cpp @@ -93,10 +93,9 @@ void CavityEnsemble::setSubdomain(int rank, double x0, double x1, double y0, dou void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1, double y1, double z1) { if ((x0 >= x1) || (y0 >= y1) || (z0 >= z1)) { - Log::global_log->error() << "\nInvalid control volume (" << x0 << " / " << y0 + std::ostringstream error_message; error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " - << z1 << ")." << std::endl; - MARDYN_EXIT(711); + << z1 << ")." << std::endl; MARDYN_EXIT(error_message); } this->restrictedControlVolume = true; @@ -111,20 +110,24 @@ void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1 void CavityEnsemble::init(Component *component, unsigned Nx, unsigned Ny, unsigned Nz) { if (this->ownrank < 0) { - Log::global_log->error() << "\nInvalid rank " << ownrank << ".\n"; - MARDYN_EXIT(712); + std::ostringstream error_message; + error_message << "\nInvalid rank " << ownrank << ".\n"; + MARDYN_EXIT(error_message); } if (this->initialized) { - Log::global_log->error() << "\nCavity ensemble initialized twice.\n"; - MARDYN_EXIT(713); + std::ostringstream error_message; + error_message << "\nCavity ensemble initialized twice.\n"; + MARDYN_EXIT(error_message); } if (0.0 >= this->T) { - Log::global_log->error() << "\nInvalid temperature T = " << T << ".\n"; - MARDYN_EXIT(714); + std::ostringstream error_message; + error_message << "\nInvalid temperature T = " << T << ".\n"; + MARDYN_EXIT(error_message); } if (0.0 >= this->globalV) { - Log::global_log->error() << "\nInvalid control volume V_ctrl = " << globalV << ".\n"; - MARDYN_EXIT(715); + std::ostringstream error_message; + error_message << "\nInvalid control volume V_ctrl = " << globalV << ".\n"; + MARDYN_EXIT(error_message); } this->componentid = component->ID(); diff --git a/src/ensemble/ChemicalPotential.cpp b/src/ensemble/ChemicalPotential.cpp index 05a9cb87c2..3a6c2c55c0 100644 --- a/src/ensemble/ChemicalPotential.cpp +++ b/src/ensemble/ChemicalPotential.cpp @@ -284,8 +284,9 @@ bool ChemicalPotential::decideDeletion(double deltaUTilde) << "SEVERE WARNING: The Widom method is (erroneously) trying to carry out test deletions.\n"; return false; } - Log::global_log->error() << "No decision is possible." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "No decision is possible." << std::endl; + MARDYN_EXIT(error_message); } float dec = *_remainingDecisions.begin(); _remainingDecisions.erase(_remainingDecisions.begin()); @@ -317,8 +318,9 @@ bool ChemicalPotential::decideInsertion(double deltaUTilde) << ": no decision is possible !!!\n"; return false; } - Log::global_log->error() << "No decision is possible." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "No decision is possible." << std::endl; + MARDYN_EXIT(error_message); } double acc = _globalReducedVolume * exp(_muTilde - deltaUTilde) / (1.0 + (double) (_globalN)); @@ -373,10 +375,9 @@ void ChemicalPotential::setControlVolume(double x0, double y0, double z0, double x1, double y1, double z1) { if ((x0 >= x1) || (y0 >= y1) || (z0 >= z1)) { - Log::global_log->error() << "\nInvalid control volume (" << x0 << " / " << y0 + std::ostringstream error_message; error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 - << ")." << std::endl; - MARDYN_EXIT(611); + << ")." << std::endl; MARDYN_EXIT(error_message); } _restrictedControlVolume = true; _globalV = (x1 - x0) * (y1 - y0) * (z1 - z0); diff --git a/src/ensemble/EnsembleBase.cpp b/src/ensemble/EnsembleBase.cpp index ee34db1b6d..7a59985c43 100644 --- a/src/ensemble/EnsembleBase.cpp +++ b/src/ensemble/EnsembleBase.cpp @@ -23,8 +23,9 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { numComponents = query.card(); Log::global_log->info() << "Number of components: " << numComponents << std::endl; if (numComponents == 0) { - Log::global_log->fatal() << "No components found. Please verify that you have input them correctly." << std::endl; - MARDYN_EXIT(96123); + std::ostringstream error_message; + error_message << "No components found. Please verify that you have input them correctly." << std::endl; + MARDYN_EXIT(error_message); } _components.resize(numComponents); XMLfile::Query::const_iterator componentIter; @@ -57,8 +58,9 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { mixingrule = std::make_shared(); } else { - Log::global_log->error() << "Unknown mixing rule " << mixingruletype << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown mixing rule " << mixingruletype << std::endl; + MARDYN_EXIT(error_message); } mixingrule->readXML(xmlconfig); @@ -67,9 +69,10 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { // Check if cid is larger than number of components // cid starts with 0 and cid2 is always larger than cid1 if (cid2 >= numComponents) { - Log::global_log->error() << "Mixing: cid=" << cid2+1 << " is larger than number of components (" - << numComponents << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing: cid=" << cid2+1 << " is larger than number of components (" + << numComponents << ")" << std::endl; + MARDYN_EXIT(error_message); } _mixingrules[cid1][cid2] = mixingrule; } @@ -115,17 +118,20 @@ void Ensemble::setMixingrule(std::shared_ptr mixingrule) { // Check if cids are valid if (cid1 == cid2) { - Log::global_log->error() << "Mixing setMixingrule: cids must not be the same" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing setMixingrule: cids must not be the same" << std::endl; + MARDYN_EXIT(error_message); } if (std::min(cid1, cid2) < 0) { - Log::global_log->error() << "Mixing setMixingrule: cids must not be negative" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing setMixingrule: cids must not be negative" << std::endl; + MARDYN_EXIT(error_message); } if (std::max(cid1, cid2) >= _components.size()) { - Log::global_log->error() << "Mixing setMixingrule: cids must not exceed number of components (" - << _components.size() << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing setMixingrule: cids must not exceed number of components (" + << _components.size() << ")" << std::endl; + MARDYN_EXIT(error_message); } _mixingrules[cid1][cid2] = mixingrule; diff --git a/src/ensemble/GrandCanonicalEnsemble.h b/src/ensemble/GrandCanonicalEnsemble.h index 05e45ca440..96cd058f91 100644 --- a/src/ensemble/GrandCanonicalEnsemble.h +++ b/src/ensemble/GrandCanonicalEnsemble.h @@ -40,8 +40,9 @@ class GrandCanonicalEnsemble : public Ensemble { // TODO: Implement STUB void readXML(XMLfileUnits& xmlconfig) override { - Log::global_log->info() << "[GrandCanonicalEnsemble] readXML not implemented!" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[GrandCanonicalEnsemble] readXML not implemented!" << std::endl; + MARDYN_EXIT(error_message); }; unsigned long N() override { @@ -70,8 +71,9 @@ class GrandCanonicalEnsemble : public Ensemble { // TODO: Implement void updateGlobalVariable(ParticleContainer* particleContainer, GlobalVariable variable) override { - Log::global_log->info() << "[GrandCanonicalEnsemble] updateGlobalVariable not implemented!" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[GrandCanonicalEnsemble] updateGlobalVariable not implemented!" << std::endl; + MARDYN_EXIT(error_message); }; /*! Runs steps formerly in initConfigXML in simulation.cpp */ diff --git a/src/ensemble/PressureGradient.cpp b/src/ensemble/PressureGradient.cpp index 83af623597..b7fe3dc5b5 100644 --- a/src/ensemble/PressureGradient.cpp +++ b/src/ensemble/PressureGradient.cpp @@ -219,8 +219,9 @@ void PressureGradient::specifyTauPrime(double tauPrime, double dt) if(this->_localRank != 0) return; if(this->_universalConstantAccelerationTimesteps == 0) { - Log::global_log->error() << "SEVERE ERROR: unknown UCAT!\n"; - MARDYN_EXIT(78); + std::ostringstream error_message; + error_message << "SEVERE ERROR: unknown UCAT!\n"; + MARDYN_EXIT(error_message); } unsigned int vql = (unsigned int)ceil(tauPrime / (dt*this->_universalConstantAccelerationTimesteps)); std::map::iterator vqlit; diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index a41ce21a59..1f933cbc8a 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -56,21 +56,24 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream.open(_phaseSpaceHeaderFile.c_str()); _phaseSpaceHeaderFileStream >> token; if(token != "mardyn") { - Log::global_log->error() << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; + MARDYN_EXIT(error_message); } std::string inputversion; _phaseSpaceHeaderFileStream >> token >> inputversion; // FIXME: remove tag trunk from file specification? if(token != "trunk") { - Log::global_log->error() << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; + MARDYN_EXIT(error_message); } if(std::stoi(inputversion) < 20080701) { - Log::global_log->error() << "Input version too old (" << inputversion << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Input version too old (" << inputversion << ")" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -163,9 +166,8 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream >> numljcenters >> numcharges >> numdipoles >> numquadrupoles >> numtersoff; if(numtersoff != 0) { - Log::global_log->error() << "tersoff no longer supported." - << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; error_message << "tersoff no longer supported." + << std::endl; MARDYN_EXIT(error_message); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -274,8 +276,9 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain Log::global_log->info() << "Opening phase space file " << _phaseSpaceFile << std::endl; _phaseSpaceFileStream.open(_phaseSpaceFile.c_str()); if(!_phaseSpaceFileStream.is_open()) { - Log::global_log->error() << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; #ifdef ENABLE_MPI @@ -300,8 +303,9 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain _phaseSpaceFileStream >> token; } if((token != "NumberOfMolecules") && (token != "N")) { - Log::global_log->error() << "Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; + MARDYN_EXIT(error_message); } _phaseSpaceFileStream >> nummolecules; #ifdef ENABLE_MPI @@ -327,8 +331,9 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain else if(ntypestring == "ICRV") ntype = Ndatatype::ICRV; else if(ntypestring == "IRV") ntype = Ndatatype::IRV; else { - Log::global_log->error() << "Unknown molecule format '" << ntypestring << "'" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown molecule format '" << ntypestring << "'" << std::endl; + MARDYN_EXIT(error_message); } } else { _phaseSpaceFileStream.seekg(spos); @@ -388,8 +393,9 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain componentid = 1; break; default: - Log::global_log->error() << "[ASCIIReader.cpp] Unknown ntype" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ASCIIReader.cpp] Unknown ntype" << std::endl; + MARDYN_EXIT(error_message); } if((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) @@ -398,12 +404,11 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain } if(componentid > numcomponents) { - Log::global_log->error() << "Molecule id " << id + std::ostringstream error_message; error_message << "Molecule id " << id << " has a component ID greater than the existing number of components: " << componentid << ">" - << numcomponents << std::endl; - MARDYN_EXIT(1); + << numcomponents << std::endl; MARDYN_EXIT(error_message); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/Adios2Reader.cpp b/src/io/Adios2Reader.cpp index 02b2faf3fe..0ebd1c7e29 100644 --- a/src/io/Adios2Reader.cpp +++ b/src/io/Adios2Reader.cpp @@ -88,7 +88,9 @@ unsigned long Adios2Reader::readPhaseSpace(ParticleContainer* particleContainer, } else if (_mode == "parallelRead") { parallelRead(particleContainer, domain, domainDecomp); } else { - Log::global_log->error() << "[Adios2Reader] Unknown _mode '" << _mode << "'" << std::endl; + std::ostringstream error_message; + error_message << "[Adios2Reader] Unknown _mode '" << _mode << "'" << std::endl; + MARDYN_EXIT(error_message); } _simulation.setSimulationTime(_simtime); @@ -532,23 +534,20 @@ void Adios2Reader::initAdios2() { } } catch (std::invalid_argument& e) { - Log::global_log->fatal() - << "[Adios2Reader] Invalid argument exception, STOPPING PROGRAM from rank" - << domainDecomp.getRank() - << ": " << e.what() << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[Adios2Reader] Invalid argument exception, STOPPING PROGRAM from rank" + << domainDecomp.getRank() << ": " << e.what() << std::endl; + MARDYN_EXIT(error_message); } catch (std::ios_base::failure& e) { - Log::global_log->fatal() - << "[Adios2Reader] IO System base failure exception, STOPPING PROGRAM from rank " - << domainDecomp.getRank() - << ": " << e.what() << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[Adios2Reader] IO System base failure exception, STOPPING PROGRAM from rank " + << domainDecomp.getRank() << ": " << e.what() << std::endl; + MARDYN_EXIT(error_message); } catch (std::exception& e) { - Log::global_log->fatal() - << "[Adios2Reader] Exception, STOPPING PROGRAM from rank" - << domainDecomp.getRank() - << ": " << e.what() << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[Adios2Reader] Exception, STOPPING PROGRAM from rank" + << domainDecomp.getRank() << ": " << e.what() << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[Adios2Reader] Init complete." << std::endl; }; diff --git a/src/io/Adios2Writer.cpp b/src/io/Adios2Writer.cpp index a829f06c26..88d67a128a 100644 --- a/src/io/Adios2Writer.cpp +++ b/src/io/Adios2Writer.cpp @@ -264,15 +264,20 @@ void Adios2Writer::initAdios2() { } resetContainers(); } catch (std::invalid_argument& e) { - Log::global_log->fatal() << "Invalid argument exception, STOPPING PROGRAM from rank: " << e.what() << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Invalid argument exception:" << std::endl; + error_message << e.what() << std::endl; + MARDYN_EXIT(error_message); } catch (std::ios_base::failure& e) { - Log::global_log->fatal() << "IO System base failure exception, STOPPING PROGRAM from rank: " << e.what() << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "IO System base failure exception: " << std::endl; + error_message << e.what() << std::endl; + MARDYN_EXIT(error_message); } catch (std::exception& e) { - Log::global_log->fatal() << "Exception, STOPPING PROGRAM from rank: " << e.what() - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Exception: " << std::endl; + error_message << e.what() << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[Adios2Writer] Init complete." << std::endl; } @@ -417,14 +422,20 @@ void Adios2Writer::endStep(ParticleContainer* particleContainer, DomainDecompBas clearContainers(); } catch (std::invalid_argument& e) { - Log::global_log->error() << "[Adios2Writer] Invalid argument exception, STOPPING PROGRAM"; - Log::global_log->error() << e.what(); + std::ostringstream error_message; + error_message << "[Adios2Writer] Invalid argument exception:" << std::endl; + error_message << e.what(); + MARDYN_EXIT(error_message); } catch (std::ios_base::failure& e) { - Log::global_log->error() << "[Adios2Writer] IO System base failure exception, STOPPING PROGRAM"; - Log::global_log->error() << e.what(); + std::ostringstream error_message; + error_message << "[Adios2Writer] IO System base failure exception:" << std::endl; + error_message << e.what(); + MARDYN_EXIT(error_message); } catch (std::exception& e) { - Log::global_log->error() << "[Adios2Writer] Exception, STOPPING PROGRAM"; - Log::global_log->error() << e.what(); + std::ostringstream error_message; + error_message << "[Adios2Writer] Exception:" << std::endl; + error_message << e.what(); + MARDYN_EXIT(error_message); } Log::global_log->info() << "[Adios2Writer] endStep." << std::endl; } diff --git a/src/io/BinaryReader.cpp b/src/io/BinaryReader.cpp index 1bb02f1955..86c3ca73d8 100644 --- a/src/io/BinaryReader.cpp +++ b/src/io/BinaryReader.cpp @@ -76,9 +76,10 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { XMLfileUnits inp(_phaseSpaceHeaderFile); if(not inp.changecurrentnode("/mardyn")) { - Log::global_log->error() << "Could not find root node /mardyn in XML input file." << std::endl; - Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Could not find root node /mardyn in XML input file." << std::endl; + error_message << "Not a valid MarDyn XML input file." << std::endl; + MARDYN_EXIT(error_message); } bool bInputOk = true; @@ -95,8 +96,9 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { bInputOk = bInputOk && inp.getNodeValue("format@type", strMoleculeFormat); if(not bInputOk) { - Log::global_log->error() << "Content of file: '" << _phaseSpaceHeaderFile << "' corrupted! Program exit ..." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Content of file: '" << _phaseSpaceHeaderFile << "' corrupted! Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } if("ICRVQD" == strMoleculeFormat) @@ -106,8 +108,9 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { else if("ICRV" == strMoleculeFormat) _nMoleculeFormat = ICRV; else { - Log::global_log->error() << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; + MARDYN_EXIT(error_message); } // Set parameters of Domain and Simulation class @@ -132,9 +135,8 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai _phaseSpaceFileStream.open(_phaseSpaceFile.c_str(), std::ios::binary | std::ios::in); if(!_phaseSpaceFileStream.is_open()) { - Log::global_log->error() << "Could not open phaseSpaceFile " - << _phaseSpaceFile << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "Could not open phaseSpaceFile " + << _phaseSpaceFile << std::endl; MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; @@ -176,9 +178,8 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai if (domainDecomp->getRank() == 0) { // Rank 0 only #endif if(_phaseSpaceFileStream.eof()) { - Log::global_log->error() << "End of file was hit before all " << numMolecules << " expected molecules were read." - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "End of file was hit before all " << numMolecules << " expected molecules were read." + << std::endl; MARDYN_EXIT(error_message); } _phaseSpaceFileStream.read(reinterpret_cast (&id), 8); switch (_nMoleculeFormat) { @@ -219,9 +220,10 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai _phaseSpaceFileStream.read(reinterpret_cast (&vz), 8); break; default: - Log::global_log->error() << "BinaryReader: Unknown phase space format: " << _nMoleculeFormat << std::endl + std::ostringstream error_message; + error_message << "BinaryReader: Unknown phase space format: " << _nMoleculeFormat << std::endl << "Aborting simulation." << std::endl; - MARDYN_EXIT(12); + MARDYN_EXIT(error_message); } if ((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) || (z < 0.0 || z >= domain->getGlobalLength(2))) { @@ -229,17 +231,18 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai } if(componentid > numcomponents) { - Log::global_log->error() << "Molecule id " << id + std::ostringstream error_message; + error_message << "Molecule id " << id << " has a component ID greater than the existing number of components: " << componentid << ">" << numcomponents << std::endl; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } if(componentid == 0) { - Log::global_log->error() << "Molecule id " << id - << " has componentID == 0." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Molecule id " << id << " has componentID == 0." << std::endl; + MARDYN_EXIT(error_message); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/CavityWriter.cpp b/src/io/CavityWriter.cpp index 288edcad36..8472c0bf07 100644 --- a/src/io/CavityWriter.cpp +++ b/src/io/CavityWriter.cpp @@ -37,29 +37,34 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { xmlconfig.getNodeValue("maxNeighbours", _maxNeighbors); if (_maxNeighbors <= 0) { - Log::global_log->error() << "[CavityWriter] Invalid number of maxNeighbors: " << _maxNeighbors << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; + error_message << "[CavityWriter] Invalid number of maxNeighbors: " << _maxNeighbors << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("radius", _radius); if (_radius <= 0.0f) { - Log::global_log->error() << "[CavityWriter] Invalid size of radius: " << _radius << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; + error_message << "[CavityWriter] Invalid size of radius: " << _radius << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("Nx", _Nx); if (_Nx <= 0) { - Log::global_log->error() << "[CavityWriter] Invalid number of cells Nx: " << _Nx << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; + error_message << "[CavityWriter] Invalid number of cells Nx: " << _Nx << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("Ny", _Ny); if (_Ny <= 0) { - Log::global_log->error() << "[CavityWriter] Invalid number of cells Ny: " << _Ny << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; + error_message << "[CavityWriter] Invalid number of cells Ny: " << _Ny << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("Nz", _Nz); if (_Nz <= 0) { - Log::global_log->error() << "[CavityWriter] Invalid number of cells Nz: " << _Nz << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; + error_message << "[CavityWriter] Invalid number of cells Nz: " << _Nz << std::endl; + MARDYN_EXIT(error_message); } // Default Control Volume is entire Domain @@ -75,15 +80,13 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { xmlconfig.getNodeValue("ControlVolume/z1", _controlVolume[5]); for (int d = 0; d < 3; d++) { if (_controlVolume[d * 2] > _controlVolume[d * 2 + 1]) { - Log::global_log->error() << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound. " - << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; error_message << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound. " + << std::endl; MARDYN_EXIT(error_message); } if (_controlVolume[d * 2] < 0 || _controlVolume[d * 2 + 1] > global_simulation->getDomain()->getGlobalLength(d)) { - Log::global_log->error() << "[CavityWriter] Control volume bounds may not be outside of domain boundaries. " - << std::endl; - MARDYN_EXIT(999); + std::ostringstream error_message; error_message << "[CavityWriter] Control volume bounds may not be outside of domain boundaries. " + << std::endl; MARDYN_EXIT(error_message); } } diff --git a/src/io/CheckpointWriter.cpp b/src/io/CheckpointWriter.cpp index 69d2dbc632..95fe9abfd4 100644 --- a/src/io/CheckpointWriter.cpp +++ b/src/io/CheckpointWriter.cpp @@ -19,8 +19,9 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; if(_writeFrequency == 0) { - Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + MARDYN_EXIT(error_message); } std::string checkpointType = "unknown"; @@ -32,8 +33,9 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { _useBinaryFormat = true; } else { - Log::global_log->error() << "Unknown CheckpointWriter type '" << checkpointType << "', expected: ASCII|binary." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Unknown CheckpointWriter type '" << checkpointType << "', expected: ASCII|binary." << std::endl; + MARDYN_EXIT(error_message); } _outputPrefix = "mardyn"; diff --git a/src/io/CommunicationPartnerWriter.cpp b/src/io/CommunicationPartnerWriter.cpp index 08980ceb24..7f9e9302f2 100644 --- a/src/io/CommunicationPartnerWriter.cpp +++ b/src/io/CommunicationPartnerWriter.cpp @@ -17,8 +17,9 @@ void CommunicationPartnerWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; if(_writeFrequency == 0) { - Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + MARDYN_EXIT(error_message); } std::string HaloParticleType = "unknown"; diff --git a/src/io/CubicGridGeneratorInternal.cpp b/src/io/CubicGridGeneratorInternal.cpp index 720c38e0ca..e9ab4ebb09 100644 --- a/src/io/CubicGridGeneratorInternal.cpp +++ b/src/io/CubicGridGeneratorInternal.cpp @@ -40,17 +40,17 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "binaryMixture: " << _binaryMixture << std::endl; // setting both or none is not allowed! if((_numMolecules == 0 && density == -1.) || (_numMolecules != 0 && density != -1.) ){ - Log::global_log->error() << "Error in CubicGridGeneratorInternal: You have to set either density or numMolecules!" << std::endl; - MARDYN_EXIT(2341); + std::ostringstream error_message; + error_message << "Error in CubicGridGeneratorInternal: You have to set either density or numMolecules!" << std::endl; + MARDYN_EXIT(error_message); } if(density != -1.){ // density has been set if(density <= 0){ - Log::global_log->error() + std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: Density has to be positive and non-zero!" - << std::endl; - MARDYN_EXIT(2342); + << std::endl; MARDYN_EXIT(error_message); } double vol = 1.0; for (int d = 0; d < 3; ++d) @@ -65,9 +65,8 @@ unsigned long CubicGridGeneratorInternal::readPhaseSpace(ParticleContainer *part Log::global_log->info() << "Reading phase space file (CubicGridGenerator)." << std::endl; if(_numMolecules == 0){ - Log::global_log->error() << "Error in CubicGridGeneratorInternal: numMolecules is not set!" - << std::endl << "Please make sure to run readXML()!" << std::endl; - MARDYN_EXIT(2341); + std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: numMolecules is not set!" + << std::endl << "Please make sure to run readXML()!" << std::endl; MARDYN_EXIT(error_message); } // create a body centered cubic layout, by creating by placing the molecules on the @@ -145,9 +144,10 @@ std::array CubicGridGeneratorInternal::determineMolsPerDimensi mardyn_assert(answer >= 1); if (answer < 1) { - Log::global_log->error() << "computed num Molecules along dimension " << d << ": " << answer << std::endl; - Log::global_log->error() << "Should be larger than 1. Exiting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "computed num Molecules along dimension " << d << ": " << answer << std::endl; + error_message << "Should be larger than 1. Exiting." << std::endl; + MARDYN_EXIT(error_message); } ret[d] = answer; diff --git a/src/io/FlopRateWriter.cpp b/src/io/FlopRateWriter.cpp index e93018d1fd..8cdf645a18 100644 --- a/src/io/FlopRateWriter.cpp +++ b/src/io/FlopRateWriter.cpp @@ -26,7 +26,9 @@ void FlopRateWriter::readXML(XMLfileUnits& xmlconfig) { _writeToStdout = true; _writeToFile = true; } else { - Log::global_log->error() << "Unknown FlopRateOutputPlugin::mode. Choose \"stdout\", \"file\" or \"both\"." << std::endl; + std::ostringstream error_message; + error_message << "Unknown FlopRateOutputPlugin::mode. Choose \"stdout\", \"file\" or \"both\"." << std::endl; + MARDYN_EXIT(error_message); } _writeFrequency = 1; @@ -35,8 +37,9 @@ void FlopRateWriter::readXML(XMLfileUnits& xmlconfig) { // TODO: if(_writeToFile) { - Log::global_log->error() << "TODO: file output not yet supported." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "TODO: file output not yet supported." << std::endl; + MARDYN_EXIT(error_message); } if(_writeToFile) { diff --git a/src/io/FlopRateWriter.h b/src/io/FlopRateWriter.h index 9939da626c..48768f3489 100644 --- a/src/io/FlopRateWriter.h +++ b/src/io/FlopRateWriter.h @@ -11,6 +11,7 @@ #include "plugins/PluginBase.h" #include +#include class FlopCounter; diff --git a/src/io/HaloParticleWriter.cpp b/src/io/HaloParticleWriter.cpp index 08e1e389cd..71483936ed 100644 --- a/src/io/HaloParticleWriter.cpp +++ b/src/io/HaloParticleWriter.cpp @@ -17,8 +17,9 @@ void HaloParticleWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; if(_writeFrequency == 0) { - Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + MARDYN_EXIT(error_message); } std::string HaloParticleType = "unknown"; diff --git a/src/io/KDTreePrinter.cpp b/src/io/KDTreePrinter.cpp index 714132f2f2..3c5476bd17 100644 --- a/src/io/KDTreePrinter.cpp +++ b/src/io/KDTreePrinter.cpp @@ -18,9 +18,8 @@ void KDTreePrinter::readXML(XMLfileUnits &xmlconfig) { Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; if (_writeFrequency == 0) { - Log::global_log->error() << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency - << std::endl; - MARDYN_EXIT(948947); + std::ostringstream error_message; error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency + << std::endl; MARDYN_EXIT(error_message); } _outputPrefix = "mardyn"; diff --git a/src/io/MPI_IOCheckpointWriter.cpp b/src/io/MPI_IOCheckpointWriter.cpp index 95bbc82797..4f0cf8b461 100644 --- a/src/io/MPI_IOCheckpointWriter.cpp +++ b/src/io/MPI_IOCheckpointWriter.cpp @@ -434,8 +434,7 @@ void MPI_IOCheckpointWriter::handle_error(int i) { MPI_Error_string(i, error_string, &length_of_error_string); - Log::global_log->error() << "Writing of file was not successfull " << " , " << i - << " , " << error_string << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i + << " , " << error_string << std::endl; MARDYN_EXIT(error_message); #endif } diff --git a/src/io/MPI_IOReader.cpp b/src/io/MPI_IOReader.cpp index b40a73fe2e..2648cf71cb 100644 --- a/src/io/MPI_IOReader.cpp +++ b/src/io/MPI_IOReader.cpp @@ -58,21 +58,24 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream.open(_phaseSpaceHeaderFile.c_str()); _phaseSpaceHeaderFileStream >> token; if(token != "mardyn") { - Log::global_log->error() << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; + MARDYN_EXIT(error_message); } std::string inputversion; _phaseSpaceHeaderFileStream >> token >> inputversion; // FIXME: remove tag trunk from file specification? if(token != "trunk") { - Log::global_log->error() << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; + MARDYN_EXIT(error_message); } if(strtoul(inputversion.c_str(), NULL, 0) < 20080701) { - Log::global_log->error() << "Input version tool old (" << inputversion << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Input version tool old (" << inputversion << ")" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -115,9 +118,8 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(!(ntypestring == "ICRVQD" || ntypestring == "ICRV" || ntypestring == "IRV")) { - Log::global_log->error() << "Unknown molecule format: '" - << ntypestring << "'" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "Unknown molecule format: '" + << ntypestring << "'" << std::endl; MARDYN_EXIT(error_message); } _moleculeFormat = ntypestring; Log::global_log->info() << " molecule format: " << ntypestring << std::endl; @@ -182,8 +184,9 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream >> numljcenters >> numcharges >> numdipoles >> numquadrupoles >> numtersoff; if(numtersoff != 0) { - Log::global_log->error() << "tersoff no longer supported." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "tersoff no longer supported." << std::endl; + MARDYN_EXIT(error_message); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -654,8 +657,7 @@ void MPI_IOReader::handle_error(int i) { MPI_Error_string(i, error_string, &length_of_error_string); - Log::global_log->error() << "Writing of file was not successfull " << " , " << i - << " , " << error_string << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i + << " , " << error_string << std::endl; MARDYN_EXIT(error_message); #endif } diff --git a/src/io/Mkesfera.cpp b/src/io/Mkesfera.cpp index 82795eb602..cafb3fcfa6 100755 --- a/src/io/Mkesfera.cpp +++ b/src/io/Mkesfera.cpp @@ -175,8 +175,9 @@ MkesferaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* if(idx[0] - startx[0] >= fl_units_local[0] or idx[1] - startx[1] >= fl_units_local[1] or idx[2] - startx[2] >= fl_units_local[2] or startx[0] > idx[0] or startx[1] > idx[1] or startx[2] > idx[2]) { - Log::global_log->error() << "Error in calculation of start and end values! \n"; - MARDYN_EXIT(0); + std::ostringstream error_message; + error_message << "Error in calculation of start and end values! \n"; + MARDYN_EXIT(error_message); } fill[idx[0] - startx[0]][idx[1] - startx[1]][idx[2] - startx[2]][p] = tfill; if(tfill) { diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index a91dd73648..8929988d60 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -56,7 +56,9 @@ MmpldWriter::MmpldWriter(uint64_t startTimestep, uint64_t writeFrequency, uint64 _color_type(MMPLD_COLOR_NONE) { if (0 == _writeFrequency) { - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MMPLD Writer] writefrequency must not be 0" << std::endl; + MARDYN_EXIT(error_message); } } @@ -88,8 +90,9 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) case 102: break; default: - Log::global_log->error() << "Unsupported MMPLD version:" << _mmpldversion << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unsupported MMPLD version:" << _mmpldversion << std::endl; + MARDYN_EXIT(error_message); break; } xmlconfig.getNodeValue("outputprefix", _outputPrefix); @@ -101,8 +104,9 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) numSites = query.card(); Log::global_log->info() << "[MMPLD Writer] Number of sites: " << numSites << std::endl; if(numSites < 1) { - Log::global_log->fatal() << "[MMPLD Writer] No site parameters specified." << std::endl; - MARDYN_EXIT(48973); + std::ostringstream error_message; + error_message << "[MMPLD Writer] No site parameters specified." << std::endl; + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSiteIter; @@ -143,8 +147,9 @@ 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); + std::ostringstream error_message; + error_message << "[MMPLD Writer] The MMPLD Writer currently only supports running on little endian systems." << std::endl; + MARDYN_EXIT(error_message); } // only executed once @@ -391,8 +396,9 @@ long MmpldWriter::get_data_frame_header_size() { data_frame_header_size = sizeof(float) + sizeof(uint32_t); break; default: - Log::global_log->error() << "[MMPLD Writer] Unsupported MMPLD version: " << _mmpldversion << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MMPLD Writer] Unsupported MMPLD version: " << _mmpldversion << std::endl; + MARDYN_EXIT(error_message); break; } return data_frame_header_size; diff --git a/src/io/ObjectGenerator.cpp b/src/io/ObjectGenerator.cpp index 9b07fd0b8c..5f7462ee92 100644 --- a/src/io/ObjectGenerator.cpp +++ b/src/io/ObjectGenerator.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "utils/mardyn_assert.h" #include "ensemble/EnsembleBase.h" @@ -24,15 +25,17 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { ObjectFillerFactory objectFillerFactory; _filler = std::shared_ptr(objectFillerFactory.create(fillerType)); if(!_filler) { - Log::global_log->error() << "Object filler could not be created" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Object filler could not be created" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->debug() << "Using object filler of type: " << _filler->getPluginName() << std::endl; _filler->readXML(xmlconfig); xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "No filler specified." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "No filler specified." << std::endl; + MARDYN_EXIT(error_message); } if(xmlconfig.changecurrentnode("object")) { @@ -42,14 +45,17 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { ObjectFactory objectFactory; _object = std::shared_ptr(objectFactory.create(objectType)); if(!_object) { - Log::global_log->error() << "Unknown object type: " << objectType << std::endl; + std::ostringstream error_message; + error_message << "Unknown object type: " << objectType << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->debug() << "Created object of type: " << _object->getPluginName() << std::endl; _object->readXML(xmlconfig); xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "No object specified." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "No object specified." << std::endl; + MARDYN_EXIT(error_message); } if(xmlconfig.changecurrentnode("velocityAssigner")) { @@ -78,8 +84,9 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { } else if(velocityAssignerName == "MaxwellVelocityDistribution") { _velocityAssigner = std::make_shared(0, seed); } else { - Log::global_log->error() << "Unknown velocity assigner specified." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown velocity assigner specified." << std::endl; + MARDYN_EXIT(error_message); } Ensemble* ensemble = _simulation.getEnsemble(); Log::global_log->info() << "Setting temperature for velocity assigner to " << ensemble->T() << std::endl; diff --git a/src/io/PerCellGenerator.cpp b/src/io/PerCellGenerator.cpp index 9f7a61a93e..55e2d89956 100644 --- a/src/io/PerCellGenerator.cpp +++ b/src/io/PerCellGenerator.cpp @@ -42,16 +42,18 @@ void PerCellGenerator::readXML(XMLfileUnits &xmlconfig) { if (_numMoleculesPerCell != std::numeric_limits::max()) { Log::global_log->info() << "numMoleculesPerCell: " << _numMoleculesPerCell << std::endl; } else { - Log::global_log->error() << "Missing required field numMoleculesPerCell. Aborting!" << std::endl; - MARDYN_EXIT(1949); + std::ostringstream error_message; + error_message << "Missing required field numMoleculesPerCell. Aborting!" << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("initTemperature", _initTemperature); if (_initTemperature > 0.) { Log::global_log->info() << "initTemperature: " << _initTemperature << std::endl; } else { - Log::global_log->error() << "Missing required field initTemperature. Aborting!" << std::endl; - MARDYN_EXIT(1949); + std::ostringstream error_message; + error_message << "Missing required field initTemperature. Aborting!" << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("generateAtLeastTwoParticles", _generateAtLeastTwoParticles); diff --git a/src/io/RDF.cpp b/src/io/RDF.cpp index a33004b0d6..f03096b6ca 100644 --- a/src/io/RDF.cpp +++ b/src/io/RDF.cpp @@ -33,8 +33,9 @@ RDF::RDF() : void RDF::init() { if(!_readConfig){ - Log::global_log->error() << "RDF initialized without reading the configuration, exiting" << std::endl; - MARDYN_EXIT(25); + std::ostringstream error_message; + error_message << "RDF initialized without reading the configuration, exiting" << std::endl; + MARDYN_EXIT(error_message); } _cellProcessor = new RDFCellProcessor(global_simulation->getcutoffRadius(), this); @@ -153,27 +154,27 @@ void RDF::init() { void RDF::readXML(XMLfileUnits& xmlconfig) { _writeFrequency = 1; xmlconfig.getNodeValue("writefrequency", _writeFrequency); - Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; + Log::global_log->info() << "[RDF] Write frequency: " << _writeFrequency << std::endl; _samplingFrequency = 1; xmlconfig.getNodeValue("samplingfrequency", _samplingFrequency); - Log::global_log->info() << "Sampling frequency: " << _samplingFrequency << std::endl; + Log::global_log->info() << "[RDF] Sampling frequency: " << _samplingFrequency << std::endl; _outputPrefix = "mardyn"; xmlconfig.getNodeValue("outputprefix", _outputPrefix); - Log::global_log->info() << "Output prefix: " << _outputPrefix << std::endl; + Log::global_log->info() << "[RDF] Output prefix: " << _outputPrefix << std::endl; _bins = 1; xmlconfig.getNodeValue("bins", _bins); - Log::global_log->info() << "Number of bins: " << _bins << std::endl; + Log::global_log->info() << "[RDF] Number of bins: " << _bins << std::endl; _angularBins = 1; xmlconfig.getNodeValue("angularbins", _angularBins); - Log::global_log->info() << "Number of angular bins: " << _angularBins << std::endl; + Log::global_log->info() << "[RDF] Number of angular bins: " << _angularBins << std::endl; _intervalLength = 1; xmlconfig.getNodeValueReduced("intervallength", _intervalLength); - Log::global_log->info() << "Interval length: " << _intervalLength << std::endl; + Log::global_log->info() << "[RDF] Interval length: " << _intervalLength << std::endl; _readConfig = true; } diff --git a/src/io/ReplicaGenerator.cpp b/src/io/ReplicaGenerator.cpp index de974ed92e..d1c9d75c66 100755 --- a/src/io/ReplicaGenerator.cpp +++ b/src/io/ReplicaGenerator.cpp @@ -56,9 +56,10 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { XMLfileUnits inp(subDomain.strFilePathHeader); if(not inp.changecurrentnode("/mardyn")) { - Log::global_log->error() << "Could not find root node /mardyn in XML input file." << std::endl; - Log::global_log->fatal() << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Could not find root node /mardyn in XML input file." << std::endl; + error_message << "Not a valid MarDyn XML input file." << std::endl; + MARDYN_EXIT(error_message); } bool bInputOk = true; @@ -80,9 +81,8 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { subDomain.dDensity = subDomain.numParticles / subDomain.dVolume; if(not bInputOk) { - Log::global_log->error() << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted! Program exit ..." - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted! Program exit ..." + << std::endl; MARDYN_EXIT(error_message); } if("ICRVQD" == strMoleculeFormat) @@ -92,8 +92,9 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { else if("ICRV" == strMoleculeFormat) _nMoleculeFormat = ICRV; else { - Log::global_log->error() << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -106,8 +107,9 @@ void ReplicaGenerator::readReplicaPhaseSpaceData(SubDomain& subDomain, DomainDec std::ifstream ifs; ifs.open(subDomain.strFilePathData.c_str(), std::ios::binary | std::ios::in); if(!ifs.is_open()) { - Log::global_log->error() << "Could not open phaseSpaceFile " << subDomain.strFilePathData << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Could not open phaseSpaceFile " << subDomain.strFilePathData << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space file " << subDomain.strFilePathData << std::endl; @@ -188,9 +190,8 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { } else if("heterogeneous_LV" == strType) { _nSystemType = ST_HETEROGENEOUS_LIQUID_VAPOR; } else { - Log::global_log->error() << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" - << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; error_message << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" + << std::endl; MARDYN_EXIT(error_message); } SubDomain sd; @@ -240,8 +241,9 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { numChanges = query.card(); Log::global_log->info() << "Number of components to change: " << (uint32_t) numChanges << std::endl; if(numChanges < 1) { - Log::global_log->error() << "No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "No component change defined in XML-config file. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -263,8 +265,9 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { numChanges = query.card(); Log::global_log->info() << "Number of components to change: " << (uint32_t) numChanges << std::endl; if(numChanges < 1) { - Log::global_log->error() << "No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "No component change defined in XML-config file. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -528,11 +531,10 @@ ReplicaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* d << std::endl; if(domainDecomp->getRank() == 0 && numParticlesGlobal != _numParticlesTotal - numAddedParticlesFreespaceGlobal) { - Log::global_log->info() << "Number of particles: " << numParticlesGlobal << " (added)" - " != " - << (_numParticlesTotal - numAddedParticlesFreespaceGlobal) << " (expected). Program exit ..." - << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Number of particles: " << numParticlesGlobal << " (added) != " + << (_numParticlesTotal - numAddedParticlesFreespaceGlobal) << " (expected)." << std::endl; + MARDYN_EXIT(error_message); } global_simulation->timers()->stop("REPLICA_GENERATOR_VLE_INPUT"); diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index db02bf84e2..736c131ca6 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -14,8 +14,9 @@ void ResultWriter::readXML(XMLfileUnits& xmlconfig) { xmlconfig.getNodeValue("writefrequency", _writeFrequency); Log::global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << std::endl; if (_writeFrequency <= 0) { - Log::global_log->error() << "[ResultWriter] Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(123); + std::ostringstream error_message; + error_message << "[ResultWriter] Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("outputprefix", _outputPrefix); diff --git a/src/io/TimerProfiler.cpp b/src/io/TimerProfiler.cpp index 94bc1fcb2b..7f1fd22742 100644 --- a/src/io/TimerProfiler.cpp +++ b/src/io/TimerProfiler.cpp @@ -7,11 +7,13 @@ #include #include +#include #include "TimerProfiler.h" #include "utils/Logger.h" #include "utils/String_utils.h" #include "utils/xmlfileUnits.h" +#include "utils/mardyn_assert.h" @@ -35,7 +37,9 @@ void TimerProfiler::readXML(XMLfileUnits& xmlconfig) { } else if (displayMode == "none") { setDisplayMode(Displaymode::NONE); } else { - Log::global_log->error() << "Unknown display mode: " << displayMode << std::endl; + std::ostringstream error_message; + error_message << "Unknown display mode: " << displayMode << std::endl; + MARDYN_EXIT(error_message); } } } diff --git a/src/io/TimerWriter.cpp b/src/io/TimerWriter.cpp index fe1dabcc70..024b0b9663 100644 --- a/src/io/TimerWriter.cpp +++ b/src/io/TimerWriter.cpp @@ -34,8 +34,9 @@ void TimerWriter::readXML(XMLfileUnits& xmlconfig) { << std::endl; } if (_timerNames.empty()) { - Log::global_log->error() << "TimerWriter: no timers given. make sure you specify them correctly." << std::endl; - MARDYN_EXIT(242367); + std::ostringstream error_message; + error_message << "TimerWriter: no timers given. make sure you specify them correctly." << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode(oldpath); } diff --git a/src/io/vtk/VTKGridWriter.cpp b/src/io/vtk/VTKGridWriter.cpp index 8840c90ff2..72f81fffab 100644 --- a/src/io/vtk/VTKGridWriter.cpp +++ b/src/io/vtk/VTKGridWriter.cpp @@ -34,7 +34,9 @@ void VTKGridWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "VTKMoleculeWriter: Output prefix: " << _fileName << std::endl; if (_writeFrequency <= 0) { - Log::global_log->error() << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; + std::ostringstream error_message; + error_message << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; + MARDYN_EXIT(error_message); } } @@ -47,8 +49,9 @@ void VTKGridWriter::endStep( LinkedCells* container = dynamic_cast(particleContainer); #ifndef NDEBUG if (container == NULL) { - Log::global_log->error() << "VTKGridWriter works only with plottable LinkedCells!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "VTKGridWriter works only with plottable LinkedCells!" << std::endl; + MARDYN_EXIT(error_message); } #endif @@ -113,8 +116,9 @@ void VTKGridWriter::init(ParticleContainer *particleContainer, DomainDecompBase * /*domainDecomposition*/, Domain * /*domain*/) { #ifndef NDEBUG if (dynamic_cast(particleContainer) == NULL) { - Log::global_log->error() << "VTKGridWriter works only with LinkCells!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "VTKGridWriter works only with LinkCells!" << std::endl; + MARDYN_EXIT(error_message); } #endif } diff --git a/src/io/vtk/VTKMoleculeWriter.cpp b/src/io/vtk/VTKMoleculeWriter.cpp index 98b64cd676..150a8ae14c 100644 --- a/src/io/vtk/VTKMoleculeWriter.cpp +++ b/src/io/vtk/VTKMoleculeWriter.cpp @@ -36,7 +36,9 @@ void VTKMoleculeWriter::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "VTKMoleculeWriter: Output prefix: " << _fileName << std::endl; if (_writeFrequency <= 0) { - Log::global_log->error() << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; + std::ostringstream error_message; + error_message << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/longRange/Homogeneous.cpp b/src/longRange/Homogeneous.cpp index 90afb0fd71..4c4c31d36f 100644 --- a/src/longRange/Homogeneous.cpp +++ b/src/longRange/Homogeneous.cpp @@ -81,8 +81,9 @@ void Homogeneous::init() { double zj = cj.ljcenter(sj).rz(); double tau2 = sqrt(xj * xj + yj * yj + zj * zj); if (tau1 + tau2 >= _cutoffLJ) { - Log::global_log->error() << "Error calculating cutoff corrections, rc too small" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Error calculating cutoff corrections, rc too small" << std::endl; + MARDYN_EXIT(error_message); } double eps24; params >> eps24; diff --git a/src/longRange/Planar.cpp b/src/longRange/Planar.cpp index 3acd92b7f5..42d91b1769 100644 --- a/src/longRange/Planar.cpp +++ b/src/longRange/Planar.cpp @@ -149,8 +149,9 @@ void Planar::init() _subject->registerObserver(this); Log::global_log->info() << "Long Range Correction: Subject registered" << std::endl; } else { - Log::global_log->error() << "Long Range Correction: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Long Range Correction: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } } @@ -194,13 +195,15 @@ void Planar::readXML(XMLfileUnits& xmlconfig) bool bRet3 = xmlconfig.getNodeValue("writecontrol/stop", _nStopWritingProfiles); if(_nWriteFreqProfiles < 1) { - Log::global_log->error() << "Long Range Correction: Write frequency < 1! Programm exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Long Range Correction: Write frequency < 1! Programm exit ..." << std::endl; + MARDYN_EXIT(error_message); } if(_nStopWritingProfiles <= _nStartWritingProfiles) { - Log::global_log->error() << "Long Range Correction: Writing profiles 'stop' <= 'start'! Programm exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Long Range Correction: Writing profiles 'stop' <= 'start'! Programm exit ..." << std::endl; + MARDYN_EXIT(error_message); } bool bInputIsValid = (bRet1 && bRet2 && bRet3); if(true == bInputIsValid) @@ -211,8 +214,9 @@ void Planar::readXML(XMLfileUnits& xmlconfig) } else { - Log::global_log->error() << "Long Range Correction: Write control parameters not valid! Programm exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Long Range Correction: Write control parameters not valid! Programm exit ..." << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/molecules/AutoPasSimpleMolecule.cpp b/src/molecules/AutoPasSimpleMolecule.cpp index 988bf472fc..485c850ac6 100644 --- a/src/molecules/AutoPasSimpleMolecule.cpp +++ b/src/molecules/AutoPasSimpleMolecule.cpp @@ -20,7 +20,7 @@ AutoPasSimpleMolecule::AutoPasSimpleMolecule(unsigned long id, Component* compon } else if (_component != component and component != nullptr) { Log::global_log->warning() << "AutoPasSimpleMolecule can only handle one component" << std::endl; _component = component; - // MARDYN_EXIT(32); + // MARDYN_EXIT(error_message); } } diff --git a/src/molecules/Comp2Param.cpp b/src/molecules/Comp2Param.cpp index d0427cccf8..2867f36179 100644 --- a/src/molecules/Comp2Param.cpp +++ b/src/molecules/Comp2Param.cpp @@ -58,8 +58,9 @@ void Comp2Param::initialize( return {[=](double sigi, double sigj) { return eta * (sigi + sigj); }, // mixingSigma [=](double epsi, double epsj) { return xi * sqrt(epsi * epsj); }}; // mixingEpsilon } else { - Log::global_log->error() << "Mixing: Only LB rule supported" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing: Only LB rule supported" << std::endl; + MARDYN_EXIT(error_message); return {}; } }(); diff --git a/src/molecules/Component.cpp b/src/molecules/Component.cpp index f55d7b4ff5..d5cbba1ed7 100644 --- a/src/molecules/Component.cpp +++ b/src/molecules/Component.cpp @@ -76,11 +76,13 @@ void Component::readXML(XMLfileUnits& xmlconfig) { quadrupoleSite.readXML(xmlconfig); addQuadrupole(quadrupoleSite); } else if (siteType == "Tersoff") { - Log::global_log->error() << "Tersoff no longer supported:" << siteType << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Tersoff no longer supported:" << siteType << std::endl; + MARDYN_EXIT(error_message); } else { - Log::global_log->error() << "Unknown site type:" << siteType << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "Unknown site type:" << siteType << std::endl; + MARDYN_EXIT(error_message); } // go back to initial level, to be consistent, even if no site information is found. xmlconfig.changecurrentnode(".."); diff --git a/src/molecules/MoleculeInterface.cpp b/src/molecules/MoleculeInterface.cpp index 09c48a4793..7c024d522e 100644 --- a/src/molecules/MoleculeInterface.cpp +++ b/src/molecules/MoleculeInterface.cpp @@ -30,8 +30,9 @@ bool MoleculeInterface::isLessThan(const MoleculeInterface& m2) const { else if (r(0) > m2.r(0)) return false; else { - Log::global_log->error() << "LinkedCells::isFirstParticle: both Particles have the same position" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "LinkedCells::isFirstParticle: both Particles have the same position" << std::endl; + MARDYN_EXIT(error_message); } } } diff --git a/src/molecules/mixingrules/MixingRuleBase.cpp b/src/molecules/mixingrules/MixingRuleBase.cpp index da90c9efc5..5a4097e09e 100644 --- a/src/molecules/mixingrules/MixingRuleBase.cpp +++ b/src/molecules/mixingrules/MixingRuleBase.cpp @@ -15,11 +15,13 @@ void MixingRuleBase::readXML(const XMLfileUnits& xmlconfig) { // catch invalid inputs if (cid1 == cid2) { - Log::global_log->error() << "Mixing rules: cid1 and cid2 must not be the same but are both " << cid1 << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing rules: cid1 and cid2 must not be the same but are both " << cid1 << std::endl; + MARDYN_EXIT(error_message); } else if (std::min(cid1, cid2) < 0) { - Log::global_log->error() << "Mixing rules: cid1 and cid2 must be greater than zero" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Mixing rules: cid1 and cid2 must be greater than zero" << std::endl; + MARDYN_EXIT(error_message); } // Symmetry for mixing rules is assumed diff --git a/src/parallel/CollectiveCommunication.h b/src/parallel/CollectiveCommunication.h index 1f42ce5bcc..7a5c91ce28 100644 --- a/src/parallel/CollectiveCommunication.h +++ b/src/parallel/CollectiveCommunication.h @@ -170,8 +170,9 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu commutative, &agglomeratedTypeAddOperator)); break; default: - Log::global_log->error()<<"invalid reducetype, aborting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message<<"invalid reducetype, aborting." << std::endl; + MARDYN_EXIT(error_message); } MPI_CHECK( @@ -192,8 +193,9 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu op = MPI_MAX; break; default: - Log::global_log->error()<<"invalid reducetype, aborting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message<<"invalid reducetype, aborting." << std::endl; + MARDYN_EXIT(error_message); } MPI_CHECK(MPI_Allreduce( MPI_IN_PLACE, &_values[i], 1, _types[i], op, _communicator )); } diff --git a/src/parallel/CollectiveCommunicationNonBlocking.h b/src/parallel/CollectiveCommunicationNonBlocking.h index 774d32ccb9..6c319187ff 100644 --- a/src/parallel/CollectiveCommunicationNonBlocking.h +++ b/src/parallel/CollectiveCommunicationNonBlocking.h @@ -39,9 +39,8 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac //! @param numValues number of values that shall be communicated void init(MPI_Comm communicator, int numValues, int key = 0) override { if (_currentKey != -1) { - Log::global_log->error() << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey - << " not yet finalized" << std::endl; - MARDYN_EXIT(234); + std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey + << " not yet finalized" << std::endl; MARDYN_EXIT(error_message); } _currentKey = key; @@ -57,9 +56,8 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac // Creates the CollectiveCommunicationSingleNonBlocking object auto [_, inserted] = _comms.try_emplace(_currentKey); if (not inserted) { - Log::global_log->error() << "CollectiveCommunicationNonBlocking: key " << _currentKey - << " could not be inserted. Aborting!" << std::endl; - MARDYN_EXIT(498789); + std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: key " << _currentKey + << " could not be inserted. Aborting!" << std::endl; MARDYN_EXIT(error_message); } } _comms.at(_currentKey).init(communicator, numValues, _currentKey); diff --git a/src/parallel/CommunicationPartner.cpp b/src/parallel/CommunicationPartner.cpp index 9d7879d601..517783ff13 100644 --- a/src/parallel/CommunicationPartner.cpp +++ b/src/parallel/CommunicationPartner.cpp @@ -195,8 +195,9 @@ void CommunicationPartner::initSend(ParticleContainer* moleculeContainer, const break; } default: - Log::global_log->error() << "[CommunicationPartner] MessageType unknown!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[CommunicationPartner] MessageType unknown!" << std::endl; + MARDYN_EXIT(error_message); } #ifndef NDEBUG @@ -599,8 +600,9 @@ void CommunicationPartner::collectLeavingMoleculesFromInvalidParticles(std::vect // it will add the given molecule to _sendBuf with the necessary shift. auto shiftAndAdd = [domain, lowCorner, highCorner, shift, this, &numMolsAlreadyIn](Molecule& m) { if (not m.inBox(lowCorner, highCorner)) { - Log::global_log->error() << "trying to remove a particle that is not in the halo region" << std::endl; - MARDYN_EXIT(456); + std::ostringstream error_message; + error_message << "trying to remove a particle that is not in the halo region" << std::endl; + MARDYN_EXIT(error_message); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompBase.cpp b/src/parallel/DomainDecompBase.cpp index f4f39f616a..937efb4695 100644 --- a/src/parallel/DomainDecompBase.cpp +++ b/src/parallel/DomainDecompBase.cpp @@ -231,8 +231,9 @@ void DomainDecompBase::handleDomainLeavingParticlesDirect(const HaloRegion& halo auto shiftAndAdd = [&moleculeContainer, haloRegion, shift](Molecule& m) { if (not m.inBox(haloRegion.rmin, haloRegion.rmax)) { - Log::global_log->error() << "trying to remove a particle that is not in the halo region" << std::endl; - MARDYN_EXIT(456); + std::ostringstream error_message; + error_message << "trying to remove a particle that is not in the halo region" << std::endl; + MARDYN_EXIT(error_message); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index 68c05cde96..cc5aad9469 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -149,9 +149,8 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else if(zonalMethod=="nt") { zonalMethodP = new NeutralTerritory(); } else { - Log::global_log->error() << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" + << std::endl; MARDYN_EXIT(error_message); } Log::global_log->info() << "Using zonal method: " << zonalMethod << std::endl; @@ -165,9 +164,8 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons Log::global_log->info() << "DomainDecompMPIBase: Using IndirectCommunicationScheme" << std::endl; _neighbourCommunicationScheme = std::make_unique(zonalMethodP); } else { - Log::global_log->error() << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" + << std::endl; MARDYN_EXIT(error_message); } } @@ -197,7 +195,7 @@ void DomainDecompMPIBase::assertIntIdentity(int IX) { MPI_CHECK(MPI_Recv(&recv, 1, MPI_INT, i, 2 * i + 17, _comm, &s)); if (recv != IX) { Log::global_log->error() << "IX is " << IX << " for rank 0, but " << recv << " for rank " << i << ".\n"; - MPI_Abort(_comm, 911); + MPI_Abort(_comm, 911); // TODO FIXME } } Log::global_log->info() << "IX = " << recv << " for all " << _numProcs << " ranks.\n"; diff --git a/src/parallel/DomainDecomposition.cpp b/src/parallel/DomainDecomposition.cpp index 542046534c..ce350c1f4f 100644 --- a/src/parallel/DomainDecomposition.cpp +++ b/src/parallel/DomainDecomposition.cpp @@ -1,10 +1,13 @@ #include "DomainDecomposition.h" +#include + #include "Domain.h" #include "molecules/Molecule.h" #include "particleContainer/ParticleContainer.h" #include "utils/xmlfileUnits.h" #include "utils/Logger.h" +#include "utils/mardyn_assert.h" #include "parallel/NeighbourCommunicationScheme.h" #include "parallel/HaloRegion.h" #include "ParticleData.h" @@ -23,12 +26,13 @@ void DomainDecomposition::initMPIGridDims() { { auto numProcsGridSize = _gridSize[0] * _gridSize[1] * _gridSize[2]; if (numProcsGridSize != _numProcs and numProcsGridSize != 0) { - Log::global_log->error() << "DomainDecomposition: Wrong grid size given!" << std::endl; - Log::global_log->error() << "\tnumProcs is " << _numProcs << "," << std::endl; - Log::global_log->error() << "\tbut grid is " << _gridSize[0] << " x " << _gridSize[1] << " x " << _gridSize[2] << std::endl; - Log::global_log->error() << "\tresulting in " << numProcsGridSize << " subdomains!" << std::endl; - Log::global_log->error() << "\tplease check your input file!" << std::endl; - MARDYN_EXIT(2134); + std::ostringstream error_message; + error_message << "DomainDecomposition: Wrong grid size given!" << std::endl; + error_message << "\tnumProcs is " << _numProcs << "," << std::endl; + error_message << "\tbut grid is " << _gridSize[0] << " x " << _gridSize[1] << " x " << _gridSize[2] << std::endl; + error_message << "\tresulting in " << numProcsGridSize << " subdomains!" << std::endl; + error_message << "\tplease check your input file!" << std::endl; + MARDYN_EXIT(error_message); } } @@ -59,10 +63,11 @@ void DomainDecomposition::prepareNonBlockingStage(bool /*forceRebalancing*/, Par LEAVING_AND_HALO_COPIES); } else { // Would first need to send leaving, then halo -> not good for overlapping! - Log::global_log->error() << "nonblocking P2P using separate messages for leaving and halo is currently not " + std::ostringstream error_message; + error_message << "nonblocking P2P using separate messages for leaving and halo is currently not " "supported. Please use the indirect neighbor communication scheme!" << std::endl; - MARDYN_EXIT(235861); + MARDYN_EXIT(error_message); } } @@ -73,9 +78,10 @@ void DomainDecomposition::finishNonBlockingStage(bool /*forceRebalancing*/, Part LEAVING_AND_HALO_COPIES); } else { // Would first need to send leaving, then halo -> not good for overlapping! - Log::global_log->error() + std::ostringstream error_message; + error_message << "nonblocking P2P using separate messages for leaving and halo is currently not supported." << std::endl; - MARDYN_EXIT(235861); + MARDYN_EXIT(error_message); } } diff --git a/src/parallel/ForceHelper.cpp b/src/parallel/ForceHelper.cpp index 227717a979..f2cf207280 100644 --- a/src/parallel/ForceHelper.cpp +++ b/src/parallel/ForceHelper.cpp @@ -1,6 +1,7 @@ #include "ForceHelper.h" +#include #include #include "utils/mardyn_assert.h" @@ -37,8 +38,9 @@ std::variant> addValuesAndGet [&](auto originalIter) { if (not originalIter.isValid()) { // This should not happen - std::cout << "Original molecule not usePreviousIterator"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Original molecule not usePreviousIterator" << std::endl; + MARDYN_EXIT(error_message); } mardyn_assert(originalIter->getID() == haloMolecule.getID()); diff --git a/src/parallel/GeneralDomainDecomposition.cpp b/src/parallel/GeneralDomainDecomposition.cpp index 7b28fb4160..17238cfc29 100644 --- a/src/parallel/GeneralDomainDecomposition.cpp +++ b/src/parallel/GeneralDomainDecomposition.cpp @@ -21,6 +21,7 @@ #include #include #include +#include GeneralDomainDecomposition::GeneralDomainDecomposition(double interactionLength, Domain* domain, bool forceGrid) : _boxMin{0.}, @@ -58,8 +59,9 @@ void GeneralDomainDecomposition::initializeALL() { _loadBalancer = std::make_unique(_boxMin, _boxMax, 4 /*gamma*/, this->getCommunicator(), gridSize, gridCoords, minimalDomainSize); #else - Log::global_log->error() << "ALL load balancing library not enabled. Aborting." << std::endl; - MARDYN_EXIT(24235); + std::ostringstream error_message; + error_message << "ALL load balancing library not enabled. Aborting." << std::endl; + MARDYN_EXIT(error_message); #endif Log::global_log->info() << "GeneralDomainDecomposition initial box: [" << _boxMin[0] << ", " << _boxMax[0] << "] x [" << _boxMin[1] << ", " << _boxMax[1] << "] x [" << _boxMin[2] << ", " << _boxMax[2] << "]" @@ -184,7 +186,8 @@ void GeneralDomainDecomposition::migrateParticles(Domain* domain, ParticleContai ownMolecules.push_back(*iter); // TODO: This check should be in debug mode only if (not iter->inBox(newMin.data(), newMax.data())) { - Log::global_log->error_always_output() + std::ostringstream error_message; + error_message << "Particle still in domain that should have been migrated." << "BoxMin: " << particleContainer->getBoundingBoxMin(0) << ", " @@ -196,7 +199,7 @@ void GeneralDomainDecomposition::migrateParticles(Domain* domain, ParticleContai << particleContainer->getBoundingBoxMax(2) << "\n" << "Particle: \n" << *iter << std::endl; - MARDYN_EXIT(2315); + MARDYN_EXIT(error_message); } } particleContainer->clear(); @@ -287,10 +290,11 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { if (gridSizeString.find(',') != std::string::npos) { auto strings = string_utils::split(gridSizeString, ','); if (strings.size() != 3) { - Log::global_log->error() + std::ostringstream error_message; + error_message << "GeneralDomainDecomposition's gridSize should have three entries if a list is given, but has " << strings.size() << "!" << std::endl; - MARDYN_EXIT(8134); + MARDYN_EXIT(error_message); } _gridSize = {std::stod(strings[0]), std::stod(strings[1]), std::stod(strings[2])}; } else { @@ -299,10 +303,11 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { } for (auto gridSize : *_gridSize) { if (gridSize < _interactionLength) { - Log::global_log->error() << "GeneralDomainDecomposition's gridSize (" << gridSize + std::ostringstream error_message; + error_message << "GeneralDomainDecomposition's gridSize (" << gridSize << ") is smaller than the interactionLength (" << _interactionLength << "). This is forbidden, as it leads to errors! " << std::endl; - MARDYN_EXIT(8136); + MARDYN_EXIT(error_message); } } } @@ -317,14 +322,16 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { if (loadBalancerString.find("all") != std::string::npos) { initializeALL(); } else { - Log::global_log->error() << "GeneralDomainDecomposition: Unknown load balancer " << loadBalancerString + std::ostringstream error_message; + error_message << "GeneralDomainDecomposition: Unknown load balancer " << loadBalancerString << ". Aborting! Please select a valid option! Valid options: ALL"; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } _loadBalancer->readXML(xmlconfig); } else { - Log::global_log->error() << "loadBalancer section missing! Aborting!" << std::endl; - MARDYN_EXIT(8466); + std::ostringstream error_message; + error_message << "loadBalancer section missing! Aborting!" << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode(".."); } diff --git a/src/parallel/KDDecomposition.cpp b/src/parallel/KDDecomposition.cpp index c8875717a8..d25d612d74 100644 --- a/src/parallel/KDDecomposition.cpp +++ b/src/parallel/KDDecomposition.cpp @@ -65,10 +65,11 @@ void KDDecomposition::init(Domain* domain){ _decompTree = new KDNode(_numProcs, lowCorner, highCorner, 0, 0, coversWholeDomain, 0); if (!_decompTree->isResolvable()) { auto minCellCountPerProc = std::pow(KDDStaticValues::minNumCellsPerDimension, 3); - Log::global_log->error() << "KDDecomposition not possible. Each process needs at least " << minCellCountPerProc - << " cells." << std::endl; - Log::global_log->error() << "The number of Cells is only sufficient for " << _decompTree->getNumMaxProcs() << " Procs!" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "KDDecomposition not possible. Each process needs at least " + << minCellCountPerProc << " cells." << std::endl; + error_message << "The number of Cells is only sufficient for " << _decompTree->getNumMaxProcs() << " Procs!" << std::endl; + MARDYN_EXIT(error_message); } _decompTree->buildKDTree(); _ownArea = _decompTree->findAreaForProcess(_rank); @@ -103,8 +104,9 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { Log::global_log->info() << "KDDecomposition minNumCellsPerDimension: " << KDDStaticValues::minNumCellsPerDimension << std::endl; if(KDDStaticValues::minNumCellsPerDimension==0u){ - Log::global_log->error() << "KDDecomposition minNumCellsPerDimension has to be bigger than zero!" << std::endl; - MARDYN_EXIT(43); + std::ostringstream error_message; + error_message << "KDDecomposition minNumCellsPerDimension has to be bigger than zero!" << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("updateFrequency", _frequency); Log::global_log->info() << "KDDecomposition update frequency: " << _frequency << std::endl; @@ -124,9 +126,10 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { } else if (deviationReductionOperation == "max") { _deviationReductionOperation = MPI_MAX; } else { - Log::global_log->fatal() << "Wrong deviationReductionOperation given: " << _deviationReductionOperation + std::ostringstream error_message; + error_message << "Wrong deviationReductionOperation given: " << _deviationReductionOperation << ". Should be 'max' or 'sum'." << std::endl; - MARDYN_EXIT(45681); + MARDYN_EXIT(error_message); } } Log::global_log->info() << "KDDecomposition uses " << deviationReductionOperation @@ -316,9 +319,10 @@ void KDDecomposition::balanceAndExchange(double lastTraversalTime, bool forceReb constructNewTree(newDecompRoot, newOwnLeaf, moleculeContainer); bool migrationSuccessful = migrateParticles(*newDecompRoot, *newOwnLeaf, moleculeContainer, domain); if (not migrationSuccessful) { - Log::global_log->error() << "A problem occurred during particle migration between old decomposition and new decomposition of the KDDecomposition." << std::endl; - Log::global_log->error() << "Aborting. Please save your input files and last available checkpoint and contact TUM SCCS." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "A problem occurred during particle migration between old decomposition and new decomposition of the KDDecomposition." << std::endl; + error_message << "Aborting. Please save your input files and last available checkpoint and contact TUM SCCS." << std::endl; + MARDYN_EXIT(error_message); } delete _decompTree; _decompTree = newDecompRoot; @@ -554,8 +558,9 @@ bool KDDecomposition::migrateParticles(const KDNode& newRoot, const KDNode& newO void KDDecomposition::fillTimeVecs(CellProcessor **cellProc){ if(cellProc == nullptr){ - Log::global_log->error() << "The cellProcessor was not yet set! Please reorder fillTimeVecs, so that there won't be a problem!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The cellProcessor was not yet set! Please reorder fillTimeVecs, so that there won't be a problem!" << std::endl; + MARDYN_EXIT(error_message); } auto _tunerLoadCalc = dynamic_cast(_loadCalc); if(_tunerLoadCalc){ @@ -1024,8 +1029,9 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::listerror() << "no processor speeds given" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "no processor speeds given" << std::endl; + MARDYN_EXIT(error_message); } double optimalLoad = (_accumulatedProcessorSpeeds[node->_owningProc + node->_numProcs] - _accumulatedProcessorSpeeds[node->_owningProc]) * leftRightLoadRatio / (1. + leftRightLoadRatio); @@ -1087,8 +1093,9 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::list_child1->_numProcs <= 0 || clone->_child1->_numProcs >= node->_numProcs) || (clone->_child2->_numProcs <= 0 || clone->_child2->_numProcs >= node->_numProcs) ){ //continue; - Log::global_log->error_always_output() << "ERROR in calculateAllPossibleSubdivisions(), part of the domain was not assigned to a proc" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "ERROR in calculateAllPossibleSubdivisions(), part of the domain was not assigned to a proc" << std::endl; + MARDYN_EXIT(error_message); } mardyn_assert( clone->_child1->isResolvable() && clone->_child2->isResolvable() ); @@ -1247,8 +1254,9 @@ void KDDecomposition::calculateCostsPar(KDNode* area, std::vectorerror() << "[KDDecomposition] zeroCounts too large!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[KDDecomposition] zeroCounts too large!" << std::endl; + MARDYN_EXIT(error_message); } } } @@ -1432,14 +1440,16 @@ void KDDecomposition::calcNumParticlesPerCell(ParticleContainer* moleculeContain } std::vector KDDecomposition::getNeighbourRanks() { - //global_log->error() << "not implemented \n"; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "KDDecomposition::getNeighbourRanks() not implemented" << std::endl; + MARDYN_EXIT(error_message); return std::vector (0); } std::vector KDDecomposition::getNeighbourRanksFullShell() { - //global_log->error() << "not implemented \n"; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "KDDecomposition::getNeighbourRanksFullShell() not implemented" << std::endl; + MARDYN_EXIT(error_message); return std::vector (0); } @@ -1772,8 +1782,9 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN size_t biggestDim = maxInd; if (costsLeft[biggestDim].size()<=2){ - Log::global_log->error_always_output() << "The domain is far to small!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The domain is far to small!" << std::endl; + MARDYN_EXIT(error_message); } int startIndex = 1; @@ -1816,8 +1827,9 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN optimalNode->split(biggestDim, node->_lowCorner[biggestDim] + i, numProcsLeft); if ( (unsigned int) (optimalNode->_child1->_numProcs + optimalNode->_child2->_numProcs) > (optimalNode->_child1->getNumMaxProcs() + optimalNode->_child2->getNumMaxProcs())) { - Log::global_log->error() << "Domain is not resolvable at all!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Domain is not resolvable at all!" << std::endl; + MARDYN_EXIT(error_message); } while ( (! optimalNode->_child1->isResolvable()) && optimalNode->_child2->isResolvable()) { @@ -1844,8 +1856,9 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN if ((optimalNode->_child1->_numProcs <= 0 || optimalNode->_child1->_numProcs >= node->_numProcs) || (optimalNode->_child2->_numProcs <= 0 || optimalNode->_child2->_numProcs >= node->_numProcs) ){ //continue; - Log::global_log->error_always_output() << "ERROR in calculateHeteroSubdivision(), part of the domain was not assigned to a proc" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "ERROR in calculateHeteroSubdivision(), part of the domain was not assigned to a proc" << std::endl; + MARDYN_EXIT(error_message); } mardyn_assert( optimalNode->_child1->isResolvable() && optimalNode->_child2->isResolvable() ); diff --git a/src/parallel/LoadCalc.cpp b/src/parallel/LoadCalc.cpp index e4ac51cab4..f043447fdf 100644 --- a/src/parallel/LoadCalc.cpp +++ b/src/parallel/LoadCalc.cpp @@ -40,13 +40,12 @@ std::vector TunerLoad::readVec(std::istream& in, int& count1, int& count tempCount2 = i; } else { if (i != tempCount2) { - Log::global_log->error_always_output() - << "The file contains data of 2D-vectors with a different amounts of elements in the second dimension!" - << std::endl; - Log::global_log->error_always_output() - << "This means the files is corrupted. Please remove it (or disallow the tuner to read from inputfiles) before restarting!" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The file contains data of 2D-vectors" + << " with a different amounts of elements in the second dimension!" << std::endl; + error_message << "This means the files is corrupted. " + << "Please remove it (or disallow the tuner to read from inputfiles) before restarting!" << std::endl; + MARDYN_EXIT(error_message); } } } @@ -122,23 +121,31 @@ TunerLoad::TunerLoad(int count1, int count2, std::vector&& ownTime, std: calcConsts(_cornerTime, false)) { if (_ownTime.size() != size_t(_count1 * _count2)) { - Log::global_log->error_always_output() << "_edgeTime was initialized with the wrong size of " << _ownTime.size() + std::ostringstream error_message; + error_message << "_edgeTime was initialized with the wrong size of " << _ownTime.size() << " expected: " << _count1 * _count2; + MARDYN_EXIT(error_message); } if (_faceTime.size() != size_t(count1 * _count2)) { - Log::global_log->error_always_output() << "_edgeTime was initialized with the wrong size of " << _faceTime.size() + std::ostringstream error_message; + error_message << "_edgeTime was initialized with the wrong size of " << _faceTime.size() << " expected: " << _count1 * _count2; + MARDYN_EXIT(error_message); } if (_edgeTime.size() != size_t(_count1 * _count2)) { - Log::global_log->error_always_output() << "_edgeTime was initialized with the wrong size of " << _edgeTime.size() + std::ostringstream error_message; + error_message << "_edgeTime was initialized with the wrong size of " << _edgeTime.size() << " expected: " << _count1 * _count2; + MARDYN_EXIT(error_message); } if (_cornerTime.size() != size_t(_count1 * _count2)) { - Log::global_log->error_always_output() << "_edgeTime was initialized with the wrong size of " << _cornerTime.size() + std::ostringstream error_message; + error_message << "_edgeTime was initialized with the wrong size of " << _cornerTime.size() << " expected: " << _count1 * _count2; + MARDYN_EXIT(error_message); } } @@ -146,9 +153,10 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::string inStr { }; std::getline(stream, inStr); if (inStr != "Vectorization Tuner File") { - Log::global_log->error() << "The tunerfile is corrupted! Missing header \"Vectorization Tuner File\""; - Log::global_log->error() << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The tunerfile is corrupted! Missing header \"Vectorization Tuner File\""; + error_message << "Please remove it or fix it before restarting!"; + MARDYN_EXIT(error_message); } int count1; @@ -156,33 +164,37 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::getline(stream, inStr); if (inStr != "own") { - Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"own\""; - Log::global_log->error() << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The tunerfile is corrupted! Missing Section \"own\""; + error_message << "Please remove it or fix it before restarting!"; + MARDYN_EXIT(error_message); } auto ownTime = readVec(stream, count1, count2); std::getline(stream, inStr); if (inStr != "face") { - Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"face\""; - Log::global_log->error() << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message<< "The tunerfile is corrupted! Missing Section \"face\""; + error_message << "Please remove it or fix it before restarting!"; + MARDYN_EXIT(error_message); } auto faceTime = readVec(stream, count1, count2); std::getline(stream, inStr); if (inStr != "edge") { - Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"edge\""; - Log::global_log->error() << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The tunerfile is corrupted! Missing Section \"edge\""; + error_message << "Please remove it or fix it before restarting!"; + MARDYN_EXIT(error_message); } auto edgeTime = readVec(stream, count1, count2); std::getline(stream, inStr); if (inStr != "corner") { - Log::global_log->error() << "The tunerfile is corrupted! Missing Section \"corner\""; - Log::global_log->error() << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The tunerfile is corrupted! Missing Section \"corner\""; + error_message << "Please remove it or fix it before restarting!"; + MARDYN_EXIT(error_message); } auto cornerTime = readVec(stream, count1, count2); return TunerLoad { count1, count2, std::move(ownTime), std::move(faceTime), std::move(edgeTime), std::move( diff --git a/src/parallel/NeighbourCommunicationScheme.cpp b/src/parallel/NeighbourCommunicationScheme.cpp index 02923e0d9b..d1b7417076 100644 --- a/src/parallel/NeighbourCommunicationScheme.cpp +++ b/src/parallel/NeighbourCommunicationScheme.cpp @@ -8,7 +8,9 @@ class NeighbourCommunicationScheme; class DirectNeighbourCommunicationScheme; class IndirectNeighbourCommunicationScheme; +#include #include + #include "NeighbourCommunicationScheme.h" #include "Domain.h" #include "Simulation.h" @@ -246,7 +248,8 @@ void DirectNeighbourCommunicationScheme::initExchangeMoleculesMPI(ParticleContai } } if(not invalidParticles.empty()){ - Log::global_log->error_always_output() << "NeighbourCommunicationScheme: Invalid particles that should have been " + std::ostringstream error_message; + error_message << "NeighbourCommunicationScheme: Invalid particles that should have been " "sent, are still existent. They would be lost. Aborting...\n" << "BoxMin: " << moleculeContainer->getBoundingBoxMin(0) << ", " @@ -258,15 +261,15 @@ void DirectNeighbourCommunicationScheme::initExchangeMoleculesMPI(ParticleContai << moleculeContainer->getBoundingBoxMax(2) << "\n" << "The particles:" << std::endl; for (auto& invalidParticle : invalidParticles) { - Log::global_log->error_always_output() << invalidParticle << std::endl; + error_message << invalidParticle << std::endl; } - Log::global_log->error_always_output() << "The leavingExportNeighbours:" << std::endl; + error_message << "The leavingExportNeighbours:" << std::endl; for (auto& neighbour : (*_leavingExportNeighbours)[0]) { std::stringstream ss; neighbour.print(ss); - Log::global_log->error_always_output() << ss.str() << std::endl; + error_message << ss.str() << std::endl; } - MARDYN_EXIT(544); + MARDYN_EXIT(error_message); } } @@ -377,7 +380,8 @@ void DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI(ParticleCo } if (waitingTime > deadlockTimeOut) { - Log::global_log->error() + std::ostringstream error_message; + error_message << "DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI1d: Deadlock error: Rank " << domainDecomp->getRank() << " is waiting for more than " << deadlockTimeOut << " seconds" << std::endl; @@ -396,7 +400,7 @@ void DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI(ParticleCo }); } - MARDYN_EXIT(457); + MARDYN_EXIT(error_message); } } // while not allDone @@ -422,10 +426,11 @@ void NeighbourCommunicationScheme::selectNeighbours(MessageType msgType, bool im else _neighbours = _haloImportForceExportNeighbours; break; case LEAVING_AND_HALO_COPIES: - Log::global_log->error() << "WRONG type in selectNeighbours - this should not be used for push-pull-partners " + std::ostringstream error_message; + error_message << "WRONG type in selectNeighbours - this should not be used for push-pull-partners " "selectNeighbours method" << std::endl; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); break; } } @@ -587,14 +592,15 @@ void IndirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI1D(Partic } if (waitingTime > deadlockTimeOut) { - Log::global_log->error() + std::ostringstream error_message; + error_message << "IndirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI1d: Deadlock error: Rank " << domainDecomp->getRank() << " is waiting for more than " << deadlockTimeOut << " seconds" << std::endl; for (int i = 0; i < numNeighbours; ++i) { (*_neighbours)[d][i].deadlockDiagnosticSendRecv(); } - MARDYN_EXIT(457); + MARDYN_EXIT(error_message); } } // while not allDone diff --git a/src/parallel/ParticleDataRMM.cpp b/src/parallel/ParticleDataRMM.cpp index f3560d881c..22fdc1c0ed 100644 --- a/src/parallel/ParticleDataRMM.cpp +++ b/src/parallel/ParticleDataRMM.cpp @@ -29,8 +29,9 @@ void ParticleDataRMM::getMPIType(MPI_Datatype &sendPartType) { } else if (sizeof(pdata_dummy.r[0]) == 4) { // 4 bytes for single types[1] = MPI_FLOAT; } else { - Log::global_log->error() << "invalid size of vcp_real_calc"; - MARDYN_EXIT(4852); + std::ostringstream error_message; + error_message << "invalid size of vcp_real_calc"; + MARDYN_EXIT(error_message); } //if the following statement is not true, then the 6 double values do not follow one after the other. diff --git a/src/parallel/StaticIrregDomainDecomposition.cpp b/src/parallel/StaticIrregDomainDecomposition.cpp index c067a60181..f02b6a29bc 100644 --- a/src/parallel/StaticIrregDomainDecomposition.cpp +++ b/src/parallel/StaticIrregDomainDecomposition.cpp @@ -69,12 +69,13 @@ void StaticIrregDomainDecomposition::readXML(XMLfileUnits &xmlconfig) { // We check for this failure, and additionally check for positive // integer if (!(ss >> temp) || temp <= 0) { - Log::global_log->fatal() + std::ostringstream error_message; + error_message << "Weights in " << axes.at(i) << " axis have a non-natural number! Only integer weights > " "0 allowed, please check XML file!" << std::endl; - MARDYN_EXIT(5003); + MARDYN_EXIT(error_message); } _subdomainWeights[i].push_back(temp); if (ss.peek() == ',' || ss.peek() == ' ') // skip commas and spaces diff --git a/src/particleContainer/AutoPasContainer.cpp b/src/particleContainer/AutoPasContainer.cpp index 71a914a41f..374c07aeaf 100644 --- a/src/particleContainer/AutoPasContainer.cpp +++ b/src/particleContainer/AutoPasContainer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Domain.h" #include "Simulation.h" #include "utils/mardyn_assert.h" @@ -183,11 +184,12 @@ auto parseAutoPasOption(XMLfileUnits &xmlconfig, const std::string &xmlString, try { return OptionType::template parseOptions(stringInXml); } catch (const std::exception &e) { - Log::global_log->error() << "AutoPasContainer: error when parsing " << xmlString << ":" << std::endl; - Log::global_log->error() << e.what() << std::endl; - Log::global_log->error() << "Possible options: " + std::ostringstream error_message; + error_message << "AutoPasContainer: error when parsing " << xmlString << ":" << std::endl; + error_message << e.what() << std::endl; + error_message << "Possible options: " << autopas::utils::ArrayUtils::to_string(OptionType::getAllOptions()) << std::endl; - MARDYN_EXIT(4432); + MARDYN_EXIT(error_message); // dummy return return decltype(OptionType::template parseOptions(""))(); } @@ -240,7 +242,9 @@ void AutoPasContainer::readXML(XMLfileUnits &xmlconfig) { } else if (vlSkinPerTimestep == -1 ){ _verletSkin = vlSkin; } else { - Log::global_log->error() << "Input XML specifies skin AND skinPerTimestep. Please choose only one." << std::endl; + std::ostringstream error_message; + error_message << "Input XML specifies skin AND skinPerTimestep. Please choose only one." << std::endl; + MARDYN_EXIT(error_message); } _relativeOptimumRange = xmlconfig.getNodeValue_double("optimumRange", _relativeOptimumRange); _relativeBlacklistRange = xmlconfig.getNodeValue_double("blacklistRange", _relativeBlacklistRange); @@ -394,12 +398,13 @@ bool AutoPasContainer::rebuild(double *bBoxMin, double *bBoxMax) { void AutoPasContainer::update() { // in case we update the container before handling the invalid particles, this might lead to lost particles. if (not _invalidParticles.empty()) { - Log::global_log->error() << "AutoPasContainer: trying to update container, even though invalidParticles still " + std::ostringstream error_message; + error_message << "AutoPasContainer: trying to update container, even though invalidParticles still " "exist. This would lead to lost particles => ERROR!\n" "Remaining invalid particles:\n" << autopas::utils::ArrayUtils::to_string(_invalidParticles, "\n", {"", ""}) << std::endl; - MARDYN_EXIT(434); + MARDYN_EXIT(error_message); } _invalidParticles = _autopasContainer.updateContainer(); diff --git a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h index 1db5cd8e33..38baa9fe6a 100644 --- a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h @@ -78,8 +78,9 @@ template void C08CellPairTraversal::traverseCellPairsOuter( CellProcessor& cellProcessor) { if(eighthShell){ - Log::global_log->error() << "eightshell + overlapping not yet supported." << std::endl; - MARDYN_EXIT(-2); + std::ostringstream error_message; + error_message << "eightshell + overlapping not yet supported." << std::endl; + MARDYN_EXIT(error_message); } using std::array; diff --git a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h index 1603b5bc47..44fcb9e132 100644 --- a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h @@ -124,15 +124,17 @@ void NeutralTerritoryTraversal::traverseCellPairs(CellProcessor& c template void NeutralTerritoryTraversal::traverseCellPairsOuter(CellProcessor& cellProcessor) { - Log::global_log->error() << "NT: overlapping Comm not implemented." << std::endl; - MARDYN_EXIT(46); + std::ostringstream error_message; + error_message << "NT: overlapping Comm not implemented." << std::endl; + MARDYN_EXIT(error_message); } template void NeutralTerritoryTraversal::traverseCellPairsInner(CellProcessor& cellProcessor, unsigned stage, unsigned stageCount) { - Log::global_log->error() << "NT: overlapping Comm not implemented." << std::endl; - MARDYN_EXIT(47); + std::ostringstream error_message; + error_message << "NT: overlapping Comm not implemented." << std::endl; + MARDYN_EXIT(error_message); } template diff --git a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h index 4af4e7c745..bb7b3976de 100644 --- a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h @@ -74,8 +74,9 @@ void OriginalCellPairTraversal::rebuild(std::vector } } } else { - Log::global_log->error() << "OriginalCellPairTraversalDat::rebuild was called with incompatible Traversal data!" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "OriginalCellPairTraversalDat::rebuild was called with incompatible Traversal data!" << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h index 5ce1e2d341..63beebed1e 100644 --- a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h @@ -108,10 +108,11 @@ void QuickschedTraversal::init() { // check that blocksize is within domain size for (int i = 0; i < 3; ++i) { if (_taskBlocksize[i] > this->_dims[i]) { - Log::global_log->error() << "Blocksize is bigger than number of cells in dimension " + std::ostringstream error_message; + error_message << "Blocksize is bigger than number of cells in dimension " << (char) ('x' + i) << ". (" << _taskBlocksize[i] << " > " << this->_dims[i] << ")" << std::endl; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } } @@ -175,8 +176,7 @@ void QuickschedTraversal::init() { break; } /* end case PackedAdjustable */ default: - Log::global_log->error() << "QuickschedHandler::init() received non existing task type!" - << std::endl; + Log::global_log->error() << "QuickschedHandler::init() received non existing task type!" << std::endl; } #endif // QUICKSCHED } diff --git a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h index 9127d11a14..bfda8f2ccc 100644 --- a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h @@ -190,8 +190,9 @@ inline void SlicedCellPairTraversal::traverseCellPairsBackend( // Note: in the following we quasi-reimplement an OpenMP for-loop parallelisation with static scheduling if (not isApplicable(start, end) ) { - Log::global_log->error() << "The SlicedCellPairTraversal is not applicable. Aborting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The SlicedCellPairTraversal is not applicable. Aborting." << std::endl; + MARDYN_EXIT(error_message); } std::array diff; diff --git a/src/particleContainer/LinkedCells.cpp b/src/particleContainer/LinkedCells.cpp index c44ffd32ca..670dfec765 100644 --- a/src/particleContainer/LinkedCells.cpp +++ b/src/particleContainer/LinkedCells.cpp @@ -83,19 +83,19 @@ LinkedCells::LinkedCells(double bBoxMin[3], double bBoxMax[3], if (_boxWidthInNumCells[0] < 2 * _haloWidthInNumCells[0] || _boxWidthInNumCells[1] < 2 * _haloWidthInNumCells[1] || _boxWidthInNumCells[2] < 2 * _haloWidthInNumCells[2]) { - Log::global_log->error_always_output() - << "LinkedCells (constructor): bounding box too small for calculated cell length" + std::ostringstream error_message; + error_message << "LinkedCells (constructor): bounding box too small for calculated cell length" << std::endl; - Log::global_log->error_always_output() << "_cellsPerDimension: " << _cellsPerDimension[0] + error_message << "_cellsPerDimension: " << _cellsPerDimension[0] << " / " << _cellsPerDimension[1] << " / " << _cellsPerDimension[2] << std::endl; - Log::global_log->error_always_output() << "_haloWidthInNumCells: " + error_message << "_haloWidthInNumCells: " << _haloWidthInNumCells[0] << " / " << _haloWidthInNumCells[1] << " / " << _haloWidthInNumCells[2] << std::endl; - Log::global_log->error_always_output() << "_boxWidthInNumCells: " << _boxWidthInNumCells[0] + error_message << "_boxWidthInNumCells: " << _boxWidthInNumCells[0] << " / " << _boxWidthInNumCells[1] << " / " << _boxWidthInNumCells[2] << std::endl; - MARDYN_EXIT(5); + MARDYN_EXIT(error_message); } initializeCells(); @@ -155,8 +155,9 @@ bool LinkedCells::rebuild(double bBoxMin[3], double bBoxMax[3]) { // in each dimension at least one layer of (inner+boundary) cells necessary if (_cellsPerDimension[dim] == 2 * _haloWidthInNumCells[dim]) { - Log::global_log->error_always_output() << "LinkedCells::rebuild: region too small" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "LinkedCells::rebuild: region too small" << std::endl; + MARDYN_EXIT(error_message); } numberOfCells *= _cellsPerDimension[dim]; @@ -224,16 +225,17 @@ void LinkedCells::check_molecules_in_box() { } if (numBadMolecules > 0) { - Log::global_log->error() << "Found " << numBadMolecules << " outside of bounding box:" << std::endl; + std::ostringstream error_message; + error_message << "Found " << numBadMolecules << " outside of bounding box:" << std::endl; for (auto & m : badMolecules) { - Log::global_log->error() << "Particle (id=" << m.getID() << "), (current position: x=" + error_message << "Particle (id=" << m.getID() << "), (current position: x=" << m.r(0) << ", y=" << m.r(1) << ", z=" << m.r(2) << ")" << std::endl; } - Log::global_log->error() << "The bounding box is: [" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMax[0] + error_message << "The bounding box is: [" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMax[0] << ") x [" << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMax[1] << ") x [" << _haloBoundingBoxMin[2] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - Log::global_log->error() << "Particles will be lost. Aborting simulation." << std::endl; - MARDYN_EXIT(311); + error_message << "Particles will be lost. Aborting simulation." << std::endl; + MARDYN_EXIT(error_message); } } @@ -292,8 +294,9 @@ void LinkedCells::update() { if (numBadMolecules > 0) { - Log::global_log->error() << "Found " << numBadMolecules << " outside of their correct cells. Aborting." << std::endl; - MARDYN_EXIT(311); + std::ostringstream error_message; + error_message << "Found " << numBadMolecules << " outside of their correct cells. Aborting." << std::endl; + MARDYN_EXIT(error_message); } #endif } @@ -542,8 +545,9 @@ void LinkedCells::addParticles(std::vector& particles, bool checkWheth void LinkedCells::traverseNonInnermostCells(CellProcessor& cellProcessor) { if (not _cellsValid) { - Log::global_log->error() << "Cell structure in LinkedCells (traverseNonInnermostCells) invalid, call update first" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cell structure in LinkedCells (traverseNonInnermostCells) invalid, call update first" << std::endl; + MARDYN_EXIT(error_message); } _traversalTuner->traverseCellPairsOuter(cellProcessor); @@ -551,8 +555,9 @@ void LinkedCells::traverseNonInnermostCells(CellProcessor& cellProcessor) { void LinkedCells::traversePartialInnermostCells(CellProcessor& cellProcessor, unsigned int stage, int stageCount) { if (not _cellsValid) { - Log::global_log->error() << "Cell structure in LinkedCells (traversePartialInnermostCells) invalid, call update first" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cell structure in LinkedCells (traversePartialInnermostCells) invalid, call update first" << std::endl; + MARDYN_EXIT(error_message); } _traversalTuner->traverseCellPairsInner(cellProcessor, stage, stageCount); @@ -560,10 +565,9 @@ void LinkedCells::traversePartialInnermostCells(CellProcessor& cellProcessor, un void LinkedCells::traverseCells(CellProcessor& cellProcessor) { if (not _cellsValid) { - Log::global_log->error() - << "Cell structure in LinkedCells (traversePairs) invalid, call update first" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cell structure in LinkedCells (traversePairs) invalid, call update first" << std::endl; + MARDYN_EXIT(error_message); } cellProcessor.initTraversal(); @@ -609,10 +613,9 @@ void LinkedCells::deleteParticlesOutsideBox(double boxMin[3], double boxMax[3]) void LinkedCells::deleteOuterParticles() { /*if (_cellsValid == false) { - Log::global_log->error() - << "Cell structure in LinkedCells (deleteOuterParticles) invalid, call update first" - << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Cell structure in LinkedCells (deleteOuterParticles) invalid, call update first" << std::endl; + MARDYN_EXIT(error_message); }*/ const size_t numHaloCells = _haloCellIndices.size(); @@ -641,7 +644,7 @@ RegionParticleIterator LinkedCells::regionIterator(const double startRegion[3], const auto &localBoxOfInterestMin = type == ParticleIterator::ALL_CELLS ? _haloBoundingBoxMin : _boundingBoxMin; const auto &localBoxOfInterestMax = type == ParticleIterator::ALL_CELLS ? _haloBoundingBoxMax : _boundingBoxMax; - // clamp iterated region to local MPI subdomain + // clamp iterated region to local MPI subdomain const std::array startRegionClamped = { std::clamp(startRegion[0], localBoxOfInterestMin[0], localBoxOfInterestMax[0]), std::clamp(startRegion[1], localBoxOfInterestMin[1], localBoxOfInterestMax[1]), @@ -833,11 +836,12 @@ unsigned long int LinkedCells::getCellIndexOfMolecule(Molecule* molecule) const for (int dim = 0; dim < 3; dim++) { #ifndef NDEBUG if (molecule->r(dim) < _haloBoundingBoxMin[dim] || molecule->r(dim) >= _haloBoundingBoxMax[dim]) { - Log::global_log->error() << "Molecule is outside of bounding box" << std::endl; - Log::global_log->error() << "Molecule:\n" << *molecule << std::endl; - Log::global_log->error() << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; - Log::global_log->error() << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Molecule is outside of bounding box" << std::endl; + error_message << "Molecule:\n" << *molecule << std::endl; + error_message << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; + error_message << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; + MARDYN_EXIT(error_message); } #endif //this version is sensitive to roundoffs, if we have molecules (initialized) precisely at position 0.0: @@ -882,11 +886,12 @@ unsigned long int LinkedCells::getCellIndexOfPoint(const double point[3]) const #ifndef NDEBUG //this should never ever happen! if (localPoint[dim] < _haloBoundingBoxMin[dim] || localPoint[dim] >= _haloBoundingBoxMax[dim]) { - Log::global_log->error() << "Point is outside of halo bounding box" << std::endl; - Log::global_log->error() << "Point p = (" << localPoint[0] << ", " << localPoint[1] << ", " << localPoint[2] << ")" << std::endl; - Log::global_log->error() << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; - Log::global_log->error() << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Point is outside of halo bounding box" << std::endl; + error_message << "Point p = (" << localPoint[0] << ", " << localPoint[1] << ", " << localPoint[2] << ")" << std::endl; + error_message << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; + error_message << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; + MARDYN_EXIT(error_message); } #endif @@ -1003,14 +1008,13 @@ void LinkedCells::deleteMolecule(ParticleIterator &moleculeIter, const bool& reb moleculeIter.deleteCurrentParticle(); - if (rebuildCaches) { - auto cellid = getCellIndexOfMolecule(&*moleculeIter); - if (cellid >= _cells.size()) { - Log::global_log->error_always_output() - << "coordinates for atom deletion lie outside bounding box." - << std::endl; - MARDYN_EXIT(1); - } + if (rebuildCaches) { + auto cellid = getCellIndexOfMolecule(&*moleculeIter); + if (cellid >= _cells.size()) { + std::ostringstream error_message; + error_message << "coordinates for atom deletion lie outside bounding box." << std::endl; + MARDYN_EXIT(error_message); + } _cells[cellid].buildSoACaches(); } } @@ -1066,7 +1070,7 @@ double LinkedCells::getEnergy(ParticlePairsHandler* particlePairsHandler, Molecu delete cellProcessor; } - mardyn_assert(not std::isnan(u)); // catches NaN + mardyn_assert(not std::isnan(u)); // catches NaN return u; } diff --git a/src/particleContainer/TraversalTuner.h b/src/particleContainer/TraversalTuner.h index 1db3367ba5..4d445aa0e9 100644 --- a/src/particleContainer/TraversalTuner.h +++ b/src/particleContainer/TraversalTuner.h @@ -154,8 +154,9 @@ void TraversalTuner::findOptimalTraversal() { else if (dynamic_cast *>(_optimalTraversal)) { Log::global_log->info() << "Using QuickschedTraversal." << std::endl; #ifndef QUICKSCHED - Log::global_log->error() << "MarDyn was compiled without Quicksched Support. Aborting!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "MarDyn was compiled without Quicksched Support. Aborting!" << std::endl; + MARDYN_EXIT(error_message); #endif } else if (dynamic_cast *>(_optimalTraversal)) Log::global_log->info() << "Using SlicedCellPairTraversal." << std::endl; @@ -163,9 +164,8 @@ void TraversalTuner::findOptimalTraversal() { Log::global_log->warning() << "Using unknown traversal." << std::endl; if (_cellsInCutoff > _optimalTraversal->maxCellsInCutoff()) { - Log::global_log->error() << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() - << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; - MARDYN_EXIT(45); + std::ostringstream error_message; error_message << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() + << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; MARDYN_EXIT(error_message); } } @@ -240,12 +240,11 @@ void TraversalTuner::readXML(XMLfileUnits &xmlconfig) { tag += (dimension + j); xmlconfig.getNodeValue(tag, quiData->taskBlockSize[j]); if (quiData->taskBlockSize[j] < 2) { - Log::global_log->error() << "Task block size in " + std::ostringstream error_message; error_message << "Task block size in " << (char) (dimension + j) << " direction is <2 and thereby invalid! (" << quiData->taskBlockSize[j] << ")" - << std::endl; - MARDYN_EXIT(1); + << std::endl; MARDYN_EXIT(error_message); } } break; @@ -306,8 +305,9 @@ void TraversalTuner::rebuild(std::vector &cells, con traversalPointerReference = new QuickschedTraversal(cells, dims, quiData->taskBlockSize); } break; default: - Log::global_log->error() << "Unknown traversal data found in TraversalTuner._traversals!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "Unknown traversal data found in TraversalTuner._traversals!" << std::endl; + MARDYN_EXIT(error_message); } } traversalPointerReference->rebuild(cells, dims, cellLength, cutoff, traversalData); @@ -335,8 +335,9 @@ inline void TraversalTuner::traverseCellPairs(traversalNames name, slicedTraversal.traverseCellPairs(cellProcessor); break; default: - Log::global_log->error()<< "Calling traverseCellPairs(traversalName, CellProcessor&) for something else than the Sliced Traversal is disabled for now. Aborting." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message<< "Calling traverseCellPairs(traversalName, CellProcessor&) for something else than the Sliced Traversal is disabled for now. Aborting." << std::endl; + MARDYN_EXIT(error_message); break; } } diff --git a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h index 6627e6d0d3..8a686608f2 100644 --- a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h +++ b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h @@ -175,7 +175,9 @@ class ParticlePairs2PotForceAdapter : public ParticlePairsHandler { FluidPot(molecule1, molecule2, params, distanceVector, dummy1, dummy2, dummy3, calculateLJ); return dummy1 / 6.0 + dummy2 + dummy3; default: - MARDYN_EXIT(666); + std::ostringstream error_message; + error_message << "[ParticlePairs2PotForceAdapter9] pairType is unknown" << std::endl; + MARDYN_EXIT(error_message); } return 0.0; } diff --git a/src/plugins/COMaligner.cpp b/src/plugins/COMaligner.cpp index 51f1d4e63a..fc1be31f66 100755 --- a/src/plugins/COMaligner.cpp +++ b/src/plugins/COMaligner.cpp @@ -7,6 +7,10 @@ #include "COMaligner.h" +#include + +#include "utils/mardyn_assert.h" + //! @brief will be called to read configuration //! //! All values have defaults and are not mandatory to be supplied
@@ -27,11 +31,12 @@ void COMaligner::readXML(XMLfileUnits& xmlconfig){ // SANITY CHECK if(_interval < 1 || _alignmentCorrection < 0 || _alignmentCorrection > 1){ - Log::global_log -> error() << "[COMaligner] INVALID CONFIGURATION!!! DISABLED!" << std::endl; - Log::global_log -> error() << "[COMaligner] HALTING SIMULATION" << std::endl; + std::ostringstream error_message; + error_message << "[COMaligner] INVALID CONFIGURATION!!! DISABLED!" << std::endl; + error_message << "[COMaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); return; } diff --git a/src/plugins/DirectedPM.cpp b/src/plugins/DirectedPM.cpp index b2087794a3..4935f1e079 100644 --- a/src/plugins/DirectedPM.cpp +++ b/src/plugins/DirectedPM.cpp @@ -100,19 +100,20 @@ void DirectedPM::beforeForces(ParticleContainer* particleContainer, DomainDecomp (phiUN < _phiIncrements)) { unID = (hUN * _rIncrements * _phiIncrements) + (rUN * _phiIncrements) + phiUN; } else { - Log::global_log->error() + std::ostringstream error_message; + error_message << "INV PROFILE UNITS " << _universalInvProfileUnit[0] << " " << _universalInvProfileUnit[1] << " " << _universalInvProfileUnit[2] << "\n"; - Log::global_log->error() << "PROFILE UNITS " << _rIncrements << " " << _hIncrements << " " + error_message << "PROFILE UNITS " << _rIncrements << " " << _hIncrements << " " << _phiIncrements << "\n"; - Log::global_log->error() << "Severe error!! Invalid profile ID (" << rUN << " / " << hUN << " / " + error_message << "Severe error!! Invalid profile ID (" << rUN << " / " << hUN << " / " << phiUN << ").\n\n"; - Log::global_log->error() << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " + error_message << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " << phi << ").\n\n"; - Log::global_log->error() + error_message << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; - Log::global_log->error() << "unID = " << unID << "\n"; - MARDYN_EXIT(707); + error_message << "unID = " << unID << "\n"; + MARDYN_EXIT(error_message); } // ADD VELOCITCY AND VIRIAL TO RESPECTIVE BIN _localnumberOfParticles[unID] += 1.; diff --git a/src/plugins/Dropaccelerator.cpp b/src/plugins/Dropaccelerator.cpp index 64ec3c87bb..7550513fca 100644 --- a/src/plugins/Dropaccelerator.cpp +++ b/src/plugins/Dropaccelerator.cpp @@ -31,11 +31,12 @@ void Dropaccelerator::readXML(XMLfileUnits& xmlconfig) { // SANITY CHECK if (_interval < 1 || _steps <= 0 || _startSimStep < 0 || _xPosition <= 0. || _yPosition <= 0. || _zPosition <= 0. || _dropRadius <= 0) { - Log::global_log->error() << "[Dropaccelerator] INVALID CONFIGURATION!!! DISABLED!" << std::endl; - Log::global_log->error() << "[Dropaccelerator] HALTING SIMULATION" << std::endl; + std::ostringstream error_message; + error_message << "[Dropaccelerator] INVALID CONFIGURATION!!! DISABLED!" << std::endl; + error_message << "[Dropaccelerator] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); return; } diff --git a/src/plugins/Dropaligner.cpp b/src/plugins/Dropaligner.cpp index 54a1148f73..4a38821ebf 100644 --- a/src/plugins/Dropaligner.cpp +++ b/src/plugins/Dropaligner.cpp @@ -23,11 +23,12 @@ void Dropaligner::readXML(XMLfileUnits& xmlconfig) { // SANITY CHECK if (_interval < 1 || _alignmentCorrection < 0 || _alignmentCorrection > 1 || _xPos <= 0. || _yPos <= 0. || _zPos <= 0. || _radius <= 0) { - Log::global_log->error() << "[Dropaligner] INVALID CONFIGURATION!!! DISABLED!" << std::endl; - Log::global_log->error() << "[Dropaligner] HALTING SIMULATION" << std::endl; + std::ostringstream error_message; + error_message << "[Dropaligner] INVALID CONFIGURATION!!! DISABLED!" << std::endl; + error_message << "[Dropaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); return; } diff --git a/src/plugins/ExamplePlugin.cpp b/src/plugins/ExamplePlugin.cpp index 2d0d7fcc73..c81b415fb1 100644 --- a/src/plugins/ExamplePlugin.cpp +++ b/src/plugins/ExamplePlugin.cpp @@ -54,13 +54,13 @@ void ExamplePlugin::readXML(XMLfileUnits& xmlconfig) { _displaySelector = WhereToDisplay::AT_FINISH; Log::global_log->info() << "Displaying at finish." << std::endl; } else { - Log::global_log->error() - << "Unknown option specified to ExamplePlugin::where_to_display." - << std::endl; - Log::global_log->error() + std::ostringstream error_message; + error_message + << "Unknown option specified to ExamplePlugin::where_to_display." << std::endl; + error_message << "Valid options are: all, beforeEventNewTimestep, beforeForces, afterForces, endStep, init, finish." << std::endl; - MARDYN_EXIT(11); + MARDYN_EXIT(error_message); } } diff --git a/src/plugins/FixRegion.cpp b/src/plugins/FixRegion.cpp index 5907bebf36..efc63a9cb8 100644 --- a/src/plugins/FixRegion.cpp +++ b/src/plugins/FixRegion.cpp @@ -29,10 +29,11 @@ void FixRegion::init(ParticleContainer* particleContainer, DomainDecompBase* dom // SANITY CHECK if (_xMin < 0. || _yMin < 0. || _zMin < 0. || _xMax > _boxLength[0] || _yMax > _boxLength[1] || _zMax > _boxLength[2]) { - Log::global_log->error() << "[FixRegion] INVALID INPUT!!! DISABLED!" << std::endl; - Log::global_log->error() << "[FixRegion] HALTING SIMULATION" << std::endl; + std::ostringstream error_message; + error_message << "[FixRegion] INVALID INPUT!!! DISABLED!" << std::endl; + error_message << "[FixRegion] HALTING SIMULATION" << std::endl; // HALT SIM - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); return; } diff --git a/src/plugins/MaxCheck.cpp b/src/plugins/MaxCheck.cpp index f323dea434..9e21358ed5 100644 --- a/src/plugins/MaxCheck.cpp +++ b/src/plugins/MaxCheck.cpp @@ -16,6 +16,7 @@ #include "utils/mardyn_assert.h" #include +#include MaxCheck::MaxCheck() { @@ -75,8 +76,9 @@ void MaxCheck::readXML(XMLfileUnits& xmlconfig) { numTargets = query.card(); Log::global_log->info() << "[MaxCheck] Number of component targets: " << numTargets << std::endl; if (numTargets < 1) { - Log::global_log->warning() << "[MaxCheck] No target parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MaxCheck] No target parameters specified. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/Mirror.cpp b/src/plugins/Mirror.cpp index 707cee3b8f..1efd731377 100644 --- a/src/plugins/Mirror.cpp +++ b/src/plugins/Mirror.cpp @@ -85,8 +85,9 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if(nullptr != subject) subject->registerObserver(this); else { - Log::global_log->error() << "[Mirror] Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Initialization of plugin DistControl is needed before! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } Log::global_log->info() << "[Mirror] Enabled at position: y = " << _position.coord << std::endl; @@ -124,15 +125,17 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) /** zero gradient */ if(MT_ZERO_GRADIENT == _type) { - Log::global_log->error() << "[Mirror] Method 3 (MT_ZERO_GRADIENT) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Method 3 (MT_ZERO_GRADIENT) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } /** normal distributions */ if(MT_NORMDISTR_MB == _type) { - Log::global_log->error() << "[Mirror] Method 4 (MT_NORMDISTR_MB) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Method 4 (MT_NORMDISTR_MB) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } /** Meland2004 */ @@ -142,8 +145,9 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if(!xmlconfig.getNodeValue("meland/velo_target", _melandParams.velo_target)) { - Log::global_log->error() << "[Mirror] Meland: Parameters for method 5 (MT_MELAND_2004) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - MARDYN_EXIT(-2004); + std::ostringstream error_message; + error_message << "[Mirror] Meland: Parameters for method 5 (MT_MELAND_2004) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } else { Log::global_log->info() << "[Mirror] Meland: target velocity = " << _melandParams.velo_target << std::endl; @@ -168,13 +172,15 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) bRet = bRet && xmlconfig.getNodeValue("ramping/treatment", _rampingParams.treatment); if (not bRet) { - Log::global_log->error() << "[Mirror] Ramping: Parameters for method 5 (MT_RAMPING) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Ramping: Parameters for method 5 (MT_RAMPING) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } else { if(_rampingParams.startStep > _rampingParams.stopStep) { - Log::global_log->error() << "[Mirror] Ramping: Start > Stop. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Ramping: Start > Stop. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } else { Log::global_log->info() << "[Mirror] Ramping from " << _rampingParams.startStep << " to " << _rampingParams.stopStep << std::endl; @@ -185,8 +191,9 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) case 1 : treatmentStr = "Transmission"; break; default: - Log::global_log->error() << "[Mirror] Ramping: No proper treatment was set. Use 0 (Deletion) or 1 (Transmission). Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[Mirror] Ramping: No proper treatment was set. Use 0 (Deletion) or 1 (Transmission). Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[Mirror] Ramping: Treatment for non-reflected particles: " << _rampingParams.treatment << " ( " << treatmentStr << " ) " << std::endl; } diff --git a/src/plugins/NEMD/DensityControl.cpp b/src/plugins/NEMD/DensityControl.cpp index 05fe0e2685..bd99419ff6 100644 --- a/src/plugins/NEMD/DensityControl.cpp +++ b/src/plugins/NEMD/DensityControl.cpp @@ -84,10 +84,9 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { _vecPriority.push_back(0); const uint32_t nRet = this->tokenize_int_list(_vecPriority, strPrio); if (nRet != numComponents) { - Log::global_log->error() << "[DensityControl] Number of component IDs specified in element ..." + std::ostringstream error_message; error_message << "[DensityControl] Number of component IDs specified in element ..." << " does not match the number of components in the simulation. Programm exit ..." - << std::endl; - MARDYN_EXIT(-1); + << std::endl; MARDYN_EXIT(error_message); } // targets @@ -111,8 +110,9 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { numTargets = query.card(); Log::global_log->info() << "[DensityControl] Number of component targets: " << numTargets << std::endl; if (numTargets < 1) { - Log::global_log->error() << "[DensityControl] No target parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DensityControl] No target parameters specified. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } const std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/NEMD/DistControl.cpp b/src/plugins/NEMD/DistControl.cpp index c6bfee8783..af11f6f3f5 100644 --- a/src/plugins/NEMD/DistControl.cpp +++ b/src/plugins/NEMD/DistControl.cpp @@ -79,16 +79,18 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) std::string strSubdivisionType; if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { - Log::global_log->error() << "[DistControl] Missing attribute \"subdivision@type\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing attribute \"subdivision@type\"! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } if("number" == strSubdivisionType) { unsigned int nNumSlabs = 0; if( !xmlconfig.getNodeValue("subdivision/number", nNumSlabs) ) { - Log::global_log->error() << "[DistControl] Missing element \"subdivision/number\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing element \"subdivision/number\"! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } else this->SetSubdivision(nNumSlabs); @@ -98,16 +100,18 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) double dSlabWidth = 0.; if( !xmlconfig.getNodeValue("subdivision/width", dSlabWidth) ) { - Log::global_log->error() << "[DistControl] Missing element \"subdivision/width\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing element \"subdivision/width\"! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } else this->SetSubdivision(dSlabWidth); } else { - Log::global_log->error() << "[DistControl] Wrong attribute \"subdivision@type\". Expected: type=\"number|width\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Wrong attribute \"subdivision@type\". Expected: type=\"number|width\"! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } // init method @@ -137,8 +141,9 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) } else { - Log::global_log->error() << "[DistControl] Missing elements \"init/values/left\" or \"init/values/right\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing elements \"init/values/left\" or \"init/values/right\" or both! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } } else if("file" == strInitMethodType) @@ -154,15 +159,17 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) } else { - Log::global_log->error() << "[DistControl] Missing elements \"init/file\" or \"init/simstep\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing elements \"init/file\" or \"init/simstep\" or both! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } } else { - Log::global_log->error() << "[DistControl] Wrong attribute \"init@type\", type = " << strInitMethodType << ", " + std::ostringstream error_message; + error_message << "[DistControl] Wrong attribute \"init@type\", type = " << strInitMethodType << ", " "expected: type=\"startconfig|values|file\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } // update method @@ -189,8 +196,9 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) } else { - Log::global_log->error() << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } } else if("denderiv" == strUpdateMethodType) @@ -213,15 +221,17 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) } else { - Log::global_log->error() << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } } else { - Log::global_log->error() << "[DistControl] Wrong attribute \"method@type\", type = " << strUpdateMethodType << ", " + std::ostringstream error_message; + error_message << "[DistControl] Wrong attribute \"method@type\", type = " << strUpdateMethodType << ", " "expected: type=\"density|denderiv\"! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } } @@ -266,8 +276,9 @@ void DistControl::PrepareSubdivision() break; case SDOPT_UNKNOWN: default: - Log::global_log->error() << "[DistControl] PrepareSubdivision(): Neither _binParams.width nor _binParams.count was set correctly! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] PrepareSubdivision(): Neither _binParams.width nor _binParams.count was set correctly! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } _binParams.invWidth = 1. / _binParams.width; @@ -702,13 +713,14 @@ void DistControl::UpdatePositionsInit(ParticleContainer* particleContainer) } case DCIM_UNKNOWN: default: - Log::global_log->error() << "[DistControl] Wrong Init Method! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] Wrong Init Method! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } #ifndef NDEBUG - Log::global_log->error() << "[DistControl] _dInterfaceMidLeft = " << _dInterfaceMidLeft << std::endl; - Log::global_log->error() << "[DistControl] _dInterfaceMidRight = " << _dInterfaceMidRight << std::endl; + Log::global_log->debug() << "[DistControl] _dInterfaceMidLeft = " << _dInterfaceMidLeft << std::endl; + Log::global_log->debug() << "[DistControl] _dInterfaceMidRight = " << _dInterfaceMidRight << std::endl; #endif // update positions @@ -738,8 +750,9 @@ void DistControl::UpdatePositions(const uint64_t& simstep) break; case DCUM_UNKNOWN: default: - Log::global_log->error() << "[DistControl] UpdatePositions() Corrupted code!!! Programm exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[DistControl] UpdatePositions() Corrupted code!!! Programm exit..." << std::endl; + MARDYN_EXIT(error_message); } // update positions diff --git a/src/plugins/NEMD/MettDeamon.cpp b/src/plugins/NEMD/MettDeamon.cpp index 4ddaaa7e2f..18f29c27e2 100644 --- a/src/plugins/NEMD/MettDeamon.cpp +++ b/src/plugins/NEMD/MettDeamon.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -416,8 +417,9 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) numChanges = query.card(); Log::global_log->info() << "[MettDeamon] Number of fixed molecules components: " << numChanges << std::endl; if(numChanges < 1) { - Log::global_log->error() << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -434,8 +436,9 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "[MettDeamon] No component changes defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] No component changes defined in XML-config file. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -1188,8 +1191,9 @@ void MettDeamon::InsertReservoirSlab(ParticleContainer* particleContainer) } _feedrate.feed.sum -= _reservoir->getBinWidth(); // reset feed sum if(not _reservoir->nextBin(_nMaxMoleculeID.global) ) { - Log::global_log->error() << "[MettDeamon] Failed to activate new bin of particle Reservoir's BinQueue => Program exit." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] Failed to activate new bin of particle Reservoir's BinQueue => Program exit." << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->debug() << "[" << nRank << "]: ADDED " << numAdded.local << "/" << numParticlesCurrentSlab.local << " particles (" << numAdded.local/static_cast(numParticlesCurrentSlab.local)*100 << ")%." << std::endl; // calc global values @@ -1208,8 +1212,9 @@ void MettDeamon::initRestart() bool bRet = _reservoir->activateBin(_restartInfo.nBindindex); if(not bRet) { - Log::global_log->info() << "[MettDeamon] Failed to activate reservoir bin after restart! Program exit ... " << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] Failed to activate reservoir bin after restart! Program exit ... " << std::endl; + MARDYN_EXIT(error_message); } _feedrate.feed.sum = _restartInfo.dYsum; } @@ -1225,8 +1230,9 @@ void MettDeamon::readNormDistr() //check to see that the file was opened correctly: if (!ifs.vxz.is_open() || !ifs.vy.is_open() ) { - std::cerr << "[MettDeamon] There was a problem opening the input file!\n"; - MARDYN_EXIT(-1);//exit or do additional error checking + std::ostringstream error_message; + error_message << "[MettDeamon] There was a problem opening the input file!\n"; + MARDYN_EXIT(error_message);//exit or do additional error checking } double dVal = 0.0; @@ -1235,12 +1241,17 @@ void MettDeamon::readNormDistr() _norm.vxz.push_back(dVal); } while (ifs.vy >> dVal) { - if(MD_LEFT_TO_RIGHT == _nMovingDirection) + if (MD_LEFT_TO_RIGHT == _nMovingDirection) { _norm.vy.push_back( abs(dVal) ); - else if (MD_RIGHT_TO_LEFT == _nMovingDirection) + } + else if (MD_RIGHT_TO_LEFT == _nMovingDirection) { _norm.vy.push_back( abs(dVal) * (-1.) ); - else - MARDYN_EXIT(-1); + } + else { + std::ostringstream error_message; + error_message << "[MettDeamon] Something went wrong with the direction." << std::endl; + MARDYN_EXIT(error_message); + } } // close files ifs.vxz.close(); @@ -1308,8 +1319,9 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) xmlconfig.getNodeValue("file/data", _filepath.data); } else { - Log::global_log->error() << "[MettDeamon] Reservoir file type not specified or unknown. Programm exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] Reservoir file type not specified or unknown. Programm exit ..." << std::endl; + MARDYN_EXIT(error_message); } // Possibly change component IDs @@ -1318,8 +1330,9 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) XMLfile::Query query = xmlconfig.query("change"); numChanges = query.card(); if(numChanges < 1) { - Log::global_log->error() << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -1347,8 +1360,9 @@ void Reservoir::readParticleData(DomainDecompBase* domainDecomp, ParticleContain this->readFromFileBinary(domainDecomp, particleContainer); break; default: - Log::global_log->error() << "[MettDeamon] Unknown (or ambiguous) method to read reservoir for feature MettDeamon. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown (or ambiguous) method to read reservoir for feature MettDeamon. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } // sort particles into bins @@ -1476,7 +1490,9 @@ void Reservoir::sortParticlesToBins(DomainDecompBase* domainDecomp, ParticleCont mol.setr(1, y - nBinIndex*_dBinWidth + (domain->getGlobalLength(1) - _dBinWidth) ); break; default: - Log::global_log->error() << "[MettDeamon] Unknown moving direction" << std::endl; + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown moving direction" << std::endl; + MARDYN_EXIT(error_message); } // check if molecule is in bounding box of the process domain bool bIsInsideBB = domainDecomp->procOwnsPos(mol.r(0), mol.r(1), mol.r(2), domain); @@ -1506,7 +1522,9 @@ void Reservoir::sortParticlesToBins(DomainDecompBase* domainDecomp, ParticleCont } break; default: - Log::global_log->error() << "[MettDeamon] Unknown moving direction" << std::endl; + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown moving direction" << std::endl; + MARDYN_EXIT(error_message); } } @@ -1518,8 +1536,9 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* Log::global_log->info() << "[MettDeamon] Opening Reservoirfile " << _filepath.data << std::endl; ifs.open( _filepath.data.c_str() ); if (!ifs.is_open()) { - Log::global_log->error() << "[MettDeamon] Could not open Mettdeamon Reservoirfile " << _filepath.data << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Could not open Mettdeamon Reservoirfile " << _filepath.data << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[MettDeamon] Reading Mettdeamon Reservoirfile " << _filepath.data << std::endl; @@ -1547,8 +1566,9 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* } if((token != "NumberOfMolecules") && (token != "N")) { - Log::global_log->error() << "[MettDeamon] Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; + MARDYN_EXIT(error_message); } ifs >> _numMoleculesRead; @@ -1567,8 +1587,9 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* else if (ntypestring == "ICRV") ntype = ICRV; else if (ntypestring == "IRV") ntype = IRV; else { - Log::global_log->error() << "[MettDeamon] Unknown molecule format '" << ntypestring << "'" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown molecule format '" << ntypestring << "'" << std::endl; + MARDYN_EXIT(error_message); } } else { ifs.seekg(spos); @@ -1609,16 +1630,19 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* ifs >> id >> x >> y >> z >> vx >> vy >> vz; break; default: - Log::global_log->error() << "[MettDeamon] Unknown molecule format" << std::endl; + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown molecule format" << std::endl; + MARDYN_EXIT(error_message); } if( componentid > numcomponents ) { - Log::global_log->error() << "[MettDeamon] Molecule id " << id + std::ostringstream error_message; + error_message << "[MettDeamon] Molecule id " << id << " has a component ID greater than the existing number of components: " << componentid << ">" << numcomponents << std::endl; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. @@ -1645,9 +1669,10 @@ void Reservoir::readFromFileBinaryHeader() XMLfileUnits inp(_filepath.header); if(not inp.changecurrentnode("/mardyn")) { - Log::global_log->error() << "[MettDeamon] Could not find root node /mardyn in XML header file or file itself." << std::endl; - Log::global_log->fatal() << "[MettDeamon] Not a valid MarDyn XML header file." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Could not find root node /mardyn in XML header file or file itself." << std::endl; + error_message << "[MettDeamon] Not a valid MarDyn XML header file." << std::endl; + MARDYN_EXIT(error_message); } bool bInputOk = true; @@ -1674,8 +1699,9 @@ void Reservoir::readFromFileBinaryHeader() if(not bInputOk) { - Log::global_log->error() << "[MettDeamon] Content of file: '" << _filepath.header << "' corrupted! Program exit ..." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Content of file: '" << _filepath.header << "' corrupted! Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } if("ICRVQD" == strMoleculeFormat) @@ -1686,8 +1712,9 @@ void Reservoir::readFromFileBinaryHeader() _nMoleculeFormat = ICRV; else { - Log::global_log->error() << "[MettDeamon] Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -1705,8 +1732,9 @@ void Reservoir::readFromFileBinary(DomainDecompBase* domainDecomp, ParticleConta std::ifstream ifs; ifs.open(_filepath.data.c_str(), std::ios::binary | std::ios::in); if (!ifs.is_open()) { - Log::global_log->error() << "[MettDeamon] Could not open reservoir phaseSpaceFile " << _filepath.data << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[MettDeamon] Could not open reservoir phaseSpaceFile " << _filepath.data << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[MettDeamon] Reading phase space file " << _filepath.data << std::endl; @@ -1724,7 +1752,10 @@ void Reservoir::readFromFileBinary(DomainDecompBase* domainDecomp, ParticleConta case IRV: _moleculeDataReader = std::make_unique(); break; - default: Log::global_log->error() << "[MettDeamon] Unknown molecule format" << std::endl; + default: + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown molecule format" << std::endl; + MARDYN_EXIT(error_message); } for (uint64_t pi=0; pi<_numMoleculesRead; pi++) { @@ -1807,7 +1838,9 @@ bool Reservoir::isRelevant(DomainDecompBase* domainDecomp, Domain* domain, Molec dOffset = nBinIndex*_dBinWidth + (domain->getGlobalLength(1) - _dBinWidth); break; default: - Log::global_log->error() << "[MettDeamon] Unknown moving direction" << std::endl; + std::ostringstream error_message; + error_message << "[MettDeamon] Unknown moving direction" << std::endl; + MARDYN_EXIT(error_message); } return domainDecomp->procOwnsPos(mol.r(0), y-dOffset, mol.r(2), domain); } diff --git a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp index 3b46c6957d..42aa10f4e5 100644 --- a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp +++ b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp @@ -134,12 +134,14 @@ void MettDeamonFeedrateDirector::beforeForces( // Check if other plugins were found if(nullptr == mirror) { - Log::global_log->error() << "[MettDeamonFeedrateDirector] No Mirror plugin found in plugin list. Program exit ..." << std::endl; - MARDYN_EXIT(-2004); + std::ostringstream error_message; + error_message << "[MettDeamonFeedrateDirector] No Mirror plugin found in plugin list. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } if(nullptr == mettDeamon) { - Log::global_log->error() << "[MettDeamonFeedrateDirector] No MettDeamon plugin found in plugin list. Program exit ..." << std::endl; - MARDYN_EXIT(-2004); + std::ostringstream error_message; + error_message << "[MettDeamonFeedrateDirector] No MettDeamon plugin found in plugin list. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } // Get number of deleted/reflected particles from Mirror plugin diff --git a/src/plugins/NEMD/RegionSampling.cpp b/src/plugins/NEMD/RegionSampling.cpp index a1c0ef9b87..c0d0357725 100644 --- a/src/plugins/NEMD/RegionSampling.cpp +++ b/src/plugins/NEMD/RegionSampling.cpp @@ -171,8 +171,9 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) distControl->registerObserver(this); else { - Log::global_log->error() << "RegionSampling->region["<GetID()<<"]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()<<"]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -183,8 +184,9 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) numSamplingModules = query.card(); Log::global_log->info() << "RegionSampling->region["<GetID()-1<<"]: Number of sampling modules: " << numSamplingModules << std::endl; if(numSamplingModules < 1) { - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: No sampling module parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()-1<<"]: No sampling module parameters specified. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } XMLfile::Query::const_iterator outputSamplingIter; @@ -219,16 +221,18 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) std::string strSubdivisionType; if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<info() << "RegionSampling->region["<GetID()-1<<"]: Number of velocity discretizations: " << numDiscretizations << std::endl; if(numDiscretizations < 1) { - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: No velocity discretizations specified for VDF sampling. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()-1<<"]: No velocity discretizations specified for VDF sampling. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } XMLfile::Query::const_iterator nodeIter; for( nodeIter = query_vd.begin(); nodeIter != query_vd.end(); nodeIter++ ) @@ -306,8 +313,9 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) uint32_t cid = 0; bool bVal = xmlconfig.getNodeValue("@cid", cid); if( (cid > _numComponents) || ((not bVal) && (not _boolSingleComp)) ){ - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]: VDF velocity discretization corrupted. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()-1<<"]: VDF velocity discretization corrupted. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } if(_boolSingleComp){ @@ -333,16 +341,18 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) std::string strSubdivisionType; if( !xmlconfig.getNodeValue("subdivision@type", strSubdivisionType) ) { - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]: Found " << numSubdivisions << " 'subdivision' elements, " + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()-1<<"]: Found " << numSubdivisions << " 'subdivision' elements, " "expected: 2. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSubdivisionIter; @@ -473,16 +488,18 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if(not bInputIsValid) { - Log::global_log->error() << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<error() << "RegionSampling->region["<GetID()-1<<"]: Wrong attribute 'sampling@type', expected type='profiles|VDF|fieldYR'! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling->region["<GetID()-1<<"]: Wrong attribute 'sampling@type', expected type='profiles|VDF|fieldYR'! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } // for( outputSamplingIter = query.begin(); outputSamplingIter; outputSamplingIter++ ) } @@ -506,8 +523,9 @@ void SampleRegion::prepareSubdivisionProfiles() break; case SDOPT_UNKNOWN: default: - Log::global_log->error() << "tec::ControlRegion::PrepareSubdivisionProfiles(): Unknown subdivision type! Program exit..." << std::endl; - exit(-1); + std::ostringstream error_message; + error_message << "tec::ControlRegion::PrepareSubdivisionProfiles(): Unknown subdivision type! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -530,8 +548,9 @@ void SampleRegion::prepareSubdivisionVDF() break; case SDOPT_UNKNOWN: default: - Log::global_log->error() << "ERROR in SampleRegion::PrepareSubdivisionVDF(): Unknown subdivision type! Program exit..." << std::endl; - exit(-1); + std::ostringstream error_message; + error_message << "ERROR in SampleRegion::PrepareSubdivisionVDF(): Unknown subdivision type! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -554,8 +573,9 @@ void SampleRegion::prepareSubdivisionFieldYR() break; case SDOPT_UNKNOWN: default: - Log::global_log->error() << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } dWidth = (this->GetWidth(0) < this->GetWidth(2) ) ? this->GetWidth(0) : this->GetWidth(2); @@ -573,8 +593,9 @@ void SampleRegion::prepareSubdivisionFieldYR() break; case SDOPT_UNKNOWN: default: - Log::global_log->error() << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; + MARDYN_EXIT(error_message); } } @@ -2047,8 +2068,9 @@ void RegionSampling::readXML(XMLfileUnits& xmlconfig) numRegions = query.card(); Log::global_log->info() << "RegionSampling: Number of sampling regions: " << numRegions << std::endl; if(numRegions < 1) { - Log::global_log->warning() << "RegionSampling: No region parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "RegionSampling: No region parameters specified. Program exit ..." << std::endl; + MARDYN_EXIT(error_message); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputRegionIter; diff --git a/src/plugins/Permittivity.cpp b/src/plugins/Permittivity.cpp index be6e1c54f6..84aab5743e 100644 --- a/src/plugins/Permittivity.cpp +++ b/src/plugins/Permittivity.cpp @@ -10,6 +10,9 @@ // If a simulation is resumed from a restart file, then the existing running average file is ammended but the computation of the running averages starts anew at the time step of the restart file #include "Permittivity.h" +#include + +#include "utils/mardyn_assert.h" #include "Simulation.h" void Permittivity::readXML(XMLfileUnits& xmlconfig) { @@ -74,7 +77,9 @@ void Permittivity::init(ParticleContainer* particleContainer, DomainDecompBase* bool orientationIsCorrect = ci.dipole(0).e() == std::array{0,0,1}; _myAbs[i] = ci.dipole(0).abs(); if(not orientationIsCorrect){ - Log::global_log->error() << "Wrong dipole vector chosen! Please always choose [eMyx eMyy eMyz] = [0 0 1] when using the permittivity plugin" << std::endl; + std::ostringstream error_message; + error_message << "Wrong dipole vector chosen! Please always choose [eMyx eMyy eMyz] = [0 0 1] when using the permittivity plugin" << std::endl; + MARDYN_EXIT(error_message); } } } diff --git a/src/plugins/PluginFactory.cpp b/src/plugins/PluginFactory.cpp index 765ae121a9..b986293247 100644 --- a/src/plugins/PluginFactory.cpp +++ b/src/plugins/PluginFactory.cpp @@ -192,9 +192,8 @@ long PluginFactory::enablePlugins(std::list& _plugins, } else if ("multi" == sphere_representation) { plugin = new MmpldWriterMultiSphere(); } else { - Log::global_log->error() << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation - << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; error_message << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation + << std::endl; MARDYN_EXIT(error_message); } } else if (pluginname == "DomainProfiles") { plugin = this->create("DensityProfileWriter"); diff --git a/src/plugins/SpatialProfile.cpp b/src/plugins/SpatialProfile.cpp index 136972aaed..0eca608c08 100644 --- a/src/plugins/SpatialProfile.cpp +++ b/src/plugins/SpatialProfile.cpp @@ -45,8 +45,9 @@ void SpatialProfile::readXML(XMLfileUnits& xmlconfig) { xmlconfig.getNodeValue("z", samplInfo.universalProfileUnit[2]); samplInfo.cylinder = false; } else { - Log::global_log->error() << "[SpatialProfile] Invalid mode. cylinder/cartesian" << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[SpatialProfile] Invalid mode. cylinder/cartesian" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[SpatialProfile] Binning units: " << samplInfo.universalProfileUnit[0] << " " @@ -394,17 +395,18 @@ long SpatialProfile::getCylUID(ParticleIterator& thismol) { unID = (long) (hUn * samplInfo.universalProfileUnit[0] * samplInfo.universalProfileUnit[2] + rUn * samplInfo.universalProfileUnit[2] + phiUn); } else { - Log::global_log->error() << "INV PROFILE UNITS " << samplInfo.universalInvProfileUnit[0] << " " + std::ostringstream error_message; + error_message << "INV PROFILE UNITS " << samplInfo.universalInvProfileUnit[0] << " " << samplInfo.universalInvProfileUnit[1] << " " << samplInfo.universalInvProfileUnit[2] << "\n"; - Log::global_log->error() << "PROFILE UNITS " << samplInfo.universalProfileUnit[0] << " " + error_message << "PROFILE UNITS " << samplInfo.universalProfileUnit[0] << " " << samplInfo.universalProfileUnit[1] << " " << samplInfo.universalProfileUnit[2] << "\n"; - Log::global_log->error() << "Severe error!! Invalid profile ID (" << rUn << " / " << hUn << " / " << phiUn + error_message << "Severe error!! Invalid profile ID (" << rUn << " / " << hUn << " / " << phiUn << ").\n\n"; - Log::global_log->error() << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " << phi << ").\n\n"; - Log::global_log->error() << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; - Log::global_log->error() << "unID = " << unID << "\n"; - MARDYN_EXIT(707); + error_message << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " << phi << ").\n\n"; + error_message << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; + error_message << "unID = " << unID << "\n"; + MARDYN_EXIT(error_message); } return unID; } diff --git a/src/plugins/VectorizationTuner.cpp b/src/plugins/VectorizationTuner.cpp index 14e726a566..3134b6df52 100644 --- a/src/plugins/VectorizationTuner.cpp +++ b/src/plugins/VectorizationTuner.cpp @@ -34,8 +34,9 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { } else if (mode == "file") { vtWriter.reset(new VTWriter()); } else { - Log::global_log->error() << R"(Unknown FlopRateOutputPlugin::mode. Choose "stdout" or "file".)" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << R"(Unknown FlopRateOutputPlugin::mode. Choose "stdout" or "file".)" << std::endl; + MARDYN_EXIT(error_message); } _outputPrefix = "mardyn"; @@ -61,10 +62,9 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { } else if (incTypeStr == "both") { _moleculeCntIncreaseType = MoleculeCntIncreaseTypeEnum::both; } else { - Log::global_log->error() + std::ostringstream error_message; error_message << R"(Unknown FlopRateOutputPlugin::moleculecntincreasetype. Choose "linear" or "exponential" or "both".)" - << std::endl; - MARDYN_EXIT(798123); + << std::endl; MARDYN_EXIT(error_message); } Log::global_log->info() << "Molecule count increase type: " << incTypeStr << std::endl; @@ -282,8 +282,9 @@ void VectorizationTuner::tune(std::vector& componentList, TunerLoad& mardyn_assert(componentList.size() == particleNums.size()); if(componentList.size() > 2){ - Log::global_log->error_always_output() << "The tuner currently supports only two different particle types!" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "The tuner currently supports only two different particle types!" << std::endl; + MARDYN_EXIT(error_message); } int maxMols = particleNums.at(0); diff --git a/src/plugins/WallPotential.cpp b/src/plugins/WallPotential.cpp index b442a1c01c..f9e316f45d 100755 --- a/src/plugins/WallPotential.cpp +++ b/src/plugins/WallPotential.cpp @@ -5,6 +5,8 @@ #include "WallPotential.h" +#include + #include "Simulation.h" #include "utils/mardyn_assert.h" @@ -40,7 +42,7 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { _potential = LJ9_3; // TODO: is this allowed or should simulation be halted // HALT SIM - //MARDYN_EXIT(1); + //MARDYN_EXIT(error_message); } XMLfile::Query query = xmlconfig.query("component"); @@ -87,8 +89,9 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { Log::global_log->info() << "[WallPotential] LJ10_4 initialized." << std::endl; } else{ - Log::global_log -> error() << "[WallPotential] UNKNOWN WALL POTENTIAL! EXITING!" << std::endl; - MARDYN_EXIT(11); + std::ostringstream error_message; + error_message << "[WallPotential] Unknown wall potential" << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/plugins/profiles/ProfileBase.cpp b/src/plugins/profiles/ProfileBase.cpp index 3f685c23d5..822b79cc58 100644 --- a/src/plugins/profiles/ProfileBase.cpp +++ b/src/plugins/profiles/ProfileBase.cpp @@ -2,8 +2,11 @@ // Created by Kruegener on 10/25/2018. // +#include + #include "ProfileBase.h" #include "plugins/SpatialProfile.h" +#include "utils/mardyn_assert.h" void ProfileBase::writeMatrix (std::ofstream& outfile) { if (_samplInfo.cylinder) { @@ -43,7 +46,9 @@ void ProfileBase::writeKartMatrix (std::ofstream& outfile) { } void ProfileBase::writeSimpleMatrix (std::ofstream& outfile) { - Log::global_log->error() << "SIMPLE MATRIX OUTPUT NOT IMPLEMENTED!\n"; + std::ostringstream error_message; + error_message << "SIMPLE MATRIX OUTPUT NOT IMPLEMENTED!\n"; + MARDYN_EXIT(error_message); } void ProfileBase::writeCylMatrix (std::ofstream& outfile) { diff --git a/src/thermostats/TemperatureControl.cpp b/src/thermostats/TemperatureControl.cpp index f80ff6455f..d63f0573a8 100644 --- a/src/thermostats/TemperatureControl.cpp +++ b/src/thermostats/TemperatureControl.cpp @@ -167,8 +167,9 @@ void ControlRegionT::readXML(XMLfileUnits& xmlconfig) { _timestep = global_simulation->getIntegrator()->getTimestepLength(); _nuDt = _nuAndersen * _timestep; } else { - Log::global_log->error() << "[TemperatureControl] REGION: Invalid 'method' param: " << methods << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[TemperatureControl] REGION: Invalid 'method' param: " << methods << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[TemperatureControl] REGION 'method' param: " << methods << std::endl; } @@ -191,8 +192,9 @@ void ControlRegionT::VelocityScalingInit(XMLfileUnits& xmlconfig, std::string st // settings xmlconfig.getNodeValue("settings/numslabs", _nNumSlabs); if (_nNumSlabs < 1) { - Log::global_log->fatal() << "TemperatureControl: need at least one slab! (settings/numslabs)"; - MARDYN_EXIT(932); + std::ostringstream error_message; + error_message << "TemperatureControl: need at least one slab! (settings/numslabs)"; + MARDYN_EXIT(error_message); } xmlconfig.getNodeValue("settings/exponent", _dTemperatureExponent); xmlconfig.getNodeValue("settings/directions", strDirections); @@ -417,8 +419,9 @@ void ControlRegionT::ControlTemperature(Molecule* mol) { } } } else { - Log::global_log->error() << "[TemperatureControl] Invalid localMethod param: " << _localMethod << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; + error_message << "[TemperatureControl] Invalid localMethod param: " << _localMethod << std::endl; + MARDYN_EXIT(error_message); } } @@ -504,9 +507,8 @@ void ControlRegionT::registerAsObserver() { if (distControl != nullptr) distControl->registerObserver(this); else { - Log::global_log->error() << "TemperatureControl->region[" << this->GetID() - << "]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(-1); + std::ostringstream error_message; error_message << "TemperatureControl->region[" << this->GetID() + << "]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; MARDYN_EXIT(error_message); } } } diff --git a/src/utils/OptionParser.cpp b/src/utils/OptionParser.cpp index 920308d2c1..d1c007c40c 100644 --- a/src/utils/OptionParser.cpp +++ b/src/utils/OptionParser.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #if defined(ENABLE_NLS) && ENABLE_NLS # include @@ -345,11 +346,13 @@ void OptionParser::process_opt(const Option& o, const std::string& opt, const st } else if (o.action() == "help") { print_help(); - MARDYN_EXIT(0); + std::ostringstream empty_message; + mardyn_exit(empty_message, __FILE__, __LINE__, EXIT_SUCCESS); } else if (o.action() == "version") { print_version(); - MARDYN_EXIT(0); + std::ostringstream empty_message; + mardyn_exit(empty_message, __FILE__, __LINE__, EXIT_SUCCESS); } else if (o.action() == "callback" && o.callback()) { (*o.callback())(o, opt, value, *this); @@ -437,12 +440,15 @@ void OptionParser::print_version() const { } void OptionParser::exit() const { - MARDYN_EXIT(2); + std::ostringstream error_message; + error_message << "OptionParser::exit() called" << std::endl; + MARDYN_EXIT(error_message); } void OptionParser::error(const std::string& msg) const { print_usage(std::cerr); - std::cerr << prog() << ": " << _("error") << ": " << msg << std::endl; - MARDYN_EXIT(-4); + std::ostringstream error_message; + error_message << prog() << ": " << _("error") << ": " << msg << std::endl; + MARDYN_EXIT(error_message); } ////////// } class OptionParser ////////// diff --git a/src/utils/SigsegvHandler.h b/src/utils/SigsegvHandler.h index 0e682df7af..add1bdc5f9 100644 --- a/src/utils/SigsegvHandler.h +++ b/src/utils/SigsegvHandler.h @@ -28,7 +28,7 @@ void handler(int sig) { // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, STDERR_FILENO); - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } void registerSigsegvHandler() { diff --git a/src/utils/Testing.cpp b/src/utils/Testing.cpp index 157163dee3..bca12087f4 100644 --- a/src/utils/Testing.cpp +++ b/src/utils/Testing.cpp @@ -94,7 +94,7 @@ utils::Test::~Test() { } void utils::Test::setTestDataDirectory(std::string& testDataDir) { if (!fileExists(testDataDir.c_str())) { test_log->error() << "Directory '" << testDataDirectory << "' for test input data does not exist!" << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } testDataDirectory = testDataDir; } @@ -105,7 +105,7 @@ std::string utils::Test::getTestDataFilename(const std::string& file, bool check if (!fileExists(fullPath.c_str()) and checkExistence) { test_log->error() << "File " << fullPath << " for test input data does not exist!" << std::endl; - MARDYN_EXIT(-1); + MARDYN_EXIT(error_message); } return fullPath; } diff --git a/src/utils/generator/ReplicaFiller.cpp b/src/utils/generator/ReplicaFiller.cpp index d499c22713..9405aaec9d 100644 --- a/src/utils/generator/ReplicaFiller.cpp +++ b/src/utils/generator/ReplicaFiller.cpp @@ -146,19 +146,22 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { std::string inputPluginName; xmlconfig.getNodeValue("@type", inputPluginName); if (inputPluginName != "BinaryReader") { - Log::global_log->error() << "[ReplicaFiller] ReplicaFiller only works with inputPlugins: BinaryReader at the moment" << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ReplicaFiller] ReplicaFiller only works with inputPlugins: BinaryReader at the moment" << std::endl; + MARDYN_EXIT(error_message); } setInputReader(std::make_shared()); _inputReader->readXML(xmlconfig); if (_inputReader == nullptr) { - Log::global_log->error() << "[ReplicaFiller] Could not create input reader " << inputPluginName << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ReplicaFiller] Could not create input reader " << inputPluginName << std::endl; + MARDYN_EXIT(error_message); } xmlconfig.changecurrentnode(".."); } else { - Log::global_log->error() << "[ReplicaFiller] Input reader for original not specified." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ReplicaFiller] Input reader for original not specified." << std::endl; + MARDYN_EXIT(error_message); } if (xmlconfig.changecurrentnode("origin")) { Coordinate3D origin; @@ -176,8 +179,9 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { if (xmlconfig.getNodeValue("componentid", componentid)) { const size_t numComps = global_simulation->getEnsemble()->getComponents()->size(); if ((componentid < 1) || (componentid > numComps)) { - Log::global_log->error() << "[ReplicaFiller] Specified componentid is invalid. Valid range: 1 <= componentid <= " << numComps << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ReplicaFiller] Specified componentid is invalid. Valid range: 1 <= componentid <= " << numComps << std::endl; + MARDYN_EXIT(error_message); } _componentid = componentid - 1; // Internally stored in array starting at index 0 _keepComponent = false; @@ -205,8 +209,9 @@ void ReplicaFiller::init() { Log::global_log->info() << "[ReplicaFiller] Number of molecules in the replica: " << numberOfParticles << std::endl; if (numberOfParticles == 0) { - Log::global_log->error_always_output() << "[ReplicaFiller] No molecules in replica, aborting! " << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "[ReplicaFiller] No molecules in replica, aborting! " << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "[ReplicaFiller] Setting simulation time to 0.0" << std::endl; diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index 18d5d0eab5..c24cbaa4d7 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -193,9 +193,10 @@ bool XMLfile::initfile_local(const std::string& filepath) { //version using ifstream std::ifstream fstrm(filepathTrimmed.c_str(),std::ifstream::binary|std::ifstream::ate); if(!fstrm) { - std::cerr << "ERROR opening " << filepathTrimmed << std::endl; + std::ostringstream error_message; + error_message << "ERROR opening " << filepathTrimmed << std::endl; clear(); - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } std::ifstream::pos_type filesize=fstrm.tellg(); fstrm.close(); fstrm.clear(); @@ -538,17 +539,19 @@ template bool XMLfile::Node::getValue(T& value) const // Check if input has correct sign if (std::is_unsigned_v) { if (ss.str().find_first_of("-") != std::string::npos) { - std::cerr << "ERROR parsing \"" << ss.str() << "\" to data type " << typeid(T).name() << " from tag \"<" << name() << ">\" in xml file" << std::endl; - std::cerr << "The tag contains a negative value but an unsigned value was expected." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "ERROR parsing \"" << ss.str() << "\" to data type " << typeid(T).name() << " from tag \"<" << name() << ">\" in xml file" << std::endl; + error_message << "The tag contains a negative value but an unsigned value was expected." << std::endl; + MARDYN_EXIT(error_message); } } ss >> value; // Check if the entire string was consumed if (!ss.eof() || ss.fail()) { - std::cerr << "ERROR parsing all chars of \"" << ss.str() << "\" from tag \"<" << name() << ">\" in xml file" << std::endl; - std::cerr << "This might be the result of using a float while an integer is expected." << std::endl; - MARDYN_EXIT(1); + std::ostringstream error_message; + error_message << "ERROR parsing all chars of \"" << ss.str() << "\" from tag \"<" << name() << ">\" in xml file" << std::endl; + error_message << "This might be the result of using a float while an integer is expected." << std::endl; + MARDYN_EXIT(error_message); } return true; } @@ -582,9 +585,10 @@ template<> bool XMLfile::Node::getValue(bool& value) const } else if (v == "FALSE" || v == "NO" || v == "OFF") { value = false; } else { - std::cerr << "ERROR parsing \"" << v << "\" to boolean from tag \"" << name() << "\" in xml file." + std::ostringstream error_message; + error_message << "ERROR parsing \"" << v << "\" to boolean from tag \"" << name() << "\" in xml file." << " Valid values are: true, false, yes, no, on, off. " << std::endl; - MARDYN_EXIT(1); + MARDYN_EXIT(error_message); } } return found; From f43270416b14d72bf611e8a0d9965e248dd4f4ce Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Fri, 4 Oct 2024 13:54:20 +0200 Subject: [PATCH 17/28] Fix in Testing.cpp --- src/utils/Testing.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/Testing.cpp b/src/utils/Testing.cpp index bca12087f4..fce9273ddc 100644 --- a/src/utils/Testing.cpp +++ b/src/utils/Testing.cpp @@ -93,7 +93,8 @@ utils::Test::~Test() { } void utils::Test::setTestDataDirectory(std::string& testDataDir) { if (!fileExists(testDataDir.c_str())) { - test_log->error() << "Directory '" << testDataDirectory << "' for test input data does not exist!" << std::endl; + std::ostringstream error_message; + error_message << "Directory '" << testDataDir.c_str() << "' for test input data does not exist!" << std::endl; MARDYN_EXIT(error_message); } testDataDirectory = testDataDir; @@ -104,7 +105,8 @@ std::string utils::Test::getTestDataFilename(const std::string& file, bool check std::string fullPath = testDataDirectory +"/"+ file; if (!fileExists(fullPath.c_str()) and checkExistence) { - test_log->error() << "File " << fullPath << " for test input data does not exist!" << std::endl; + std::ostringstream error_message; + error_message << "File " << fullPath << " for test input data does not exist!" << std::endl; MARDYN_EXIT(error_message); } return fullPath; From ec9a2ddbd0ba4a03c07fca72bced53ca16615e45 Mon Sep 17 00:00:00 2001 From: FG-TUM Date: Tue, 8 Oct 2024 13:32:11 +0200 Subject: [PATCH 18/28] Mention all-options in the main README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bfeb0e4027..88bf3beef2 100644 --- a/README.md +++ b/README.md @@ -161,10 +161,13 @@ MarDyn [options] ``` where `MarDyn` is the executable build in the INSTALLATION section, `[options]` are any "--"-prefixed options as listed by `MarDyn --help` and `` is a input file. -Detailed help can be obtained by running +To get an overview of further command line options run ```sh MarDyn --help ``` + +To understand how to write an input file check out [examples/all-options.xml](https://github.com/ls1mardyn/ls1-mardyn/blob/master/examples/all-options.xml), the various examples in the examples folder and the documentation of the various `readXML()` methods, e.g. via our doxygen documentation. + ### running examples ls1-MarDyn comes with a set of examples, which can be found in the examples folder. ```sh From e963b2e3415a1c2ecc13b4462bb2e95a3e045fe1 Mon Sep 17 00:00:00 2001 From: FG-TUM Date: Tue, 8 Oct 2024 13:32:56 +0200 Subject: [PATCH 19/28] Add hint about necessary doc in the PR template --- .github/PULL_REQUEST_TEMPLATE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0b1aece4f8..8f89b94cde 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,3 +17,8 @@ Please describe the tests that you ran to verify your changes. - [ ] Test A - [ ] Test B + +## Documentation +(Only relevant if this PR introduces new features) +- [ ] `all-options.xml` documents how to use the feature. +- [ ] The responsible `readXML()` documents how to use the feature. From 34b5c7c2dbdce5896cf95cd38f83eceda0681e8f Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 16:18:07 +0200 Subject: [PATCH 20/28] Fix formating --- src/ensemble/CavityEnsemble.cpp | 6 ++++-- src/ensemble/ChemicalPotential.cpp | 6 ++++-- src/io/ASCIIReader.cpp | 13 +++++++------ src/io/BinaryReader.cpp | 12 ++++++++---- src/io/CavityWriter.cpp | 10 ++++++---- src/io/CubicGridGeneratorInternal.cpp | 12 +++++++----- src/io/KDTreePrinter.cpp | 4 ++-- src/io/MPI_IOCheckpointWriter.cpp | 6 ++++-- src/io/MPI_IOReader.cpp | 12 ++++++++---- src/io/ReplicaGenerator.cpp | 10 ++++++---- src/parallel/CollectiveCommunicationNonBlocking.h | 12 ++++++++---- src/parallel/DomainDecompMPIBase.cpp | 10 ++++++---- src/particleContainer/TraversalTuner.h | 12 ++++++++---- src/plugins/NEMD/DensityControl.cpp | 6 ++++-- src/plugins/PluginFactory.cpp | 5 +++-- src/plugins/VectorizationTuner.cpp | 6 ++++-- src/thermostats/TemperatureControl.cpp | 6 ++++-- 17 files changed, 93 insertions(+), 55 deletions(-) diff --git a/src/ensemble/CavityEnsemble.cpp b/src/ensemble/CavityEnsemble.cpp index e62a3ed9f7..dd8b505953 100644 --- a/src/ensemble/CavityEnsemble.cpp +++ b/src/ensemble/CavityEnsemble.cpp @@ -93,9 +93,11 @@ void CavityEnsemble::setSubdomain(int rank, double x0, double x1, double y0, dou void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1, double y1, double z1) { if ((x0 >= x1) || (y0 >= y1) || (z0 >= z1)) { - std::ostringstream error_message; error_message << "\nInvalid control volume (" << x0 << " / " << y0 + std::ostringstream error_message; + error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " - << z1 << ")." << std::endl; MARDYN_EXIT(error_message); + << z1 << ")." << std::endl; + MARDYN_EXIT(error_message); } this->restrictedControlVolume = true; diff --git a/src/ensemble/ChemicalPotential.cpp b/src/ensemble/ChemicalPotential.cpp index 3a6c2c55c0..687f2c42fe 100644 --- a/src/ensemble/ChemicalPotential.cpp +++ b/src/ensemble/ChemicalPotential.cpp @@ -375,9 +375,11 @@ void ChemicalPotential::setControlVolume(double x0, double y0, double z0, double x1, double y1, double z1) { if ((x0 >= x1) || (y0 >= y1) || (z0 >= z1)) { - std::ostringstream error_message; error_message << "\nInvalid control volume (" << x0 << " / " << y0 + std::ostringstream error_message; + error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 - << ")." << std::endl; MARDYN_EXIT(error_message); + << ")." << std::endl; + MARDYN_EXIT(error_message); } _restrictedControlVolume = true; _globalV = (x1 - x0) * (y1 - y0) * (z1 - z0); diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index 1f933cbc8a..61d87e1499 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -166,8 +166,9 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { _phaseSpaceHeaderFileStream >> numljcenters >> numcharges >> numdipoles >> numquadrupoles >> numtersoff; if(numtersoff != 0) { - std::ostringstream error_message; error_message << "tersoff no longer supported." - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "tersoff no longer supported." << std::endl; + MARDYN_EXIT(error_message); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -404,11 +405,11 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain } if(componentid > numcomponents) { - std::ostringstream error_message; error_message << "Molecule id " << id + std::ostringstream error_message; + error_message << "Molecule id " << id << " has a component ID greater than the existing number of components: " - << componentid - << ">" - << numcomponents << std::endl; MARDYN_EXIT(error_message); + << componentid << ">" << numcomponents << std::endl; + MARDYN_EXIT(error_message); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/BinaryReader.cpp b/src/io/BinaryReader.cpp index 86c3ca73d8..26f106690c 100644 --- a/src/io/BinaryReader.cpp +++ b/src/io/BinaryReader.cpp @@ -135,8 +135,10 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai _phaseSpaceFileStream.open(_phaseSpaceFile.c_str(), std::ios::binary | std::ios::in); if(!_phaseSpaceFileStream.is_open()) { - std::ostringstream error_message; error_message << "Could not open phaseSpaceFile " - << _phaseSpaceFile << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Could not open phaseSpaceFile " + << _phaseSpaceFile << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; @@ -178,8 +180,10 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai if (domainDecomp->getRank() == 0) { // Rank 0 only #endif if(_phaseSpaceFileStream.eof()) { - std::ostringstream error_message; error_message << "End of file was hit before all " << numMolecules << " expected molecules were read." - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "End of file was hit before all " << numMolecules << " expected molecules were read." + << std::endl; + MARDYN_EXIT(error_message); } _phaseSpaceFileStream.read(reinterpret_cast (&id), 8); switch (_nMoleculeFormat) { diff --git a/src/io/CavityWriter.cpp b/src/io/CavityWriter.cpp index 8472c0bf07..b782b0e2ba 100644 --- a/src/io/CavityWriter.cpp +++ b/src/io/CavityWriter.cpp @@ -80,13 +80,15 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { xmlconfig.getNodeValue("ControlVolume/z1", _controlVolume[5]); for (int d = 0; d < 3; d++) { if (_controlVolume[d * 2] > _controlVolume[d * 2 + 1]) { - std::ostringstream error_message; error_message << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound. " - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound." << std::endl; + MARDYN_EXIT(error_message); } if (_controlVolume[d * 2] < 0 || _controlVolume[d * 2 + 1] > global_simulation->getDomain()->getGlobalLength(d)) { - std::ostringstream error_message; error_message << "[CavityWriter] Control volume bounds may not be outside of domain boundaries. " - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "[CavityWriter] Control volume bounds may not be outside of domain boundaries." << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/io/CubicGridGeneratorInternal.cpp b/src/io/CubicGridGeneratorInternal.cpp index e9ab4ebb09..d564b51bdd 100644 --- a/src/io/CubicGridGeneratorInternal.cpp +++ b/src/io/CubicGridGeneratorInternal.cpp @@ -48,9 +48,9 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { if(density != -1.){ // density has been set if(density <= 0){ - std::ostringstream error_message; error_message - << "Error in CubicGridGeneratorInternal: Density has to be positive and non-zero!" - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Error in CubicGridGeneratorInternal: Density has to be positive and non-zero!" << std::endl; + MARDYN_EXIT(error_message); } double vol = 1.0; for (int d = 0; d < 3; ++d) @@ -65,8 +65,10 @@ unsigned long CubicGridGeneratorInternal::readPhaseSpace(ParticleContainer *part Log::global_log->info() << "Reading phase space file (CubicGridGenerator)." << std::endl; if(_numMolecules == 0){ - std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: numMolecules is not set!" - << std::endl << "Please make sure to run readXML()!" << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Error in CubicGridGeneratorInternal: numMolecules is not set!" + << std::endl << "Please make sure to run readXML()!" << std::endl; + MARDYN_EXIT(error_message); } // create a body centered cubic layout, by creating by placing the molecules on the diff --git a/src/io/KDTreePrinter.cpp b/src/io/KDTreePrinter.cpp index 3c5476bd17..8a4a7ce127 100644 --- a/src/io/KDTreePrinter.cpp +++ b/src/io/KDTreePrinter.cpp @@ -18,8 +18,8 @@ void KDTreePrinter::readXML(XMLfileUnits &xmlconfig) { Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; if (_writeFrequency == 0) { - std::ostringstream error_message; error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message;error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + MARDYN_EXIT(error_message); } _outputPrefix = "mardyn"; diff --git a/src/io/MPI_IOCheckpointWriter.cpp b/src/io/MPI_IOCheckpointWriter.cpp index 4f0cf8b461..46c4a49ee6 100644 --- a/src/io/MPI_IOCheckpointWriter.cpp +++ b/src/io/MPI_IOCheckpointWriter.cpp @@ -434,7 +434,9 @@ void MPI_IOCheckpointWriter::handle_error(int i) { MPI_Error_string(i, error_string, &length_of_error_string); - std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i - << " , " << error_string << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Writing of file was not successfull " << " , " << i + << " , " << error_string << std::endl; + MARDYN_EXIT(error_message); #endif } diff --git a/src/io/MPI_IOReader.cpp b/src/io/MPI_IOReader.cpp index 2648cf71cb..b06c48b664 100644 --- a/src/io/MPI_IOReader.cpp +++ b/src/io/MPI_IOReader.cpp @@ -118,8 +118,10 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(!(ntypestring == "ICRVQD" || ntypestring == "ICRV" || ntypestring == "IRV")) { - std::ostringstream error_message; error_message << "Unknown molecule format: '" - << ntypestring << "'" << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Unknown molecule format: '" + << ntypestring << "'" << std::endl; + MARDYN_EXIT(error_message); } _moleculeFormat = ntypestring; Log::global_log->info() << " molecule format: " << ntypestring << std::endl; @@ -657,7 +659,9 @@ void MPI_IOReader::handle_error(int i) { MPI_Error_string(i, error_string, &length_of_error_string); - std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i - << " , " << error_string << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Writing of file was not successfull " << " , " << i + << " , " << error_string << std::endl; + MARDYN_EXIT(error_message); #endif } diff --git a/src/io/ReplicaGenerator.cpp b/src/io/ReplicaGenerator.cpp index d1c9d75c66..60b07b86ff 100755 --- a/src/io/ReplicaGenerator.cpp +++ b/src/io/ReplicaGenerator.cpp @@ -81,8 +81,9 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { subDomain.dDensity = subDomain.numParticles / subDomain.dVolume; if(not bInputOk) { - std::ostringstream error_message; error_message << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted! Program exit ..." - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted!" << std::endl; + MARDYN_EXIT(error_message); } if("ICRVQD" == strMoleculeFormat) @@ -190,8 +191,9 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { } else if("heterogeneous_LV" == strType) { _nSystemType = ST_HETEROGENEOUS_LIQUID_VAPOR; } else { - std::ostringstream error_message; error_message << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" << std::endl; + MARDYN_EXIT(error_message); } SubDomain sd; diff --git a/src/parallel/CollectiveCommunicationNonBlocking.h b/src/parallel/CollectiveCommunicationNonBlocking.h index 6c319187ff..e4b2d9cbc4 100644 --- a/src/parallel/CollectiveCommunicationNonBlocking.h +++ b/src/parallel/CollectiveCommunicationNonBlocking.h @@ -39,8 +39,10 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac //! @param numValues number of values that shall be communicated void init(MPI_Comm communicator, int numValues, int key = 0) override { if (_currentKey != -1) { - std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey - << " not yet finalized" << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey + << " not yet finalized" << std::endl; + MARDYN_EXIT(error_message); } _currentKey = key; @@ -56,8 +58,10 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac // Creates the CollectiveCommunicationSingleNonBlocking object auto [_, inserted] = _comms.try_emplace(_currentKey); if (not inserted) { - std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: key " << _currentKey - << " could not be inserted. Aborting!" << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "CollectiveCommunicationNonBlocking: key " << _currentKey + << " could not be inserted. Aborting!" << std::endl; + MARDYN_EXIT(error_message); } } _comms.at(_currentKey).init(communicator, numValues, _currentKey); diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index cc5aad9469..8e46b98637 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -149,8 +149,9 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else if(zonalMethod=="nt") { zonalMethodP = new NeutralTerritory(); } else { - std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Using zonal method: " << zonalMethod << std::endl; @@ -164,8 +165,9 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons Log::global_log->info() << "DomainDecompMPIBase: Using IndirectCommunicationScheme" << std::endl; _neighbourCommunicationScheme = std::make_unique(zonalMethodP); } else { - std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" << std::endl; + MARDYN_EXIT(error_message); } } diff --git a/src/particleContainer/TraversalTuner.h b/src/particleContainer/TraversalTuner.h index 4d445aa0e9..92b7d89ef2 100644 --- a/src/particleContainer/TraversalTuner.h +++ b/src/particleContainer/TraversalTuner.h @@ -164,8 +164,10 @@ void TraversalTuner::findOptimalTraversal() { Log::global_log->warning() << "Using unknown traversal." << std::endl; if (_cellsInCutoff > _optimalTraversal->maxCellsInCutoff()) { - std::ostringstream error_message; error_message << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() - << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() + << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; + MARDYN_EXIT(error_message); } } @@ -240,11 +242,13 @@ void TraversalTuner::readXML(XMLfileUnits &xmlconfig) { tag += (dimension + j); xmlconfig.getNodeValue(tag, quiData->taskBlockSize[j]); if (quiData->taskBlockSize[j] < 2) { - std::ostringstream error_message; error_message << "Task block size in " + std::ostringstream error_message; + error_message << "Task block size in " << (char) (dimension + j) << " direction is <2 and thereby invalid! (" << quiData->taskBlockSize[j] << ")" - << std::endl; MARDYN_EXIT(error_message); + << std::endl; + MARDYN_EXIT(error_message); } } break; diff --git a/src/plugins/NEMD/DensityControl.cpp b/src/plugins/NEMD/DensityControl.cpp index bd99419ff6..20572e6098 100644 --- a/src/plugins/NEMD/DensityControl.cpp +++ b/src/plugins/NEMD/DensityControl.cpp @@ -84,9 +84,11 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { _vecPriority.push_back(0); const uint32_t nRet = this->tokenize_int_list(_vecPriority, strPrio); if (nRet != numComponents) { - std::ostringstream error_message; error_message << "[DensityControl] Number of component IDs specified in element ..." + std::ostringstream error_message; + error_message << "[DensityControl] Number of component IDs specified in element ..." << " does not match the number of components in the simulation. Programm exit ..." - << std::endl; MARDYN_EXIT(error_message); + << std::endl; + MARDYN_EXIT(error_message); } // targets diff --git a/src/plugins/PluginFactory.cpp b/src/plugins/PluginFactory.cpp index b986293247..2c7e5f4868 100644 --- a/src/plugins/PluginFactory.cpp +++ b/src/plugins/PluginFactory.cpp @@ -192,8 +192,9 @@ long PluginFactory::enablePlugins(std::list& _plugins, } else if ("multi" == sphere_representation) { plugin = new MmpldWriterMultiSphere(); } else { - std::ostringstream error_message; error_message << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation - << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation << std::endl; + MARDYN_EXIT(error_message); } } else if (pluginname == "DomainProfiles") { plugin = this->create("DensityProfileWriter"); diff --git a/src/plugins/VectorizationTuner.cpp b/src/plugins/VectorizationTuner.cpp index 3134b6df52..4918edeadb 100644 --- a/src/plugins/VectorizationTuner.cpp +++ b/src/plugins/VectorizationTuner.cpp @@ -62,9 +62,11 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { } else if (incTypeStr == "both") { _moleculeCntIncreaseType = MoleculeCntIncreaseTypeEnum::both; } else { - std::ostringstream error_message; error_message + std::ostringstream error_message; + error_message << R"(Unknown FlopRateOutputPlugin::moleculecntincreasetype. Choose "linear" or "exponential" or "both".)" - << std::endl; MARDYN_EXIT(error_message); + << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Molecule count increase type: " << incTypeStr << std::endl; diff --git a/src/thermostats/TemperatureControl.cpp b/src/thermostats/TemperatureControl.cpp index d63f0573a8..dc826e4222 100644 --- a/src/thermostats/TemperatureControl.cpp +++ b/src/thermostats/TemperatureControl.cpp @@ -507,8 +507,10 @@ void ControlRegionT::registerAsObserver() { if (distControl != nullptr) distControl->registerObserver(this); else { - std::ostringstream error_message; error_message << "TemperatureControl->region[" << this->GetID() - << "]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; MARDYN_EXIT(error_message); + std::ostringstream error_message; + error_message << "TemperatureControl->region[" << this->GetID() + << "]: Initialization of plugin DistControl is needed before!" << std::endl; + MARDYN_EXIT(error_message); } } } From 7f62ea79b10a303bc86fc2a555995da6f226bddf Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 16:38:35 +0200 Subject: [PATCH 21/28] Use MARDYN_EXIT instead of MPI_Abort --- src/parallel/DomainDecompMPIBase.cpp | 16 ++++++++++------ src/parallel/tests/KDDecompositionTest.cpp | 9 ++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index 8e46b98637..14a66f553f 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -196,8 +196,10 @@ void DomainDecompMPIBase::assertIntIdentity(int IX) { for (int i = 1; i < _numProcs; i++) { MPI_CHECK(MPI_Recv(&recv, 1, MPI_INT, i, 2 * i + 17, _comm, &s)); if (recv != IX) { - Log::global_log->error() << "IX is " << IX << " for rank 0, but " << recv << " for rank " << i << ".\n"; - MPI_Abort(_comm, 911); // TODO FIXME + std::ostringstream error_message; + error_message << "[DomainDecompMPIBase] IX is " << IX << " for rank 0, " + << "but " << recv << " for rank " << i << "." << std::endl; + MARDYN_EXIT(error_message); } } Log::global_log->info() << "IX = " << recv << " for all " << _numProcs << " ranks.\n"; @@ -224,8 +226,9 @@ void DomainDecompMPIBase::assertDisjunctivity(ParticleContainer* moleculeContain for (auto m = moleculeContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); m.isValid(); ++m) { if(check.find(m->getID()) != check.end()){ - Log::global_log->error() << "Rank 0 contains a duplicated particle with id " << m->getID() << std::endl; - MPI_Abort(_comm, 1); + std::ostringstream error_message; + error_message << "Rank 0 contains a duplicated particle with id " << m->getID() << std::endl; + MARDYN_EXIT(error_message); } check[m->getID()] = 0; } @@ -248,8 +251,9 @@ void DomainDecompMPIBase::assertDisjunctivity(ParticleContainer* moleculeContain } } if (not isOk) { - Log::global_log->error() << "Aborting because of duplicated particles." << std::endl; - MPI_Abort(_comm, 1); + std::ostringstream error_message; + error_message << "Aborting because of duplicated particles." << std::endl; + MARDYN_EXIT(error_message); } Log::global_log->info() << "Data consistency checked: No duplicate IDs detected among " << check.size() diff --git a/src/parallel/tests/KDDecompositionTest.cpp b/src/parallel/tests/KDDecompositionTest.cpp index af0f67dcba..328f19fecd 100644 --- a/src/parallel/tests/KDDecompositionTest.cpp +++ b/src/parallel/tests/KDDecompositionTest.cpp @@ -13,6 +13,7 @@ #include "particleContainer/LinkedCells.h" #include "io/ASCIIReader.h" #include "parallel/NeighbourCommunicationScheme.h" +#include #include #include @@ -415,9 +416,11 @@ void KDDecompositionTest::testRebalancingDeadlocks() { kdd->barrier(); ASSERT_TRUE_MSG("Deadlock!", isOK); - if (not isOK) - MPI_Abort(MPI_COMM_WORLD, 1); - + if (not isOK) { + std::ostringstream error_message; + error_message << "[KDDecompositionTest] Deadlock detected." << std::endl; + MARDYN_EXIT(error_message); + } delete kdd->_decompTree; kdd->_decompTree = newDecompRoot; kdd->_ownArea = newOwnLeaf; From 1b363c82b6453ebb1321b4d9797624466f91cbd7 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 16:48:25 +0200 Subject: [PATCH 22/28] Properly exit options "help" and "version" --- src/MarDyn.cpp | 2 +- src/parallel/DomainDecompMPIBase.cpp | 1 + src/utils/OptionParser.cpp | 16 ++++++++++++---- src/utils/mardyn_assert.h | 12 +++++------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index 2854232198..d6af8511f9 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -183,7 +183,7 @@ int main(int argc, char** argv) { #ifdef ENABLE_MPI MPI_Finalize(); #endif - exit(testresult); // using exit here should be OK + std::exit(testresult); // using exit here should be OK } diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index 14a66f553f..d55e5771f7 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -6,6 +6,7 @@ */ #include #include +#include #include "DomainDecompMPIBase.h" #include "molecules/Molecule.h" diff --git a/src/utils/OptionParser.cpp b/src/utils/OptionParser.cpp index d1c007c40c..d0ef97e099 100644 --- a/src/utils/OptionParser.cpp +++ b/src/utils/OptionParser.cpp @@ -14,6 +14,10 @@ #include #include +#ifdef ENABLE_MPI +#include // For MPI_Finalize() +#endif + #if defined(ENABLE_NLS) && ENABLE_NLS # include # define _(s) gettext(s) @@ -346,13 +350,17 @@ void OptionParser::process_opt(const Option& o, const std::string& opt, const st } else if (o.action() == "help") { print_help(); - std::ostringstream empty_message; - mardyn_exit(empty_message, __FILE__, __LINE__, EXIT_SUCCESS); + #ifdef ENABLE_MPI + MPI_Finalize(); + #endif + std::exit(EXIT_SUCCESS); } else if (o.action() == "version") { print_version(); - std::ostringstream empty_message; - mardyn_exit(empty_message, __FILE__, __LINE__, EXIT_SUCCESS); + #ifdef ENABLE_MPI + MPI_Finalize(); + #endif + std::exit(EXIT_SUCCESS); } else if (o.action() == "callback" && o.callback()) { (*o.callback())(o, opt, value, *this); diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index be5007889c..c2062ab4a7 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -19,15 +19,13 @@ #define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __FILE__, __LINE__) inline void mardyn_exit(const std::ostringstream & exit_message, - const char* file, const int line, const int exit_code=EXIT_FAILURE) { - if (exit_code == EXIT_FAILURE) { - Log::global_log->error_always_output() - << "Exit called in file `" << file << ":" << line << "` with message:" << std::endl; - std::cerr << exit_message.str() << std::endl; - } + const char* file, const int line) { + Log::global_log->error_always_output() + << "Exit called in file `" << file << ":" << line << "` with message:" << std::endl; + std::cerr << exit_message.str() << std::endl; #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode - MPI_Abort(MPI_COMM_WORLD, exit_code); + MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); #else // call global abort - this stops the debugger at the right spot. ::abort(); From 2a2976566c1edc639b79e0c4e06a3d77af49db23 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 17:04:13 +0200 Subject: [PATCH 23/28] Pass string instead of stringstream to MARDYN_EXIT --- src/Domain.cpp | 6 +- src/MarDyn.cpp | 4 +- src/Simulation.cpp | 80 +++++++++---------- src/bhfmm/FastMultipoleMethod.cpp | 6 +- .../UniformPseudoParticleContainer.cpp | 6 +- ...PseudoParticleContainer_old_Wigner_cpp.txt | 10 +-- src/ensemble/CanonicalEnsemble.cpp | 2 +- src/ensemble/CavityEnsemble.cpp | 10 +-- src/ensemble/ChemicalPotential.cpp | 6 +- src/ensemble/EnsembleBase.cpp | 12 +-- src/ensemble/GrandCanonicalEnsemble.h | 4 +- src/ensemble/PressureGradient.cpp | 2 +- src/io/ASCIIReader.cpp | 18 ++--- src/io/Adios2Reader.cpp | 8 +- src/io/Adios2Writer.cpp | 12 +-- src/io/BinaryReader.cpp | 16 ++-- src/io/CavityWriter.cpp | 14 ++-- src/io/CheckpointWriter.cpp | 4 +- src/io/CommunicationPartnerWriter.cpp | 2 +- src/io/CubicGridGeneratorInternal.cpp | 8 +- src/io/FlopRateWriter.cpp | 4 +- src/io/HaloParticleWriter.cpp | 2 +- src/io/KDTreePrinter.cpp | 2 +- src/io/MPI_IOCheckpointWriter.cpp | 2 +- src/io/MPI_IOReader.cpp | 12 +-- src/io/Mkesfera.cpp | 2 +- src/io/MmpldWriter.cpp | 10 +-- src/io/ObjectGenerator.cpp | 10 +-- src/io/PerCellGenerator.cpp | 4 +- src/io/RDF.cpp | 2 +- src/io/ReplicaGenerator.cpp | 16 ++-- src/io/ResultWriter.cpp | 2 +- src/io/TimerProfiler.cpp | 2 +- src/io/TimerWriter.cpp | 2 +- src/io/vtk/VTKGridWriter.cpp | 6 +- src/io/vtk/VTKMoleculeWriter.cpp | 2 +- src/longRange/Homogeneous.cpp | 2 +- src/longRange/Planar.cpp | 8 +- src/molecules/AutoPasSimpleMolecule.cpp | 2 +- src/molecules/Comp2Param.cpp | 2 +- src/molecules/Component.cpp | 4 +- src/molecules/MoleculeInterface.cpp | 2 +- src/molecules/mixingrules/MixingRuleBase.cpp | 4 +- src/parallel/CollectiveCommunication.h | 4 +- .../CollectiveCommunicationNonBlocking.h | 4 +- src/parallel/CommunicationPartner.cpp | 4 +- src/parallel/DomainDecompBase.cpp | 2 +- src/parallel/DomainDecompMPIBase.cpp | 10 +-- src/parallel/DomainDecomposition.cpp | 6 +- src/parallel/ForceHelper.cpp | 2 +- src/parallel/GeneralDomainDecomposition.cpp | 12 +-- src/parallel/KDDecomposition.cpp | 26 +++--- src/parallel/LoadCalc.cpp | 20 ++--- src/parallel/NeighbourCommunicationScheme.cpp | 8 +- src/parallel/ParticleDataRMM.cpp | 2 +- .../StaticIrregDomainDecomposition.cpp | 2 +- src/parallel/tests/KDDecompositionTest.cpp | 2 +- src/particleContainer/AutoPasContainer.cpp | 6 +- .../C08CellPairTraversal.h | 2 +- .../NeutralTerritoryTraversal.h | 4 +- .../OriginalCellPairTraversal.h | 2 +- .../QuickschedTraversal.h | 2 +- .../SlicedCellPairTraversal.h | 2 +- src/particleContainer/LinkedCells.cpp | 22 ++--- src/particleContainer/TraversalTuner.h | 10 +-- .../adapter/ParticlePairs2PotForceAdapter.h | 2 +- src/plugins/COMaligner.cpp | 2 +- src/plugins/DirectedPM.cpp | 2 +- src/plugins/Dropaccelerator.cpp | 2 +- src/plugins/Dropaligner.cpp | 2 +- src/plugins/ExamplePlugin.cpp | 2 +- src/plugins/FixRegion.cpp | 2 +- src/plugins/MaxCheck.cpp | 2 +- src/plugins/Mirror.cpp | 14 ++-- src/plugins/NEMD/DensityControl.cpp | 4 +- src/plugins/NEMD/DistControl.cpp | 26 +++--- src/plugins/NEMD/MettDeamon.cpp | 44 +++++----- .../NEMD/MettDeamonFeedrateDirector.cpp | 4 +- src/plugins/NEMD/RegionSampling.cpp | 44 +++++----- src/plugins/Permittivity.cpp | 2 +- src/plugins/PluginFactory.cpp | 2 +- src/plugins/SpatialProfile.cpp | 4 +- src/plugins/VectorizationTuner.cpp | 6 +- src/plugins/WallPotential.cpp | 4 +- src/plugins/profiles/ProfileBase.cpp | 2 +- src/thermostats/TemperatureControl.cpp | 8 +- src/utils/OptionParser.cpp | 4 +- src/utils/SigsegvHandler.h | 2 +- src/utils/Testing.cpp | 4 +- src/utils/generator/ReplicaFiller.cpp | 10 +-- src/utils/mardyn_assert.h | 6 +- src/utils/xmlfile.cpp | 8 +- 92 files changed, 351 insertions(+), 351 deletions(-) diff --git a/src/Domain.cpp b/src/Domain.cpp index 9b5d82df56..00a3a3bf8b 100644 --- a/src/Domain.cpp +++ b/src/Domain.cpp @@ -96,7 +96,7 @@ void Domain::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Unsupported volume type " << type << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode(".."); } @@ -557,7 +557,7 @@ void Domain::writeCheckpointHeader(std::string filename, } else { std::ostringstream error_message; error_message << "Only LB mixing rule supported" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } @@ -716,7 +716,7 @@ void Domain::setComponentThermostat(int cid, int thermostat) { if ((0 > cid) || (0 >= thermostat)) { std::ostringstream error_message; error_message << "Domain::setComponentThermostat: cid or thermostat id too low" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } this->_componentToThermostatIdMap[cid] = thermostat; this->_universalThermostatN[thermostat] = 0; diff --git a/src/MarDyn.cpp b/src/MarDyn.cpp index d6af8511f9..e40535decc 100644 --- a/src/MarDyn.cpp +++ b/src/MarDyn.cpp @@ -195,7 +195,7 @@ int main(int argc, char** argv) { op.print_usage(); std::ostringstream error_message; error_message << "Incorrect number of arguments provided." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* First read the given config file if it exists, then overwrite parameters with command line arguments. */ std::string configFileName(args[0]); @@ -205,7 +205,7 @@ int main(int argc, char** argv) { } else { std::ostringstream error_message; error_message << "Cannot open config file '" << configFileName << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* processing command line arguments */ diff --git a/src/Simulation.cpp b/src/Simulation.cpp index a13ce6202c..2f648676ce 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -174,7 +174,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { #ifdef ENABLE_REDUCED_MEMORY_MODE std::ostringstream error_message; error_message << "The reduced memory mode (RMM) requires the LeapfrogRMM integrator." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif _integrator = new Leapfrog(); } else if (integratorType == "LeapfrogRMM") { @@ -182,7 +182,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown integrator " << integratorType << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _integrator->readXML(xmlconfig); _integrator->init(); @@ -190,7 +190,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Integrator section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* run section */ @@ -212,7 +212,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Run section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* ensemble */ @@ -230,7 +230,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown ensemble type: " << ensembletype << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _ensemble->readXML(xmlconfig); /** @todo Here we store data in the _domain member as long as we do not use the ensemble everywhere */ @@ -244,7 +244,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Ensemble section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* algorithm */ @@ -266,14 +266,14 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { if(_cutoffRadius <= 0) { std::ostringstream error_message; error_message << "cutoff radius <= 0." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "dimensionless cutoff radius:\t" << _cutoffRadius << std::endl; xmlconfig.changecurrentnode(".."); } else { std::ostringstream error_message; error_message << "Cutoff section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /* electrostatics */ @@ -287,7 +287,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Electrostatics section for reaction field setup missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (xmlconfig.changecurrentnode("electrostatic[@type='FastMultipoleMethod']")) { @@ -295,7 +295,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "The fast multipole method is not compatible with AutoPas. " << "Please disable the AutoPas mode (ENABLE_AUTOPAS)!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif _FMM = new bhfmm::FastMultipoleMethod(); _FMM->readXML(xmlconfig); @@ -355,7 +355,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { "vs the GeneralDomainDecomposition which can lead ALL to shrink the " "domain too small." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else { Log::global_log->warning() << "Using the GeneralDomainDecomposition without AutoPas is not " @@ -372,19 +372,19 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Datastructure section missing" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(not xmlconfig.changecurrentnode("../parallelisation")){ std::ostringstream error_message; error_message << "Could not go back to parallelisation path. Aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } delete _domainDecomposition; _domainDecomposition = new GeneralDomainDecomposition(getcutoffRadius() + skin, _domain, forceLatchingToLinkedCellsGrid); } else { std::ostringstream error_message; error_message << "Unknown parallelisation type: " << parallelisationtype << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #else /* serial */ if(parallelisationtype != "DummyDecomposition") { @@ -392,7 +392,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { << "Executable was compiled without support for parallel execution: " << parallelisationtype << " not available. Using serial mode." << std::endl; - //MARDYN_EXIT(error_message); + //MARDYN_EXIT(error_message.str()); } //_domainDecomposition = new DomainDecompBase(); // already set in initialize() #endif @@ -411,7 +411,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "'timerForLoad' set to a timer that does not exist('" << loadTimerStr << "')! Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::size_t timerForLoadAveragingLength{1ul}; @@ -421,7 +421,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { if(timerForLoadAveragingLength < 1ul) { std::ostringstream error_message; error_message << "timerForLoadAveragingLength has to be at least 1" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _lastTraversalTimeHistory.setCapacity(timerForLoadAveragingLength); @@ -431,7 +431,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { #ifdef ENABLE_MPI std::ostringstream error_message; error_message << "Parallelisation section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #else /* serial */ // set _timerForLoad, s.t. it always exists. _timerForLoad = timers()->getTimer("SIMULATION_COMPUTATION"); @@ -450,7 +450,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { error_message << "LinkedCells not compiled (use AutoPas instead, or compile with disabled autopas mode)!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #else _moleculeContainer = new LinkedCells(); /** @todo Review if we need to know the max cutoff radius usable with any datastructure. */ @@ -460,7 +460,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else if(datastructuretype == "AdaptiveSubCells") { std::ostringstream error_message; error_message << "AdaptiveSubCells no longer supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else if(datastructuretype == "AutoPas" || datastructuretype == "AutoPasContainer") { #ifdef MARDYN_AUTOPAS Log::global_log->info() << "Using AutoPas container." << std::endl; @@ -469,13 +469,13 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { #else std::ostringstream error_message; error_message << "AutoPas not compiled (use LinkedCells instead, or compile with enabled autopas mode)!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif } else { std::ostringstream error_message; error_message << "Unknown data structure type: " << datastructuretype << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _moleculeContainer->readXML(xmlconfig); @@ -488,7 +488,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Datastructure section missing" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // TODO: move parts to readXML in TemperatureControl? @@ -532,7 +532,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Instance of TemperatureControl already exist!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else @@ -556,7 +556,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { { std::ostringstream error_message; error_message << "LongRangeCorrection: Missing type specification. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if("planar" == type) { @@ -581,7 +581,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { { std::ostringstream error_message; error_message << "LongRangeCorrection: Wrong type. Expected type == homogeneous|planar|none. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode(".."); } else { @@ -595,7 +595,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Algorithm section missing." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log -> info() << "Registering default plugins..." << std::endl; @@ -650,7 +650,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Unknown phase space file type" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } xmlconfig.changecurrentnode(oldpath); @@ -681,7 +681,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Unknown generator: " << generatorName << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _inputReader->readXML(xmlconfig); } @@ -717,7 +717,7 @@ void Simulation::readConfigFile(std::string filename) { else { std::ostringstream error_message; error_message << "Unknown config file extension '" << extension << "'." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -733,7 +733,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { std::ostringstream error_message; error_message << "Cound not find root node /mardyn in XML input file." << std::endl; error_message << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string version("unknown"); @@ -749,7 +749,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { else { std::ostringstream error_message; error_message << "Simulation section missing" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } parseMiscOptions(inp); @@ -763,7 +763,7 @@ void Simulation::initConfigXML(const std::string& inputfilename) { std::ostringstream error_message; error_message << "Error in XML config. Please check your input file!" << std::endl; error_message << "Exception: " << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #ifdef ENABLE_MPI @@ -890,7 +890,7 @@ void Simulation::prepare_start() { } else { std::ostringstream error_message; error_message << "No _longRangeCorrection set!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // longRangeCorrection is a site-wise force plugin, so we have to call it before updateForces() _longRangeCorrection->calculateLongRange(); @@ -988,7 +988,7 @@ void Simulation::preSimLoopSteps() << "Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } @@ -1053,7 +1053,7 @@ void Simulation::simulateOneTimestep() << "Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #ifdef MAMICO_COUPLING @@ -1287,7 +1287,7 @@ void Simulation::postSimLoopSteps() << "Status: (pre sim loop steps done:" << preSimLoopStepsDone << ", simulation done: " << simulationDone << ", post sim loop steps done: " << postSimLoopStepsDone << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } @@ -1353,7 +1353,7 @@ void Simulation::pluginEndStepCall(unsigned long simstep) { if (std::isnan(_domain->getGlobalCurrentTemperature()) || std::isnan(_domain->getGlobalUpot()) || std::isnan(_domain->getGlobalPressure())) { std::ostringstream error_message; error_message << "NaN detected, exiting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -1424,7 +1424,7 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim if (not dd) { std::ostringstream error_message; error_message << "DomainDecompMPIBase* required for overlapping comm, but dynamic_cast failed." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } NonBlockingMPIMultiStepHandler nonBlockingMPIHandler {dd, _moleculeContainer, _domain, _cellProcessor}; @@ -1434,7 +1434,7 @@ void Simulation::performOverlappingDecompositionAndCellTraversalStep(double etim #else std::ostringstream error_message; error_message << "performOverlappingDecompositionAndCellTraversalStep() called with disabled MPI." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif } diff --git a/src/bhfmm/FastMultipoleMethod.cpp b/src/bhfmm/FastMultipoleMethod.cpp index 5d2c60fa1c..f40d474b52 100644 --- a/src/bhfmm/FastMultipoleMethod.cpp +++ b/src/bhfmm/FastMultipoleMethod.cpp @@ -71,7 +71,7 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], error_message << "Fast Multipole Method: bad subdivision factor:" << _LJCellSubdivisionFactor << std::endl; error_message << "expected 1,2,4 or 8" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Fast Multipole Method: each LJ cell will be subdivided in " @@ -110,7 +110,7 @@ void FastMultipoleMethod::init(double globalDomainLength[3], double bBoxMin[3], #if defined(ENABLE_MPI) std::ostringstream error_message; error_message << "MPI in combination with adaptive is not supported yet" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif //int threshold = 100; _pseudoParticleContainer = new AdaptivePseudoParticleContainer( @@ -317,7 +317,7 @@ void FastMultipoleMethod::runner(int type, void *data) { { std::ostringstream error_message; error_message << "Quicksched runner without FMM_FFT not implemented!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif /* FMM_FFT */ } diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp index 5947762c51..a60b38df55 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer.cpp +++ b/src/bhfmm/containers/UniformPseudoParticleContainer.cpp @@ -114,7 +114,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( #if WIGNER == 1 std::ostringstream error_message; error_message << "WIGNER not supported yet" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif #ifdef ENABLE_MPI /* @@ -179,7 +179,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( if(_globalLevel > _maxLevel){ std::ostringstream error_message; error_message << "Too many MPI ranks" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } //numProcessers has to be a power of 2 mardyn_assert(pow(2,log2(numProcessors)) == numProcessors); @@ -383,7 +383,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( if(size2 > 8){ //neighbourhood comms need to have size 8 std::ostringstream error_message; error_message << "Error wrong communicator" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } #endif diff --git a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt index 3932c08184..53b8427a75 100644 --- a/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt +++ b/src/bhfmm/containers/UniformPseudoParticleContainer_old_Wigner_cpp.txt @@ -45,7 +45,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( #endif #if WIGNER == 1 //global_log->error() << "not supported yet" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif #ifdef ENABLE_MPI _timerProcessCells.set_sync(false); @@ -81,7 +81,7 @@ UniformPseudoParticleContainer::UniformPseudoParticleContainer( _globalLevel = log2(numProcessors)/3; if(_globalLevel > _maxLevel){ std::cout << "too many MPI ranks \n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } //numProcessers has to be a power of 8 mardyn_assert(log2(numProcessors) == _globalLevel * 3); @@ -778,7 +778,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2z = LoLim(2) + 2; m2z <= HiLim(2) + 2; m2z++) { if (m2z < 0 or m2z >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } @@ -786,7 +786,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2y = LoLim(1) + 2; m2y <= HiLim(1) + 2; m2y++) { if (m2y < 0 or m2y >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } @@ -794,7 +794,7 @@ void UniformPseudoParticleContainer::GatherWellSepLo_MPI(double *cellWid, int lo for (m2x = LoLim(0) + 2; m2x <= HiLim(0) + 2; m2x++) { if (m2x < 0 or m2x >= localMpCells) { std::cout << "Error \n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } m2v[0] = m2x; diff --git a/src/ensemble/CanonicalEnsemble.cpp b/src/ensemble/CanonicalEnsemble.cpp index 441006ff06..b7e536e613 100644 --- a/src/ensemble/CanonicalEnsemble.cpp +++ b/src/ensemble/CanonicalEnsemble.cpp @@ -197,7 +197,7 @@ void CanonicalEnsemble::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Volume type not supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode("domain"); _domain->readXML(xmlconfig); diff --git a/src/ensemble/CavityEnsemble.cpp b/src/ensemble/CavityEnsemble.cpp index dd8b505953..dafb7d55b0 100644 --- a/src/ensemble/CavityEnsemble.cpp +++ b/src/ensemble/CavityEnsemble.cpp @@ -97,7 +97,7 @@ void CavityEnsemble::setControlVolume(double x0, double y0, double z0, double x1 error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 << ")." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } this->restrictedControlVolume = true; @@ -114,22 +114,22 @@ void CavityEnsemble::init(Component *component, unsigned Nx, unsigned Ny, unsign if (this->ownrank < 0) { std::ostringstream error_message; error_message << "\nInvalid rank " << ownrank << ".\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (this->initialized) { std::ostringstream error_message; error_message << "\nCavity ensemble initialized twice.\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (0.0 >= this->T) { std::ostringstream error_message; error_message << "\nInvalid temperature T = " << T << ".\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (0.0 >= this->globalV) { std::ostringstream error_message; error_message << "\nInvalid control volume V_ctrl = " << globalV << ".\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } this->componentid = component->ID(); diff --git a/src/ensemble/ChemicalPotential.cpp b/src/ensemble/ChemicalPotential.cpp index 687f2c42fe..7475d741e0 100644 --- a/src/ensemble/ChemicalPotential.cpp +++ b/src/ensemble/ChemicalPotential.cpp @@ -286,7 +286,7 @@ bool ChemicalPotential::decideDeletion(double deltaUTilde) } std::ostringstream error_message; error_message << "No decision is possible." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } float dec = *_remainingDecisions.begin(); _remainingDecisions.erase(_remainingDecisions.begin()); @@ -320,7 +320,7 @@ bool ChemicalPotential::decideInsertion(double deltaUTilde) } std::ostringstream error_message; error_message << "No decision is possible." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } double acc = _globalReducedVolume * exp(_muTilde - deltaUTilde) / (1.0 + (double) (_globalN)); @@ -379,7 +379,7 @@ void ChemicalPotential::setControlVolume(double x0, double y0, double z0, error_message << "\nInvalid control volume (" << x0 << " / " << y0 << " / " << z0 << ") to (" << x1 << " / " << y1 << " / " << z1 << ")." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _restrictedControlVolume = true; _globalV = (x1 - x0) * (y1 - y0) * (z1 - z0); diff --git a/src/ensemble/EnsembleBase.cpp b/src/ensemble/EnsembleBase.cpp index 7a59985c43..e1fa33446d 100644 --- a/src/ensemble/EnsembleBase.cpp +++ b/src/ensemble/EnsembleBase.cpp @@ -25,7 +25,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { if (numComponents == 0) { std::ostringstream error_message; error_message << "No components found. Please verify that you have input them correctly." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _components.resize(numComponents); XMLfile::Query::const_iterator componentIter; @@ -60,7 +60,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown mixing rule " << mixingruletype << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } mixingrule->readXML(xmlconfig); @@ -72,7 +72,7 @@ void Ensemble::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "Mixing: cid=" << cid2+1 << " is larger than number of components (" << numComponents << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _mixingrules[cid1][cid2] = mixingrule; } @@ -120,18 +120,18 @@ void Ensemble::setMixingrule(std::shared_ptr mixingrule) { if (cid1 == cid2) { std::ostringstream error_message; error_message << "Mixing setMixingrule: cids must not be the same" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (std::min(cid1, cid2) < 0) { std::ostringstream error_message; error_message << "Mixing setMixingrule: cids must not be negative" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (std::max(cid1, cid2) >= _components.size()) { std::ostringstream error_message; error_message << "Mixing setMixingrule: cids must not exceed number of components (" << _components.size() << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _mixingrules[cid1][cid2] = mixingrule; diff --git a/src/ensemble/GrandCanonicalEnsemble.h b/src/ensemble/GrandCanonicalEnsemble.h index 96cd058f91..03feb3d9dc 100644 --- a/src/ensemble/GrandCanonicalEnsemble.h +++ b/src/ensemble/GrandCanonicalEnsemble.h @@ -42,7 +42,7 @@ class GrandCanonicalEnsemble : public Ensemble { void readXML(XMLfileUnits& xmlconfig) override { std::ostringstream error_message; error_message << "[GrandCanonicalEnsemble] readXML not implemented!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); }; unsigned long N() override { @@ -73,7 +73,7 @@ class GrandCanonicalEnsemble : public Ensemble { void updateGlobalVariable(ParticleContainer* particleContainer, GlobalVariable variable) override { std::ostringstream error_message; error_message << "[GrandCanonicalEnsemble] updateGlobalVariable not implemented!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); }; /*! Runs steps formerly in initConfigXML in simulation.cpp */ diff --git a/src/ensemble/PressureGradient.cpp b/src/ensemble/PressureGradient.cpp index b7fe3dc5b5..70f796847c 100644 --- a/src/ensemble/PressureGradient.cpp +++ b/src/ensemble/PressureGradient.cpp @@ -221,7 +221,7 @@ void PressureGradient::specifyTauPrime(double tauPrime, double dt) { std::ostringstream error_message; error_message << "SEVERE ERROR: unknown UCAT!\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } unsigned int vql = (unsigned int)ceil(tauPrime / (dt*this->_universalConstantAccelerationTimesteps)); std::map::iterator vqlit; diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index 61d87e1499..4cd29cb517 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -58,7 +58,7 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(token != "mardyn") { std::ostringstream error_message; error_message << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string inputversion; @@ -67,13 +67,13 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(token != "trunk") { std::ostringstream error_message; error_message << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(std::stoi(inputversion) < 20080701) { std::ostringstream error_message; error_message << "Input version too old (" << inputversion << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -168,7 +168,7 @@ void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(numtersoff != 0) { std::ostringstream error_message; error_message << "tersoff no longer supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -279,7 +279,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain if(!_phaseSpaceFileStream.is_open()) { std::ostringstream error_message; error_message << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; #ifdef ENABLE_MPI @@ -306,7 +306,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain if((token != "NumberOfMolecules") && (token != "N")) { std::ostringstream error_message; error_message << "Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _phaseSpaceFileStream >> nummolecules; #ifdef ENABLE_MPI @@ -334,7 +334,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain else { std::ostringstream error_message; error_message << "Unknown molecule format '" << ntypestring << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else { _phaseSpaceFileStream.seekg(spos); @@ -396,7 +396,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain default: std::ostringstream error_message; error_message << "[ASCIIReader.cpp] Unknown ntype" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) @@ -409,7 +409,7 @@ ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain error_message << "Molecule id " << id << " has a component ID greater than the existing number of components: " << componentid << ">" << numcomponents << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/Adios2Reader.cpp b/src/io/Adios2Reader.cpp index 0ebd1c7e29..728f765802 100644 --- a/src/io/Adios2Reader.cpp +++ b/src/io/Adios2Reader.cpp @@ -90,7 +90,7 @@ unsigned long Adios2Reader::readPhaseSpace(ParticleContainer* particleContainer, } else { std::ostringstream error_message; error_message << "[Adios2Reader] Unknown _mode '" << _mode << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _simulation.setSimulationTime(_simtime); @@ -537,17 +537,17 @@ void Adios2Reader::initAdios2() { std::ostringstream error_message; error_message << "[Adios2Reader] Invalid argument exception, STOPPING PROGRAM from rank" << domainDecomp.getRank() << ": " << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::ios_base::failure& e) { std::ostringstream error_message; error_message << "[Adios2Reader] IO System base failure exception, STOPPING PROGRAM from rank " << domainDecomp.getRank() << ": " << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::exception& e) { std::ostringstream error_message; error_message << "[Adios2Reader] Exception, STOPPING PROGRAM from rank" << domainDecomp.getRank() << ": " << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[Adios2Reader] Init complete." << std::endl; }; diff --git a/src/io/Adios2Writer.cpp b/src/io/Adios2Writer.cpp index 88d67a128a..29b652e567 100644 --- a/src/io/Adios2Writer.cpp +++ b/src/io/Adios2Writer.cpp @@ -267,17 +267,17 @@ void Adios2Writer::initAdios2() { std::ostringstream error_message; error_message << "Invalid argument exception:" << std::endl; error_message << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::ios_base::failure& e) { std::ostringstream error_message; error_message << "IO System base failure exception: " << std::endl; error_message << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::exception& e) { std::ostringstream error_message; error_message << "Exception: " << std::endl; error_message << e.what() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[Adios2Writer] Init complete." << std::endl; } @@ -425,17 +425,17 @@ void Adios2Writer::endStep(ParticleContainer* particleContainer, DomainDecompBas std::ostringstream error_message; error_message << "[Adios2Writer] Invalid argument exception:" << std::endl; error_message << e.what(); - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::ios_base::failure& e) { std::ostringstream error_message; error_message << "[Adios2Writer] IO System base failure exception:" << std::endl; error_message << e.what(); - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } catch (std::exception& e) { std::ostringstream error_message; error_message << "[Adios2Writer] Exception:" << std::endl; error_message << e.what(); - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[Adios2Writer] endStep." << std::endl; } diff --git a/src/io/BinaryReader.cpp b/src/io/BinaryReader.cpp index 26f106690c..891575908a 100644 --- a/src/io/BinaryReader.cpp +++ b/src/io/BinaryReader.cpp @@ -79,7 +79,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { std::ostringstream error_message; error_message << "Could not find root node /mardyn in XML input file." << std::endl; error_message << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } bool bInputOk = true; @@ -98,7 +98,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(not bInputOk) { std::ostringstream error_message; error_message << "Content of file: '" << _phaseSpaceHeaderFile << "' corrupted! Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if("ICRVQD" == strMoleculeFormat) @@ -110,7 +110,7 @@ void BinaryReader::readPhaseSpaceHeader(Domain* domain, double timestep) { else { std::ostringstream error_message; error_message << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // Set parameters of Domain and Simulation class @@ -138,7 +138,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai std::ostringstream error_message; error_message << "Could not open phaseSpaceFile " << _phaseSpaceFile << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Reading phase space file " << _phaseSpaceFile << std::endl; @@ -183,7 +183,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai std::ostringstream error_message; error_message << "End of file was hit before all " << numMolecules << " expected molecules were read." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _phaseSpaceFileStream.read(reinterpret_cast (&id), 8); switch (_nMoleculeFormat) { @@ -227,7 +227,7 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai std::ostringstream error_message; error_message << "BinaryReader: Unknown phase space format: " << _nMoleculeFormat << std::endl << "Aborting simulation." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if ((x < 0.0 || x >= domain->getGlobalLength(0)) || (y < 0.0 || y >= domain->getGlobalLength(1)) || (z < 0.0 || z >= domain->getGlobalLength(2))) { @@ -241,12 +241,12 @@ BinaryReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domai << componentid << ">" << numcomponents << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(componentid == 0) { std::ostringstream error_message; error_message << "Molecule id " << id << " has componentID == 0." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. diff --git a/src/io/CavityWriter.cpp b/src/io/CavityWriter.cpp index b782b0e2ba..87c1ab8764 100644 --- a/src/io/CavityWriter.cpp +++ b/src/io/CavityWriter.cpp @@ -39,32 +39,32 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { if (_maxNeighbors <= 0) { std::ostringstream error_message; error_message << "[CavityWriter] Invalid number of maxNeighbors: " << _maxNeighbors << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("radius", _radius); if (_radius <= 0.0f) { std::ostringstream error_message; error_message << "[CavityWriter] Invalid size of radius: " << _radius << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("Nx", _Nx); if (_Nx <= 0) { std::ostringstream error_message; error_message << "[CavityWriter] Invalid number of cells Nx: " << _Nx << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("Ny", _Ny); if (_Ny <= 0) { std::ostringstream error_message; error_message << "[CavityWriter] Invalid number of cells Ny: " << _Ny << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("Nz", _Nz); if (_Nz <= 0) { std::ostringstream error_message; error_message << "[CavityWriter] Invalid number of cells Nz: " << _Nz << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // Default Control Volume is entire Domain @@ -82,13 +82,13 @@ void CavityWriter::readXML(XMLfileUnits &xmlconfig) { if (_controlVolume[d * 2] > _controlVolume[d * 2 + 1]) { std::ostringstream error_message; error_message << "[CavityWriter] Lower Bound of Control Volume may not be larger than upper bound." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (_controlVolume[d * 2] < 0 || _controlVolume[d * 2 + 1] > global_simulation->getDomain()->getGlobalLength(d)) { std::ostringstream error_message; error_message << "[CavityWriter] Control volume bounds may not be outside of domain boundaries." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/io/CheckpointWriter.cpp b/src/io/CheckpointWriter.cpp index 95fe9abfd4..4685f518b4 100644 --- a/src/io/CheckpointWriter.cpp +++ b/src/io/CheckpointWriter.cpp @@ -21,7 +21,7 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { std::ostringstream error_message; error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string checkpointType = "unknown"; @@ -35,7 +35,7 @@ void CheckpointWriter::readXML(XMLfileUnits& xmlconfig) { else { std::ostringstream error_message; error_message << "Unknown CheckpointWriter type '" << checkpointType << "', expected: ASCII|binary." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _outputPrefix = "mardyn"; diff --git a/src/io/CommunicationPartnerWriter.cpp b/src/io/CommunicationPartnerWriter.cpp index 7f9e9302f2..84d10bbb86 100644 --- a/src/io/CommunicationPartnerWriter.cpp +++ b/src/io/CommunicationPartnerWriter.cpp @@ -19,7 +19,7 @@ void CommunicationPartnerWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { std::ostringstream error_message; error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string HaloParticleType = "unknown"; diff --git a/src/io/CubicGridGeneratorInternal.cpp b/src/io/CubicGridGeneratorInternal.cpp index d564b51bdd..8ee1e5f396 100644 --- a/src/io/CubicGridGeneratorInternal.cpp +++ b/src/io/CubicGridGeneratorInternal.cpp @@ -42,7 +42,7 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { if((_numMolecules == 0 && density == -1.) || (_numMolecules != 0 && density != -1.) ){ std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: You have to set either density or numMolecules!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(density != -1.){ @@ -50,7 +50,7 @@ void CubicGridGeneratorInternal::readXML(XMLfileUnits& xmlconfig) { if(density <= 0){ std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: Density has to be positive and non-zero!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } double vol = 1.0; for (int d = 0; d < 3; ++d) @@ -68,7 +68,7 @@ unsigned long CubicGridGeneratorInternal::readPhaseSpace(ParticleContainer *part std::ostringstream error_message; error_message << "Error in CubicGridGeneratorInternal: numMolecules is not set!" << std::endl << "Please make sure to run readXML()!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // create a body centered cubic layout, by creating by placing the molecules on the @@ -149,7 +149,7 @@ std::array CubicGridGeneratorInternal::determineMolsPerDimensi std::ostringstream error_message; error_message << "computed num Molecules along dimension " << d << ": " << answer << std::endl; error_message << "Should be larger than 1. Exiting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } ret[d] = answer; diff --git a/src/io/FlopRateWriter.cpp b/src/io/FlopRateWriter.cpp index 8cdf645a18..49e6ae40b7 100644 --- a/src/io/FlopRateWriter.cpp +++ b/src/io/FlopRateWriter.cpp @@ -28,7 +28,7 @@ void FlopRateWriter::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown FlopRateOutputPlugin::mode. Choose \"stdout\", \"file\" or \"both\"." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _writeFrequency = 1; @@ -39,7 +39,7 @@ void FlopRateWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeToFile) { std::ostringstream error_message; error_message << "TODO: file output not yet supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(_writeToFile) { diff --git a/src/io/HaloParticleWriter.cpp b/src/io/HaloParticleWriter.cpp index 71483936ed..a0db8de823 100644 --- a/src/io/HaloParticleWriter.cpp +++ b/src/io/HaloParticleWriter.cpp @@ -19,7 +19,7 @@ void HaloParticleWriter::readXML(XMLfileUnits& xmlconfig) { if(_writeFrequency == 0) { std::ostringstream error_message; error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string HaloParticleType = "unknown"; diff --git a/src/io/KDTreePrinter.cpp b/src/io/KDTreePrinter.cpp index 8a4a7ce127..983fc2b938 100644 --- a/src/io/KDTreePrinter.cpp +++ b/src/io/KDTreePrinter.cpp @@ -19,7 +19,7 @@ void KDTreePrinter::readXML(XMLfileUnits &xmlconfig) { if (_writeFrequency == 0) { std::ostringstream error_message;error_message << "Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _outputPrefix = "mardyn"; diff --git a/src/io/MPI_IOCheckpointWriter.cpp b/src/io/MPI_IOCheckpointWriter.cpp index 46c4a49ee6..5148d3e90b 100644 --- a/src/io/MPI_IOCheckpointWriter.cpp +++ b/src/io/MPI_IOCheckpointWriter.cpp @@ -437,6 +437,6 @@ void MPI_IOCheckpointWriter::handle_error(int i) { std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i << " , " << error_string << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif } diff --git a/src/io/MPI_IOReader.cpp b/src/io/MPI_IOReader.cpp index b06c48b664..87be623061 100644 --- a/src/io/MPI_IOReader.cpp +++ b/src/io/MPI_IOReader.cpp @@ -60,7 +60,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(token != "mardyn") { std::ostringstream error_message; error_message << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string inputversion; @@ -69,13 +69,13 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(token != "trunk") { std::ostringstream error_message; error_message << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(strtoul(inputversion.c_str(), NULL, 0) < 20080701) { std::ostringstream error_message; error_message << "Input version tool old (" << inputversion << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; @@ -121,7 +121,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { std::ostringstream error_message; error_message << "Unknown molecule format: '" << ntypestring << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _moleculeFormat = ntypestring; Log::global_log->info() << " molecule format: " << ntypestring << std::endl; @@ -188,7 +188,7 @@ void MPI_IOReader::readPhaseSpaceHeader(Domain* domain, double timestep) { if(numtersoff != 0) { std::ostringstream error_message; error_message << "tersoff no longer supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } double x, y, z, m; for(unsigned int j = 0; j < numljcenters; j++) { @@ -662,6 +662,6 @@ void MPI_IOReader::handle_error(int i) { std::ostringstream error_message; error_message << "Writing of file was not successfull " << " , " << i << " , " << error_string << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif } diff --git a/src/io/Mkesfera.cpp b/src/io/Mkesfera.cpp index cafb3fcfa6..b478047539 100755 --- a/src/io/Mkesfera.cpp +++ b/src/io/Mkesfera.cpp @@ -177,7 +177,7 @@ MkesferaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* startx[2] > idx[2]) { std::ostringstream error_message; error_message << "Error in calculation of start and end values! \n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } fill[idx[0] - startx[0]][idx[1] - startx[1]][idx[2] - startx[2]][p] = tfill; if(tfill) { diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index 8929988d60..08bbc439c6 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -58,7 +58,7 @@ MmpldWriter::MmpldWriter(uint64_t startTimestep, uint64_t writeFrequency, uint64 if (0 == _writeFrequency) { std::ostringstream error_message; error_message << "[MMPLD Writer] writefrequency must not be 0" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -92,7 +92,7 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) default: std::ostringstream error_message; error_message << "Unsupported MMPLD version:" << _mmpldversion << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); break; } xmlconfig.getNodeValue("outputprefix", _outputPrefix); @@ -106,7 +106,7 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) if(numSites < 1) { std::ostringstream error_message; error_message << "[MMPLD Writer] No site parameters specified." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSiteIter; @@ -149,7 +149,7 @@ void MmpldWriter::init(ParticleContainer *particleContainer, if ( (htole32(1) != 1) || (htole64(1.0) != 1.0) ) { std::ostringstream error_message; error_message << "[MMPLD Writer] The MMPLD Writer currently only supports running on little endian systems." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // only executed once @@ -398,7 +398,7 @@ long MmpldWriter::get_data_frame_header_size() { default: std::ostringstream error_message; error_message << "[MMPLD Writer] Unsupported MMPLD version: " << _mmpldversion << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); break; } return data_frame_header_size; diff --git a/src/io/ObjectGenerator.cpp b/src/io/ObjectGenerator.cpp index 5f7462ee92..312b5ed830 100644 --- a/src/io/ObjectGenerator.cpp +++ b/src/io/ObjectGenerator.cpp @@ -27,7 +27,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { if(!_filler) { std::ostringstream error_message; error_message << "Object filler could not be created" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->debug() << "Using object filler of type: " << _filler->getPluginName() << std::endl; _filler->readXML(xmlconfig); @@ -35,7 +35,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "No filler specified." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(xmlconfig.changecurrentnode("object")) { @@ -47,7 +47,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { if(!_object) { std::ostringstream error_message; error_message << "Unknown object type: " << objectType << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->debug() << "Created object of type: " << _object->getPluginName() << std::endl; _object->readXML(xmlconfig); @@ -55,7 +55,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "No object specified." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(xmlconfig.changecurrentnode("velocityAssigner")) { @@ -86,7 +86,7 @@ void ObjectGenerator::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown velocity assigner specified." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Ensemble* ensemble = _simulation.getEnsemble(); Log::global_log->info() << "Setting temperature for velocity assigner to " << ensemble->T() << std::endl; diff --git a/src/io/PerCellGenerator.cpp b/src/io/PerCellGenerator.cpp index 55e2d89956..de643c18d7 100644 --- a/src/io/PerCellGenerator.cpp +++ b/src/io/PerCellGenerator.cpp @@ -44,7 +44,7 @@ void PerCellGenerator::readXML(XMLfileUnits &xmlconfig) { } else { std::ostringstream error_message; error_message << "Missing required field numMoleculesPerCell. Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("initTemperature", _initTemperature); @@ -53,7 +53,7 @@ void PerCellGenerator::readXML(XMLfileUnits &xmlconfig) { } else { std::ostringstream error_message; error_message << "Missing required field initTemperature. Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("generateAtLeastTwoParticles", _generateAtLeastTwoParticles); diff --git a/src/io/RDF.cpp b/src/io/RDF.cpp index f03096b6ca..b4a21dcba5 100644 --- a/src/io/RDF.cpp +++ b/src/io/RDF.cpp @@ -35,7 +35,7 @@ void RDF::init() { if(!_readConfig){ std::ostringstream error_message; error_message << "RDF initialized without reading the configuration, exiting" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _cellProcessor = new RDFCellProcessor(global_simulation->getcutoffRadius(), this); diff --git a/src/io/ReplicaGenerator.cpp b/src/io/ReplicaGenerator.cpp index 60b07b86ff..2925d4eba7 100755 --- a/src/io/ReplicaGenerator.cpp +++ b/src/io/ReplicaGenerator.cpp @@ -59,7 +59,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { std::ostringstream error_message; error_message << "Could not find root node /mardyn in XML input file." << std::endl; error_message << "Not a valid MarDyn XML input file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } bool bInputOk = true; @@ -83,7 +83,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { if(not bInputOk) { std::ostringstream error_message; error_message << "Content of file: '" << subDomain.strFilePathHeader << "' corrupted!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if("ICRVQD" == strMoleculeFormat) @@ -95,7 +95,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceHeader(SubDomain& subDomain) { else { std::ostringstream error_message; error_message << "Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -110,7 +110,7 @@ void ReplicaGenerator::readReplicaPhaseSpaceData(SubDomain& subDomain, DomainDec if(!ifs.is_open()) { std::ostringstream error_message; error_message << "Could not open phaseSpaceFile " << subDomain.strFilePathData << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Reading phase space file " << subDomain.strFilePathData << std::endl; @@ -193,7 +193,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Specified wrong type at XML path: " << xmlconfig.getcurrentnodepath() << "/type" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } SubDomain sd; @@ -245,7 +245,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { if(numChanges < 1) { std::ostringstream error_message; error_message << "No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -269,7 +269,7 @@ void ReplicaGenerator::readXML(XMLfileUnits& xmlconfig) { if(numChanges < 1) { std::ostringstream error_message; error_message << "No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } XMLfile::Query::const_iterator changeIter; for(changeIter = query.begin(); changeIter; changeIter++) { @@ -536,7 +536,7 @@ ReplicaGenerator::readPhaseSpace(ParticleContainer* particleContainer, Domain* d std::ostringstream error_message; error_message << "Number of particles: " << numParticlesGlobal << " (added) != " << (_numParticlesTotal - numAddedParticlesFreespaceGlobal) << " (expected)." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } global_simulation->timers()->stop("REPLICA_GENERATOR_VLE_INPUT"); diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index 736c131ca6..9212a2b021 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -16,7 +16,7 @@ void ResultWriter::readXML(XMLfileUnits& xmlconfig) { if (_writeFrequency <= 0) { std::ostringstream error_message; error_message << "[ResultWriter] Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("outputprefix", _outputPrefix); diff --git a/src/io/TimerProfiler.cpp b/src/io/TimerProfiler.cpp index 7f1fd22742..520702e376 100644 --- a/src/io/TimerProfiler.cpp +++ b/src/io/TimerProfiler.cpp @@ -39,7 +39,7 @@ void TimerProfiler::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "Unknown display mode: " << displayMode << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } diff --git a/src/io/TimerWriter.cpp b/src/io/TimerWriter.cpp index 024b0b9663..75ec55761e 100644 --- a/src/io/TimerWriter.cpp +++ b/src/io/TimerWriter.cpp @@ -36,7 +36,7 @@ void TimerWriter::readXML(XMLfileUnits& xmlconfig) { if (_timerNames.empty()) { std::ostringstream error_message; error_message << "TimerWriter: no timers given. make sure you specify them correctly." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode(oldpath); } diff --git a/src/io/vtk/VTKGridWriter.cpp b/src/io/vtk/VTKGridWriter.cpp index 72f81fffab..9872824611 100644 --- a/src/io/vtk/VTKGridWriter.cpp +++ b/src/io/vtk/VTKGridWriter.cpp @@ -36,7 +36,7 @@ void VTKGridWriter::readXML(XMLfileUnits& xmlconfig) { if (_writeFrequency <= 0) { std::ostringstream error_message; error_message << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -51,7 +51,7 @@ void VTKGridWriter::endStep( if (container == NULL) { std::ostringstream error_message; error_message << "VTKGridWriter works only with plottable LinkedCells!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif @@ -118,7 +118,7 @@ void VTKGridWriter::init(ParticleContainer *particleContainer, if (dynamic_cast(particleContainer) == NULL) { std::ostringstream error_message; error_message << "VTKGridWriter works only with LinkCells!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif } diff --git a/src/io/vtk/VTKMoleculeWriter.cpp b/src/io/vtk/VTKMoleculeWriter.cpp index 150a8ae14c..b2342a56f3 100644 --- a/src/io/vtk/VTKMoleculeWriter.cpp +++ b/src/io/vtk/VTKMoleculeWriter.cpp @@ -38,7 +38,7 @@ void VTKMoleculeWriter::readXML(XMLfileUnits& xmlconfig) { if (_writeFrequency <= 0) { std::ostringstream error_message; error_message << "VTKMoleculeWriter: writeFrequency must be > 0!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/longRange/Homogeneous.cpp b/src/longRange/Homogeneous.cpp index 4c4c31d36f..1b3e2238ed 100644 --- a/src/longRange/Homogeneous.cpp +++ b/src/longRange/Homogeneous.cpp @@ -83,7 +83,7 @@ void Homogeneous::init() { if (tau1 + tau2 >= _cutoffLJ) { std::ostringstream error_message; error_message << "Error calculating cutoff corrections, rc too small" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } double eps24; params >> eps24; diff --git a/src/longRange/Planar.cpp b/src/longRange/Planar.cpp index 42d91b1769..db72d85477 100644 --- a/src/longRange/Planar.cpp +++ b/src/longRange/Planar.cpp @@ -151,7 +151,7 @@ void Planar::init() } else { std::ostringstream error_message; error_message << "Long Range Correction: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } @@ -197,13 +197,13 @@ void Planar::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "Long Range Correction: Write frequency < 1! Programm exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(_nStopWritingProfiles <= _nStartWritingProfiles) { std::ostringstream error_message; error_message << "Long Range Correction: Writing profiles 'stop' <= 'start'! Programm exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } bool bInputIsValid = (bRet1 && bRet2 && bRet3); if(true == bInputIsValid) @@ -216,7 +216,7 @@ void Planar::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "Long Range Correction: Write control parameters not valid! Programm exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/molecules/AutoPasSimpleMolecule.cpp b/src/molecules/AutoPasSimpleMolecule.cpp index 485c850ac6..2968490833 100644 --- a/src/molecules/AutoPasSimpleMolecule.cpp +++ b/src/molecules/AutoPasSimpleMolecule.cpp @@ -20,7 +20,7 @@ AutoPasSimpleMolecule::AutoPasSimpleMolecule(unsigned long id, Component* compon } else if (_component != component and component != nullptr) { Log::global_log->warning() << "AutoPasSimpleMolecule can only handle one component" << std::endl; _component = component; - // MARDYN_EXIT(error_message); + // MARDYN_EXIT(error_message.str()); } } diff --git a/src/molecules/Comp2Param.cpp b/src/molecules/Comp2Param.cpp index 2867f36179..413e8b9d69 100644 --- a/src/molecules/Comp2Param.cpp +++ b/src/molecules/Comp2Param.cpp @@ -60,7 +60,7 @@ void Comp2Param::initialize( } else { std::ostringstream error_message; error_message << "Mixing: Only LB rule supported" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return {}; } }(); diff --git a/src/molecules/Component.cpp b/src/molecules/Component.cpp index d5cbba1ed7..ef3212f30f 100644 --- a/src/molecules/Component.cpp +++ b/src/molecules/Component.cpp @@ -78,11 +78,11 @@ void Component::readXML(XMLfileUnits& xmlconfig) { } else if (siteType == "Tersoff") { std::ostringstream error_message; error_message << "Tersoff no longer supported:" << siteType << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else { std::ostringstream error_message; error_message << "Unknown site type:" << siteType << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // go back to initial level, to be consistent, even if no site information is found. xmlconfig.changecurrentnode(".."); diff --git a/src/molecules/MoleculeInterface.cpp b/src/molecules/MoleculeInterface.cpp index 7c024d522e..f5b78b3cf3 100644 --- a/src/molecules/MoleculeInterface.cpp +++ b/src/molecules/MoleculeInterface.cpp @@ -32,7 +32,7 @@ bool MoleculeInterface::isLessThan(const MoleculeInterface& m2) const { else { std::ostringstream error_message; error_message << "LinkedCells::isFirstParticle: both Particles have the same position" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } diff --git a/src/molecules/mixingrules/MixingRuleBase.cpp b/src/molecules/mixingrules/MixingRuleBase.cpp index 5a4097e09e..5ecfa4650d 100644 --- a/src/molecules/mixingrules/MixingRuleBase.cpp +++ b/src/molecules/mixingrules/MixingRuleBase.cpp @@ -17,11 +17,11 @@ void MixingRuleBase::readXML(const XMLfileUnits& xmlconfig) { if (cid1 == cid2) { std::ostringstream error_message; error_message << "Mixing rules: cid1 and cid2 must not be the same but are both " << cid1 << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else if (std::min(cid1, cid2) < 0) { std::ostringstream error_message; error_message << "Mixing rules: cid1 and cid2 must be greater than zero" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // Symmetry for mixing rules is assumed diff --git a/src/parallel/CollectiveCommunication.h b/src/parallel/CollectiveCommunication.h index 7a5c91ce28..cf38274102 100644 --- a/src/parallel/CollectiveCommunication.h +++ b/src/parallel/CollectiveCommunication.h @@ -172,7 +172,7 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu default: std::ostringstream error_message; error_message<<"invalid reducetype, aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } MPI_CHECK( @@ -195,7 +195,7 @@ class CollectiveCommunication: public CollectiveCommBase, public CollectiveCommu default: std::ostringstream error_message; error_message<<"invalid reducetype, aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } MPI_CHECK(MPI_Allreduce( MPI_IN_PLACE, &_values[i], 1, _types[i], op, _communicator )); } diff --git a/src/parallel/CollectiveCommunicationNonBlocking.h b/src/parallel/CollectiveCommunicationNonBlocking.h index e4b2d9cbc4..b0b9966b13 100644 --- a/src/parallel/CollectiveCommunicationNonBlocking.h +++ b/src/parallel/CollectiveCommunicationNonBlocking.h @@ -42,7 +42,7 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: previous communication with key " << _currentKey << " not yet finalized" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _currentKey = key; @@ -61,7 +61,7 @@ class CollectiveCommunicationNonBlocking: public CollectiveCommunicationInterfac std::ostringstream error_message; error_message << "CollectiveCommunicationNonBlocking: key " << _currentKey << " could not be inserted. Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } _comms.at(_currentKey).init(communicator, numValues, _currentKey); diff --git a/src/parallel/CommunicationPartner.cpp b/src/parallel/CommunicationPartner.cpp index 517783ff13..16f5efa8ac 100644 --- a/src/parallel/CommunicationPartner.cpp +++ b/src/parallel/CommunicationPartner.cpp @@ -197,7 +197,7 @@ void CommunicationPartner::initSend(ParticleContainer* moleculeContainer, const default: std::ostringstream error_message; error_message << "[CommunicationPartner] MessageType unknown!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #ifndef NDEBUG @@ -602,7 +602,7 @@ void CommunicationPartner::collectLeavingMoleculesFromInvalidParticles(std::vect if (not m.inBox(lowCorner, highCorner)) { std::ostringstream error_message; error_message << "trying to remove a particle that is not in the halo region" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompBase.cpp b/src/parallel/DomainDecompBase.cpp index 937efb4695..6a3499e5a1 100644 --- a/src/parallel/DomainDecompBase.cpp +++ b/src/parallel/DomainDecompBase.cpp @@ -233,7 +233,7 @@ void DomainDecompBase::handleDomainLeavingParticlesDirect(const HaloRegion& halo if (not m.inBox(haloRegion.rmin, haloRegion.rmax)) { std::ostringstream error_message; error_message << "trying to remove a particle that is not in the halo region" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } for (int dim = 0; dim < 3; dim++) { if (shift[dim] != 0) { diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index d55e5771f7..0cb934df6a 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -152,7 +152,7 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else { std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid zonal method specified. Valid values are 'fs', 'es', 'hs', 'mp' and 'nt'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Using zonal method: " << zonalMethod << std::endl; @@ -168,7 +168,7 @@ void DomainDecompMPIBase::setCommunicationScheme(const std::string& scheme, cons } else { std::ostringstream error_message; error_message << "DomainDecompMPIBase: invalid NeighbourCommunicationScheme specified. Valid values are 'direct' and 'indirect'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -200,7 +200,7 @@ void DomainDecompMPIBase::assertIntIdentity(int IX) { std::ostringstream error_message; error_message << "[DomainDecompMPIBase] IX is " << IX << " for rank 0, " << "but " << recv << " for rank " << i << "." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } Log::global_log->info() << "IX = " << recv << " for all " << _numProcs << " ranks.\n"; @@ -229,7 +229,7 @@ void DomainDecompMPIBase::assertDisjunctivity(ParticleContainer* moleculeContain if(check.find(m->getID()) != check.end()){ std::ostringstream error_message; error_message << "Rank 0 contains a duplicated particle with id " << m->getID() << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } check[m->getID()] = 0; } @@ -254,7 +254,7 @@ void DomainDecompMPIBase::assertDisjunctivity(ParticleContainer* moleculeContain if (not isOk) { std::ostringstream error_message; error_message << "Aborting because of duplicated particles." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Data consistency checked: No duplicate IDs detected among " << check.size() diff --git a/src/parallel/DomainDecomposition.cpp b/src/parallel/DomainDecomposition.cpp index ce350c1f4f..67d4c8ce9c 100644 --- a/src/parallel/DomainDecomposition.cpp +++ b/src/parallel/DomainDecomposition.cpp @@ -32,7 +32,7 @@ void DomainDecomposition::initMPIGridDims() { error_message << "\tbut grid is " << _gridSize[0] << " x " << _gridSize[1] << " x " << _gridSize[2] << std::endl; error_message << "\tresulting in " << numProcsGridSize << " subdomains!" << std::endl; error_message << "\tplease check your input file!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -67,7 +67,7 @@ void DomainDecomposition::prepareNonBlockingStage(bool /*forceRebalancing*/, Par error_message << "nonblocking P2P using separate messages for leaving and halo is currently not " "supported. Please use the indirect neighbor communication scheme!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -81,7 +81,7 @@ void DomainDecomposition::finishNonBlockingStage(bool /*forceRebalancing*/, Part std::ostringstream error_message; error_message << "nonblocking P2P using separate messages for leaving and halo is currently not supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/parallel/ForceHelper.cpp b/src/parallel/ForceHelper.cpp index f2cf207280..3bf5177c48 100644 --- a/src/parallel/ForceHelper.cpp +++ b/src/parallel/ForceHelper.cpp @@ -40,7 +40,7 @@ std::variant> addValuesAndGet // This should not happen std::ostringstream error_message; error_message << "Original molecule not usePreviousIterator" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } mardyn_assert(originalIter->getID() == haloMolecule.getID()); diff --git a/src/parallel/GeneralDomainDecomposition.cpp b/src/parallel/GeneralDomainDecomposition.cpp index 17238cfc29..ec656fbefe 100644 --- a/src/parallel/GeneralDomainDecomposition.cpp +++ b/src/parallel/GeneralDomainDecomposition.cpp @@ -61,7 +61,7 @@ void GeneralDomainDecomposition::initializeALL() { #else std::ostringstream error_message; error_message << "ALL load balancing library not enabled. Aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif Log::global_log->info() << "GeneralDomainDecomposition initial box: [" << _boxMin[0] << ", " << _boxMax[0] << "] x [" << _boxMin[1] << ", " << _boxMax[1] << "] x [" << _boxMin[2] << ", " << _boxMax[2] << "]" @@ -199,7 +199,7 @@ void GeneralDomainDecomposition::migrateParticles(Domain* domain, ParticleContai << particleContainer->getBoundingBoxMax(2) << "\n" << "Particle: \n" << *iter << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } particleContainer->clear(); @@ -294,7 +294,7 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { error_message << "GeneralDomainDecomposition's gridSize should have three entries if a list is given, but has " << strings.size() << "!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _gridSize = {std::stod(strings[0]), std::stod(strings[1]), std::stod(strings[2])}; } else { @@ -307,7 +307,7 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { error_message << "GeneralDomainDecomposition's gridSize (" << gridSize << ") is smaller than the interactionLength (" << _interactionLength << "). This is forbidden, as it leads to errors! " << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } @@ -325,13 +325,13 @@ void GeneralDomainDecomposition::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "GeneralDomainDecomposition: Unknown load balancer " << loadBalancerString << ". Aborting! Please select a valid option! Valid options: ALL"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _loadBalancer->readXML(xmlconfig); } else { std::ostringstream error_message; error_message << "loadBalancer section missing! Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode(".."); } diff --git a/src/parallel/KDDecomposition.cpp b/src/parallel/KDDecomposition.cpp index d25d612d74..814cbd6fad 100644 --- a/src/parallel/KDDecomposition.cpp +++ b/src/parallel/KDDecomposition.cpp @@ -69,7 +69,7 @@ void KDDecomposition::init(Domain* domain){ error_message << "KDDecomposition not possible. Each process needs at least " << minCellCountPerProc << " cells." << std::endl; error_message << "The number of Cells is only sufficient for " << _decompTree->getNumMaxProcs() << " Procs!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _decompTree->buildKDTree(); _ownArea = _decompTree->findAreaForProcess(_rank); @@ -106,7 +106,7 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { if(KDDStaticValues::minNumCellsPerDimension==0u){ std::ostringstream error_message; error_message << "KDDecomposition minNumCellsPerDimension has to be bigger than zero!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("updateFrequency", _frequency); Log::global_log->info() << "KDDecomposition update frequency: " << _frequency << std::endl; @@ -129,7 +129,7 @@ void KDDecomposition::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "Wrong deviationReductionOperation given: " << _deviationReductionOperation << ". Should be 'max' or 'sum'." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } Log::global_log->info() << "KDDecomposition uses " << deviationReductionOperation @@ -322,7 +322,7 @@ void KDDecomposition::balanceAndExchange(double lastTraversalTime, bool forceReb std::ostringstream error_message; error_message << "A problem occurred during particle migration between old decomposition and new decomposition of the KDDecomposition." << std::endl; error_message << "Aborting. Please save your input files and last available checkpoint and contact TUM SCCS." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } delete _decompTree; _decompTree = newDecompRoot; @@ -560,7 +560,7 @@ void KDDecomposition::fillTimeVecs(CellProcessor **cellProc){ if(cellProc == nullptr){ std::ostringstream error_message; error_message << "The cellProcessor was not yet set! Please reorder fillTimeVecs, so that there won't be a problem!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } auto _tunerLoadCalc = dynamic_cast(_loadCalc); if(_tunerLoadCalc){ @@ -1031,7 +1031,7 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::list_owningProc + node->_numProcs] - _accumulatedProcessorSpeeds[node->_owningProc]) * leftRightLoadRatio / (1. + leftRightLoadRatio); @@ -1095,7 +1095,7 @@ bool KDDecomposition::calculateAllPossibleSubdivisions(KDNode* node, std::list_child1->isResolvable() && clone->_child2->isResolvable() ); @@ -1256,7 +1256,7 @@ void KDDecomposition::calculateCostsPar(KDNode* area, std::vector KDDecomposition::getNeighbourRanks() { std::ostringstream error_message; error_message << "KDDecomposition::getNeighbourRanks() not implemented" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return std::vector (0); } std::vector KDDecomposition::getNeighbourRanksFullShell() { std::ostringstream error_message; error_message << "KDDecomposition::getNeighbourRanksFullShell() not implemented" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return std::vector (0); } @@ -1784,7 +1784,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN if (costsLeft[biggestDim].size()<=2){ std::ostringstream error_message; error_message << "The domain is far to small!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } int startIndex = 1; @@ -1829,7 +1829,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN (optimalNode->_child1->getNumMaxProcs() + optimalNode->_child2->getNumMaxProcs())) { std::ostringstream error_message; error_message << "Domain is not resolvable at all!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } while ( (! optimalNode->_child1->isResolvable()) && optimalNode->_child2->isResolvable()) { @@ -1858,7 +1858,7 @@ bool KDDecomposition::calculateHeteroSubdivision(KDNode* node, KDNode*& optimalN //continue; std::ostringstream error_message; error_message << "ERROR in calculateHeteroSubdivision(), part of the domain was not assigned to a proc" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } mardyn_assert( optimalNode->_child1->isResolvable() && optimalNode->_child2->isResolvable() ); diff --git a/src/parallel/LoadCalc.cpp b/src/parallel/LoadCalc.cpp index f043447fdf..e02bf20276 100644 --- a/src/parallel/LoadCalc.cpp +++ b/src/parallel/LoadCalc.cpp @@ -45,7 +45,7 @@ std::vector TunerLoad::readVec(std::istream& in, int& count1, int& count << " with a different amounts of elements in the second dimension!" << std::endl; error_message << "This means the files is corrupted. " << "Please remove it (or disallow the tuner to read from inputfiles) before restarting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } @@ -124,28 +124,28 @@ TunerLoad::TunerLoad(int count1, int count2, std::vector&& ownTime, std: std::ostringstream error_message; error_message << "_edgeTime was initialized with the wrong size of " << _ownTime.size() << " expected: " << _count1 * _count2; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (_faceTime.size() != size_t(count1 * _count2)) { std::ostringstream error_message; error_message << "_edgeTime was initialized with the wrong size of " << _faceTime.size() << " expected: " << _count1 * _count2; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (_edgeTime.size() != size_t(_count1 * _count2)) { std::ostringstream error_message; error_message << "_edgeTime was initialized with the wrong size of " << _edgeTime.size() << " expected: " << _count1 * _count2; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (_cornerTime.size() != size_t(_count1 * _count2)) { std::ostringstream error_message; error_message << "_edgeTime was initialized with the wrong size of " << _cornerTime.size() << " expected: " << _count1 * _count2; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -156,7 +156,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::ostringstream error_message; error_message << "The tunerfile is corrupted! Missing header \"Vectorization Tuner File\""; error_message << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } int count1; @@ -167,7 +167,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::ostringstream error_message; error_message << "The tunerfile is corrupted! Missing Section \"own\""; error_message << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } auto ownTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -176,7 +176,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::ostringstream error_message; error_message<< "The tunerfile is corrupted! Missing Section \"face\""; error_message << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } auto faceTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -185,7 +185,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::ostringstream error_message; error_message << "The tunerfile is corrupted! Missing Section \"edge\""; error_message << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } auto edgeTime = readVec(stream, count1, count2); std::getline(stream, inStr); @@ -194,7 +194,7 @@ TunerLoad TunerLoad::read(std::istream& stream) { std::ostringstream error_message; error_message << "The tunerfile is corrupted! Missing Section \"corner\""; error_message << "Please remove it or fix it before restarting!"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } auto cornerTime = readVec(stream, count1, count2); return TunerLoad { count1, count2, std::move(ownTime), std::move(faceTime), std::move(edgeTime), std::move( diff --git a/src/parallel/NeighbourCommunicationScheme.cpp b/src/parallel/NeighbourCommunicationScheme.cpp index d1b7417076..6353fe5393 100644 --- a/src/parallel/NeighbourCommunicationScheme.cpp +++ b/src/parallel/NeighbourCommunicationScheme.cpp @@ -269,7 +269,7 @@ void DirectNeighbourCommunicationScheme::initExchangeMoleculesMPI(ParticleContai neighbour.print(ss); error_message << ss.str() << std::endl; } - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -400,7 +400,7 @@ void DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI(ParticleCo }); } - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } // while not allDone @@ -430,7 +430,7 @@ void NeighbourCommunicationScheme::selectNeighbours(MessageType msgType, bool im error_message << "WRONG type in selectNeighbours - this should not be used for push-pull-partners " "selectNeighbours method" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); break; } } @@ -600,7 +600,7 @@ void IndirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI1D(Partic for (int i = 0; i < numNeighbours; ++i) { (*_neighbours)[d][i].deadlockDiagnosticSendRecv(); } - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } // while not allDone diff --git a/src/parallel/ParticleDataRMM.cpp b/src/parallel/ParticleDataRMM.cpp index 22fdc1c0ed..943ad37e9e 100644 --- a/src/parallel/ParticleDataRMM.cpp +++ b/src/parallel/ParticleDataRMM.cpp @@ -31,7 +31,7 @@ void ParticleDataRMM::getMPIType(MPI_Datatype &sendPartType) { } else { std::ostringstream error_message; error_message << "invalid size of vcp_real_calc"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } //if the following statement is not true, then the 6 double values do not follow one after the other. diff --git a/src/parallel/StaticIrregDomainDecomposition.cpp b/src/parallel/StaticIrregDomainDecomposition.cpp index f02b6a29bc..2da2b42af4 100644 --- a/src/parallel/StaticIrregDomainDecomposition.cpp +++ b/src/parallel/StaticIrregDomainDecomposition.cpp @@ -75,7 +75,7 @@ void StaticIrregDomainDecomposition::readXML(XMLfileUnits &xmlconfig) { << " axis have a non-natural number! Only integer weights > " "0 allowed, please check XML file!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _subdomainWeights[i].push_back(temp); if (ss.peek() == ',' || ss.peek() == ' ') // skip commas and spaces diff --git a/src/parallel/tests/KDDecompositionTest.cpp b/src/parallel/tests/KDDecompositionTest.cpp index 328f19fecd..c4bea90e23 100644 --- a/src/parallel/tests/KDDecompositionTest.cpp +++ b/src/parallel/tests/KDDecompositionTest.cpp @@ -419,7 +419,7 @@ void KDDecompositionTest::testRebalancingDeadlocks() { if (not isOK) { std::ostringstream error_message; error_message << "[KDDecompositionTest] Deadlock detected." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } delete kdd->_decompTree; kdd->_decompTree = newDecompRoot; diff --git a/src/particleContainer/AutoPasContainer.cpp b/src/particleContainer/AutoPasContainer.cpp index 374c07aeaf..d445392748 100644 --- a/src/particleContainer/AutoPasContainer.cpp +++ b/src/particleContainer/AutoPasContainer.cpp @@ -189,7 +189,7 @@ auto parseAutoPasOption(XMLfileUnits &xmlconfig, const std::string &xmlString, error_message << e.what() << std::endl; error_message << "Possible options: " << autopas::utils::ArrayUtils::to_string(OptionType::getAllOptions()) << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); // dummy return return decltype(OptionType::template parseOptions(""))(); } @@ -244,7 +244,7 @@ void AutoPasContainer::readXML(XMLfileUnits &xmlconfig) { } else { std::ostringstream error_message; error_message << "Input XML specifies skin AND skinPerTimestep. Please choose only one." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _relativeOptimumRange = xmlconfig.getNodeValue_double("optimumRange", _relativeOptimumRange); _relativeBlacklistRange = xmlconfig.getNodeValue_double("blacklistRange", _relativeBlacklistRange); @@ -404,7 +404,7 @@ void AutoPasContainer::update() { "Remaining invalid particles:\n" << autopas::utils::ArrayUtils::to_string(_invalidParticles, "\n", {"", ""}) << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _invalidParticles = _autopasContainer.updateContainer(); diff --git a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h index 38baa9fe6a..b9bc6bc30c 100644 --- a/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/C08CellPairTraversal.h @@ -80,7 +80,7 @@ void C08CellPairTraversal::traverseCellPairsOuter( if(eighthShell){ std::ostringstream error_message; error_message << "eightshell + overlapping not yet supported." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } using std::array; diff --git a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h index 44fcb9e132..7b7bcfb85f 100644 --- a/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/NeutralTerritoryTraversal.h @@ -126,7 +126,7 @@ template void NeutralTerritoryTraversal::traverseCellPairsOuter(CellProcessor& cellProcessor) { std::ostringstream error_message; error_message << "NT: overlapping Comm not implemented." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } template @@ -134,7 +134,7 @@ void NeutralTerritoryTraversal::traverseCellPairsInner(CellProcess unsigned stageCount) { std::ostringstream error_message; error_message << "NT: overlapping Comm not implemented." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } template diff --git a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h index bb7b3976de..e54e67e461 100644 --- a/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/OriginalCellPairTraversal.h @@ -76,7 +76,7 @@ void OriginalCellPairTraversal::rebuild(std::vector } else { std::ostringstream error_message; error_message << "OriginalCellPairTraversalDat::rebuild was called with incompatible Traversal data!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h index 63beebed1e..5c47f0e60f 100644 --- a/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/QuickschedTraversal.h @@ -112,7 +112,7 @@ void QuickschedTraversal::init() { error_message << "Blocksize is bigger than number of cells in dimension " << (char) ('x' + i) << ". (" << _taskBlocksize[i] << " > " << this->_dims[i] << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h index bfda8f2ccc..c22e8ea967 100644 --- a/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h +++ b/src/particleContainer/LinkedCellTraversals/SlicedCellPairTraversal.h @@ -192,7 +192,7 @@ inline void SlicedCellPairTraversal::traverseCellPairsBackend( if (not isApplicable(start, end) ) { std::ostringstream error_message; error_message << "The SlicedCellPairTraversal is not applicable. Aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::array diff; diff --git a/src/particleContainer/LinkedCells.cpp b/src/particleContainer/LinkedCells.cpp index 670dfec765..9087b21d74 100644 --- a/src/particleContainer/LinkedCells.cpp +++ b/src/particleContainer/LinkedCells.cpp @@ -95,7 +95,7 @@ LinkedCells::LinkedCells(double bBoxMin[3], double bBoxMax[3], error_message << "_boxWidthInNumCells: " << _boxWidthInNumCells[0] << " / " << _boxWidthInNumCells[1] << " / " << _boxWidthInNumCells[2] << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } initializeCells(); @@ -157,7 +157,7 @@ bool LinkedCells::rebuild(double bBoxMin[3], double bBoxMax[3]) { if (_cellsPerDimension[dim] == 2 * _haloWidthInNumCells[dim]) { std::ostringstream error_message; error_message << "LinkedCells::rebuild: region too small" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } numberOfCells *= _cellsPerDimension[dim]; @@ -235,7 +235,7 @@ void LinkedCells::check_molecules_in_box() { << ") x [" << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMax[1] << ") x [" << _haloBoundingBoxMin[2] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; error_message << "Particles will be lost. Aborting simulation." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -296,7 +296,7 @@ void LinkedCells::update() { if (numBadMolecules > 0) { std::ostringstream error_message; error_message << "Found " << numBadMolecules << " outside of their correct cells. Aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif } @@ -547,7 +547,7 @@ void LinkedCells::traverseNonInnermostCells(CellProcessor& cellProcessor) { if (not _cellsValid) { std::ostringstream error_message; error_message << "Cell structure in LinkedCells (traverseNonInnermostCells) invalid, call update first" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _traversalTuner->traverseCellPairsOuter(cellProcessor); @@ -557,7 +557,7 @@ void LinkedCells::traversePartialInnermostCells(CellProcessor& cellProcessor, un if (not _cellsValid) { std::ostringstream error_message; error_message << "Cell structure in LinkedCells (traversePartialInnermostCells) invalid, call update first" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _traversalTuner->traverseCellPairsInner(cellProcessor, stage, stageCount); @@ -567,7 +567,7 @@ void LinkedCells::traverseCells(CellProcessor& cellProcessor) { if (not _cellsValid) { std::ostringstream error_message; error_message << "Cell structure in LinkedCells (traversePairs) invalid, call update first" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } cellProcessor.initTraversal(); @@ -615,7 +615,7 @@ void LinkedCells::deleteOuterParticles() { /*if (_cellsValid == false) { std::ostringstream error_message; error_message << "Cell structure in LinkedCells (deleteOuterParticles) invalid, call update first" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); }*/ const size_t numHaloCells = _haloCellIndices.size(); @@ -841,7 +841,7 @@ unsigned long int LinkedCells::getCellIndexOfMolecule(Molecule* molecule) const error_message << "Molecule:\n" << *molecule << std::endl; error_message << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; error_message << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif //this version is sensitive to roundoffs, if we have molecules (initialized) precisely at position 0.0: @@ -891,7 +891,7 @@ unsigned long int LinkedCells::getCellIndexOfPoint(const double point[3]) const error_message << "Point p = (" << localPoint[0] << ", " << localPoint[1] << ", " << localPoint[2] << ")" << std::endl; error_message << "_haloBoundingBoxMin = (" << _haloBoundingBoxMin[0] << ", " << _haloBoundingBoxMin[1] << ", " << _haloBoundingBoxMin[2] << ")" << std::endl; error_message << "_haloBoundingBoxMax = (" << _haloBoundingBoxMax[0] << ", " << _haloBoundingBoxMax[1] << ", " << _haloBoundingBoxMax[2] << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #endif @@ -1013,7 +1013,7 @@ void LinkedCells::deleteMolecule(ParticleIterator &moleculeIter, const bool& reb if (cellid >= _cells.size()) { std::ostringstream error_message; error_message << "coordinates for atom deletion lie outside bounding box." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _cells[cellid].buildSoACaches(); } diff --git a/src/particleContainer/TraversalTuner.h b/src/particleContainer/TraversalTuner.h index 92b7d89ef2..93e501a4f4 100644 --- a/src/particleContainer/TraversalTuner.h +++ b/src/particleContainer/TraversalTuner.h @@ -156,7 +156,7 @@ void TraversalTuner::findOptimalTraversal() { #ifndef QUICKSCHED std::ostringstream error_message; error_message << "MarDyn was compiled without Quicksched Support. Aborting!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); #endif } else if (dynamic_cast *>(_optimalTraversal)) Log::global_log->info() << "Using SlicedCellPairTraversal." << std::endl; @@ -167,7 +167,7 @@ void TraversalTuner::findOptimalTraversal() { std::ostringstream error_message; error_message << "Traversal supports up to " << _optimalTraversal->maxCellsInCutoff() << " cells in cutoff, but value is chosen as " << _cellsInCutoff << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -248,7 +248,7 @@ void TraversalTuner::readXML(XMLfileUnits &xmlconfig) { << " direction is <2 and thereby invalid! (" << quiData->taskBlockSize[j] << ")" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } break; @@ -311,7 +311,7 @@ void TraversalTuner::rebuild(std::vector &cells, con default: std::ostringstream error_message; error_message << "Unknown traversal data found in TraversalTuner._traversals!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } traversalPointerReference->rebuild(cells, dims, cellLength, cutoff, traversalData); @@ -341,7 +341,7 @@ inline void TraversalTuner::traverseCellPairs(traversalNames name, default: std::ostringstream error_message; error_message<< "Calling traverseCellPairs(traversalName, CellProcessor&) for something else than the Sliced Traversal is disabled for now. Aborting." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); break; } } diff --git a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h index 8a686608f2..e21ecac19c 100644 --- a/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h +++ b/src/particleContainer/adapter/ParticlePairs2PotForceAdapter.h @@ -177,7 +177,7 @@ class ParticlePairs2PotForceAdapter : public ParticlePairsHandler { default: std::ostringstream error_message; error_message << "[ParticlePairs2PotForceAdapter9] pairType is unknown" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } return 0.0; } diff --git a/src/plugins/COMaligner.cpp b/src/plugins/COMaligner.cpp index fc1be31f66..21fda4be2f 100755 --- a/src/plugins/COMaligner.cpp +++ b/src/plugins/COMaligner.cpp @@ -36,7 +36,7 @@ void COMaligner::readXML(XMLfileUnits& xmlconfig){ error_message << "[COMaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return; } diff --git a/src/plugins/DirectedPM.cpp b/src/plugins/DirectedPM.cpp index 4935f1e079..9ba0c95884 100644 --- a/src/plugins/DirectedPM.cpp +++ b/src/plugins/DirectedPM.cpp @@ -113,7 +113,7 @@ void DirectedPM::beforeForces(ParticleContainer* particleContainer, DomainDecomp error_message << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; error_message << "unID = " << unID << "\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // ADD VELOCITCY AND VIRIAL TO RESPECTIVE BIN _localnumberOfParticles[unID] += 1.; diff --git a/src/plugins/Dropaccelerator.cpp b/src/plugins/Dropaccelerator.cpp index 7550513fca..26fe0d6cf3 100644 --- a/src/plugins/Dropaccelerator.cpp +++ b/src/plugins/Dropaccelerator.cpp @@ -36,7 +36,7 @@ void Dropaccelerator::readXML(XMLfileUnits& xmlconfig) { error_message << "[Dropaccelerator] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return; } diff --git a/src/plugins/Dropaligner.cpp b/src/plugins/Dropaligner.cpp index 4a38821ebf..9402bbdb48 100644 --- a/src/plugins/Dropaligner.cpp +++ b/src/plugins/Dropaligner.cpp @@ -28,7 +28,7 @@ void Dropaligner::readXML(XMLfileUnits& xmlconfig) { error_message << "[Dropaligner] HALTING SIMULATION" << std::endl; _enabled = false; // HALT SIM - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return; } diff --git a/src/plugins/ExamplePlugin.cpp b/src/plugins/ExamplePlugin.cpp index c81b415fb1..5b6420a3e0 100644 --- a/src/plugins/ExamplePlugin.cpp +++ b/src/plugins/ExamplePlugin.cpp @@ -60,7 +60,7 @@ void ExamplePlugin::readXML(XMLfileUnits& xmlconfig) { error_message << "Valid options are: all, beforeEventNewTimestep, beforeForces, afterForces, endStep, init, finish." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/plugins/FixRegion.cpp b/src/plugins/FixRegion.cpp index efc63a9cb8..e67ad58228 100644 --- a/src/plugins/FixRegion.cpp +++ b/src/plugins/FixRegion.cpp @@ -33,7 +33,7 @@ void FixRegion::init(ParticleContainer* particleContainer, DomainDecompBase* dom error_message << "[FixRegion] INVALID INPUT!!! DISABLED!" << std::endl; error_message << "[FixRegion] HALTING SIMULATION" << std::endl; // HALT SIM - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); return; } diff --git a/src/plugins/MaxCheck.cpp b/src/plugins/MaxCheck.cpp index 9e21358ed5..e7e56a2997 100644 --- a/src/plugins/MaxCheck.cpp +++ b/src/plugins/MaxCheck.cpp @@ -78,7 +78,7 @@ void MaxCheck::readXML(XMLfileUnits& xmlconfig) { if (numTargets < 1) { std::ostringstream error_message; error_message << "[MaxCheck] No target parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/Mirror.cpp b/src/plugins/Mirror.cpp index 1efd731377..c820b1bd10 100644 --- a/src/plugins/Mirror.cpp +++ b/src/plugins/Mirror.cpp @@ -87,7 +87,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) else { std::ostringstream error_message; error_message << "[Mirror] Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } Log::global_log->info() << "[Mirror] Enabled at position: y = " << _position.coord << std::endl; @@ -127,7 +127,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[Mirror] Method 3 (MT_ZERO_GRADIENT) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /** normal distributions */ @@ -135,7 +135,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[Mirror] Method 4 (MT_NORMDISTR_MB) is deprecated. Use 5 (MT_MELAND_2004) instead. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } /** Meland2004 */ @@ -147,7 +147,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[Mirror] Meland: Parameters for method 5 (MT_MELAND_2004) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else { Log::global_log->info() << "[Mirror] Meland: target velocity = " << _melandParams.velo_target << std::endl; @@ -174,13 +174,13 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) if (not bRet) { std::ostringstream error_message; error_message << "[Mirror] Ramping: Parameters for method 5 (MT_RAMPING) provided in config-file *.xml corrupted/incomplete. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else { if(_rampingParams.startStep > _rampingParams.stopStep) { std::ostringstream error_message; error_message << "[Mirror] Ramping: Start > Stop. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else { Log::global_log->info() << "[Mirror] Ramping from " << _rampingParams.startStep << " to " << _rampingParams.stopStep << std::endl; @@ -193,7 +193,7 @@ void Mirror::readXML(XMLfileUnits& xmlconfig) default: std::ostringstream error_message; error_message << "[Mirror] Ramping: No proper treatment was set. Use 0 (Deletion) or 1 (Transmission). Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[Mirror] Ramping: Treatment for non-reflected particles: " << _rampingParams.treatment << " ( " << treatmentStr << " ) " << std::endl; } diff --git a/src/plugins/NEMD/DensityControl.cpp b/src/plugins/NEMD/DensityControl.cpp index 20572e6098..7d39ac3ed8 100644 --- a/src/plugins/NEMD/DensityControl.cpp +++ b/src/plugins/NEMD/DensityControl.cpp @@ -88,7 +88,7 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { error_message << "[DensityControl] Number of component IDs specified in element ..." << " does not match the number of components in the simulation. Programm exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // targets @@ -114,7 +114,7 @@ void DensityControl::readXML(XMLfileUnits& xmlconfig) { if (numTargets < 1) { std::ostringstream error_message; error_message << "[DensityControl] No target parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } const std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator nodeIter; diff --git a/src/plugins/NEMD/DistControl.cpp b/src/plugins/NEMD/DistControl.cpp index af11f6f3f5..f6b461c721 100644 --- a/src/plugins/NEMD/DistControl.cpp +++ b/src/plugins/NEMD/DistControl.cpp @@ -81,7 +81,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing attribute \"subdivision@type\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if("number" == strSubdivisionType) { @@ -90,7 +90,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing element \"subdivision/number\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else this->SetSubdivision(nNumSlabs); @@ -102,7 +102,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing element \"subdivision/width\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } else this->SetSubdivision(dSlabWidth); @@ -111,7 +111,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Wrong attribute \"subdivision@type\". Expected: type=\"number|width\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // init method @@ -143,7 +143,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing elements \"init/values/left\" or \"init/values/right\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else if("file" == strInitMethodType) @@ -161,7 +161,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing elements \"init/file\" or \"init/simstep\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else @@ -169,7 +169,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) std::ostringstream error_message; error_message << "[DistControl] Wrong attribute \"init@type\", type = " << strInitMethodType << ", " "expected: type=\"startconfig|values|file\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // update method @@ -198,7 +198,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else if("denderiv" == strUpdateMethodType) @@ -223,7 +223,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "[DistControl] Missing elements \"method/componentID\" or \"method/density\" or both! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else @@ -231,7 +231,7 @@ void DistControl::readXML(XMLfileUnits& xmlconfig) std::ostringstream error_message; error_message << "[DistControl] Wrong attribute \"method@type\", type = " << strUpdateMethodType << ", " "expected: type=\"density|denderiv\"! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -278,7 +278,7 @@ void DistControl::PrepareSubdivision() default: std::ostringstream error_message; error_message << "[DistControl] PrepareSubdivision(): Neither _binParams.width nor _binParams.count was set correctly! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _binParams.invWidth = 1. / _binParams.width; @@ -715,7 +715,7 @@ void DistControl::UpdatePositionsInit(ParticleContainer* particleContainer) default: std::ostringstream error_message; error_message << "[DistControl] Wrong Init Method! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #ifndef NDEBUG @@ -752,7 +752,7 @@ void DistControl::UpdatePositions(const uint64_t& simstep) default: std::ostringstream error_message; error_message << "[DistControl] UpdatePositions() Corrupted code!!! Programm exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // update positions diff --git a/src/plugins/NEMD/MettDeamon.cpp b/src/plugins/NEMD/MettDeamon.cpp index 18f29c27e2..0585fbf4c9 100644 --- a/src/plugins/NEMD/MettDeamon.cpp +++ b/src/plugins/NEMD/MettDeamon.cpp @@ -419,7 +419,7 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) if(numChanges < 1) { std::ostringstream error_message; error_message << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -438,7 +438,7 @@ void MettDeamon::readXML(XMLfileUnits& xmlconfig) else { std::ostringstream error_message; error_message << "[MettDeamon] No component changes defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -1193,7 +1193,7 @@ void MettDeamon::InsertReservoirSlab(ParticleContainer* particleContainer) if(not _reservoir->nextBin(_nMaxMoleculeID.global) ) { std::ostringstream error_message; error_message << "[MettDeamon] Failed to activate new bin of particle Reservoir's BinQueue => Program exit." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->debug() << "[" << nRank << "]: ADDED " << numAdded.local << "/" << numParticlesCurrentSlab.local << " particles (" << numAdded.local/static_cast(numParticlesCurrentSlab.local)*100 << ")%." << std::endl; // calc global values @@ -1214,7 +1214,7 @@ void MettDeamon::initRestart() { std::ostringstream error_message; error_message << "[MettDeamon] Failed to activate reservoir bin after restart! Program exit ... " << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _feedrate.feed.sum = _restartInfo.dYsum; } @@ -1232,7 +1232,7 @@ void MettDeamon::readNormDistr() if (!ifs.vxz.is_open() || !ifs.vy.is_open() ) { std::ostringstream error_message; error_message << "[MettDeamon] There was a problem opening the input file!\n"; - MARDYN_EXIT(error_message);//exit or do additional error checking + MARDYN_EXIT(error_message.str());//exit or do additional error checking } double dVal = 0.0; @@ -1250,7 +1250,7 @@ void MettDeamon::readNormDistr() else { std::ostringstream error_message; error_message << "[MettDeamon] Something went wrong with the direction." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } // close files @@ -1321,7 +1321,7 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) else { std::ostringstream error_message; error_message << "[MettDeamon] Reservoir file type not specified or unknown. Programm exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // Possibly change component IDs @@ -1332,7 +1332,7 @@ void Reservoir::readXML(XMLfileUnits& xmlconfig) if(numChanges < 1) { std::ostringstream error_message; error_message << "[MettDeamon] No component change defined in XML-config file. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator changeIter; @@ -1362,7 +1362,7 @@ void Reservoir::readParticleData(DomainDecompBase* domainDecomp, ParticleContain default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown (or ambiguous) method to read reservoir for feature MettDeamon. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // sort particles into bins @@ -1492,7 +1492,7 @@ void Reservoir::sortParticlesToBins(DomainDecompBase* domainDecomp, ParticleCont default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown moving direction" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // check if molecule is in bounding box of the process domain bool bIsInsideBB = domainDecomp->procOwnsPos(mol.r(0), mol.r(1), mol.r(2), domain); @@ -1524,7 +1524,7 @@ void Reservoir::sortParticlesToBins(DomainDecompBase* domainDecomp, ParticleCont default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown moving direction" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -1538,7 +1538,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* if (!ifs.is_open()) { std::ostringstream error_message; error_message << "[MettDeamon] Could not open Mettdeamon Reservoirfile " << _filepath.data << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[MettDeamon] Reading Mettdeamon Reservoirfile " << _filepath.data << std::endl; @@ -1568,7 +1568,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* if((token != "NumberOfMolecules") && (token != "N")) { std::ostringstream error_message; error_message << "[MettDeamon] Expected the token 'NumberOfMolecules (N)' instead of '" << token << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } ifs >> _numMoleculesRead; @@ -1589,7 +1589,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* else { std::ostringstream error_message; error_message << "[MettDeamon] Unknown molecule format '" << ntypestring << "'" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else { ifs.seekg(spos); @@ -1632,7 +1632,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown molecule format" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if( componentid > numcomponents ) { @@ -1642,7 +1642,7 @@ void Reservoir::readFromFile(DomainDecompBase* domainDecomp, ParticleContainer* << componentid << ">" << numcomponents << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // ComponentIDs are used as array IDs, hence need to start at 0. // In the input files they always start with 1 so we need to adapt that all the time. @@ -1672,7 +1672,7 @@ void Reservoir::readFromFileBinaryHeader() std::ostringstream error_message; error_message << "[MettDeamon] Could not find root node /mardyn in XML header file or file itself." << std::endl; error_message << "[MettDeamon] Not a valid MarDyn XML header file." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } bool bInputOk = true; @@ -1701,7 +1701,7 @@ void Reservoir::readFromFileBinaryHeader() { std::ostringstream error_message; error_message << "[MettDeamon] Content of file: '" << _filepath.header << "' corrupted! Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if("ICRVQD" == strMoleculeFormat) @@ -1714,7 +1714,7 @@ void Reservoir::readFromFileBinaryHeader() { std::ostringstream error_message; error_message << "[MettDeamon] Not a valid molecule format: " << strMoleculeFormat << ", program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -1734,7 +1734,7 @@ void Reservoir::readFromFileBinary(DomainDecompBase* domainDecomp, ParticleConta if (!ifs.is_open()) { std::ostringstream error_message; error_message << "[MettDeamon] Could not open reservoir phaseSpaceFile " << _filepath.data << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[MettDeamon] Reading phase space file " << _filepath.data << std::endl; @@ -1755,7 +1755,7 @@ void Reservoir::readFromFileBinary(DomainDecompBase* domainDecomp, ParticleConta default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown molecule format" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } for (uint64_t pi=0; pi<_numMoleculesRead; pi++) { @@ -1840,7 +1840,7 @@ bool Reservoir::isRelevant(DomainDecompBase* domainDecomp, Domain* domain, Molec default: std::ostringstream error_message; error_message << "[MettDeamon] Unknown moving direction" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } return domainDecomp->procOwnsPos(mol.r(0), y-dOffset, mol.r(2), domain); } diff --git a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp index 42aa10f4e5..ea7f39e152 100644 --- a/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp +++ b/src/plugins/NEMD/MettDeamonFeedrateDirector.cpp @@ -136,12 +136,12 @@ void MettDeamonFeedrateDirector::beforeForces( if(nullptr == mirror) { std::ostringstream error_message; error_message << "[MettDeamonFeedrateDirector] No Mirror plugin found in plugin list. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(nullptr == mettDeamon) { std::ostringstream error_message; error_message << "[MettDeamonFeedrateDirector] No MettDeamon plugin found in plugin list. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } // Get number of deleted/reflected particles from Mirror plugin diff --git a/src/plugins/NEMD/RegionSampling.cpp b/src/plugins/NEMD/RegionSampling.cpp index c0d0357725..9f6484436a 100644 --- a/src/plugins/NEMD/RegionSampling.cpp +++ b/src/plugins/NEMD/RegionSampling.cpp @@ -173,7 +173,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()<<"]: Initialization of plugin DistControl is needed before! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -186,7 +186,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if(numSamplingModules < 1) { std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()-1<<"]: No sampling module parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } XMLfile::Query::const_iterator outputSamplingIter; @@ -223,7 +223,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]: No velocity discretizations specified for VDF sampling. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } XMLfile::Query::const_iterator nodeIter; for( nodeIter = query_vd.begin(); nodeIter != query_vd.end(); nodeIter++ ) @@ -315,7 +315,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) if( (cid > _numComponents) || ((not bVal) && (not _boolSingleComp)) ){ std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()-1<<"]: VDF velocity discretization corrupted. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if(_boolSingleComp){ @@ -343,7 +343,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]: Found " << numSubdivisions << " 'subdivision' elements, " "expected: 2. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputSubdivisionIter; @@ -490,7 +490,7 @@ void SampleRegion::readXML(XMLfileUnits& xmlconfig) { std::ostringstream error_message; error_message << "RegionSampling->region["<GetID()-1<<"]->sampling('"<region["<GetID()-1<<"]: Wrong attribute 'sampling@type', expected type='profiles|VDF|fieldYR'! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } // for( outputSamplingIter = query.begin(); outputSamplingIter; outputSamplingIter++ ) } @@ -525,7 +525,7 @@ void SampleRegion::prepareSubdivisionProfiles() default: std::ostringstream error_message; error_message << "tec::ControlRegion::PrepareSubdivisionProfiles(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -550,7 +550,7 @@ void SampleRegion::prepareSubdivisionVDF() default: std::ostringstream error_message; error_message << "ERROR in SampleRegion::PrepareSubdivisionVDF(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -575,7 +575,7 @@ void SampleRegion::prepareSubdivisionFieldYR() default: std::ostringstream error_message; error_message << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } dWidth = (this->GetWidth(0) < this->GetWidth(2) ) ? this->GetWidth(0) : this->GetWidth(2); @@ -595,7 +595,7 @@ void SampleRegion::prepareSubdivisionFieldYR() default: std::ostringstream error_message; error_message << "SampleRegion::PrepareSubdivisionFieldYR(): Unknown subdivision type! Program exit..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -2070,7 +2070,7 @@ void RegionSampling::readXML(XMLfileUnits& xmlconfig) if(numRegions < 1) { std::ostringstream error_message; error_message << "RegionSampling: No region parameters specified. Program exit ..." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::string oldpath = xmlconfig.getcurrentnodepath(); XMLfile::Query::const_iterator outputRegionIter; diff --git a/src/plugins/Permittivity.cpp b/src/plugins/Permittivity.cpp index 84aab5743e..84b60e439f 100644 --- a/src/plugins/Permittivity.cpp +++ b/src/plugins/Permittivity.cpp @@ -79,7 +79,7 @@ void Permittivity::init(ParticleContainer* particleContainer, DomainDecompBase* if(not orientationIsCorrect){ std::ostringstream error_message; error_message << "Wrong dipole vector chosen! Please always choose [eMyx eMyy eMyz] = [0 0 1] when using the permittivity plugin" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } diff --git a/src/plugins/PluginFactory.cpp b/src/plugins/PluginFactory.cpp index 2c7e5f4868..2c1041455e 100644 --- a/src/plugins/PluginFactory.cpp +++ b/src/plugins/PluginFactory.cpp @@ -194,7 +194,7 @@ long PluginFactory::enablePlugins(std::list& _plugins, } else { std::ostringstream error_message; error_message << "[MMPLD Writer] Unknown sphere representation type: " << sphere_representation << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } else if (pluginname == "DomainProfiles") { plugin = this->create("DensityProfileWriter"); diff --git a/src/plugins/SpatialProfile.cpp b/src/plugins/SpatialProfile.cpp index 0eca608c08..a549cdcfa6 100644 --- a/src/plugins/SpatialProfile.cpp +++ b/src/plugins/SpatialProfile.cpp @@ -47,7 +47,7 @@ void SpatialProfile::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "[SpatialProfile] Invalid mode. cylinder/cartesian" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[SpatialProfile] Binning units: " << samplInfo.universalProfileUnit[0] << " " @@ -406,7 +406,7 @@ long SpatialProfile::getCylUID(ParticleIterator& thismol) { error_message << "Severe error!! Invalid profile unit (" << R2 << " / " << yc << " / " << phi << ").\n\n"; error_message << "Coordinates off center (" << xc << " / " << yc << " / " << zc << ").\n"; error_message << "unID = " << unID << "\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } return unID; } diff --git a/src/plugins/VectorizationTuner.cpp b/src/plugins/VectorizationTuner.cpp index 4918edeadb..bcc3ad011a 100644 --- a/src/plugins/VectorizationTuner.cpp +++ b/src/plugins/VectorizationTuner.cpp @@ -36,7 +36,7 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << R"(Unknown FlopRateOutputPlugin::mode. Choose "stdout" or "file".)" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _outputPrefix = "mardyn"; @@ -66,7 +66,7 @@ void VectorizationTuner::readXML(XMLfileUnits& xmlconfig) { error_message << R"(Unknown FlopRateOutputPlugin::moleculecntincreasetype. Choose "linear" or "exponential" or "both".)" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "Molecule count increase type: " << incTypeStr << std::endl; @@ -286,7 +286,7 @@ void VectorizationTuner::tune(std::vector& componentList, TunerLoad& if(componentList.size() > 2){ std::ostringstream error_message; error_message << "The tuner currently supports only two different particle types!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } int maxMols = particleNums.at(0); diff --git a/src/plugins/WallPotential.cpp b/src/plugins/WallPotential.cpp index f9e316f45d..45161c0e14 100755 --- a/src/plugins/WallPotential.cpp +++ b/src/plugins/WallPotential.cpp @@ -42,7 +42,7 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { _potential = LJ9_3; // TODO: is this allowed or should simulation be halted // HALT SIM - //MARDYN_EXIT(error_message); + //MARDYN_EXIT(error_message.str()); } XMLfile::Query query = xmlconfig.query("component"); @@ -91,7 +91,7 @@ void WallPotential::readXML(XMLfileUnits &xmlconfig) { else{ std::ostringstream error_message; error_message << "[WallPotential] Unknown wall potential" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } diff --git a/src/plugins/profiles/ProfileBase.cpp b/src/plugins/profiles/ProfileBase.cpp index 822b79cc58..f0ec2cc639 100644 --- a/src/plugins/profiles/ProfileBase.cpp +++ b/src/plugins/profiles/ProfileBase.cpp @@ -48,7 +48,7 @@ void ProfileBase::writeKartMatrix (std::ofstream& outfile) { void ProfileBase::writeSimpleMatrix (std::ofstream& outfile) { std::ostringstream error_message; error_message << "SIMPLE MATRIX OUTPUT NOT IMPLEMENTED!\n"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } void ProfileBase::writeCylMatrix (std::ofstream& outfile) { diff --git a/src/thermostats/TemperatureControl.cpp b/src/thermostats/TemperatureControl.cpp index dc826e4222..0946e9146b 100644 --- a/src/thermostats/TemperatureControl.cpp +++ b/src/thermostats/TemperatureControl.cpp @@ -169,7 +169,7 @@ void ControlRegionT::readXML(XMLfileUnits& xmlconfig) { } else { std::ostringstream error_message; error_message << "[TemperatureControl] REGION: Invalid 'method' param: " << methods << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[TemperatureControl] REGION 'method' param: " << methods << std::endl; } @@ -194,7 +194,7 @@ void ControlRegionT::VelocityScalingInit(XMLfileUnits& xmlconfig, std::string st if (_nNumSlabs < 1) { std::ostringstream error_message; error_message << "TemperatureControl: need at least one slab! (settings/numslabs)"; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.getNodeValue("settings/exponent", _dTemperatureExponent); xmlconfig.getNodeValue("settings/directions", strDirections); @@ -421,7 +421,7 @@ void ControlRegionT::ControlTemperature(Molecule* mol) { } else { std::ostringstream error_message; error_message << "[TemperatureControl] Invalid localMethod param: " << _localMethod << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } @@ -510,7 +510,7 @@ void ControlRegionT::registerAsObserver() { std::ostringstream error_message; error_message << "TemperatureControl->region[" << this->GetID() << "]: Initialization of plugin DistControl is needed before!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } } diff --git a/src/utils/OptionParser.cpp b/src/utils/OptionParser.cpp index d0ef97e099..de5d01c144 100644 --- a/src/utils/OptionParser.cpp +++ b/src/utils/OptionParser.cpp @@ -450,13 +450,13 @@ void OptionParser::print_version() const { void OptionParser::exit() const { std::ostringstream error_message; error_message << "OptionParser::exit() called" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } void OptionParser::error(const std::string& msg) const { print_usage(std::cerr); std::ostringstream error_message; error_message << prog() << ": " << _("error") << ": " << msg << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } ////////// } class OptionParser ////////// diff --git a/src/utils/SigsegvHandler.h b/src/utils/SigsegvHandler.h index add1bdc5f9..6dc345228f 100644 --- a/src/utils/SigsegvHandler.h +++ b/src/utils/SigsegvHandler.h @@ -28,7 +28,7 @@ void handler(int sig) { // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, STDERR_FILENO); - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } void registerSigsegvHandler() { diff --git a/src/utils/Testing.cpp b/src/utils/Testing.cpp index fce9273ddc..84da160ebb 100644 --- a/src/utils/Testing.cpp +++ b/src/utils/Testing.cpp @@ -95,7 +95,7 @@ void utils::Test::setTestDataDirectory(std::string& testDataDir) { if (!fileExists(testDataDir.c_str())) { std::ostringstream error_message; error_message << "Directory '" << testDataDir.c_str() << "' for test input data does not exist!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } testDataDirectory = testDataDir; } @@ -107,7 +107,7 @@ std::string utils::Test::getTestDataFilename(const std::string& file, bool check if (!fileExists(fullPath.c_str()) and checkExistence) { std::ostringstream error_message; error_message << "File " << fullPath << " for test input data does not exist!" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } return fullPath; } diff --git a/src/utils/generator/ReplicaFiller.cpp b/src/utils/generator/ReplicaFiller.cpp index 9405aaec9d..f2fc5d0fe6 100644 --- a/src/utils/generator/ReplicaFiller.cpp +++ b/src/utils/generator/ReplicaFiller.cpp @@ -148,20 +148,20 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { if (inputPluginName != "BinaryReader") { std::ostringstream error_message; error_message << "[ReplicaFiller] ReplicaFiller only works with inputPlugins: BinaryReader at the moment" << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } setInputReader(std::make_shared()); _inputReader->readXML(xmlconfig); if (_inputReader == nullptr) { std::ostringstream error_message; error_message << "[ReplicaFiller] Could not create input reader " << inputPluginName << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } xmlconfig.changecurrentnode(".."); } else { std::ostringstream error_message; error_message << "[ReplicaFiller] Input reader for original not specified." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } if (xmlconfig.changecurrentnode("origin")) { Coordinate3D origin; @@ -181,7 +181,7 @@ void ReplicaFiller::readXML(XMLfileUnits& xmlconfig) { if ((componentid < 1) || (componentid > numComps)) { std::ostringstream error_message; error_message << "[ReplicaFiller] Specified componentid is invalid. Valid range: 1 <= componentid <= " << numComps << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } _componentid = componentid - 1; // Internally stored in array starting at index 0 _keepComponent = false; @@ -211,7 +211,7 @@ void ReplicaFiller::init() { if (numberOfParticles == 0) { std::ostringstream error_message; error_message << "[ReplicaFiller] No molecules in replica, aborting! " << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } Log::global_log->info() << "[ReplicaFiller] Setting simulation time to 0.0" << std::endl; diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index c2062ab4a7..f7c584dd7a 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -18,11 +18,11 @@ // Macro to wrap mardyn_exit and pass the caller file and line #define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __FILE__, __LINE__) -inline void mardyn_exit(const std::ostringstream & exit_message, +inline void mardyn_exit(const std::string & exit_message, const char* file, const int line) { Log::global_log->error_always_output() << "Exit called in file `" << file << ":" << line << "` with message:" << std::endl; - std::cerr << exit_message.str() << std::endl; + std::cerr << exit_message << std::endl; #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); @@ -35,7 +35,7 @@ inline void mardyn_exit(const std::ostringstream & exit_message, inline void __mardyn_assert__(const char * expr, const char* file, int line) { std::ostringstream error_message; error_message << "Assertion \"" << expr << "\" failed at " << file << ":" << line << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } #ifdef NDEBUG diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index c24cbaa4d7..acedd95cb2 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -196,7 +196,7 @@ bool XMLfile::initfile_local(const std::string& filepath) { std::ostringstream error_message; error_message << "ERROR opening " << filepathTrimmed << std::endl; clear(); - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } std::ifstream::pos_type filesize=fstrm.tellg(); fstrm.close(); fstrm.clear(); @@ -542,7 +542,7 @@ template bool XMLfile::Node::getValue(T& value) const std::ostringstream error_message; error_message << "ERROR parsing \"" << ss.str() << "\" to data type " << typeid(T).name() << " from tag \"<" << name() << ">\" in xml file" << std::endl; error_message << "The tag contains a negative value but an unsigned value was expected." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } ss >> value; @@ -551,7 +551,7 @@ template bool XMLfile::Node::getValue(T& value) const std::ostringstream error_message; error_message << "ERROR parsing all chars of \"" << ss.str() << "\" from tag \"<" << name() << ">\" in xml file" << std::endl; error_message << "This might be the result of using a float while an integer is expected." << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } return true; } @@ -588,7 +588,7 @@ template<> bool XMLfile::Node::getValue(bool& value) const std::ostringstream error_message; error_message << "ERROR parsing \"" << v << "\" to boolean from tag \"" << name() << "\" in xml file." << " Valid values are: true, false, yes, no, on, off. " << std::endl; - MARDYN_EXIT(error_message); + MARDYN_EXIT(error_message.str()); } } return found; From c80fde886adb60c1dc9a3387d2c4fc1ebb8317f0 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 17:39:46 +0200 Subject: [PATCH 24/28] Some beauty treatment for mardyn_exit --- src/utils/mardyn_assert.h | 40 +++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index f7c584dd7a..dc878263c4 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -12,17 +12,49 @@ #include #include #include +#include +#include #include "Logger.h" // Macro to wrap mardyn_exit and pass the caller file and line -#define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __FILE__, __LINE__) +#define MARDYN_EXIT(exit_message) mardyn_exit(exit_message, __func__, __FILE__, __LINE__) inline void mardyn_exit(const std::string & exit_message, - const char* file, const int line) { + const char* function, const char* filepath, const int line) { + + // Only print the file path relative to the "/src/" directory + // The following code extracts this relative path from "filepath" + // It starts searching from the end (i.e. from the right) to avoid user-specific "src" dirs + const char* filepath_truncated = nullptr; + const char* temp = filepath; + while ((temp = std::strstr(temp, "/src/")) != nullptr) { + filepath_truncated = temp; + temp++; + } + if (filepath_truncated == nullptr) { + filepath_truncated = filepath; + } + + // Print code location from which MARDYN_EXIT() was called Log::global_log->error_always_output() - << "Exit called in file `" << file << ":" << line << "` with message:" << std::endl; - std::cerr << exit_message << std::endl; + << "Exit called from function `" << function << "`" + << " in file `" << filepath_truncated+1 << ":" << line // +1 to ignore the first "/" + << "` with message:" << std::endl; + + // Print exit message line by line to always have Logger output + std::stringstream ss(exit_message); + std::string exit_message_line; + std::vector exit_message_lines; + // First, split exit message by "\n" + while (std::getline(ss, exit_message_line, '\n')) { + exit_message_lines.push_back(exit_message_line); + } + // Second, print each line separately and prepend Logger output + for (const auto& message_line : exit_message_lines) { + Log::global_log->error_always_output() << message_line << std::endl; + } + #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); From a758352b39414d6f9cbdc1a4e4fdadf3f0581ee1 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 17:44:47 +0200 Subject: [PATCH 25/28] Remove commented-out code --- src/Simulation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 2f648676ce..ac459db6f8 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -392,7 +392,6 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { << "Executable was compiled without support for parallel execution: " << parallelisationtype << " not available. Using serial mode." << std::endl; - //MARDYN_EXIT(error_message.str()); } //_domainDecomposition = new DomainDecompBase(); // already set in initialize() #endif From 30557f383885ed2619c0b8115b6b2b87bb0ca893 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 17:49:52 +0200 Subject: [PATCH 26/28] Use tab instead of whitespace --- src/utils/mardyn_assert.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index dc878263c4..85b9c94384 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -27,14 +27,14 @@ inline void mardyn_exit(const std::string & exit_message, // The following code extracts this relative path from "filepath" // It starts searching from the end (i.e. from the right) to avoid user-specific "src" dirs const char* filepath_truncated = nullptr; - const char* temp = filepath; - while ((temp = std::strstr(temp, "/src/")) != nullptr) { - filepath_truncated = temp; - temp++; - } - if (filepath_truncated == nullptr) { - filepath_truncated = filepath; - } + const char* temp = filepath; + while ((temp = std::strstr(temp, "/src/")) != nullptr) { + filepath_truncated = temp; + temp++; + } + if (filepath_truncated == nullptr) { + filepath_truncated = filepath; + } // Print code location from which MARDYN_EXIT() was called Log::global_log->error_always_output() @@ -43,17 +43,17 @@ inline void mardyn_exit(const std::string & exit_message, << "` with message:" << std::endl; // Print exit message line by line to always have Logger output - std::stringstream ss(exit_message); - std::string exit_message_line; - std::vector exit_message_lines; + std::stringstream ss(exit_message); + std::string exit_message_line; + std::vector exit_message_lines; // First, split exit message by "\n" - while (std::getline(ss, exit_message_line, '\n')) { - exit_message_lines.push_back(exit_message_line); - } - // Second, print each line separately and prepend Logger output - for (const auto& message_line : exit_message_lines) { - Log::global_log->error_always_output() << message_line << std::endl; - } + while (std::getline(ss, exit_message_line, '\n')) { + exit_message_lines.push_back(exit_message_line); + } + // Second, print each line separately and prepend Logger output + for (const auto& message_line : exit_message_lines) { + Log::global_log->error_always_output() << message_line << std::endl; + } #ifdef ENABLE_MPI // terminate all mpi processes and return exitcode From c7f78f5cb18c8724f6ac1f7c443ecde044c5611b Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Thu, 10 Oct 2024 20:58:24 +0200 Subject: [PATCH 27/28] Simplify print of single lines --- src/utils/mardyn_assert.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index 85b9c94384..65f23fb426 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -25,7 +25,7 @@ inline void mardyn_exit(const std::string & exit_message, // Only print the file path relative to the "/src/" directory // The following code extracts this relative path from "filepath" - // It starts searching from the end (i.e. from the right) to avoid user-specific "src" dirs + // Search until last "/src/" was found to avoid user-specific "src" dirs const char* filepath_truncated = nullptr; const char* temp = filepath; while ((temp = std::strstr(temp, "/src/")) != nullptr) { @@ -33,26 +33,24 @@ inline void mardyn_exit(const std::string & exit_message, temp++; } if (filepath_truncated == nullptr) { + // Print absolute path if "/src/" not found filepath_truncated = filepath; + } else { + filepath_truncated++; // +1 to ignore the first "/" } // Print code location from which MARDYN_EXIT() was called - Log::global_log->error_always_output() + Log::global_log->error() << "Exit called from function `" << function << "`" - << " in file `" << filepath_truncated+1 << ":" << line // +1 to ignore the first "/" + << " in file `" << filepath_truncated << ":" << line << "` with message:" << std::endl; // Print exit message line by line to always have Logger output std::stringstream ss(exit_message); std::string exit_message_line; - std::vector exit_message_lines; - // First, split exit message by "\n" + // Split exit message by "\n" and print via Logger while (std::getline(ss, exit_message_line, '\n')) { - exit_message_lines.push_back(exit_message_line); - } - // Second, print each line separately and prepend Logger output - for (const auto& message_line : exit_message_lines) { - Log::global_log->error_always_output() << message_line << std::endl; + Log::global_log->error() << exit_message_line << std::endl; } #ifdef ENABLE_MPI From 3f2488ee132c044fd8e741caaffca9592eaa5eaf Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:26:15 +0200 Subject: [PATCH 28/28] print exit messages from all ranks --- src/utils/mardyn_assert.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/mardyn_assert.h b/src/utils/mardyn_assert.h index 65f23fb426..08ad520e73 100644 --- a/src/utils/mardyn_assert.h +++ b/src/utils/mardyn_assert.h @@ -40,7 +40,7 @@ inline void mardyn_exit(const std::string & exit_message, } // Print code location from which MARDYN_EXIT() was called - Log::global_log->error() + Log::global_log->error_always_output() << "Exit called from function `" << function << "`" << " in file `" << filepath_truncated << ":" << line << "` with message:" << std::endl; @@ -50,7 +50,7 @@ inline void mardyn_exit(const std::string & exit_message, std::string exit_message_line; // Split exit message by "\n" and print via Logger while (std::getline(ss, exit_message_line, '\n')) { - Log::global_log->error() << exit_message_line << std::endl; + Log::global_log->error_always_output() << exit_message_line << std::endl; } #ifdef ENABLE_MPI