[MOAB-dev] commit/MOAB: danwu: Added more NCWrite helper classes. NC writer will use them later.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Apr 9 17:31:18 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/6d1af8d08343/
Changeset:   6d1af8d08343
Branch:      ncwriter
User:        danwu
Date:        2014-04-10 00:30:47
Summary:     Added more NCWrite helper classes. NC writer will use them later.

Affected #:  10 files

diff --git a/src/io/Makefile.am b/src/io/Makefile.am
index 232de85..1269523 100644
--- a/src/io/Makefile.am
+++ b/src/io/Makefile.am
@@ -15,16 +15,19 @@ AM_CPPFLAGS += -DIS_BUILDING_MB \
 if NETCDF_FILE
   MOAB_NETCDF_SRCS = ReadNCDF.cpp  ReadNCDF.hpp \
                      WriteNCDF.cpp WriteNCDF.hpp \
-                     WriteNC.cpp WriteNC.hpp \
-                     NCWriteHelper.cpp NCWriteHelper.hpp \
-                     NCWriteEuler.cpp NCWriteEuler.hpp \
                      WriteSLAC.cpp WriteSLAC.hpp \
                      ReadNC.cpp ReadNC.hpp \
+                     WriteNC.cpp WriteNC.hpp \
                      NCHelper.cpp NCHelper.hpp \
                      NCHelperEuler.cpp NCHelperEuler.hpp \
                      NCHelperFV.cpp NCHelperFV.hpp \
                      NCHelperHOMME.cpp NCHelperHOMME.hpp \
                      NCHelperMPAS.cpp NCHelperMPAS.hpp \
+                     NCWriteHelper.cpp NCWriteHelper.hpp \
+                     NCWriteEuler.cpp NCWriteEuler.hpp \
+                     NCWriteFV.cpp NCWriteFV.hpp \
+                     NCWriteHOMME.cpp NCWriteHOMME.hpp \
+                     NCWriteMPAS.cpp NCWriteMPAS.hpp \
                      ReadGCRM.cpp ReadGCRM.hpp
 else
   MOAB_NETCDF_SRCS =
@@ -33,11 +36,17 @@ endif
 if PNETCDF_FILE
 if !NETCDF_FILE
      MOAB_NETCDF_SRCS += ReadNC.cpp ReadNC.hpp \
+                     WriteNC.cpp WriteNC.hpp \
                      NCHelper.cpp NCHelper.hpp \
                      NCHelperEuler.cpp NCHelperEuler.hpp \
                      NCHelperFV.cpp NCHelperFV.hpp \
                      NCHelperHOMME.cpp NCHelperHOMME.hpp \
                      NCHelperMPAS.cpp NCHelperMPAS.hpp \
+                     NCWriteHelper.cpp NCWriteHelper.hpp \
+                     NCWriteEuler.cpp NCWriteEuler.hpp \
+                     NCWriteFV.cpp NCWriteFV.hpp \
+                     NCWriteHOMME.cpp NCWriteHOMME.hpp \
+                     NCWriteMPAS.cpp NCWriteMPAS.hpp \
                      ReadGCRM.cpp ReadGCRM.hpp
 endif
 endif

diff --git a/src/io/NCWriteFV.cpp b/src/io/NCWriteFV.cpp
new file mode 100644
index 0000000..a5df58d
--- /dev/null
+++ b/src/io/NCWriteFV.cpp
@@ -0,0 +1,16 @@
+/*
+ * NCWriteFV.cpp
+ *
+ *  Created on: April 9, 2014
+ */
+
+#include "NCWriteFV.hpp"
+
+namespace moab {
+
+NCWriteFV::~NCWriteFV()
+{
+  // TODO Auto-generated destructor stub
+}
+
+} /* namespace moab */

diff --git a/src/io/NCWriteFV.hpp b/src/io/NCWriteFV.hpp
new file mode 100644
index 0000000..5ecb49d
--- /dev/null
+++ b/src/io/NCWriteFV.hpp
@@ -0,0 +1,26 @@
+/*
+ * NCWriteFV.hpp
+ *
+ *  nc write helper for FV type data (CAM)
+ *  Created on: April 9, 2014
+ *
+ */
+
+#ifndef NCWRITEFV_HPP_
+#define NCWRITEFV_HPP_
+
+#include "NCWriteHelper.hpp"
+
+namespace moab {
+
+class NCWriteFV: public NCWriteHelper
+{
+public:
+  NCWriteFV(WriteNC* writeNC,  const FileOptions& opts, EntityHandle fileSet) :
+    NCWriteHelper(writeNC, opts, fileSet) {};
+
+  virtual ~NCWriteFV();
+};
+
+} /* namespace moab */
+#endif /* NCWRITEFV_HPP_ */

diff --git a/src/io/NCWriteHOMME.cpp b/src/io/NCWriteHOMME.cpp
new file mode 100644
index 0000000..3b6b1fc
--- /dev/null
+++ b/src/io/NCWriteHOMME.cpp
@@ -0,0 +1,16 @@
+/*
+ * NCWriteHOMME.cpp
+ *
+ *  Created on: April 9, 2014
+ */
+
+#include "NCWriteHOMME.hpp"
+
+namespace moab {
+
+NCWriteHOMME::~NCWriteHOMME()
+{
+  // TODO Auto-generated destructor stub
+}
+
+} /* namespace moab */

