]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // Copyright (C) 2018 Alain Miniussi <alain.miniussi -at- oca.eu>. |
2 | ||
3 | // Use, modification and distribution is subject to the Boost Software | |
4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #include <sstream> | |
8 | #include <boost/mpi/error_string.hpp> | |
9 | ||
10 | namespace boost { namespace mpi { | |
11 | ||
12 | std::string error_string(int err) | |
13 | { | |
14 | char buffer[MPI_MAX_ERROR_STRING]; | |
15 | int len; | |
16 | int status = MPI_Error_string(err, buffer, &len); | |
17 | if (status == MPI_SUCCESS) { | |
18 | return std::string(buffer); | |
19 | } else { | |
20 | std::ostringstream out; | |
21 | if (status == MPI_ERR_ARG) { | |
22 | out << "<invalid MPI error code " << err << ">"; | |
23 | } else { | |
24 | out << "<got error " << status | |
25 | << " while probing MPI error " << err << ">"; | |
26 | } | |
27 | return out.str(); | |
28 | } | |
29 | } | |
30 | ||
31 | } } |