[cig-commits] r13725 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Dec 17 02:32:15 PST 2008


Author: luis
Date: 2008-12-17 02:32:15 -0800 (Wed, 17 Dec 2008)
New Revision: 13725

Modified:
   cs/cigma/trunk/src/io_hdf5.cpp
   cs/cigma/trunk/src/io_hdf5.h
Log:
Use h5_open_dataset() instead of file->openDataSet(), and add more logging

Modified: cs/cigma/trunk/src/io_hdf5.cpp
===================================================================
--- cs/cigma/trunk/src/io_hdf5.cpp	2008-12-17 10:32:14 UTC (rev 13724)
+++ cs/cigma/trunk/src/io_hdf5.cpp	2008-12-17 10:32:15 UTC (rev 13725)
@@ -166,7 +166,7 @@
     }
     catch (H5::FileIException error)
     {
-        error.printError();
+        std::cout << "Error: " << error.getCDetailMsg() << " (in " << error.getCFuncName() << ")" <<  std::endl;
     }
 
     return file;
@@ -189,6 +189,7 @@
         }
         catch (H5::Exception error)
         {
+            //std::cout << "Error: " << error.getCDetailMsg() << " (in " << error.getCFuncName() << ")" <<  std::endl;
         }
     }
 
@@ -212,6 +213,7 @@
         }
         catch (H5::Exception error)
         {
+            std::cout << "Error: " << error.getCDetailMsg() << " (in " << error.getCFuncName() << ")" <<  std::endl;
         }
     }
 
@@ -253,7 +255,7 @@
         }
         catch (H5::Exception error)
         {
-            //error.printError();
+            //std::cout << "Error: " << error.getCDetailMsg() << " (in " << error.getCFuncName() << ")" <<  std::endl;
         }
     }
 

Modified: cs/cigma/trunk/src/io_hdf5.h
===================================================================
--- cs/cigma/trunk/src/io_hdf5.h	2008-12-17 10:32:14 UTC (rev 13724)
+++ cs/cigma/trunk/src/io_hdf5.h	2008-12-17 10:32:15 UTC (rev 13725)
@@ -75,6 +75,8 @@
 template <typename MT>
 int get_full_dataset(H5::H5File *file, const char *loc, MT **data, int *nrows, int *ncols)
 {
+    TRI_LOG_STR("get_full_dataset<MT>()");
+
     if (file == 0)
     {
         return -1;
@@ -82,22 +84,28 @@
 
     try
     {
-        H5::DataSet dataset = file->openDataSet(loc);
+        //H5::DataSet dataset = file->openDataSet(loc);
+        H5::DataSet* dataset = h5_open_dataset(file, loc);
+        if (dataset == 0)
+        {
+            return -2;
+        }
 
-        H5T_class_t type_class = dataset.getTypeClass();
+        H5T_class_t type_class = dataset->getTypeClass();
+        TRI_LOG(type_class);
         if (type_class != h5_typeclass_from<MT>())
         {
             std::cerr << "Dataset type mismatch in read operation." << std::endl;
-            return -2;
+            return -3;
         }
 
-        H5::DataSpace dataspace = dataset.getSpace();
-
+        H5::DataSpace dataspace = dataset->getSpace();
         int rank = dataspace.getSimpleExtentNdims();
+        TRI_LOG(rank);
         if ((rank != 1) && (rank != 2))
         {
             std::cerr << "Dataset rank must be 1 or 2." << std::endl;
-            return -3;
+            return -4;
         }
 
         hsize_t dims[2];
@@ -105,23 +113,28 @@
         int size = dataspace.getSimpleExtentNpoints();
         MT *array = 0;
 
+        TRI_LOG(ndims);
+        TRI_LOG(size);
+
         try
         {
             array = new MT[size];
-            dataset.read(array, h5_datatype_from<MT>());
+            dataset->read(array, h5_datatype_from<MT>());
         }
         catch (H5::DataSetIException error)
         {
             std::cerr << "Dataset '" << loc << "' could not be read." << std::endl;
-            delete array;
+            if (array) { delete array; }
             array = 0;
         }
 
         if (array == 0)
         {
-            return -1;
+            return -5;
         }
 
+        if (dataset) { delete dataset; }
+
         *nrows = dims[0];
         *ncols = dims[1];
         *data  = array;
@@ -129,17 +142,17 @@
     catch (H5::DataSetIException error)
     {
         error.printError();
-        return -1;
+        return -5;
     }
     catch (H5::DataSpaceIException error)
     {
         error.printError();
-        return -1;
+        return -6;
     }
     catch (H5::Exception error)
     {
-        //error.printError();
-        return -1;
+        error.printError();
+        return -7;
     }
     return 0;
 }



More information about the CIG-COMMITS mailing list