[MOAB-dev] [PATCH] scdtest.cpp: print what failed and where on error
Jed Brown
jed at 59A2.org
Thu Nov 26 07:41:21 CST 2009
This now produces error messages like
[0/2] MOAB Error: MB_NOT_IMPLEMENTED : mbpc->resolve_shared_ents(0, -1, -1)
in resolve_and_exchange at ../../parallel/scdtest.cpp:208
[1/2] MOAB Error: MB_NOT_IMPLEMENTED : mbpc->resolve_shared_ents(0, -1, -1)
in resolve_and_exchange at ../../parallel/scdtest.cpp:208
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 1 in communicator MPI_COMM_WORLD
with errorcode 9.
Note that the line number is correct. The former behavior gave only
Error: MOAB function failed
lt-scdtest: ../../parallel/scdtest.cpp:203: void error(MBErrorCode): Assertion `0' failed.
[kunyang:31680] *** Process received signal ***
---
parallel/scdtest.cpp | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/parallel/scdtest.cpp b/parallel/scdtest.cpp
index 64ca4d8..6269129 100644
--- a/parallel/scdtest.cpp
+++ b/parallel/scdtest.cpp
@@ -40,7 +40,20 @@ int size;
void set_local_domain_bounds();
void create_hexes_and_verts();
void resolve_and_exchange();
-void error(MBErrorCode err);
+
+#define error(err) do { \
+ MBErrorCode e; \
+ if((e = (err)) != MB_SUCCESS) { \
+ cerr << "[" << rank << "/" << size << "] MOAB Error: " \
+ << mbint->get_error_string(e) << " : " << #err \
+ << "\n\tin " << __FUNCTION__ << " at " << __FILE__ \
+ << ":" << __LINE__ << endl; \
+ cerr.flush(); \
+ sleep(1); \
+ MPI_Abort(MPI_COMM_WORLD,e); \
+ } \
+ } while (0)
+
int main(int argc, char *argv[])
{
@@ -196,10 +209,3 @@ void resolve_and_exchange()
error(mbpc->exchange_ghost_cells(-1, 0, 1, true));
}
-void error(MBErrorCode err)
-{
- if(err != MB_SUCCESS) {
- cerr << "Error: MOAB function failed\n";
- assert(0);
- }
-}
--
1.6.5.3
More information about the moab-dev
mailing list