[MOAB-dev] commit/MOAB: danwu: Create an example file TestErrorHandlingPar.cpp under moab/examples, to demonstrate enhanced error handling of parallel MOAB.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Jan 31 10:49:53 CST 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/7b1a33569316/
Changeset: 7b1a33569316
Branch: error_handling_enhancement
User: danwu
Date: 2014-01-31 17:49:31
Summary: Create an example file TestErrorHandlingPar.cpp under moab/examples, to demonstrate enhanced error handling of parallel MOAB.
Affected #: 2 files
diff --git a/examples/TestErrorHandlingPar.cpp b/examples/TestErrorHandlingPar.cpp
new file mode 100644
index 0000000..09287ed
--- /dev/null
+++ b/examples/TestErrorHandlingPar.cpp
@@ -0,0 +1,70 @@
+/** @example TestErrorHandlingPar.cpp
+ * Description: Demonstrates enhanced error handling of parallel MOAB.\n
+ * This example tests MOAB's trace back error handler in parallel.\n
+ *
+ * <b>To run</b>: mpiexec -np 4 ./TestErrorHandlingPar \n
+ */
+
+#include "moab/Core.hpp"
+
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+using namespace moab;
+
+// Call hierarchy: A calls B, and B calls C
+ErrorInfo FunctionC(int rank)
+{
+ // Simulate MB_FILE_WRITE_ERROR
+ ErrorInfo err_info(MB_FILE_WRITE_ERROR);
+ err_info << "FunctionC created a contrived error MB_FILE_WRITE_ERROR in processor " << rank;
+ SET_ERR(err_info);
+
+ return ERROR_INFO_SUCCESS;
+}
+
+ErrorInfo FunctionB(int rank)
+{
+ ErrorInfo err_info = FunctionC(rank);CHK_ERR(err_info);
+
+ return ERROR_INFO_SUCCESS;
+}
+
+ErrorInfo FunctionA(int rank)
+{
+ ErrorInfo err_info = FunctionB(rank);CHK_ERR(err_info);
+
+ return ERROR_INFO_SUCCESS;
+}
+
+// In this test case, MB_FILE_WRITE_ERROR is returned by FunctionC in each processor
+ErrorInfo TestErrorHandlingPar(int rank)
+{
+ ErrorInfo err_code = FunctionA(rank);CHK_ERR(err_code);
+
+ return ERROR_INFO_SUCCESS;
+}
+
+int main(int argc, char** argv)
+{
+#ifdef USE_MPI
+ MPI_Init(&argc, &argv);
+#endif
+
+ MBErrorHandler_Init();
+
+ int rank = 0;
+#ifdef USE_MPI
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+#endif
+ TestErrorHandlingPar(rank);
+
+ MBErrorHandler_Finalize();
+
+#ifdef USE_MPI
+ MPI_Finalize();
+#endif
+
+ return 0;
+}
diff --git a/examples/makefile b/examples/makefile
index 5f64461..c2d13cb 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -59,6 +59,9 @@ DeformMeshRemap: DeformMeshRemap.o ${MOAB_LIBDIR}/libMOAB.la
TestErrorHandling: TestErrorHandling.o ${MOAB_LIBDIR}/libMOAB.la
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+TestErrorHandlingPar: TestErrorHandlingPar.o ${MOAB_LIBDIR}/libMOAB.la
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
clean:
rm -rf *.o ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES}
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list