[cig-commits] r13586 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:15:12 PST 2008
Author: luis
Date: 2008-12-09 18:15:11 -0800 (Tue, 09 Dec 2008)
New Revision: 13586
Modified:
cs/cigma/trunk/src/core_writers.cpp
cs/cigma/trunk/src/io_hdf5_reader.cpp
cs/cigma/trunk/src/io_hdf5_reader.h
cs/cigma/trunk/src/io_hdf5_writer.cpp
cs/cigma/trunk/src/io_hdf5_writer.h
Log:
Using io_hdf5.h functions and commented out internal implementations
Modified: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp 2008-12-10 02:15:10 UTC (rev 13585)
+++ cs/cigma/trunk/src/core_writers.cpp 2008-12-10 02:15:11 UTC (rev 13586)
@@ -91,6 +91,7 @@
HDF5_Writer *hdf5_writer = static_cast<HDF5_Writer*>(&(*writer));
status = hdf5_writer->writeDataset(wts_loc.c_str(), Q->weights, Q->npts, 1);
+
if (status < 0)
{
ostringstream stream;
Modified: cs/cigma/trunk/src/io_hdf5_reader.cpp
===================================================================
--- cs/cigma/trunk/src/io_hdf5_reader.cpp 2008-12-10 02:15:10 UTC (rev 13585)
+++ cs/cigma/trunk/src/io_hdf5_reader.cpp 2008-12-10 02:15:11 UTC (rev 13586)
@@ -1,4 +1,6 @@
#include "io_hdf5_reader.h"
+#include "io_hdf5.h"
+
#include "Common.h"
#include <iostream>
@@ -25,6 +27,30 @@
TRI_LOG_STR("HDF5_Reader::open()");
TRI_LOG(filename);
+ if (file != 0)
+ {
+ return -3;
+ }
+
+ string m(mode);
+ if ((m == "r") || (m == "rw") || (m == "a"))
+ {
+ file = h5_open_file(filename, mode);
+ }
+ else
+ {
+ // invalid mode for file reader
+ return -2;
+ }
+
+ if (file == 0)
+ {
+ return -1;
+ }
+
+ return 0;
+
+ /*
H5::Exception::dontPrint();
if (file != 0) { return -2; }
@@ -62,6 +88,7 @@
if (file == 0) { return -3; }
return 0;
+ // */
}
int HDF5_Reader::close()
@@ -77,17 +104,22 @@
// ----------------------------------------------------------------------------
+/*
template <typename T> static H5::PredType predtype_from();
template <> H5::PredType predtype_from<int>() { return H5::PredType::NATIVE_INT; }
template <> H5::PredType predtype_from<long>() { return H5::PredType::NATIVE_LONG; }
template <> H5::PredType predtype_from<float>() { return H5::PredType::NATIVE_FLOAT; }
template <> H5::PredType predtype_from<double>(){ return H5::PredType::NATIVE_DOUBLE; }
+// */
+/*
template <typename T> static H5T_class_t typeclass_from();
template <> H5T_class_t typeclass_from<float>() { return H5T_FLOAT; }
template <> H5T_class_t typeclass_from<double>() { return H5T_FLOAT; }
template <> H5T_class_t typeclass_from<int>() { return H5T_INTEGER; }
+// */
+/*
template <typename MT>
static int get_full_dataset(H5::H5File *file, const char *loc, MT **data, int *nrows, int *ncols)
{
@@ -154,6 +186,7 @@
}
return 0;
}
+// */
int HDF5_Reader::getDataset(const char *loc, double **data, int *num, int *dim)
{
@@ -178,6 +211,7 @@
// ----------------------------------------------------------------------------
+/*
static H5::H5Object* load_h5obj(H5::H5File *file, const char *loc)
{
H5::H5Object* obj = 0;
@@ -207,8 +241,9 @@
}
return obj;
-}
+} // */
+/*
int HDF5_Reader::readAttrString(const char *loc, const char *attr_name, std::string& val)
{
H5::H5Object* obj = 0;
@@ -237,8 +272,9 @@
}
return 0;
-}
+} // */
+/*
template <typename T>
static int read_attribute(H5::H5File *file, const char *loc, const char *attr_name, T* val)
{
@@ -293,5 +329,32 @@
{
return read_attribute<double>(file, loc, attr_name, &val);
}
+// */
+
+int HDF5_Reader::readAttrString(const char *loc, const char *attr_name, string& val)
+{
+ return read_scalar_attribute<string>(file, loc, attr_name, val);
+}
+
+int HDF5_Reader::readAttrInteger(const char *loc, const char *attr_name, int& val)
+{
+ return read_scalar_attribute<int>(file, loc, attr_name, val);
+}
+
+int HDF5_Reader::readAttrLong(const char *loc, const char *attr_name, long& val)
+{
+ return read_scalar_attribute<long>(file, loc, attr_name, val);
+}
+
+int HDF5_Reader::readAttrFloat(const char *loc, const char *attr_name, float& val)
+{
+ return read_scalar_attribute<float>(file, loc, attr_name, val);
+}
+
+int HDF5_Reader::readAttrDouble(const char *loc, const char *attr_name, double& val)
+{
+ return read_scalar_attribute<double>(file, loc, attr_name, val);
+}
+
// ----------------------------------------------------------------------------
Modified: cs/cigma/trunk/src/io_hdf5_reader.h
===================================================================
--- cs/cigma/trunk/src/io_hdf5_reader.h 2008-12-10 02:15:10 UTC (rev 13585)
+++ cs/cigma/trunk/src/io_hdf5_reader.h 2008-12-10 02:15:11 UTC (rev 13586)
@@ -1,8 +1,8 @@
#ifndef __CIGMA_HDF5_READER_H__
#define __CIGMA_HDF5_READER_H__
+#include "io_file_reader.h"
#include "H5Cpp.h"
-#include "io_file_reader.h"
namespace cigma
{
Modified: cs/cigma/trunk/src/io_hdf5_writer.cpp
===================================================================
--- cs/cigma/trunk/src/io_hdf5_writer.cpp 2008-12-10 02:15:10 UTC (rev 13585)
+++ cs/cigma/trunk/src/io_hdf5_writer.cpp 2008-12-10 02:15:11 UTC (rev 13586)
@@ -1,4 +1,5 @@
#include "io_hdf5_writer.h"
+#include "io_hdf5.h"
#include "Common.h"
using namespace std;
@@ -23,6 +24,30 @@
TRI_LOG_STR("HDF5_Writer::open()");
TRI_LOG(filename);
+
+ if (file != 0)
+ {
+ return -3;
+ }
+
+ string m(mode);
+ if ((m == "w") || (m == "rw") || (m == "x"))
+ {
+ file = h5_open_file(filename, mode);
+ }
+ else
+ {
+ // invalid mode for file writer
+ return -2;
+ }
+
+ if (file == 0)
+ {
+ return -1;
+ }
+
+ return 0;
+ /*
H5::Exception::dontPrint();
if (file != 0) { return -2; }
@@ -60,6 +85,7 @@
if (file == 0) { return -3; }
return 0;
+ // */
}
int HDF5_Writer::close()
@@ -75,11 +101,14 @@
// ----------------------------------------------------------------------------
+/*
template <typename T> static H5::PredType predtype_from();
template <> H5::PredType predtype_from<float>() { return H5::PredType::NATIVE_FLOAT; }
template <> H5::PredType predtype_from<double>(){ return H5::PredType::NATIVE_DOUBLE; }
template <> H5::PredType predtype_from<int>() { return H5::PredType::NATIVE_INT; }
+// */
+/*
template <typename MT, typename FT>
static int write_dataset(H5::H5File *file, const char *loc, const MT *data, int nrows, int ncols)
{
@@ -107,27 +136,28 @@
}
return 0;
}
+// */
int HDF5_Writer::writeDataset(const char *loc, const double *data, int nno, int ndim)
{
TRI_LOG_STR("HDF5_Writer::writeDataset()");
TRI_LOG(loc);
- return write_dataset<double,double>(file, loc, data, nno, ndim);
+ return write_full_dataset<double,double>(file, loc, data, nno, ndim);
}
int HDF5_Writer::writeCoordinates(const char *loc, const double *coordinates, int nno, int nsd)
{
TRI_LOG_STR("HDF5_Writer::writeCoordinates()");
TRI_LOG(loc);
- return write_dataset<double,double>(file, loc, coordinates, nno, nsd);
+ return write_full_dataset<double,double>(file, loc, coordinates, nno, nsd);
}
int HDF5_Writer::writeConnectivity(const char *loc, const int *connectivity, int nel, int ndofs)
{
TRI_LOG_STR("HDF5_Writer::writeConnectivity()");
TRI_LOG(loc);
- return write_dataset<int,int>(file, loc, connectivity, nel, ndofs);
+ return write_full_dataset<int,int>(file, loc, connectivity, nel, ndofs);
}
// ----------------------------------------------------------------------------
Modified: cs/cigma/trunk/src/io_hdf5_writer.h
===================================================================
--- cs/cigma/trunk/src/io_hdf5_writer.h 2008-12-10 02:15:10 UTC (rev 13585)
+++ cs/cigma/trunk/src/io_hdf5_writer.h 2008-12-10 02:15:11 UTC (rev 13586)
@@ -1,8 +1,8 @@
#ifndef __CIGMA_HDF5_WRITER_H__
#define __CIGMA_HDF5_WRITER_H__
+#include "io_file_writer.h"
#include "H5Cpp.h"
-#include "io_file_writer.h"
namespace cigma
{
More information about the CIG-COMMITS
mailing list