[MOAB-dev] commit/MOAB: danwu: Applied error handling code to ReadNC::parse_options(). Updated TestErrorHandling example to test loading a HOMME file with an invalid value for GATHER_SET option, and updated TestErrorHandlingPar example to test loading a CAM-FV file with an unknown partition method specified.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Mar 7 14:54:11 CST 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/04fdb8158106/
Changeset:   04fdb8158106
Branch:      error_handling_enhancement
User:        danwu
Date:        2014-03-07 21:53:49
Summary:     Applied error handling code to ReadNC::parse_options(). Updated TestErrorHandling example to test loading a HOMME file with an invalid value for GATHER_SET option, and updated TestErrorHandlingPar example to test loading a CAM-FV file with an unknown partition method specified.

Affected #:  3 files

diff --git a/examples/TestErrorHandling.cpp b/examples/TestErrorHandling.cpp
index f160ab8..7ae140a 100644
--- a/examples/TestErrorHandling.cpp
+++ b/examples/TestErrorHandling.cpp
@@ -51,9 +51,22 @@ ErrorCode TestErrorHandling_3()
   return MB_SUCCESS;
 }
 
+// In this test case, an error MB_TYPE_OUT_OF_RANGE is returned by MOAB
+ErrorCode TestErrorHandling_4()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  // Load a HOMME file with an invalid value for GATHER_SET option
+  string test_file = string(MESH_DIR) + string("/io/homme26x3458.t.3.nc");
+  ErrorCode rval = mb.load_file(test_file.c_str(), NULL, "VARIABLE=T;GATHER_SET=0.1");CHK_ERR(rval);
+
+  return MB_SUCCESS;
+}
+
 int main(int argc, char** argv)
 {
-  // The required arg is a test case number (1, 2 or 3)
+  // The required arg is a test case number (1 to 4)
   if (argc < 2) {
     cout << "Usage: " << argv[0] << " <test_case_num>" << endl;
     return 0;
@@ -77,6 +90,9 @@ int main(int argc, char** argv)
   else if (3 == test_case_num) {
     rval = TestErrorHandling_3();CHK_ERR(rval);
   }
+  else if (4 == test_case_num) {
+    rval = TestErrorHandling_4();CHK_ERR(rval);
+  }
 
   MBErrorHandler_Finalize();
 

diff --git a/examples/TestErrorHandlingPar.cpp b/examples/TestErrorHandlingPar.cpp
index 0e3a6c2..27f8a4b 100644
--- a/examples/TestErrorHandlingPar.cpp
+++ b/examples/TestErrorHandlingPar.cpp
@@ -72,9 +72,29 @@ ErrorCode TestErrorHandlingPar_3()
   return MB_SUCCESS;
 }
 
+// In this test case, an error MB_FAILURE is returned by MOAB
+ErrorCode TestErrorHandlingPar_4()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  std::string opts = ";;";
+#ifdef USE_MPI
+  // Use parallel options
+  opts += "PARALLEL=READ_PART;PARTITION_METHOD=UNKNOWN";
+#endif
+
+  // Load a CAM-FV file with an unknown partition method specified
+  string test_file = string(MESH_DIR) + string("/io/fv26x46x72.t.3.nc");
+  opts += ";VARIABLE=T";
+  ErrorCode rval = mb.load_file(test_file.c_str(), NULL, opts.c_str());CHK_ERR(rval);
+
+  return MB_SUCCESS;
+}
+
 int main(int argc, char** argv)
 {
-  // The required arg is a test case number (1, 2 or 3)
+  // The required arg is a test case number (1 to 4)
   if (argc < 2) {
     cout << "Usage: " << argv[0] << " <test_case_num>" << endl;
     return 0;
@@ -98,6 +118,9 @@ int main(int argc, char** argv)
   else if (3 == test_case_num) {
     rval = TestErrorHandlingPar_3();CHK_ERR(rval);
   }
+  else if (4 == test_case_num) {
+    rval = TestErrorHandlingPar_4();CHK_ERR(rval);
+  }
 
   MBErrorHandler_Finalize();
 

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 38cafd2..bc60243 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -245,7 +245,7 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
   rval = opts.get_int_option("GATHER_SET", 0, gatherSetRank);
   if (MB_TYPE_OUT_OF_RANGE == rval) {
     readMeshIface->report_error("Invalid value for GATHER_SET option");
-    return rval;
+    SET_ERR(rval, "Invalid value for GATHER_SET option");
   }
 
 #ifdef USE_MPI
@@ -261,7 +261,7 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
   rval = opts.get_int_option("PARALLEL_COMM", pcomm_no);
   if (rval == MB_TYPE_OUT_OF_RANGE) {
     readMeshIface->report_error("Invalid value for PARALLEL_COMM option");
-    return rval;
+    SET_ERR(rval, "Invalid value for PARALLEL_COMM option");
   }
   myPcomm = ParallelComm::get_pcomm(mbImpl, pcomm_no);
   if (0 == myPcomm) {
@@ -274,7 +274,7 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
   rval = opts.match_option("PARTITION_METHOD", ScdParData::PartitionMethodNames, dum);
   if (rval == MB_FAILURE) {
     readMeshIface->report_error("Unknown partition method specified.");
-    partMethod = ScdParData::ALLJORKORI;
+    SET_ERR(rval, "Unknown partition method specified");
   }
   else if (rval == MB_ENTITY_NOT_FOUND)
     partMethod = ScdParData::ALLJORKORI;

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list