00001
00002
00003
00004
00005
00006
00007
00008 #ifndef QMCConfigIO_H
00009 #define QMCConfigIO_H
00010
00011 #include <iostream>
00012 #include <fstream>
00013 #include <math.h>
00014
00015 #include "Array1D.h"
00016 #include "Array2D.h"
00017 #include <string>
00018
00019 using namespace std;
00020
00021 #ifdef USEHDF5
00022 #include "H5Cpp.h"
00023
00024 #ifndef H5_NO_NAMESPACE
00025 using namespace H5;
00026 #endif
00027
00028 typedef struct {
00029 double SCF_Lap;
00030 double weight;
00031 double PE;
00032 double lnJ;
00033 } ct_typ;
00034
00035 #endif
00036
00063 class QMCConfigIO
00064 {
00065 public:
00066
00070 QMCConfigIO();
00071
00075 ~QMCConfigIO();
00076
00083 QMCConfigIO(int numElectrons);
00084
00095 void open(string filename, bool forWriting);
00096
00101 void close();
00102
00106 bool eof();
00107
00114 string getFilename();
00115
00120 int getNumberConfigsWritten();
00121
00122
00127 void setPrecision();
00128
00142 void writeCorrelatedSamplingConfiguration(
00143 Array2D<double> & R,
00144 double SCF_Laplacian_PsiRatio,
00145 Array2D<double> & SCF_Grad_PsiRatio,
00146 double lnJastrow,
00147 double PE,
00148 double weight);
00149
00161 void readCorrelatedSamplingConfiguration(
00162 Array2D<double> & R,
00163 double & SCF_Laplacian_PsiRatio,
00164 Array2D<double> & SCF_Grad_PsiRatio,
00165 double & lnJastrow,
00166 double & PE,
00167 double & weight);
00168
00174 template<class T>
00175 fstream & operator<<(T rhs)
00176 {
00177 *config_strm << rhs;
00178 return *config_strm;
00179 }
00180
00181 private:
00186 #ifdef USEHDF5
00187 static H5File * h5_f;
00188
00189 static DataSet * dst_r;
00190 static DataSet * dst_g;
00191 static DataSet * dst_o;
00192 static CompType * ct;
00193 ct_typ packet;
00194
00195 #else
00196 static fstream *config_strm;
00197 #endif
00198
00202 static string filename;
00203
00207 static bool areWriting;
00208
00212 static int numElectrons;
00213
00217 static int numWritten;
00218 static int numRead;
00219 };
00220
00221 #endif
00222