#include "moab/MOABConfig.h"
#include "moab/ErrorHandler.hpp"
#include <iostream>
#include <cstdlib>
Go to the source code of this file.
Functions | |
ErrorCode | FunctionC (int test_case_num, int rank) |
ErrorCode | FunctionB (int test_case_num, int rank) |
ErrorCode | FunctionA (int test_case_num, int rank) |
int | main (int argc, char **argv) |
ErrorCode FunctionA | ( | int | test_case_num, |
int | rank | ||
) |
Definition at line 68 of file ErrorHandlingSimulation.cpp.
69 {
70 ErrorCode err_code = FunctionB( test_case_num, rank );MB_CHK_ERR( err_code );
71
72 return MB_SUCCESS;
73 }
References ErrorCode, FunctionB(), MB_CHK_ERR, and MB_SUCCESS.
Referenced by main().
ErrorCode FunctionB | ( | int | test_case_num, |
int | rank | ||
) |
Definition at line 61 of file ErrorHandlingSimulation.cpp.
62 {
63 ErrorCode err_code = FunctionC( test_case_num, rank );MB_CHK_ERR( err_code );
64
65 return MB_SUCCESS;
66 }
References ErrorCode, FunctionC(), MB_CHK_ERR, and MB_SUCCESS.
Referenced by FunctionA().
ErrorCode FunctionC | ( | int | test_case_num, |
int | rank | ||
) |
Definition at line 24 of file ErrorHandlingSimulation.cpp.
25 {
26 switch( test_case_num )
27 {
28 case 1:
29 // Simulate a global fatal error MB_NOT_IMPLEMENTED on all processors
30 // Note, it is printed by root processor 0 only
31 MB_SET_GLB_ERR( MB_NOT_IMPLEMENTED, "A contrived global error MB_NOT_IMPLEMENTED" );
32 break;
33 case 2:
34 // Simulate a per-processor relevant error MB_INDEX_OUT_OF_RANGE on all processors
35 // Note, it is printed by all processors
36 MB_SET_ERR( MB_INDEX_OUT_OF_RANGE, "A contrived error MB_INDEX_OUT_OF_RANGE on processor " << rank );
37 break;
38 case 3:
39 // Simulate a per-processor relevant error MB_TYPE_OUT_OF_RANGE on all processors except
40 // root Note, it is printed by all non-root processors
41 if( 0 != rank )
42 MB_SET_ERR( MB_TYPE_OUT_OF_RANGE, "A contrived error MB_TYPE_OUT_OF_RANGE on processor " << rank );
43 break;
44 case 4:
45 // Simulate a per-processor relevant error MB_INDEX_OUT_OF_RANGE on processor 1
46 // Note, it is printed by processor 1 only
47 if( 1 == rank )
48 MB_SET_ERR( MB_INDEX_OUT_OF_RANGE, "A contrived error MB_INDEX_OUT_OF_RANGE on processor 1" );
49
50 // Simulate a per-processor relevant error MB_TYPE_OUT_OF_RANGE on processor 3
51 // Note, it is printed by processor 3 only
52 if( 3 == rank ) MB_SET_ERR( MB_TYPE_OUT_OF_RANGE, "A contrived error MB_TYPE_OUT_OF_RANGE on processor 3" );
53 break;
54 default:
55 break;
56 }
57
58 return MB_SUCCESS;
59 }
References MB_INDEX_OUT_OF_RANGE, MB_NOT_IMPLEMENTED, MB_SET_ERR, MB_SET_GLB_ERR, MB_SUCCESS, and MB_TYPE_OUT_OF_RANGE.
Referenced by FunctionB().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 75 of file ErrorHandlingSimulation.cpp.
76 {
77 if( argc < 2 )
78 {
79 cout << "Usage: " << argv[0] << " <test_case_num(1 to 4)>" << endl;
80 return 0;
81 }
82
83 #ifdef MOAB_HAVE_MPI
84 MPI_Init( &argc, &argv );
85 #endif
86
87 // Initialize error handler, required for this example (not using a moab instance)
88 MBErrorHandler_Init();
89
90 int test_case_num = atoi( argv[1] );
91 int rank = 0;
92 #ifdef MOAB_HAVE_MPI
93 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
94 #endif
95
96 ErrorCode rval = FunctionA( test_case_num, rank );MB_CHK_ERR( rval );
97
98 // Finalize error handler, required for this example (not using a moab instance)
99 MBErrorHandler_Finalize();
100
101 #ifdef MOAB_HAVE_MPI
102 MPI_Finalize();
103 #endif
104
105 return 0;
106 }
References ErrorCode, FunctionA(), MB_CHK_ERR, moab::MBErrorHandler_Finalize(), and moab::MBErrorHandler_Init().