/*
* vmg - a versatile multigrid solver
* Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
*
* vmg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* vmg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/**
* @file error_handler.cpp
* @author Julian Iseringhausen
* @date Mon Nov 21 13:27:22 2011
*
* @brief Convert MPI errors to C++ exceptions. Used to be
* able to call a debugger when MPI crashes
* internally.
*
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#ifdef DEBUG
#ifdef HAVE_MPI
#include
#ifdef HAVE_MARMOT
#include
#include
#endif
#include
#include "comm/mpi/error_handler.hpp"
void VMG::MPI::ConvertToException(MPI_Comm* comm, int* err, ...)
{
int rank;
char error_string[MPI_MAX_ERROR_STRING+1], comm_name[MPI_MAX_OBJECT_NAME+1];
int error_len, comm_name_len;
MPI_Comm_rank(*comm, &rank);
MPI_Error_string(*err, error_string, &error_len);
MPI_Comm_get_name(*comm, comm_name, &comm_name_len);
std::stringstream error_concat;
error_concat << "vmg: Rank " << rank << " on communicator \"" << comm_name << "\": " << error_string;
throw Exception(error_concat.str().c_str());
}
#endif /* DEBUG */
#endif /* HAVE_MPI */