[MOAB-dev] commit/MOAB: danwu: Minor updates for unit test write_nc.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Apr 30 17:48:16 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/54bc99a5bafa/
Changeset:   54bc99a5bafa
Branch:      master
User:        danwu
Date:        2014-05-01 00:47:53
Summary:     Minor updates for unit test write_nc.

Affected #:  1 file

diff --git a/test/io/write_nc.cpp b/test/io/write_nc.cpp
index 2dc8e9a..3332d4b 100644
--- a/test/io/write_nc.cpp
+++ b/test/io/write_nc.cpp
@@ -36,7 +36,6 @@ static const char example_mpas[] = "/io/mpasx1.642.t.2.nc";
 // CAM-EUL
 void test_eul_read_write_T();
 void test_eul_check_T();
-void test_eul_read_write_append();
 
 // CAM-FV
 void test_fv_read_write_T();
@@ -50,6 +49,16 @@ void test_homme_check_T();
 void test_mpas_read_write_vars();
 void test_mpas_check_vars();
 
+// Test append option
+void test_eul_read_write_append();
+void test_eul_check_append();
+
+#ifdef USE_MPI
+// Test mesh with ghosted entities
+void test_eul_read_write_ghosting();
+void test_eul_check_ghosting();
+#endif
+
 void get_eul_read_options(std::string& opts);
 void get_fv_read_options(std::string& opts);
 void get_homme_read_options(std::string& opts);
@@ -69,14 +78,24 @@ int main(int argc, char* argv[])
 
   result += RUN_TEST(test_eul_read_write_T);
   result += RUN_TEST(test_eul_check_T);
-  result += RUN_TEST(test_eul_read_write_append);
+
   result += RUN_TEST(test_fv_read_write_T);
   result += RUN_TEST(test_fv_check_T);
+
   result += RUN_TEST(test_homme_read_write_T);
   result += RUN_TEST(test_homme_check_T);
+
   result += RUN_TEST(test_mpas_read_write_vars);
   result += RUN_TEST(test_mpas_check_vars);
 
+  result += RUN_TEST(test_eul_read_write_append);
+  result += RUN_TEST(test_eul_check_append);
+
+#ifdef USE_MPI
+  result += RUN_TEST(test_eul_read_write_ghosting);
+  result += RUN_TEST(test_eul_check_ghosting);
+#endif
+
 #ifdef USE_MPI
   fail = MPI_Finalize();
   if (fail)
@@ -111,19 +130,10 @@ void test_eul_read_write_T()
   ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
   CHECK_ERR(rval);
 
-#ifdef USE_MPI
-  read_opts = "PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=2.0.1;PARTITION_METHOD=SQIJ;VARIABLE=";
-  rval = mb.load_file(example_eul, &set, read_opts.c_str());
-  CHECK_ERR(rval);
-
-  read_opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=SQIJ;VARIABLE=T,gw;NOMESH";
-  rval = mb.load_file(example_eul, &set, read_opts.c_str());
-  CHECK_ERR(rval);
-#else
+  // Load non-set variable T, set variable gw, and the mesh
   read_opts += ";DEBUG_IO=0;VARIABLE=T,gw";
   rval = mb.load_file(example_eul, &set, read_opts.c_str());
   CHECK_ERR(rval);
-#endif
 
   // Write variables T and gw
   std::string write_opts;
@@ -246,75 +256,6 @@ void test_eul_check_T()
   }
 }
 
-// We read and write variables T and U; U after we write T, so we append
-// we will also write gw, just to test the file after writing
-void test_eul_read_write_append()
-{
-  int procs = 1;
-#ifdef USE_MPI
-  MPI_Comm_size(MPI_COMM_WORLD, &procs);
-#endif
-
-// We will not test NC writer in parallel without pnetcdf support
-#ifndef PNETCDF_FILE
-  if (procs > 1)
-    return;
-#endif
-
-  Core moab;
-  Interface& mb = moab;
-
-  std::string read_opts;
-  get_eul_read_options(read_opts);
-
-  EntityHandle set;
-  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
-  CHECK_ERR(rval);
-
-  // Load non-set variable T, set variable gw, and the mesh
-  read_opts += ";DEBUG_IO=0;VARIABLE=T,U,V,gw";
-  rval = mb.load_file(example_eul, &set, read_opts.c_str());
-  CHECK_ERR(rval);
-
-  // Write variables T and gw
-  std::string write_opts;
-  write_opts = std::string(";;VARIABLE=T,gw;DEBUG_IO=0");
-#ifdef USE_MPI
-  // Use parallel options
-  write_opts += std::string(";PARALLEL=WRITE_PART");
-#endif
-  if (procs > 1)
-    rval = mb.write_file("test_par_eul_TU.nc", 0, write_opts.c_str(), &set, 1);
-  else
-    rval = mb.write_file("test_eul_TU.nc", 0, write_opts.c_str(), &set, 1);
-  CHECK_ERR(rval);
-  // append to the file variable U
-  std::string write_opts2;
-  write_opts2 = std::string(";;VARIABLE=U;DEBUG_IO=0;APPEND");
-#ifdef USE_MPI
-  // Use parallel options
-  write_opts2 += std::string(";PARALLEL=WRITE_PART");
-#endif
-  if (procs > 1)
-    rval = mb.write_file("test_par_eul_TU.nc", 0, write_opts2.c_str(), &set, 1);
-  else
-    rval = mb.write_file("test_eul_TU.nc", 0, write_opts2.c_str(), &set, 1);
-  CHECK_ERR(rval);
-
-  // append to the file variable V, renamed to VNEWNAME
-  std::string write_opts3;
-  write_opts3 = std::string(";;VARIABLE=V;RENAME=VNEWNAME;DEBUG_IO=0;APPEND");
-#ifdef USE_MPI
-  // Use parallel options
-  write_opts3 += std::string(";PARALLEL=WRITE_PART");
-#endif
-  if (procs > 1)
-    rval = mb.write_file("test_par_eul_TU.nc", 0, write_opts3.c_str(), &set, 1);
-  else
-    rval = mb.write_file("test_eul_TU.nc", 0, write_opts3.c_str(), &set, 1);
-  CHECK_ERR(rval);
-}
-
 // We also write coordinate variables slat and slon to the output file, so that
 // it can be recognized by NC reader later in test_fv_check_T()
 void test_fv_read_write_T()
