[cig-commits] [commit] master: Handle compilation without HDF5 (ff53918)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 8 17:06:28 PDT 2014


Repository : https://github.com/geodynamics/vc

On branch  : master
Link       : https://github.com/geodynamics/vc/compare/23464fca3efa2b6ad7ee0ce8f60c225b18b49741...e4325192ad1118379f46ba66899cb98143d09e04

>---------------------------------------------------------------

commit ff5391890dff57fc7493901bdaba2c963c71480c
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Fri Oct 3 16:33:12 2014 -0700

    Handle compilation without HDF5


>---------------------------------------------------------------

ff5391890dff57fc7493901bdaba2c963c71480c
 quakelib/src/QuakeLibIO.cpp |  6 ++++
 quakelib/src/QuakeLibIO.h   | 74 +++++++++++++++++++++++----------------------
 src/io/EventOutput.cpp      |  6 +++-
 3 files changed, 49 insertions(+), 37 deletions(-)

diff --git a/quakelib/src/QuakeLibIO.cpp b/quakelib/src/QuakeLibIO.cpp
index 6ba1ca2..d070f31 100644
--- a/quakelib/src/QuakeLibIO.cpp
+++ b/quakelib/src/QuakeLibIO.cpp
@@ -2403,6 +2403,7 @@ void quakelib::ModelSweeps::write_ascii_header(std::ostream &out_stream) {
     out_stream << "\n";
 }
 
