[MOAB-dev] r5367 - MOAB/trunk/src/io

xbxu at mcs.anl.gov xbxu at mcs.anl.gov
Wed Feb 1 11:28:14 CST 2012


Author: xbxu
Date: 2012-02-01 11:28:14 -0600 (Wed, 01 Feb 2012)
New Revision: 5367

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
   MOAB/trunk/src/io/ReadNC.hpp
Log:
create tags for global and all variables' attribute read from netcdf file

Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-02-01 17:20:12 UTC (rev 5366)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-02-01 17:28:14 UTC (rev 5367)
@@ -179,10 +179,6 @@
     if (MB_FAILURE == rval) return rval;
   }
   
-    // close the file
-  success = NCFUNC(close)(fileId);
-  ERRORS(success, "Trouble closing file.");
-
 #ifdef USE_MPI
     // create partition set, and populate with elements
   if (isParallel) {
@@ -215,6 +211,10 @@
     ERRORR(rval, "Trouble creating nc conventional tags.");
   }
 
+    // close the file
+  success = NCFUNC(close)(fileId);
+  ERRORS(success, "Trouble closing file.");
+
   return MB_SUCCESS;
 }
 
@@ -1513,8 +1513,135 @@
   rval = mbImpl->tag_set_data(part_tag, &file_set, 1, &partMethod);
   ERRORR(rval, "Trouble setting data for PARTITION_METHOD tag.");
   if (MB_SUCCESS == rval) dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());    
+
+  // <__GLOBAL_ATTRIBS>
+  tag_name = "__GLOBAL_ATTRIBS";
+  Tag globalAttTag = 0;
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, globalAttTag, MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_VARLEN);
+  ERRORR(rval, "Trouble creating __GLOBAL_ATTRIBS tag.");
+  std::string gattVal;
+  std::vector<int> gattLen;
+  rval = create_attrib_string(globalAtts, gattVal, gattLen);
+  ERRORR(rval, "Trouble creating attribute strings.");
+  const void* gattptr = gattVal.c_str();
+  int globalAttSz = gattVal.size();
+  rval = mbImpl->tag_set_by_ptr(globalAttTag, &file_set, 1, &gattptr, &globalAttSz);
+  ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS tag.");
+  if (MB_SUCCESS == rval) dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());    
   
+  // <__GLOBAL_ATTRIBS_LEN>
+  tag_name ="__GLOBAL_ATTRIBS_LEN";
+  Tag globalAttLenTag = 0;
+  if (gattLen.size() == 0)
+    gattLen.push_back(0);


More information about the moab-dev mailing list