@@ -715,6 +656,125 @@ void test_mpas_check_vars()
   }
 }
 
+// We read and write variables T and U; U after we write T, so we append
+// we will also write gw, just to test the file after writing
+void test_eul_read_write_append()
+{
+  int procs = 1;
+#ifdef USE_MPI
+  MPI_Comm_size(MPI_COMM_WORLD, &procs);
+#endif
+
+// We will not test NC writer in parallel without pnetcdf support
+#ifndef PNETCDF_FILE
+  if (procs > 1)
+    return;
+#endif
+
+  Core moab;
+  Interface& mb = moab;
+
+  std::string read_opts;
+  get_eul_read_options(read_opts);
+
+  EntityHandle set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  CHECK_ERR(rval);
+
+  // Load non-set variables T, U, V, and the mesh
+  read_opts += ";DEBUG_IO=0;VARIABLE=T,U,V";
+  rval = mb.load_file(example_eul, &set, read_opts.c_str());
+  CHECK_ERR(rval);
+
+  // Write variable T
+  std::string write_opts;
+  write_opts = std::string(";;VARIABLE=T;DEBUG_IO=0");
+#ifdef USE_MPI
+  // Use parallel options
+  write_opts += std::string(";PARALLEL=WRITE_PART");
+#endif
+  if (procs > 1)
+    rval = mb.write_file("test_par_eul_append.nc", 0, write_opts.c_str(), &set, 1);
+  else
+    rval = mb.write_file("test_eul_append.nc", 0, write_opts.c_str(), &set, 1);
+  CHECK_ERR(rval);
+
+  // Append to the file variable U
+  std::string write_opts2;
+  write_opts2 = std::string(";;VARIABLE=U;DEBUG_IO=0;APPEND");
+#ifdef USE_MPI
+  // Use parallel options
+  write_opts2 += std::string(";PARALLEL=WRITE_PART");
+#endif
+  if (procs > 1)
+    rval = mb.write_file("test_par_eul_append.nc", 0, write_opts2.c_str(), &set, 1);
+  else
+    rval = mb.write_file("test_eul_append.nc", 0, write_opts2.c_str(), &set, 1);
+  CHECK_ERR(rval);
+
+  // Append to the file variable V, renamed to VNEWNAME
+  std::string write_opts3;
+  write_opts3 = std::string(";;VARIABLE=V;RENAME=VNEWNAME;DEBUG_IO=0;APPEND");
+#ifdef USE_MPI
+  // Use parallel options
+  write_opts3 += std::string(";PARALLEL=WRITE_PART");
+#endif
+  if (procs > 1)
+    rval = mb.write_file("test_par_eul_append.nc", 0, write_opts3.c_str(), &set, 1);
+  else
+    rval = mb.write_file("test_eul_append.nc", 0, write_opts3.c_str(), &set, 1);
+  CHECK_ERR(rval);
+}
+
+void test_eul_check_append()
+{
+  // TBD
+}
+
+#ifdef USE_MPI
+// NC writer should filter entities that are not owned, e.g. ghosted elements
+void test_eul_read_write_ghosting()
+{
+  int procs = 1;
+  MPI_Comm_size(MPI_COMM_WORLD, &procs);
+
+// We will not test NC writer in parallel without pnetcdf support
+#ifndef PNETCDF_FILE
+  if (procs > 1)
+    return;
+#endif
+
+  Core moab;
+  Interface& mb = moab;
+
+  EntityHandle set;
+  ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+  CHECK_ERR(rval);
+
+  std::string read_opts = "PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=2.0.1;PARTITION_METHOD=SQIJ;VARIABLE=";
+  rval = mb.load_file(example_eul, &set, read_opts.c_str());
+  CHECK_ERR(rval);
+
+  read_opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=SQIJ;VARIABLE=T;NOMESH";
+  rval = mb.load_file(example_eul, &set, read_opts.c_str());
+  CHECK_ERR(rval);
+
+  // Write variable T
+  std::string write_opts;
+  write_opts = std::string(";;PARALLEL=WRITE_PART;VARIABLE=T;DEBUG_IO=0");
+  if (procs > 1)
+    rval = mb.write_file("test_par_eul_ghosting.nc", 0, write_opts.c_str(), &set, 1);
+  else
+    rval = mb.write_file("test_eul_ghosting.nc", 0, write_opts.c_str(), &set, 1);
+  CHECK_ERR(rval);
+}
+
+void test_eul_check_ghosting()
+{
+  // TBD
+}
+#endif
+
 void get_eul_read_options(std::string& opts)
 {
 #ifdef USE_MPI

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