Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
TestErrorHandlingPar.cpp
Go to the documentation of this file.
00001 /** @example TestErrorHandlingPar.cpp \n
00002  * Description: This example tests MOAB's trace back error handler in parallel.\n
00003  *
00004  * <b>To run</b>: mpiexec -np <n> ./TestErrorHandlingPar <test_case_num(1 to 2)> \n
00005  */
00006 
00007 #include "moab/Core.hpp"
00008 #ifdef MOAB_HAVE_MPI
00009 #include "moab_mpi.h"
00010 #endif
00011 
00012 #include <iostream>
00013 
00014 using namespace moab;
00015 using namespace std;
00016 
00017 // In this test case, a global fatal error MB_NOT_IMPLEMENTED is returned by MOAB
00018 // Note, it is printed by root processor 0 only
00019 ErrorCode TestErrorHandlingPar_1()
00020 {
00021     Core moab;
00022     Interface& mb = moab;
00023 
00024     string opts = ";;";
00025 #ifdef MOAB_HAVE_MPI
00026     // Use parallel options
00027     opts += "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ";
00028 #endif
00029 
00030     // Load a CAM-FV file and read a variable on edges (not supported yet)
00031     string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" );
00032     opts += ";VARIABLE=US";
00033     ErrorCode rval = mb.load_file( test_file.c_str(), NULL, opts.c_str() );MB_CHK_ERR( rval );
00034 
00035     return MB_SUCCESS;
00036 }
00037 
00038 // In this test case, a per-processor relevant error MB_FAILURE is returned by MOAB
00039 // Note, it is printed by all processors
00040 ErrorCode TestErrorHandlingPar_2()
00041 {
00042     Core moab;
00043     Interface& mb = moab;
00044 
00045     string opts = ";;";
00046 #ifdef MOAB_HAVE_MPI
00047     // Use parallel options
00048     opts += "PARALLEL=READ_PART;PARTITION_METHOD=UNKNOWN";
00049 #endif
00050 
00051     // Load a CAM-FV file with an unknown partition method specified
00052     string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" );
00053     opts += ";VARIABLE=T";
00054     ErrorCode rval = mb.load_file( test_file.c_str(), NULL, opts.c_str() );MB_CHK_ERR( rval );
00055 
00056     return MB_SUCCESS;
00057 }
00058 
00059 int main( int argc, char** argv )
00060 {
00061     if( argc < 2 )
00062     {
00063         cout << "Usage: " << argv[0] << " <test_case_num(1 to 2>" << endl;
00064         return 0;
00065     }
00066 
00067 #ifdef MOAB_HAVE_MPI
00068     MPI_Init( &argc, &argv );
00069 #endif
00070 
00071     // Initialize error handler, optional for this example (using moab instances)
00072     MBErrorHandler_Init();
00073 
00074     ErrorCode rval = MB_SUCCESS;
00075 
00076     int test_case_num = atoi( argv[1] );
00077     switch( test_case_num )
00078     {
00079         case 1:
00080             rval = TestErrorHandlingPar_1();MB_CHK_ERR( rval );
00081             break;
00082         case 2:
00083             rval = TestErrorHandlingPar_2();MB_CHK_ERR( rval );
00084             break;
00085         default:
00086             break;
00087     }
00088 
00089     // Finalize error handler, optional for this example (using moab instances)
00090     MBErrorHandler_Finalize();
00091 
00092 #ifdef MOAB_HAVE_MPI
00093     MPI_Finalize();
00094 #endif
00095 
00096     return 0;
00097 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines