Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
TestErrorHandling.cpp File Reference
#include "moab/Core.hpp"
#include <iostream>
+ Include dependency graph for TestErrorHandling.cpp:

Go to the source code of this file.

Functions

ErrorCode TestErrorHandling_1 ()
 
ErrorCode TestErrorHandling_2 ()
 
ErrorCode TestErrorHandling_3 ()
 
ErrorCode TestErrorHandling_4 ()
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
TestErrorHandling.cpp.

Definition at line 80 of file TestErrorHandling.cpp.

81 {
82  if( argc < 2 )
83  {
84  cout << "Usage: " << argv[0] << " <test_case_num(1 to 4)>" << endl;
85  return 0;
86  }
87 
88 #ifdef MOAB_HAVE_MPI
89  MPI_Init( &argc, &argv );
90 #endif
91 
92  // Initialize error handler, optional for this example (using moab instances)
94 
95  ErrorCode rval = MB_SUCCESS;
96 
97  int test_case_num = atoi( argv[1] );
98  switch( test_case_num )
99  {
100  case 1:
101  rval = TestErrorHandling_1();MB_CHK_ERR( rval );
102  break;
103  case 2:
104  rval = TestErrorHandling_2();MB_CHK_ERR( rval );
105  break;
106  case 3:
107  rval = TestErrorHandling_3();MB_CHK_ERR( rval );
108  break;
109  case 4:
110  rval = TestErrorHandling_4();MB_CHK_ERR( rval );
111  break;
112  default:
113  break;
114  }
115 
116  // Finalize error handler, optional for this example (using moab instances)
118 
119 #ifdef MOAB_HAVE_MPI
120  MPI_Finalize();
121 #endif
122 
123  return 0;
124 }

References ErrorCode, MB_CHK_ERR, MB_SUCCESS, moab::MBErrorHandler_Finalize(), moab::MBErrorHandler_Init(), TestErrorHandling_1(), TestErrorHandling_2(), TestErrorHandling_3(), and TestErrorHandling_4().

◆ TestErrorHandling_1()

ErrorCode TestErrorHandling_1 ( )
Examples
TestErrorHandling.cpp.

Definition at line 18 of file TestErrorHandling.cpp.

19 {
20  Core moab;
21  Interface& mb = moab;
22 
23  // Load a CAM-FV file and read a variable on edges (not supported yet)
24  string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" );
25  ErrorCode rval = mb.load_file( test_file.c_str(), NULL, "VARIABLE=US" );MB_CHK_ERR( rval );
26 
27  return MB_SUCCESS;
28 }

References ErrorCode, moab::Core::load_file(), mb, MB_CHK_ERR, MB_SUCCESS, and MESH_DIR.

Referenced by main().

◆ TestErrorHandling_2()

ErrorCode TestErrorHandling_2 ( )
Examples
TestErrorHandling.cpp.

Definition at line 31 of file TestErrorHandling.cpp.

32 {
33  Core moab;
34  Interface& mb = moab;
35 
36  // Load a HOMME file with an invalid GATHER_SET option
37  string test_file = string( MESH_DIR ) + string( "/io/homme3x3458.t.3.nc" );
38  ErrorCode rval = mb.load_file( test_file.c_str(), NULL, "VARIABLE=T;GATHER_SET=0.1" );MB_CHK_ERR( rval );
39 
40  return MB_SUCCESS;
41 }

References ErrorCode, moab::Core::load_file(), mb, MB_CHK_ERR, MB_SUCCESS, and MESH_DIR.

Referenced by main().

◆ TestErrorHandling_3()

ErrorCode TestErrorHandling_3 ( )
Examples
TestErrorHandling.cpp.

Definition at line 44 of file TestErrorHandling.cpp.

45 {
46  Core moab;
47  Interface& mb = moab;
48 
49  // Load a CAM-FV file with NOMESH option and a NULL file set
50  string test_file = string( MESH_DIR ) + string( "/io/fv3x46x72.t.3.nc" );
51  ErrorCode rval = mb.load_file( test_file.c_str(), NULL, "NOMESH;VARIABLE=" );MB_CHK_ERR( rval );
52 
53  return MB_SUCCESS;
54 }

References ErrorCode, moab::Core::load_file(), mb, MB_CHK_ERR, MB_SUCCESS, and MESH_DIR.

Referenced by main().

◆ TestErrorHandling_4()

ErrorCode TestErrorHandling_4 ( )
Examples
TestErrorHandling.cpp.

Definition at line 57 of file TestErrorHandling.cpp.

58 {
59  Core moab;
60  Interface& mb = moab;
61 
62  // Create 100 vertices
63  const int NUM_VTX = 100;
64  vector< double > coords( 3 * NUM_VTX );
65  Range verts;
66  ErrorCode rval = mb.create_vertices( &coords[0], NUM_VTX, verts );MB_CHK_SET_ERR( rval, "Failed to create vertices" );
67 
68  // Create a variable-length dense tag
69  Tag tag;
70  rval = mb.tag_get_handle( "var_len_den", 1, MB_TYPE_INTEGER, tag, MB_TAG_VARLEN | MB_TAG_DENSE | MB_TAG_CREAT );MB_CHK_SET_ERR( rval, "Failed to create a tag" );
71 
72  // Attempt to iterate over a variable-length tag, which will never be possible
73  void* ptr = NULL;
74  int count = 0;
75  rval = mb.tag_iterate( tag, verts.begin(), verts.end(), count, ptr );MB_CHK_SET_ERR( rval, "Failed to iterate over tag on " << NUM_VTX << " vertices" );
76 
77  return MB_SUCCESS;
78 }

References moab::Range::begin(), moab::Core::create_vertices(), moab::Range::end(), ErrorCode, mb, MB_CHK_SET_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_VARLEN, MB_TYPE_INTEGER, moab::Core::tag_get_handle(), and moab::Core::tag_iterate().

Referenced by main().