QMCPACK
HDFVersion.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_HDFWALKERVERSION_H
15 #define QMCPLUSPLUS_HDFWALKERVERSION_H
16 
17 #include <config.h>
18 #include "hdf_dataproxy.h"
19 #include "hdf_pete.h"
20 #include "hdf_stl.h"
21 
22 namespace qmcplusplus
23 {
24 namespace hdf
25 {
26 /// extension of a configuration file
27 const char config_ext[] = ".config.h5";
28 
29 //1st level
30 const char version[] = "version";
31 const char main_state[] = "state_0";
32 const char config_group[] = "config_collection";
33 
34 //2nd level for main_state
35 const char random[] = "random_state";
36 const char walkers[] = "walkers";
37 const char num_walkers[] = "number_of_walkers";
38 const char walker_weights[] = "walker_weights";
39 const char energy_history[] = "energy_history";
40 const char norm_history[] = "norm_history";
41 const char qmc_status[] = "qmc_status";
42 
43 //2nd level for config_group
44 const char num_blocks[] = "NumOfConfigurations";
45 const char append_walkers[] = "config_";
46 
47 //unused
48 const char coord[] = "coord";
49 } // namespace hdf
50 
51 struct HDFVersion
52 {
53  //enumeration to get version value
54  enum
55  {
56  MAJOR = 0,
58  };
61 
62  inline HDFVersion() : version(QMCPACK_VERSION_MAJOR, QMCPACK_VERSION_MINOR) {}
63 
64  inline explicit HDFVersion(int m, int n) : version(m, n) {}
65 
66  inline int operator[](int i) const { return version[i]; }
67 
68  inline int& operator[](int i) { return version[i]; }
69 
70  //could be general to D
71  inline bool operator==(const HDFVersion& other) const
72  {
73  return (version[0] == other.version[0] && version[1] == other.version[1]);
74  }
75 
76  inline bool operator!=(const HDFVersion& other) const
77  {
78  return (version[0] != other.version[0] || version[1] != other.version[1]);
79  }
80 
81  ///limited to 100 for each version field
82  inline int serialized() const { return version[0] * 100 + version[1]; }
83 
84  inline bool operator>=(const HDFVersion& other) const { return serialized() >= other.serialized(); }
85 
86  inline bool operator<(const HDFVersion& other) const { return serialized() < other.serialized(); }
87 
88  inline bool read(data_type& ref, hid_t grp, const std::string& aname, hid_t xfer_plist = H5P_DEFAULT)
89  {
91  return vin.read(version, grp, aname, xfer_plist);
92  }
93 
94  inline bool write(const data_type& ref, hid_t grp, const std::string& aname, hid_t xfer_plist = H5P_DEFAULT)
95  {
97  return vout.write(version, grp, aname, xfer_plist);
98  }
99 };
100 
101 inline std::ostream& operator<<(std::ostream& out, const HDFVersion& v)
102 {
103  out << v[0] << " " << v[1];
104  return out;
105 }
106 
107 inline std::istream& operator>>(std::istream& is, HDFVersion& v)
108 {
109  is >> v[0] >> v[1];
110  return is;
111 }
112 
113 /** specialize h5data_proxy for HDFVersion */
114 template<>
116 {
118 
119  inline bool read(HDFVersion& ref, hid_t grp, const std::string& aname, hid_t xfer_plist = H5P_DEFAULT)
120  {
122  return vin.read(ref.version, grp, aname, xfer_plist);
123  }
124 
125  inline bool write(const HDFVersion& ref, hid_t grp, const std::string& aname, hid_t xfer_plist = H5P_DEFAULT) const
126  {
128  return vout.write(ref.version, grp, aname, xfer_plist);
129  }
130 };
131 
132 } // namespace qmcplusplus
133 #endif
bool operator!=(const HDFVersion &other) const
Definition: HDFVersion.h:76
bool operator<(const HDFVersion &other) const
Definition: HDFVersion.h:86
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
bool write(const HDFVersion &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT) const
Definition: HDFVersion.h:125
const char norm_history[]
Definition: HDFVersion.h:40
bool operator>=(const HDFVersion &other) const
Definition: HDFVersion.h:84
bool read(HDFVersion &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
Definition: HDFVersion.h:119
const char num_walkers[]
Definition: HDFVersion.h:37
bool write(const data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT) const
Definition: hdf_dataproxy.h:47
const char walker_weights[]
Definition: HDFVersion.h:38
const char num_blocks[]
Definition: HDFVersion.h:44
const char walkers[]
Definition: HDFVersion.h:36
const char append_walkers[]
Definition: HDFVersion.h:45
bool operator==(const HDFVersion &other) const
Definition: HDFVersion.h:71
const char qmc_status[]
Definition: HDFVersion.h:41
const char config_ext[]
extension of a configuration file
Definition: HDFVersion.h:27
int serialized() const
limited to 100 for each version field
Definition: HDFVersion.h:82
std::ostream & operator<<(std::ostream &out, const AntiSymTensor< T, D > &rhs)
bool read(data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
Definition: hdf_dataproxy.h:38
const char energy_history[]
Definition: HDFVersion.h:39
const char main_state[]
Definition: HDFVersion.h:31
const char config_group[]
Definition: HDFVersion.h:32
bool read(data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
Definition: HDFVersion.h:88
const char coord[]
Definition: HDFVersion.h:48
const char random[]
Definition: HDFVersion.h:35
int operator[](int i) const
Definition: HDFVersion.h:66
int & operator[](int i)
Definition: HDFVersion.h:68
std::istream & operator>>(std::istream &is, Matrix< T, Alloc > &rhs)
Definition: OhmmsMatrix.h:427
HDFVersion(int m, int n)
Definition: HDFVersion.h:64
const char version[]
Definition: HDFVersion.h:30
generic h5data_proxy<T> for scalar basic datatypes defined in hdf_dataspace.h Note if the dataset to ...
Definition: hdf_dataproxy.h:29
bool write(const data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
Definition: HDFVersion.h:94