[MOAB-dev] commit/MOAB: danwu: Minor changes to WriteNC.cpp (code formatting, remove some compiler warnings). Added a new test for writing variable gw (gauss weights). Running this test shows "Writer with name NC for file testgw.nc using extension nc was unsuccessful. Using default writer WriteHDF5Parallel for file testgw.nc". Will update NC writer later to make it work on variable gw.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Apr 1 16:11:38 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/29ccf3e7ac29/
Changeset:   29ccf3e7ac29
Branch:      ncwriter
User:        danwu
Date:        2014-04-01 23:11:23
Summary:     Minor changes to WriteNC.cpp (code formatting, remove some compiler warnings). Added a new test for writing variable gw (gauss weights). Running this test shows "Writer with name NC for file testgw.nc using extension nc was unsuccessful. Using default writer WriteHDF5Parallel for file testgw.nc". Will update NC writer later to make it work on variable gw.

Affected #:  2 files

diff --git a/src/io/WriteNC.cpp b/src/io/WriteNC.cpp
index 0342da5..7db5fea 100644
--- a/src/io/WriteNC.cpp
+++ b/src/io/WriteNC.cpp
@@ -23,19 +23,19 @@
 
 namespace moab {
 
-WriterIface *WriteNC::factory( Interface* iface )
-  { return new WriteNC( iface ); }
-
-WriteNC::WriteNC(Interface *impl)
-    : mbImpl(impl), dbgOut(stderr), partMethod(ScdParData::ALLJORKORI), scdi(NULL),
+WriterIface *WriteNC::factory(Interface* iface)
+{
+  return new WriteNC(iface);
+}
 
+WriteNC::WriteNC(Interface* impl) :
+  mbImpl(impl), dbgOut(stderr), partMethod(ScdParData::ALLJORKORI), scdi(NULL),
 #ifdef USE_MPI
   myPcomm(NULL),
 #endif
-
   noMesh(false), noVars(false), /*spectralMesh(false), noMixedElements(false), noEdges(false),*/
   gatherSetRank(-1), mGlobalIdTag(0), isParallel(false),
-   myHelper(NULL)
+  myHelper(NULL)
 {
   assert(impl != NULL);
   impl->query_interface(mWriteIface);
@@ -48,18 +48,17 @@ WriteNC::~WriteNC()
     delete myHelper;
 }
 
-//! writes out a file
-ErrorCode WriteNC::write_file(const char *file_name,
-                                  const bool overwrite,
-                                  const FileOptions& options,
-                                  const EntityHandle *file_set,
-                                  const int num_set,
-                                  const std::vector<std::string>&,
-                                  const Tag*,
-                                  int,
-                                  int )
+//! Writes out a file
+ErrorCode WriteNC::write_file(const char* file_name,
+                              const bool overwrite,
+                              const FileOptions& options,
+                              const EntityHandle* file_set,
+                              const int num_set,
+                              const std::vector<std::string>&,
+                              const Tag*,
+                              int,
+                              int)
 {
-
   ErrorCode rval;
   // See if opts has variable(s) specified
   std::vector<std::string> var_names;
@@ -68,18 +67,18 @@ ErrorCode WriteNC::write_file(const char *file_name,
 
   // Get and cache predefined tag handles
   int dum_val = 0;
-  rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE , &dum_val);
+  rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE, &dum_val);
   if (MB_SUCCESS != rval)
     return rval;
 
   // num set has to be 1, we will write only one set, the original file set used to load
-  if (num_set!=1)
-    ERRORR(MB_FAILURE, "we should write only one set, the file set used to read data into");
+  if (num_set != 1)
+    ERRORR(MB_FAILURE, "We should write only one set, the file set used to read data into.");
 
   rval = parse_options(options, var_names, tstep_nums, tstep_vals);
   ERRORR(rval, "Trouble parsing option string.");
 
-  // important to create some data that will be used to write the file; dimensions, variables, etc
+  // Important to create some data that will be used to write the file; dimensions, variables, etc
   // new variables still need to have some way of defining their dimensions
   // maybe it will be passed as write options
   rval = process_conventional_tags(*file_set);
@@ -97,22 +96,21 @@ ErrorCode WriteNC::write_file(const char *file_name,
   else
     success = NCFUNC(create)(MPI_COMM_SELF, file_name, cmode, MPI_INFO_NULL, &fileId);
 #else
-    // this is regular netcdf file
-  success = NCFUNC(create)(file_name,  overwrite ? NC_CLOBBER : NC_NOCLOBBER, &fileId);
+  // This is a regular netcdf file
+  success = NCFUNC(create)(file_name, overwrite ? NC_CLOBBER : NC_NOCLOBBER, &fileId);
 #endif
-  ERRORS(success, "failed to create file");
-  //
+  ERRORS(success, "Failed to create file.");
   rval = collect_variable_data(var_names, tstep_nums, tstep_vals, *file_set);
   ERRORR(rval, "Trouble collecting data.");
 
   rval = initialize_file(var_names);
-  ERRORR(rval, "failed to initialize file.");
+  ERRORR(rval, "Failed to initialize file.");
 
-  rval = write_values( var_names, *file_set);
-  ERRORR(rval, "failed to write values ");
+  rval = write_values(var_names, *file_set);
+  ERRORR(rval, "Failed to write values.");
 
-  success =  NCFUNC(close)(fileId);
-  ERRORS(success, "failed to close file");
+  success = NCFUNC(close)(fileId);
+  ERRORS(success, "Failed to close file.");
 
   return MB_SUCCESS;
 }
@@ -171,17 +169,17 @@ ErrorCode WriteNC::parse_options(const FileOptions& opts, std::vector<std::strin
     }
   }
 
-  // the gather set will be important in parallel, this will be the rank that will accumulate the data
+  // The gather set will be important in parallel, this will be the rank that will accumulate the data
   // to be written in serial
-  // improvement will be for writing in true parallel
+  // Improvement will be for writing in true parallel
   rval = opts.get_int_option("GATHER_SET", 0, gatherSetRank);
   if (MB_TYPE_OUT_OF_RANGE == rval) {
-    mWriteIface->report_error("Invalid value for GATHER_SET option");
+    mWriteIface->report_error("Invalid value for GATHER_SET option.");
     return rval;
   }
 // FIXME: copied from readnc, may need revise
 #ifdef USE_MPI
