[MOAB-dev] r3924 - in MOAB/trunk/src/io/mhdf: example src

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed May 19 17:10:33 CDT 2010


Author: kraftche
Date: 2010-05-19 17:10:33 -0500 (Wed, 19 May 2010)
New Revision: 3924

Modified:
   MOAB/trunk/src/io/mhdf/example/info.c
   MOAB/trunk/src/io/mhdf/src/file-desc.c
Log:
fix bugs reading dense-formatted tag data

Modified: MOAB/trunk/src/io/mhdf/example/info.c
===================================================================
--- MOAB/trunk/src/io/mhdf/example/info.c	2010-05-19 20:43:07 UTC (rev 3923)
+++ MOAB/trunk/src/io/mhdf/example/info.c	2010-05-19 22:10:33 UTC (rev 3924)
@@ -202,6 +202,17 @@
   return buffer;
 }
 
+static const char* ent_desc_name( struct mhdf_FileDesc* all, int index )
+{
+  static const char nodes[] = "Nodes";
+  static const char sets[] = "Sets";
+  static const char invalid[] = "<INVALID INDEX!>";
+  if (index == -2) return sets;
+  if (index == -1) return nodes;
+  if (index >= all->num_elem_desc || index < -2) return invalid;
+  return all->elems[index].handle;
+}
+
 static void print_tag_desc( struct mhdf_TagDesc* data, struct mhdf_FileDesc* all )
 {
   int i, width = 8;
@@ -222,12 +233,12 @@
   if (data->have_sparse) {
     printf( "      %-*s: (sparse)", width, "tables" );
     for (i = 0; i < data->num_dense_indices; ++i)
-      printf( ", %s", all->elems[data->dense_elem_indices[i]].handle );
+      printf( ", %s", ent_desc_name( all, data->dense_elem_indices[i] ) );
   }
   else if (data->num_dense_indices) {
-    printf( "      %-*s: %s", width, "tables", all->elems[data->dense_elem_indices[0]].handle );
+    printf( "      %-*s: %s", width, "tables", ent_desc_name( all, data->dense_elem_indices[0] ) );
     for (i = 1; i < data->num_dense_indices; ++i)
-      printf( ", %s", all->elems[data->dense_elem_indices[i]].handle );
+      printf( ", %s", ent_desc_name( all, data->dense_elem_indices[i] ) );
   }
   else {
     printf( "      %-*s: (none)", width, "tables" );

Modified: MOAB/trunk/src/io/mhdf/src/file-desc.c
===================================================================
--- MOAB/trunk/src/io/mhdf/src/file-desc.c	2010-05-19 20:43:07 UTC (rev 3923)
+++ MOAB/trunk/src/io/mhdf/src/file-desc.c	2010-05-19 22:10:33 UTC (rev 3924)
@@ -214,7 +214,7 @@
     return NULL;
   }
   
-  /* For variable lengt tags, have_default and have_global will
+  /* For variable length tags, have_default and have_global will
      contain the size of the respective values.  For fixed-length
      tags, they are either zero or one.  Simplify later code by


More information about the moab-dev mailing list