Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestErrorHandlingPar.cpp
Go to the documentation of this file.
1 /** @example TestErrorHandlingPar.cpp \n 2  * Description: This example tests MOAB's trace back error handler in parallel.\n 3  * 4  * <b>To run</b>: mpiexec -np <n> ./TestErrorHandlingPar <test_case_num(1 to 2)> \n 5  */ 6  7 #include "moab/Core.hpp" 8 #ifdef MOAB_HAVE_MPI 9 #include "moab_mpi.h" 10 #endif 11  12 #include <iostream> 13  14 using namespace moab; 15 using namespace std; 16  17 // In this test case, a global fatal error MB_NOT_IMPLEMENTED is returned by MOAB 18 // Note, it is printed by root processor 0 only 19 ErrorCode TestErrorHandlingPar_1() 20 { 21  Core moab; 22  Interface& mb = moab; 23  24  string opts = ";;"; 25 #ifdef MOAB_HAVE_MPI 26  // Use parallel options 27  opts += "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ"; 28 #endif 29  30  // Load a CAM-FV file and read a variable on edges (not supported yet) 31  string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" ); 32  opts += ";VARIABLE=US"; 33  ErrorCode rval = mb.load_file( test_file.c_str(), NULL, opts.c_str() );MB_CHK_ERR( rval ); 34  35  return MB_SUCCESS; 36 } 37  38 // In this test case, a per-processor relevant error MB_FAILURE is returned by MOAB 39 // Note, it is printed by all processors 40 ErrorCode TestErrorHandlingPar_2() 41 { 42  Core moab; 43  Interface& mb = moab; 44  45  string opts = ";;"; 46 #ifdef MOAB_HAVE_MPI 47  // Use parallel options 48  opts += "PARALLEL=READ_PART;PARTITION_METHOD=UNKNOWN"; 49 #endif 50  51  // Load a CAM-FV file with an unknown partition method specified 52  string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" ); 53  opts += ";VARIABLE=T"; 54  ErrorCode rval = mb.load_file( test_file.c_str(), NULL, opts.c_str() );MB_CHK_ERR( rval ); 55  56  return MB_SUCCESS; 57 } 58  59 int main( int argc, char** argv ) 60 { 61  if( argc < 2 ) 62  { 63  cout << "Usage: " << argv[0] << " <test_case_num(1 to 2>" << endl; 64  return 0; 65  } 66  67 #ifdef MOAB_HAVE_MPI 68  MPI_Init( &argc, &argv ); 69 #endif 70  71  // Initialize error handler, optional for this example (using moab instances) 72  MBErrorHandler_Init(); 73  74  ErrorCode rval = MB_SUCCESS; 75  76  int test_case_num = atoi( argv[1] ); 77  switch( test_case_num ) 78  { 79  case 1: 80  rval = TestErrorHandlingPar_1();MB_CHK_ERR( rval ); 81  break; 82  case 2: 83  rval = TestErrorHandlingPar_2();MB_CHK_ERR( rval ); 84  break; 85  default: 86  break; 87  } 88  89  // Finalize error handler, optional for this example (using moab instances) 90  MBErrorHandler_Finalize(); 91  92 #ifdef MOAB_HAVE_MPI 93  MPI_Finalize(); 94 #endif 95  96  return 0; 97 }