diff --git a/src/io/NCWriteHOMME.hpp b/src/io/NCWriteHOMME.hpp
new file mode 100644
index 0000000..e8abd64
--- /dev/null
+++ b/src/io/NCWriteHOMME.hpp
@@ -0,0 +1,26 @@
+/*
+ * NCWriteHOMME.hpp
+ *
+ *  nc write helper for HOMME type data (CAM)
+ *  Created on: April 9, 2014
+ *
+ */
+
+#ifndef NCWRITEHOMME_HPP_
+#define NCWRITEHOMME_HPP_
+
+#include "NCWriteHelper.hpp"
+
+namespace moab {
+
+class NCWriteHOMME: public NCWriteHelper
+{
+public:
+  NCWriteHOMME(WriteNC* writeNC,  const FileOptions& opts, EntityHandle fileSet) :
+    NCWriteHelper(writeNC, opts, fileSet) {};
+
+  virtual ~NCWriteHOMME();
+};
+
+} /* namespace moab */
+#endif /* NCWRITEHOMME_HPP_ */

diff --git a/src/io/NCWriteHelper.cpp b/src/io/NCWriteHelper.cpp
index 37817d8..bb9cce6 100644
--- a/src/io/NCWriteHelper.cpp
+++ b/src/io/NCWriteHelper.cpp
@@ -7,15 +7,27 @@
 
 #include "NCWriteHelper.hpp"
 #include "NCWriteEuler.hpp"
+#include "NCWriteFV.hpp"
+#include "NCWriteHOMME.hpp"
+#include "NCWriteMPAS.hpp"
 
 namespace moab {
 
 //! Get appropriate helper instance for WriteNC class; based on some info in the file set
 NCWriteHelper* NCWriteHelper::get_nc_helper(WriteNC* writeNC, const FileOptions& opts, EntityHandle fileSet)
 {
+  std::string& grid_type = writeNC->grid_type;
+  if (grid_type == "CAM_EUL")
+    return new (std::nothrow) NCWriteEuler(writeNC, opts, fileSet);
+  else if (grid_type == "CAM_FV")
+    return new (std::nothrow) NCWriteFV(writeNC, opts, fileSet);
+  else if (grid_type == "CAM_SE")
+    return new (std::nothrow) NCWriteHOMME(writeNC, opts, fileSet);
+  else if (grid_type == "MPAS")
+    return new (std::nothrow) NCWriteMPAS(writeNC, opts, fileSet);
 
-  // right now, get a cam euler helper
-  return new (std::nothrow) NCWriteEuler(writeNC, opts, fileSet);
+  // Unknown NetCDF grid
+  return NULL;
 }
 
 

diff --git a/src/io/NCWriteHelper.hpp b/src/io/NCWriteHelper.hpp
index 54ce967..c88eb22 100644
--- a/src/io/NCWriteHelper.hpp
+++ b/src/io/NCWriteHelper.hpp
@@ -20,8 +20,8 @@ public:
     nTimeSteps(0), nLevels(1), tDim(-1), levDim(-1) {}
   virtual ~NCWriteHelper() {};
 
-  //! Get appropriate helper instance for WriteNC class; based on some info in the
-  static NCWriteHelper* get_nc_helper(WriteNC* readNC, const FileOptions& opts, EntityHandle fileSet);
+  //! Get appropriate helper instance for WriteNC class; based on some info in the file set
+  static NCWriteHelper* get_nc_helper(WriteNC* writeNC, const FileOptions& opts, EntityHandle fileSet);
 
   //! process NC conventional tags
   ErrorCode process_conventional_tags(EntityHandle fileSet);

diff --git a/src/io/NCWriteMPAS.cpp b/src/io/NCWriteMPAS.cpp
new file mode 100644
index 0000000..4c102a6
--- /dev/null
+++ b/src/io/NCWriteMPAS.cpp
@@ -0,0 +1,16 @@
+/*
+ * NCWriteMPAS.cpp
+ *
+ *  Created on: April 9, 2014
+ */
+
+#include "NCWriteMPAS.hpp"
+
+namespace moab {
+
+NCWriteMPAS::~NCWriteMPAS()
+{
+  // TODO Auto-generated destructor stub
+}
+
+} /* namespace moab */

diff --git a/src/io/NCWriteMPAS.hpp b/src/io/NCWriteMPAS.hpp
new file mode 100644
index 0000000..d7d941b
--- /dev/null
+++ b/src/io/NCWriteMPAS.hpp
@@ -0,0 +1,26 @@
+/*
+ * NCWriteMPAS.hpp
+ *
+ *  nc write helper for MPAS type data (CAM)
+ *  Created on: April 9, 2014
+ *
+ */
+
+#ifndef NCWRITEMPAS_HPP_
+#define NCWRITEMPAS_HPP_
+
+#include "NCWriteHelper.hpp"
+
+namespace moab {
+
+class NCWriteMPAS: public NCWriteHelper
+{
+public:
+  NCWriteMPAS(WriteNC* writeNC,  const FileOptions& opts, EntityHandle fileSet) :
+    NCWriteHelper(writeNC, opts, fileSet) {};
+
+  virtual ~NCWriteMPAS();
+};
+
+} /* namespace moab */
+#endif /* NCWRITEMPAS_HPP_ */

diff --git a/src/io/WriteNC.cpp b/src/io/WriteNC.cpp
index 5dd7691..cecc162 100644
--- a/src/io/WriteNC.cpp
+++ b/src/io/WriteNC.cpp
@@ -101,6 +101,15 @@ ErrorCode WriteNC::write_file(const char* file_name,
 #endif
   ERRORS(success, "Failed to create file.");
 
+  if (NULL != myHelper)
+    delete myHelper;
+
+  // Get appropriate helper instance for WriteNC class based on some info in the file set
+  myHelper = NCWriteHelper::get_nc_helper(this, options, *file_set);
+  if (NULL == myHelper) {
+    ERRORR(MB_FAILURE, "Failed to get NCWriteHelper class instance.");
+  }
+
   rval = collect_variable_data(var_names, tstep_nums, tstep_vals, *file_set);
   ERRORR(rval, "Trouble collecting data.");

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