[MOAB-dev] r3921 - in MOAB/trunk/src/io: . mhdf/src

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed May 19 13:05:38 CDT 2010


Author: kraftche
Date: 2010-05-19 13:05:37 -0500 (Wed, 19 May 2010)
New Revision: 3921

Modified:
   MOAB/trunk/src/io/WriteHDF5.cpp
   MOAB/trunk/src/io/WriteHDF5.hpp
   MOAB/trunk/src/io/mhdf/src/tags.c
Log:
clean up type handling for tag data in WriteHDF5 in preperation for enabling of writing of tag data in dense format

Modified: MOAB/trunk/src/io/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/src/io/WriteHDF5.cpp	2010-05-19 16:10:26 UTC (rev 3920)
+++ MOAB/trunk/src/io/WriteHDF5.cpp	2010-05-19 18:05:37 UTC (rev 3921)
@@ -574,11 +574,7 @@
     // Write tags
   for (t_itor = tagList.begin(); t_itor != tagList.end(); ++t_itor)
     if (t_itor->write) {
-      int size;
-      if (MB_VARIABLE_DATA_LENGTH == iFace->tag_get_size( t_itor->tag_id, size ))
-        result = write_var_len_tag( *t_itor );
-      else
-        result = write_sparse_tag( *t_itor );
+      result = write_tag( *t_itor );
       if (MB_SUCCESS != result)
         return error(result);
     }
@@ -1754,6 +1750,36 @@
 
 */
 
+ErrorCode WriteHDF5::write_tag( const SparseTag& tag_data )
+{
+  std::string name;
+  ErrorCode rval = iFace->tag_get_name( tag_data.tag_id, name );
+  if (MB_SUCCESS != rval)
+    return error(rval);
+
+  int moab_size, elem_size, array_len;
+  DataType moab_type;
+  mhdf_TagDataType mhdf_type;
+  hid_t hdf5_type;
+  rval = get_tag_size( tag_data.tag_id, moab_type, moab_size, elem_size,
+                       array_len, mhdf_type, hdf5_type );
+  if (MB_SUCCESS != rval)
+    return error(rval);
+
+  if (array_len == MB_VARIABLE_LENGTH) 
+    rval = write_var_len_tag( tag_data, name, moab_type, hdf5_type, elem_size );
+  else {
+    int data_len = elem_size;
+    if (moab_type != MB_TYPE_BIT)
+      data_len *= array_len;
+    if (tag_data.write)
+      rval = write_sparse_tag( tag_data, name, moab_type, hdf5_type, data_len );
+  }
+ 
+  H5Tclose( hdf5_type );
+  return MB_SUCCESS == rval ? MB_SUCCESS : error(rval);
+}
+


More information about the moab-dev mailing list