From 0e6693f30b478391d59b549599f468295a53127e Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Wed, 11 Mar 2020 15:35:41 +0000 Subject: [PATCH] Add macro to report the MPI error --- error.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/error.h b/error.h index d5e3314..bf723dd 100644 --- a/error.h +++ b/error.h @@ -19,3 +19,15 @@ extern int myrank; printf("[%04i] %s %s: " s "\n", myrank, clocks_get_timesincestart(), \ __FUNCTION__, ##__VA_ARGS__); \ }) + +/* Print MPI error as a string. */ +#define mpi_error_string(res, s, ...) \ + ({ \ + fprintf(stdout, "[%03i] %s %s:%s():%i: " s "\n", myrank, \ + clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \ + ##__VA_ARGS__); \ + int len = 1024; \ + char buf[len]; \ + MPI_Error_string(res, buf, &len); \ + fprintf(stdout, "%s\n\n", buf); \ + }) -- GitLab