-  isParallel = (opts.match_option("PARALLEL","READ_PART") != MB_ENTITY_NOT_FOUND);
+  isParallel = (opts.match_option("PARALLEL", "READ_PART") != MB_ENTITY_NOT_FOUND);
 
   if (!isParallel)
   // Return success here, since rval still has _NOT_FOUND from not finding option
@@ -192,7 +190,7 @@ ErrorCode WriteNC::parse_options(const FileOptions& opts, std::vector<std::strin
   int pcomm_no = 0;
   rval = opts.get_int_option("PARALLEL_COMM", pcomm_no);
   if (rval == MB_TYPE_OUT_OF_RANGE) {
-    mWriteIface->report_error("Invalid value for PARALLEL_COMM option");
+    mWriteIface->report_error("Invalid value for PARALLEL_COMM option.");
     return rval;
   }
   myPcomm = ParallelComm::get_pcomm(mbImpl, pcomm_no);
@@ -217,52 +215,49 @@ ErrorCode WriteNC::parse_options(const FileOptions& opts, std::vector<std::strin
   return MB_SUCCESS;
 }
 
-// this is the inverse process to create conventional tags
-// will look at <pargal_source>/src/core/fileinfo.cpp, init dim, vars, atts
+// This is the inverse process to create conventional tags
+// Will look at <pargal_source>/src/core/fileinfo.cpp, init dim, vars, atts
 ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
 {
   ErrorCode rval;
-  // start copy
+  // Start copy
   Tag tag = 0;
   std::string tag_name = "__DIM_NAMES";
-  const void * data = NULL;
+  const void* data = NULL;
   int num_dims = 0;
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, tag, MB_TAG_ANY);
-  ERRORR(rval, "Failed getting conventional tag __DIM_NAMES.");
+  ERRORR(rval, "Trouble getting conventional tag __DIM_NAMES.");
   rval = mbImpl->tag_get_by_ptr(tag, &fileSet, 1, &data, &num_dims);
-  ERRORR(rval, "Failed getting values for conventional tag __DIM_NAMES.");
+  ERRORR(rval, "Trouble getting values for conventional tag __DIM_NAMES.");
 
   dbgOut.tprintf(1, "dim names size: %d\n", num_dims);
 
   std::size_t start = 0;
-  const char * p = static_cast<const char *>(data);
+  const char* p = static_cast<const char*>(data);
   Tag dimValsTag = 0;
   tag_name = "__DIM_LENS";
-  const void * valdata = NULL;
+  const void* valdata = NULL;
   int num_vals = 0;
-  rval =  mbImpl->tag_get_handle(tag_name.c_str(), 0,  MB_TYPE_INTEGER,
-      dimValsTag,  MB_TAG_ANY);
-  ERRORR(rval, "Failed getting conventional tag __DIM_LENS.");
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimValsTag, MB_TAG_ANY);
+  ERRORR(rval, "Trouble getting conventional tag __DIM_LENS.");
 
   rval = mbImpl->tag_get_by_ptr(dimValsTag, &fileSet, 1, &valdata, &num_vals);
-  ERRORR(rval, "Failed getting values for conventional tag __DIM_LENS.");
+  ERRORR(rval, "Trouble getting values for conventional tag __DIM_LENS.");
 
   dbgOut.tprintf(1, "num vals in dim lens tag %d\n", num_vals);
-  const int * intp = static_cast<const int*>(valdata);
+  const int* intp = static_cast<const int*>(valdata);
   int idx = -1;
 