+#ifdef HDF5_FOUND
 void quakelib::ModelSweeps::setup_sweeps_hdf5(const hid_t &data_file) {
     std::vector<FieldDesc>  descs;
     size_t                  num_fields;
@@ -2522,6 +2523,7 @@ void quakelib::ModelSweeps::append_sweeps_hdf5(const hid_t &data_file) const {
     delete field_offsets;
     delete field_sizes;
 }
+#endif
 
 void quakelib::ModelEvent::get_field_descs(std::vector<FieldDesc> &descs) {
     FieldDesc       field_desc;
@@ -2637,6 +2639,7 @@ void quakelib::ModelEvent::write_ascii_header(std::ostream &out_stream) {
     out_stream << "\n";
 }
 
+#ifdef HDF5_FOUND
 void quakelib::ModelEvent::setup_event_hdf5(const hid_t &data_file) {
     std::vector<FieldDesc>  descs;
     size_t                  num_fields;
@@ -2747,6 +2750,7 @@ void quakelib::ModelEvent::append_event_hdf5(const hid_t &data_file) const {
     delete field_offsets;
     delete field_sizes;
 }
+#endif
 
 int quakelib::ModelEventSet::read_file_ascii(const std::string &event_file_name, const std::string &sweep_file_name) {
     std::ifstream   event_file, sweep_file;
@@ -2754,10 +2758,12 @@ int quakelib::ModelEventSet::read_file_ascii(const std::string &event_file_name,
 
     // Try to open the event file
     event_file.open(event_file_name.c_str());
+
     if (!event_file.is_open()) return -1;
 
     // Try to open the sweeps file
     sweep_file.open(sweep_file_name.c_str());
+
     if (!sweep_file.is_open()) return -1;
 
     // Keep going until we hit the end of either file
diff --git a/quakelib/src/QuakeLibIO.h b/quakelib/src/QuakeLibIO.h
index 886583f..d17fff9 100644
--- a/quakelib/src/QuakeLibIO.h
+++ b/quakelib/src/QuakeLibIO.h
@@ -689,14 +689,14 @@ namespace quakelib {
             };
 
 #ifdef HDF5_FOUND
-        static std::string hdf5_table_name(void) {
-            return "sweeps";
-        };
+            static std::string hdf5_table_name(void) {
+                return "sweeps";
+            };
+            static void setup_sweeps_hdf5(const hid_t &data_file);
+            void append_sweeps_hdf5(const hid_t &data_file) const;
 #endif
             static void get_field_descs(std::vector<FieldDesc> &descs);
             static void write_ascii_header(std::ostream &out_stream);
-            static void setup_sweeps_hdf5(const hid_t &data_file);
-            void append_sweeps_hdf5(const hid_t &data_file) const;
 
             void read_data(const SweepData &in_data);
             void write_data(SweepData &out_data) const;
@@ -913,11 +913,11 @@ namespace quakelib {
             static std::string hdf5_table_name(void) {
                 return "events";
             };
+            static void setup_event_hdf5(const hid_t &data_file);
+            void append_event_hdf5(const hid_t &data_file) const;
 #endif
             static void get_field_descs(std::vector<FieldDesc> &descs);
             static void write_ascii_header(std::ostream &out_stream);
-            static void setup_event_hdf5(const hid_t &data_file);
-            void append_event_hdf5(const hid_t &data_file) const;
 
             void read_data(const EventData &in_data);
             void write_data(EventData &out_data) const;
@@ -929,35 +929,37 @@ namespace quakelib {
     };
 
     class ModelEventSet {
-    private:
-        std::vector<ModelEvent>     _events;
-        
-    public:
-        typedef std::vector<ModelEvent>::iterator       iterator;
-        typedef std::vector<ModelEvent>::const_iterator const_iterator;
-        
-        iterator begin(void) {
-            return _events.begin();
-        };
-        iterator end(void) {
-            return _events.end();
-        };
-        
-        unsigned int size(void) const {
-            return _events.size();
-        }
-        
-        ModelEvent &operator[](const unsigned int ind) throw(std::out_of_range) {
-            if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
-            return _events[ind];
-        };
-        
-        const ModelEvent &operator[](const unsigned int ind) const throw(std::out_of_range) {
-            if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
-            return _events[ind];
-        };
-        
-        int read_file_ascii(const std::string &event_file_name, const std::string &sweep_file_name);
+        private:
+            std::vector<ModelEvent>     _events;
+
+        public:
+            typedef std::vector<ModelEvent>::iterator       iterator;
+            typedef std::vector<ModelEvent>::const_iterator const_iterator;
+
+            iterator begin(void) {
+                return _events.begin();
+            };
+            iterator end(void) {
+                return _events.end();
+            };
+
+            unsigned int size(void) const {
+                return _events.size();
+            }
+
+            ModelEvent &operator[](const unsigned int ind) throw(std::out_of_range) {
+                if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
+
+                return _events[ind];
+            };
+
+            const ModelEvent &operator[](const unsigned int ind) const throw(std::out_of_range) {
+                if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
+
+                return _events[ind];
+            };
+
+            int read_file_ascii(const std::string &event_file_name, const std::string &sweep_file_name);
     };
 }
 
diff --git a/src/io/EventOutput.cpp b/src/io/EventOutput.cpp
index 04a9b1b..fcdb824 100644
--- a/src/io/EventOutput.cpp
+++ b/src/io/EventOutput.cpp
@@ -89,6 +89,7 @@ void EventOutput::open_hdf5_file(const std::string &hdf5_file_name, const double
 
     // Close the handles we've used
     res = H5Dclose(sim_years_set);
+
     if (res < 0) exit(-1);
 
     H5Pclose(plist_id);
@@ -100,7 +101,6 @@ void EventOutput::init(SimFramework *_sim) {
     BlockList::const_iterator   it;
 
     sweep_count = 0;
-    data_file = 0;
     next_pause_check = sim->itersPerSecond();
 
     // Only the root node writes to the output file
@@ -139,6 +139,7 @@ SimRequest EventOutput::run(SimFramework *_sim) {
     unsigned int num_sweeps = sim->getCurrentEvent().getSweeps().size();
     sim->getCurrentEvent().setStartEndSweep(sweep_count, sweep_count+num_sweeps);
     sweep_count += num_sweeps;
+
     if (sim->getEventOutfileType() == "hdf5") {
 #ifdef HDF5_FOUND
         sim->getCurrentEvent().append_event_hdf5(data_file);
@@ -187,11 +188,14 @@ void EventOutput::finish(SimFramework *_sim) {
     VCSimulation        *sim = static_cast<VCSimulation *>(_sim);
 
 #ifdef HDF5_FOUND
+
     if (data_file) {
         herr_t      res;
         res = H5Fclose(data_file);
+
         if (res < 0) exit(-1);
     }
+
 #endif
 
     if (sim->getEventOutfileType() == "text") {



More information about the CIG-COMMITS mailing list