Skip to content

Commit

Permalink
Preparations in mardyn_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
HomesGH committed Oct 4, 2024
1 parent d98cb7d commit de95eaa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/utils/mardyn_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@

#include <string>
#include <sstream>
#include <iostream>
#include <cstdlib>

#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__)

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();
Expand Down

0 comments on commit de95eaa

Please sign in to comment.