-  for (std::size_t i = 0; i != static_cast<std::size_t>(num_dims); ++i)
-  {
-    if (p[i] == '\0')
-    {
+  for (std::size_t i = 0; i != static_cast<std::size_t>(num_dims); i++) {
+    if (p[i] == '\0') {
       std::string dim_name(&p[start], i - start);
       ++idx;
       int sz = intp[idx];
       dimNames.push_back(dim_name);
       dimLens.push_back(sz);
       dbgOut.tprintf(2, "dimension %s has length %d\n", dim_name.c_str(), sz);
-      // fixme: need info from moab to set unlimited dimension
-      // currently assume each file has the same number of time dimensions
+      // FIXME: need info from moab to set unlimited dimension
+      // Currently assume each file has the same number of time dimensions
       /*if ((dim_name == "time") || (dim_name == "Time"))
         insert(dim_name,
             *(new pcdim(dim_name, sz * m_file_names.size(), true)));
@@ -277,24 +272,24 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
   data = NULL;
   int sz = 0;
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, tagMeshType, MB_TAG_ANY);
-  ERRORR(rval, "Failed getting conventional tag __MESH_TYPE.");
+  ERRORR(rval, "Trouble getting conventional tag __MESH_TYPE.");
   rval = mbImpl->tag_get_by_ptr(tagMeshType, &fileSet, 1, &data, &sz);
-  ERRORR(rval, "Failed getting values for conventional tag __MESH_TYPE.");
+  ERRORR(rval, "Trouble getting values for conventional tag __MESH_TYPE.");
 
   p = static_cast<const char *>(data);
   grid_type = std::string(&p[0], sz);
   dbgOut.tprintf(2, "mesh type: %s \n", grid_type.c_str());
-  // read <__VAR_NAMES_LOCATIONS> tag
+
+  // Read <__VAR_NAMES_LOCATIONS> tag
   Tag varLocTag = 0;
   tag_name = "__VAR_NAMES_LOCATIONS";
-  const void * loc_data = NULL;
+  const void* loc_data = NULL;
   int loc_sz = 0;
-  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0,
-      MB_TYPE_INTEGER, varLocTag, MB_TAG_ANY);
-  ERRORR(rval, "Failed getting conventional tag __VAR_NAMES_LOCATIONS.");
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, varLocTag, MB_TAG_ANY);
+  ERRORR(rval, "Trouble getting conventional tag __VAR_NAMES_LOCATIONS.");
   rval = mbImpl->tag_get_by_ptr(varLocTag, &fileSet, 1, &loc_data, &loc_sz);
-  ERRORR(rval, "Failed getting values for conventional tag __VAR_NAMES_LOCATIONS.");
-  const int * loc_p = static_cast<const int *>(loc_data);
+  ERRORR(rval, "Trouble getting values for conventional tag __VAR_NAMES_LOCATIONS.");
+  const int* loc_p = static_cast<const int*>(loc_data);
   std::vector<int> varLoc(loc_sz);
   std::copy(loc_p, loc_p + loc_sz, varLoc.begin());
 
@@ -319,40 +314,35 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
 
   Tag tagVarNames = 0;
   tag_name = "__VAR_NAMES";
-  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, tagVarNames,
-      MB_TAG_ANY);
-  ERRORR(rval, "Failed getting conventional tag __VAR_NAMES.");
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, tagVarNames, MB_TAG_ANY);
+  ERRORR(rval, "Trouble getting conventional tag __VAR_NAMES.");
   data = NULL;
   int num_vars = 0;
   rval = mbImpl->tag_get_by_ptr(tagVarNames, &fileSet, 1, &data, &num_vars);
-  dbgOut.tprintf(2, "var names  has %d names \n", num_vars );
-  ERRORR(rval, "Failed getting values for conventional tag __VAR_NAMES.");
-  p = static_cast<const char *>(data);
+  dbgOut.tprintf(2, "var names has %d names \n", num_vars);
+  ERRORR(rval, "Trouble getting values for conventional tag __VAR_NAMES.");
+  p = static_cast<const char*>(data);
   start = 0;
-  int idxVar=0;
-  for (std::size_t i = 0; i != static_cast<std::size_t>(num_vars); ++i)
-  {
-    if (p[i] == '\0')
-    {
+  int idxVar = 0;
+  for (std::size_t i = 0; i != static_cast<std::size_t>(num_vars); i++) {
+    if (p[i] == '\0') {
       std::string var_name(&p[start], i - start);
 
       dbgOut.tprintf(2, "var name: %s index %d \n", var_name.c_str(), idxVar);
       // process var name:
-      // this will create/initiate map; we will populate variableDataStruct wit info about dims, tags, etc
+      // This will create/initiate map; we will populate variableDataStruct wit info about dims, tags, etc
       // reference & is important; otherwise variableDataStruct will go out of scope, and deleted :(
-      VarData  & variableDataStruct = varInfo[var_name];
+      VarData& variableDataStruct = varInfo[var_name];
 
-      dbgOut.tprintf(2, "at var name %s varInfo size %d \n", var_name.c_str(), varInfo.size() );
+      dbgOut.tprintf(2, "at var name %s varInfo size %d \n", var_name.c_str(), varInfo.size());
 
       sz = 0;
       Tag dims_tag = 0;
       std::string dim_names = "__" + var_name + "_DIMS";
-      rval = mbImpl->tag_get_handle(dim_names.c_str(), 0, MB_TYPE_OPAQUE,
-          dims_tag, MB_TAG_ANY);
-      ERRORR(rval, "FAILED to get tag for a variable dimensions");
-      //fixme: doesn't handle variables have 0 dimension
-      if (rval != moab::MB_SUCCESS)
-      {
+      rval = mbImpl->tag_get_handle(dim_names.c_str(), 0, MB_TYPE_OPAQUE, dims_tag, MB_TAG_ANY);
+      ERRORR(rval, "Failed to get tag for a variable dimensions.");
+      // FIXME: doesn't handle variables have 0 dimension
+      if (MB_SUCCESS != rval) {
         start = i + 1;
         ++nthVar;
         continue;
@@ -365,26 +355,24 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
       //std::vector<const pcdim*> dims(sz, NULL);
       const void* ptr = NULL;
       rval = mbImpl->tag_get_by_ptr(dims_tag, &fileSet, 1, &ptr);
-      //
 
-      const Tag * ptags = static_cast<const moab::Tag*>(ptr);
-      for (std::size_t j = 0; j != static_cast<std::size_t>(sz); ++j)
-      {
+      const Tag* ptags = static_cast<const moab::Tag*>(ptr);
+      for (std::size_t j = 0; j != static_cast<std::size_t>(sz); j++) {
         std::string dim_name;
         rval = mbImpl->tag_get_name(ptags[j], dim_name);
-        ERRORR(rval, "name of tag for dimension");
-        dbgOut.tprintf(2, "var name: %s has %s as dimension \n", var_name.c_str(), dim_name.c_str() );
-        std::vector<std::string>::iterator vit=std::find(dimNames.begin(), dimNames.end(), dim_name);
-        if (vit==dimNames.end())
-          ERRORR(MB_FAILURE, "dimension not found\n");
-        variableDataStruct.varDims[j]= (int)(vit-dimNames.begin()) ; // will be used for writing
-        // this will have to change to actual file dimension, for writing
-
-        // do we have a variable for each dimension? I mean, a tag?
+        ERRORR(rval, "Failed to get name of tag for dimension");
+        dbgOut.tprintf(2, "var name: %s has %s as dimension \n", var_name.c_str(), dim_name.c_str());
+        std::vector<std::string>::iterator vit = std::find(dimNames.begin(), dimNames.end(), dim_name);
+        if (vit == dimNames.end())
+          ERRORR(MB_FAILURE, "Dimension not found\n");
+        variableDataStruct.varDims[j] = (int)(vit - dimNames.begin()); // Will be used for writing
+        // This will have to change to actual file dimension, for writing
+
+        // Do we have a variable for each dimension? I mean, a tag?
         //dims[j] = &(get_dim(dim_name));
       }
 
-      // attributes for this variable
+      // Attributes for this variable
       std::stringstream ssTagName;
       ssTagName << "__" << var_name << "_ATTRIBS";
       tag_name = ssTagName.str();
@@ -405,7 +393,7 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
       Tag varAttLenTag = 0;
       rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, varAttLenTag, MB_TAG_ANY);
       ERRORR(rval, "Trouble getting __<var_name>_ATTRIBS_LEN tag.");
-      int varAttLenSz=0;
+      int varAttLenSz = 0;
       rval = mbImpl->tag_get_length(varAttLenTag, varAttLenSz);
       ERRORR(rval, "Trouble getting __<var_name>_ATTRIBS_LEN length.");
       varAttLen.resize(varAttLenSz);
@@ -414,17 +402,17 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
       ERRORR(rval, "Trouble getting data for __<var_name>_ATTRIBS_LEN tag.");
 
       rval = process_concatenated_attribute(varAttPtr, varAttSz, varAttLen, variableDataStruct.varAtts);
-      ERRORR(rval, " trouble processing global attributes ");
+      ERRORR(rval, "Trouble processing global attributes.");
 
       if (MB_SUCCESS == rval)
         dbgOut.tprintf(2, "Tag metadata for variable %s\n", tag_name.c_str());
-      // end attribute
+      // End attribute
       start = i + 1;
       idxVar++;
     }
   }
 
-  // attributes
+  // Attributes
   tag_name = "__GLOBAL_ATTRIBS";
   Tag globalAttTag = 0;
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, globalAttTag, MB_TAG_SPARSE | MB_TAG_VARLEN);
@@ -433,22 +421,22 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
   std::vector<int> gattLen;
 
   const void* gattptr;
-  int globalAttSz=0;
+  int globalAttSz = 0;
   rval = mbImpl->tag_get_by_ptr(globalAttTag, &fileSet, 1, &gattptr, &globalAttSz);
   ERRORR(rval, "Trouble getting data for __GLOBAL_ATTRIBS tag.");
 
   if (MB_SUCCESS == rval)
-      dbgOut.tprintf(2, "Tag value retrieved for %s size %d\n", tag_name.c_str(), globalAttSz);
+    dbgOut.tprintf(2, "Tag value retrieved for %s size %d\n", tag_name.c_str(), globalAttSz);
 
-    // <__GLOBAL_ATTRIBS_LEN>
+  // <__GLOBAL_ATTRIBS_LEN>
   tag_name = "__GLOBAL_ATTRIBS_LEN";
   Tag globalAttLenTag = 0;
 
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, globalAttLenTag, MB_TAG_ANY);
   ERRORR(rval, "Trouble getting __GLOBAL_ATTRIBS_LEN tag.");
-  int sizeGAtt =0;
+  int sizeGAtt = 0;
   rval = mbImpl->tag_get_length(globalAttLenTag, sizeGAtt);
-  ERRORR(rval, "Trouble getting length of __GLOBAL_ATTRIBS_LEN tag ");
+  ERRORR(rval, "Trouble getting length of __GLOBAL_ATTRIBS_LEN tag.");
   gattLen.resize(sizeGAtt);
   rval = mbImpl->tag_get_data(globalAttLenTag, &fileSet, 1, &gattLen[0]);
   ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS_LEN tag.");
@@ -456,23 +444,21 @@ ErrorCode WriteNC::process_conventional_tags(EntityHandle fileSet)
     dbgOut.tprintf(2, "Tag retrieved for variable %s\n", tag_name.c_str());
 
   rval = process_concatenated_attribute(gattptr, globalAttSz, gattLen, globalAtts);
-  ERRORR(rval, " trouble processing global attributes ");
+  ERRORR(rval, "Trouble processing global attributes.");
 
   return MB_SUCCESS;
 }
+
 // reverse process from create_attrib_string
-ErrorCode WriteNC::process_concatenated_attribute(const void * gattptr, int globalAttSz, std::vector<int> & gattLen,
-      std::map<std::string, AttData> & attributes)
+ErrorCode WriteNC::process_concatenated_attribute(const void* gattptr, int globalAttSz, std::vector<int>& gattLen,
+                                                  std::map<std::string, AttData>& attributes)
 {
-
   std::size_t start = 0;
   std::size_t att_counter = 0;
-  std::string concatString( (char*)gattptr, (char*)gattptr+globalAttSz);
+  std::string concatString((char*)gattptr, (char*)gattptr + globalAttSz);
 
-  for (std::size_t i = 0; i != (size_t)globalAttSz; ++i)
-  {
-    if (concatString[i] == '\0')
-    {
+  for (std::size_t i = 0; i != (size_t)globalAttSz; i++) {
+    if (concatString[i] == '\0') {
       std::string att_name(&concatString[start], i - start);
       start = i + 1;
       while (concatString[i] != ';')
@@ -482,174 +468,166 @@ ErrorCode WriteNC::process_concatenated_attribute(const void * gattptr, int glob
       start = i;
       i = gattLen[att_counter];
       if (concatString[i] != ';')
-        ERRORR(MB_FAILURE, "Error parsing attributes ");
+        ERRORR(MB_FAILURE, "Error parsing attributes.");
 
       std::string data_val(&concatString[start], i - start);
       start = i + 1;
       AttData attrib = attributes[att_name];
       attrib.attValue = data_val;
       ++att_counter;
-      dbgOut.tprintf(2, "       Process attribute %s with value %s \n",att_name.c_str(), data_val.c_str() );
+      dbgOut.tprintf(2, "       Process attribute %s with value %s \n", att_name.c_str(), data_val.c_str());
     }
   }
 
   return MB_SUCCESS;
 }
 
-ErrorCode WriteNC::collect_variable_data( std::vector<std::string>& var_names, std::vector<int>& tstep_nums,
-     std::vector<double>& tstep_vals, EntityHandle fileSet)
+ErrorCode WriteNC::collect_variable_data(std::vector<std::string>& var_names, std::vector<int>& /* tstep_nums */,
+                                         std::vector<double>& /* tstep_vals */, EntityHandle fileSet)
 {
-  // in general, in netcdf, variables that have the same name as their only dimension are called
+  // In general, in netcdf, variables that have the same name as their only dimension are called
   // coordinate variables
-  // for the time being, check if all dimensions for variables are coordinate variables
+  // For the time being, check if all dimensions for variables are coordinate variables
   ErrorCode rval;
 
   usedCoordinates.clear();
 
-  for (size_t i=0; i<var_names.size(); i++)
-  {
-    std::string varname=var_names[i];
+  for (size_t i = 0; i < var_names.size(); i++) {
+    std::string varname = var_names[i];
     std::map<std::string, VarData>::iterator vit = varInfo.find(varname);
-    if (vit==varInfo.end())
-      ERRORR(MB_FAILURE, "can't find one variable");
-
-    size_t sizeVar = 1;// get multiplied by dim lengths
-    VarData  & currentVarData = vit->second;
-    dbgOut.tprintf(2, "    for variable %s varDims.size %d \n", varname.c_str(), (int)currentVarData.varDims.size() );
-    for (size_t j =0; j<currentVarData.varDims.size(); j++)
-    {
-      std::string dimName= dimNames[ currentVarData.varDims[j] ];
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find one variable.");
+
+    size_t sizeVar = 1; // Get multiplied by dim lengths
+    VarData& currentVarData = vit->second;
+    dbgOut.tprintf(2, "    for variable %s varDims.size %d \n", varname.c_str(), (int)currentVarData.varDims.size());
+    for (size_t j = 0; j < currentVarData.varDims.size(); j++) {
+      std::string dimName = dimNames[currentVarData.varDims[j]];
       vit = varInfo.find(dimName);
-      if (vit==varInfo.end())
-        ERRORR(MB_FAILURE, "can't find one coordinate variable");
+      if (vit == varInfo.end())
+        ERRORR(MB_FAILURE, "Can't find one coordinate variable.");
 
-      if( (dimName == "time" || dimName == "Time" || dimName == "t") &&
-          currentVarData.varDims.size()>1 ) // so it is not time itself
-        currentVarData.has_tsteps=true;
+      if ((dimName == "time" || dimName == "Time" || dimName == "t") &&
+          currentVarData.varDims.size() > 1) // So it is not time itself
+        currentVarData.has_tsteps = true;
 
-      // probably will have to look at tstep_vals to match them
+      // Probably will have to look at tstep_vals to match them
       sizeVar *= dimLens[j];
-      usedCoordinates.insert(dimName); // collect those used, we will need to write them to the file
-      dbgOut.tprintf(2, "    for variable %s need dimension %s with length %d\n", varname.c_str(), dimName.c_str(), dimLens[ currentVarData.varDims[j] ] );
+      usedCoordinates.insert(dimName); // Collect those used, we will need to write them to the file
+      dbgOut.tprintf(2, "    for variable %s need dimension %s with length %d\n", varname.c_str(), dimName.c_str(), dimLens[currentVarData.varDims[j]]);
     }
 
-    currentVarData.sz=sizeVar;
-
-    if (currentVarData.has_tsteps)
-    {
+    currentVarData.sz = sizeVar;
 
-      int index=0;
-      while(1)
-      {
+    if (currentVarData.has_tsteps) {
+      int index = 0;
+      while(true) {
         Tag indexedTag;
         std::stringstream ssTagNameWithIndex;
         ssTagNameWithIndex << varname << index;
         rval = mbImpl->tag_get_handle(ssTagNameWithIndex.str().c_str(), indexedTag);
-        if (rval!=MB_SUCCESS)
+        if (MB_SUCCESS != rval)
           break;
-        dbgOut.tprintf(2, "    found indexed tag %d with name %s\n", index,  ssTagNameWithIndex.str().c_str());
+        dbgOut.tprintf(2, "    found indexed tag %d with name %s\n", index, ssTagNameWithIndex.str().c_str());
         currentVarData.varTags.push_back(indexedTag);
-        index++; // we should get out of the loop at some point
-        // we will have to collect data for these tags; maybe even allocate memory again
+        index++; // We should get out of the loop at some point
+        // We will have to collect data for these tags; maybe even allocate memory again
 
-        // the type of the tag is fixed though
+        // The type of the tag is fixed though
         DataType type;
         rval = mbImpl->tag_get_data_type(indexedTag, type);
-        ERRORR(rval, "can't get tag type");
+        ERRORR(rval, "Can't get tag type.");
 
         currentVarData.varDataType = NC_DOUBLE;
-        if (type==MB_TYPE_INTEGER)
+        if (MB_TYPE_INTEGER == type)
           currentVarData.varDataType = NC_INT;
       }
     }
-    else
-    {
-      // get the tag with varname
-      Tag coordtag=0;
+    else {
+      // Get the tag with varname
+      Tag coordtag = 0;
       rval = mbImpl->tag_get_handle(varname.c_str(), coordtag);
-      ERRORR(rval, "can't find one tag");
-      currentVarData.varTags.push_back(coordtag); // really, only one for these
-      const void * data;
+      ERRORR(rval, "Can't find one tag.");
+      currentVarData.varTags.push_back(coordtag); // Really, only one for these
+      const void* data;
       int sizeCoordinate;
       rval = mbImpl->tag_get_by_ptr(coordtag, &fileSet, 1, &data, &sizeCoordinate);
-      ERRORR(rval, "can't get coordinate values");
-      assert(currentVarData.memoryHogs.size()==0);// nothing so far
+      ERRORR(rval, "Can't get coordinate values.");
+      assert(currentVarData.memoryHogs.size() == 0); // Nothing so far
       currentVarData.memoryHogs.push_back((void*)data);
     }
-
   }
 
-  // check that for used coordinates we have found the tags
-  for (std::set<std::string>::iterator setIt = usedCoordinates.begin(); setIt!=usedCoordinates.end(); setIt++)
-  {
-    std::string coordName=*setIt; // deep copy
+  // Check that for used coordinates we have found the tags
+  for (std::set<std::string>::iterator setIt = usedCoordinates.begin();
+      setIt != usedCoordinates.end(); setIt++) {
+    std::string coordName = *setIt; // Deep copy
 
     std::map<std::string, VarData>::iterator vit = varInfo.find(coordName);
-    if (vit==varInfo.end())
-      ERRORR(MB_FAILURE, "can't find one coordinate variable");
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find one coordinate variable.");
 
-    VarData & varCoordData = vit->second;
-    Tag coordtag=0;
+    VarData& varCoordData = vit->second;
+    Tag coordtag = 0;
     rval = mbImpl->tag_get_handle(coordName.c_str(), coordtag);
-    ERRORR(rval, "can't find one tag");
+    ERRORR(rval, "Can't find one tag.");
     varCoordData.varTags.push_back(coordtag); // really, only one for these
 
-    const void * data;
+    const void* data;
     int sizeCoordinate;
     rval = mbImpl->tag_get_by_ptr(coordtag, &fileSet, 1, &data, &sizeCoordinate);
-    ERRORR(rval, "can't get coordinate values");
+    ERRORR(rval, "Can't get coordinate values.");
     dbgOut.tprintf(2, "    found coordinate tag with name %s and length %d\n", coordName.c_str(),
         sizeCoordinate);
-    // this is the length
+    // This is the length
     varCoordData.sz = sizeCoordinate;
     varCoordData.writeStarts.resize(1);
-    varCoordData.writeStarts[0]=0;
+    varCoordData.writeStarts[0] = 0;
     varCoordData.writeCounts.resize(1);
-    varCoordData.writeCounts[0]=sizeCoordinate;
-    // find the type of tag, and use it
+    varCoordData.writeCounts[0] = sizeCoordinate;
+    // Find the type of tag, and use it
     DataType type;
     rval = mbImpl->tag_get_data_type(coordtag, type);
-    ERRORR(rval, "can't get tag type");
+    ERRORR(rval, "Can't get tag type.");
 
     varCoordData.varDataType = NC_DOUBLE;
-    if (type==MB_TYPE_INTEGER)
+    if (MB_TYPE_INTEGER == type)
       varCoordData.varDataType = NC_INT;
 
-    assert(varCoordData.memoryHogs.size()==0);// nothing so far
+    assert(varCoordData.memoryHogs.size() == 0); // Nothing so far
     varCoordData.memoryHogs.push_back((void*)data);
   }
+
   return MB_SUCCESS;
 }
 
-ErrorCode WriteNC::initialize_file( std::vector<std::string> & var_names)
+ErrorCode WriteNC::initialize_file(std::vector<std::string>& var_names)
 {
-  // first initialize all coordinates, then fill VarData for actual variables (and dimensions)
-  // check that for used coordinates we have found the tags
-  for (std::set<std::string>::iterator setIt = usedCoordinates.begin(); setIt!=usedCoordinates.end(); setIt++)
-  {
-    std::string  coordName=*setIt; // deep copy
+  // First initialize all coordinates, then fill VarData for actual variables (and dimensions)
+  // Check that for used coordinates we have found the tags
+  for (std::set<std::string>::iterator setIt = usedCoordinates.begin();
+      setIt != usedCoordinates.end(); setIt++) {
+    std::string coordName = *setIt; // Deep copy
 
     std::map<std::string, VarData>::iterator vit = varInfo.find(coordName);
-    if (vit==varInfo.end())
-      ERRORR(MB_FAILURE, "can't find one coordinate variable");
-
-    VarData & varCoordData = vit->second;
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find one coordinate variable.");
 
+    VarData& varCoordData = vit->second;
     varCoordData.varDims.resize(1);
 
     /* int nc_def_dim (int ncid, const char *name, size_t len, int *dimidp);
        * example:  status = nc_def_dim(fileId, "lat", 18L, &latid);
     */
 
-
-    // actually define a dimension
-    if (NCFUNC(def_dim)(fileId, coordName.c_str() , (size_t)varCoordData.sz ,
+    // Actually define a dimension
+    if (NCFUNC(def_dim)(fileId, coordName.c_str(), (size_t)varCoordData.sz,
         &varCoordData.varDims[0]) != NC_NOERR)
-     ERRORR(MB_FAILURE, "failed to generate dimension");
+     ERRORR(MB_FAILURE, "Failed to generate dimension.");
 
-    dbgOut.tprintf(2, "    for coordName %s dim id is %d \n", coordName.c_str(), (int)varCoordData.varDims[0] );
+    dbgOut.tprintf(2, "    for coordName %s dim id is %d \n", coordName.c_str(), (int)varCoordData.varDims[0]);
 
-    // create a variable with the same name, and its only dimension the one we just defined
+    // Create a variable with the same name, and its only dimension the one we just defined
     /*
      * int nc_def_var (int ncid, const char *name, nc_type xtype,
                        int ndims, const int dimids[], int *varidp);
@@ -658,28 +636,26 @@ ErrorCode WriteNC::initialize_file( std::vector<std::string> & var_names)
 
     if (NCFUNC(def_var)(fileId, coordName.c_str(), varCoordData.varDataType,
         1, &(varCoordData.varDims[0]), &varCoordData.varId) != NC_NOERR)
-      ERRORR(MB_FAILURE, "failed to create coordinate variable");
-
-    dbgOut.tprintf(2, "    for coordName %s variable id is %d \n", coordName.c_str(), varCoordData.varId );
+      ERRORR(MB_FAILURE, "Failed to create coordinate variable.");
 
+    dbgOut.tprintf(2, "    for coordName %s variable id is %d \n", coordName.c_str(), varCoordData.varId);
   }
-  // now look at requested variables, and update from the index in dimNames to the actual dimension id
 
-  for (size_t i=0; i<var_names.size(); i++)
-  {
+  // Now look at requested variables, and update from the index in dimNames to the actual dimension id
+  for (size_t i = 0; i < var_names.size(); i++) {
     std::map<std::string, VarData>::iterator vit = varInfo.find(var_names[i]);
-    if (vit==varInfo.end())
-      ERRORR(MB_FAILURE, "can't find variable requested");
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find variable requested.");
 
-    VarData & variableData = vit->second;
-    int numDims = (int) variableData.varDims.size();
-    // the index is for dimNames; we need to find out the actual dimension id (from above)
-    for (int j=0; j< numDims; j++)
+    VarData& variableData = vit->second;
+    int numDims = (int)variableData.varDims.size();
+    // The index is for dimNames; we need to find out the actual dimension id (from above)
+    for (int j = 0; j < numDims; j++)
     {
       std::string dimName = dimNames[variableData.varDims[j]];
       std::map<std::string, VarData>::iterator vit2 = varInfo.find(dimName);
-      if (vit2==varInfo.end())
-        ERRORR(MB_FAILURE, "can't find coordinate variable requested");
+      if (vit2 == varInfo.end())
+        ERRORR(MB_FAILURE, "Can't find coordinate variable requested.");
 
       VarData & coordData = vit2->second;
       variableData.varDims[j] = coordData.varDims[0]; // this one, being a coordinate, is the only one
@@ -689,120 +665,114 @@ ErrorCode WriteNC::initialize_file( std::vector<std::string> & var_names)
       variableData.writeStarts.push_back(0); // assume we will write all, so start at 0 for all dimensions
       variableData.writeCounts.push_back(coordData.sz); // again, write all; times will be one at a time
     }
-    // define the variable now :
+    // Define the variable now:
     if (NCFUNC(def_var)(fileId, var_names[i].c_str(), variableData.varDataType,
-            (int)variableData.varDims.size() , &(variableData.varDims[0]),
-            &variableData.varId) != NC_NOERR)
-    ERRORR(MB_FAILURE, "failed to create coordinate variable");
+        (int)variableData.varDims.size(), &(variableData.varDims[0]),
+        &variableData.varId) != NC_NOERR)
+    ERRORR(MB_FAILURE, "Failed to create coordinate variable.");
 
-    dbgOut.tprintf(2, "    for variable %s variable id is %d \n", var_names[i].c_str(), variableData.varId );
-    // now define the variable, with all dimensions
+    dbgOut.tprintf(2, "    for variable %s variable id is %d \n", var_names[i].c_str(), variableData.varId);
+    // Now define the variable, with all dimensions
   }
 
-  // take it out of define mode
+  // Take it out of define mode
   if (NC_NOERR != NCFUNC(enddef)(fileId))
-    ERRORR(MB_FAILURE, "failed to close define mode");
+    ERRORR(MB_FAILURE, "Failed to close define mode.");
 
   return MB_SUCCESS;
 }
-ErrorCode WriteNC::write_values(std::vector<std::string> & var_names, EntityHandle fileSet)
-{
 
+ErrorCode WriteNC::write_values(std::vector<std::string>& var_names, EntityHandle fileSet)
+{
   /*
   * Write an Array of Values: nc_put_vara_ type
   * int nc_put_vara_double(int ncid, int varid, const size_t start[],
                            const size_t count[], const double *dp);
   */
-  // start with coordinates
-  for (std::set<std::string>::iterator setIt = usedCoordinates.begin(); setIt!=usedCoordinates.end(); setIt++)
- {
-   std::string  coordName=*setIt; // deep copy
+  // Start with coordinates
+  for (std::set<std::string>::iterator setIt = usedCoordinates.begin();
+      setIt != usedCoordinates.end(); setIt++) {
+    std::string coordName = *setIt; // Deep copy
 
-   std::map<std::string, VarData>::iterator vit = varInfo.find(coordName);
-   if (vit==varInfo.end())
-     ERRORR(MB_FAILURE, "can't find one coordinate variable");
+    std::map<std::string, VarData>::iterator vit = varInfo.find(coordName);
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find one coordinate variable.");
 
-   VarData & varCoordData = vit->second;
+    VarData& varCoordData = vit->second;
 
-   int success =0;
-   switch (varCoordData.varDataType) {
+    int success = 0;
+    switch (varCoordData.varDataType) {
       case NC_DOUBLE:
-        success = NCFUNCAP(_vara_double)(fileId, varCoordData.varId,  &varCoordData.writeStarts[0],
-            &varCoordData.writeCounts[0], (double*) (varCoordData.memoryHogs[0])  );
+        success = NCFUNCAP(_vara_double)(fileId, varCoordData.varId, &varCoordData.writeStarts[0],
+                  &varCoordData.writeCounts[0], (double*)(varCoordData.memoryHogs[0]));
         ERRORS(success, "Failed to write double data.");
         break;
       case NC_INT:
-        success = NCFUNCAP(_vara_int)(fileId, varCoordData.varId,  &varCoordData.writeStarts[0],
-            &varCoordData.writeCounts[0], (int*) (varCoordData.memoryHogs[0]) );
+        success = NCFUNCAP(_vara_int)(fileId, varCoordData.varId, &varCoordData.writeStarts[0],
+                  &varCoordData.writeCounts[0], (int*)(varCoordData.memoryHogs[0]));
         ERRORS(success, "Failed to write int data.");
         break;
       default:
         success = 1;
         break;
-   }
-
+    }
  }
-   // now look at requested var_names; if they have time, we will have a list, and write one at a time
-  // we may also need to gather, and transpose stuff
+
+  // Now look at requested var_names; if they have time, we will have a list, and write one at a time
+  // We may also need to gather, and transpose stuff
   Range ents2d;
-  // get all entities of dimension 2 from set; assume now location is on cells;
-  // need to reorder stuff in the order from the file, also transpose from lev dimension
+  // Get all entities of dimension 2 from set; assume now location is on cells;
+  // Need to reorder stuff in the order from the file, also transpose from lev dimension
   ErrorCode rval = mbImpl->get_entities_by_dimension(fileSet, 2, ents2d);
-  ERRORR(rval, "can't get entities for 2d");
+  ERRORR(rval, "Can't get entities for 2d.");
 
-  // for each variabletag in the indexed lists, write a time step data
-  // assume the first dimension is time (need to check); if not, just write regularly
-  //
-  for (size_t i=0; i<var_names.size(); i++)
-  {
+  // For each variable tag in the indexed lists, write a time step data
+  // Assume the first dimension is time (need to check); if not, just write regularly
+  for (size_t i = 0; i < var_names.size(); i++) {
     std::map<std::string, VarData>::iterator vit = varInfo.find(var_names[i]);
-    if (vit==varInfo.end())
-      ERRORR(MB_FAILURE, "can't find variable requested");
+    if (vit == varInfo.end())
+      ERRORR(MB_FAILURE, "Can't find variable requested.");
 
     VarData & variableData = vit->second;
     int numTimeSteps = (int)variableData.varTags.size();
-    if (variableData.has_tsteps)
-    {
+    if (variableData.has_tsteps) {
       variableData.writeCounts[0] = 1; // we will write one time step
-      for(int j=0; j<numTimeSteps; j++)
-      {
-        // we will write one time step, and count will be one; start will be different
-        // we will write values directly from tag_iterate, but we should also transpose for level
-        // so that means deep copy for transpose
+      for (int j = 0; j < numTimeSteps; j++) {
+        // We will write one time step, and count will be one; start will be different
+        // We will write values directly from tag_iterate, but we should also transpose for level
+        // So that means deep copy for transpose
         // !!!!!!!!!!!!!!
         //
-        //  FIXME !!!!!!!!!!!
-        variableData.writeStarts[0] = j; // this is time, again
+        // FIXME !!!!!!!!!!!
+        variableData.writeStarts[0] = j; // This is time, again
         int count;
-        void * dataptr;
-        rval = mbImpl->tag_iterate(variableData.varTags[j], ents2d.begin(), ents2d.end(), count, dataptr );
-        assert(count == ents2d.size());
+        void* dataptr;
+        rval = mbImpl->tag_iterate(variableData.varTags[j], ents2d.begin(), ents2d.end(), count, dataptr);
+        assert(count == (int)ents2d.size());
 
-        // now write from memory directly   FIXME: we need to transpose and gather for multiple processors
+        // Now write from memory directly
+        // FIXME: we need to transpose and gather for multiple processors
         int success = 0;
-        switch (variableData.varDataType)
-        {
-        case NC_DOUBLE:
-          success = NCFUNCAP(_vara_double)(fileId, variableData.varId,
-              &variableData.writeStarts[0], &variableData.writeCounts[0],
-              (double*) (dataptr));
-          ERRORS(success, "Failed to write double data.");
-          break;
-        case NC_INT:
-          success =NCFUNCAP(_vara_int)(fileId, variableData.varId,
-              &variableData.writeStarts[0], &variableData.writeCounts[0],
-              (int*) (dataptr));
-          ERRORS(success, "Failed to write int data.");
-          break;
-        default:
-          success = 1;
-          break;
+        switch (variableData.varDataType) {
+          case NC_DOUBLE:
+            success = NCFUNCAP(_vara_double)(fileId, variableData.varId,
+                      &variableData.writeStarts[0], &variableData.writeCounts[0],
+                      (double*)(dataptr));
+            ERRORS(success, "Failed to write double data.");
+            break;
+          case NC_INT:
+            success = NCFUNCAP(_vara_int)(fileId, variableData.varId,
+                      &variableData.writeStarts[0], &variableData.writeCounts[0],
+                      (int*)(dataptr));
+            ERRORS(success, "Failed to write int data.");
+            break;
+          default:
+            success = 1;
+            break;
         }
-
       }
     }
-    else
-    {
+    else {
       // FIXME
     }
   }
@@ -810,4 +780,4 @@ ErrorCode WriteNC::write_values(std::vector<std::string> & var_names, EntityHand
   return MB_SUCCESS;
 }
 
-} // end moab namespace
+} // namespace moab

diff --git a/test/io/write_nc.cpp b/test/io/write_nc.cpp
index 713f886..1a17ee9 100644
--- a/test/io/write_nc.cpp
+++ b/test/io/write_nc.cpp
@@ -15,7 +15,8 @@ static const char example_eul[] = "/io/camEul26x48x96.t3.nc";
 #endif
 
 // CAM-EUL
-void test_read_write_one_var();
+void test_read_write_T();
+void test_read_write_gw();
 
 ErrorCode get_options(std::string& opts);
 
@@ -31,7 +32,8 @@ int main(int argc, char* argv[])
   argv[0] = argv[argc - argc]; // To remove the warnings in serial mode about unused variables
 #endif
 
-  result += RUN_TEST(test_read_write_one_var);
+  result += RUN_TEST(test_read_write_T);
+  result += RUN_TEST(test_read_write_gw);
 
 #ifdef USE_MPI
   fail = MPI_Finalize();
@@ -42,7 +44,7 @@ int main(int argc, char* argv[])
   return result;
 }
 
-void test_read_write_one_var()
+void test_read_write_T()
 {
   Core moab;
   Interface& mb = moab;
@@ -51,13 +53,13 @@ void test_read_write_one_var()
   ErrorCode rval = get_options(orig);
   CHECK_ERR(rval);
 
-  // we will have to read without mesh and without var first, to create some tags that we need
+  // We will have to read without mesh and without var first, to create some tags that we need
   // later when we write
   std::string opts;
   opts = orig + std::string(";DEBUG_IO=3;NOMESH;VARIABLE=");
 
   // Need a set for nomesh to work right
-  // this set will have as tags a lot of header information, that will be used for writing back the file
+  // This set will have as tags a lot of header information, that will be used for writing back the file
   EntityHandle set;
   rval = mb.create_meshset(MESHSET_SET, set);
   CHECK_ERR(rval);
@@ -65,18 +67,53 @@ void test_read_write_one_var()
   rval = mb.load_file(example_eul, &set, opts.c_str());
   CHECK_ERR(rval);
 
-  // load one variable, and the mesh
+  // Load variable T, and the mesh
   opts= orig + std::string(";DEBUG_IO=3;VARIABLE=T");
   rval = mb.load_file(example_eul, &set, opts.c_str());
   CHECK_ERR(rval);
 
-  // first test will write information about one variable
+  // This test will write information about variable T
   std::string writeopts;
   writeopts = std::string(";;VARIABLE=T;DEBUG_IO=2;");
   rval = mb.write_file( "testT.nc", 0, writeopts.c_str(), &set, 1);
   CHECK_ERR(rval);
 }
 
+void test_read_write_gw()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  std::string orig;
+  ErrorCode rval = get_options(orig);
+  CHECK_ERR(rval);
+
+  // We will have to read without mesh and without var first, to create some tags that we need
+  // later when we write
+  std::string opts;
+  opts = orig + std::string(";DEBUG_IO=3;NOMESH;VARIABLE=");
+
+  // Need a set for nomesh to work right
+  // This set will have as tags a lot of header information, that will be used for writing back the file
+  EntityHandle set;
+  rval = mb.create_meshset(MESHSET_SET, set);
+  CHECK_ERR(rval);
+
+  rval = mb.load_file(example_eul, &set, opts.c_str());
+  CHECK_ERR(rval);
+
+  // Load variable gw (gauss weights), and the mesh
+  opts= orig + std::string(";DEBUG_IO=3;VARIABLE=gw");
+  rval = mb.load_file(example_eul, &set, opts.c_str());
+  CHECK_ERR(rval);
+
+  // First test will write information about variable gw
+  std::string writeopts;
+  writeopts = std::string(";;VARIABLE=gw;DEBUG_IO=2;");
+  rval = mb.write_file( "testgw.nc", 0, writeopts.c_str(), &set, 1);
+  CHECK_ERR(rval);
+}
+
 ErrorCode get_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