Skip to content
Browse files

get error code and error message with MPI_Error_class and MPI_Error_s…

…tring, respectively
  • Loading branch information...
1 parent fe33598 commit 39d25d494b1276633804e2bf6789edd2c8395d1e @seiya committed Apr 26, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 ext/mpi/mpi.c
View
13 ext/mpi/mpi.c
@@ -94,12 +94,17 @@ Status_free(void *ptr)
}
-#define CAE_ERR(type) case MPI_ERR_ ## type: rb_raise(e ## type,""); break
+#define CAE_ERR(type) case MPI_ERR_ ## type: rb_raise(e ## type,"%s",str); break
static void
check_error(int error)
{
- switch (error) {
- case MPI_SUCCESS: break;
+ if (error == MPI_SUCCESS) return;
+ int code, len;
+ char str[MPI_MAX_ERROR_STRING];
+ if (MPI_Error_class(error, &code)!=MPI_SUCCESS || MPI_Error_string(error, str, &len)!=MPI_SUCCESS)
+ rb_raise(rb_eRuntimeError, "unknown error occuerd in MPI call");
+
+ switch (code) {
CAE_ERR(BUFFER);
CAE_ERR(COUNT);
CAE_ERR(TYPE);
@@ -158,7 +163,7 @@ check_error(int error)
CAE_ERR(SYSRESOURCE);
#endif
default:
- rb_raise(rb_eRuntimeError, "unknown error");
+ rb_raise(rb_eRuntimeError, "unknown error: %d", code);
}
}

0 comments on commit 39d25d4

Please sign in to comment.
Something went wrong with that request. Please try again.