Go to the documentation of this file. 1
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
18 ErrorCode TestErrorHandling_1()
19 {
20 Core moab;
21 Interface& mb = moab;
22
23
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 }
29
30
31 ErrorCode TestErrorHandling_2()
32 {
33 Core moab;
34 Interface& mb = moab;
35
36
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 }
42
43
44 ErrorCode TestErrorHandling_3()
45 {
46 Core moab;
47 Interface& mb = moab;
48
49
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 }
55
56
57 ErrorCode TestErrorHandling_4()
58 {
59 Core moab;
60 Interface& mb = moab;
61
62
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
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
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 }
79
80 int main( int argc, char** argv )
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
93 MBErrorHandler_Init();
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
117 MBErrorHandler_Finalize();
118
119 #ifdef MOAB_HAVE_MPI
120 MPI_Finalize();
121 #endif
122
123 return 0;
124 }