diff --git a/error.h b/error.h index d5e331486620f77cbf16b15ad673a9c43ad7876b..bf723dd01dcb4adf3b9c0f9bec30156adf9405e8 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); \ + })