14 XMLReader paramtop(xml, path);
30 QDPIO::cerr <<
"Caught Exception " << error << std::endl;
58 XMLReader paramtop(xml, path);
63 if( paramtop.count(
"eigen_filefmt") == 1 ) {
72 QDPIO::cerr <<
"Caught exception " << error << std::endl;
92 multi1d<int> seed_int(4);
94 XMLReader paramtop(xml, path);
98 XMLReader xml_tmp(paramtop,
"Param/FermionAction");
99 std::ostringstream os;
103 read(paramtop,
"Param/nrow", param.
nrow);
104 read(paramtop,
"Param/rng", param.
seed);
106 read(paramtop,
"Cfg", param.
cfg);
109 if( paramtop.count(
"StateInfo") == 1 ) {
110 XMLReader xml_state_info(paramtop,
"StateInfo");
111 std::ostringstream state_info_os;
112 xml_state_info.print(state_info_os);
116 XMLBufferWriter s_i_xml;
117 push(s_i_xml,
"StateInfo");
124 QDPIO::cerr <<
"Caught exception " << error << std::endl;
152 XMLReader r2(r1,
"/StateInfo");
155 std::ostringstream s_i_o;
162 QDPIO::cerr <<
"Caught exception : " << e << std::endl;
171 multi1d<LatticeFermion>& eigv_lo, Real& lambda_hi,
172 QDP_serialparallel_t serpar)
176 QDPIO::cerr <<
"Writing Eigenvectors only supported in SciDAC format" << std::endl;
181 XMLBufferWriter file_xml;
184 push(file_xml,
"WilsonRitzEigen");
185 write(file_xml,
"InputParams", header);
186 write(file_xml,
"lambda_hi", lambda_hi);
187 write(file_xml,
"Neig_file", file_neig);
191 std::ostringstream filename;
194 XMLBufferWriter record_eval_xml;
195 push(record_eval_xml,
"record_eval");
196 write(record_eval_xml,
"eval_num", lo);
197 pop(record_eval_xml);
199 XMLBufferWriter record_evec_xml;
200 push(record_evec_xml,
"record_evec");
201 write(record_evec_xml,
"evec_num", lo);
202 pop(record_evec_xml);
204 QDPIO::cout <<
"Opening eigenstd::vector file: "<< filename.str() << std::endl;
205 QDPFileWriter outfile(file_xml, filename.str(),
209 multi1d<Real> lambda_lo_arr(1);
210 lambda_lo_arr[0] = lambda_lo[lo];
211 write(outfile, record_eval_xml, lambda_lo_arr);
212 write(outfile, record_evec_xml, eigv_lo[lo]);
218 LatticeFermion& eigv,
220 QDP_serialparallel_t serpar,
225 XMLReader record_eval_xml;
226 XMLReader record_evec_xml;
228 QDPIO::cout <<
"Attempting to read from " << filename << std::endl;
229 QDPFileReader from(file_xml, filename, serpar);
233 multi1d<Real> lambda_lo_aux(1);
234 read(from, record_eval_xml, lambda_lo_aux);
235 lambda_lo = lambda_lo_aux[0];
236 read(from, record_evec_xml, eigv);
251 read( record_eval_xml,
"/record_eval/eval_num", eval_num);
254 QDPIO::cerr <<
"Caught exception reading eval_num " << e << std::endl;
259 read( record_evec_xml,
"/record_evec/evec_num", evec_num);
262 QDPIO::cerr <<
"Caught exception reading evec_num " << e << std::endl;
266 if( eval_num != evec_num) {
270 eig_index = eval_num;
277 multi1d<LatticeFermion>& eigv_lo, Real& lambda_hi,
280 QDP_serialparallel_t serpar)
283 int neig_to_load = Neig;
285 for(
int lo=0; lo < Neig && lo < neig_to_load; lo++) {
291 LatticeFermion eigv_tmp;
293 std::ostringstream filename;
295 filename << filename_stem <<
"_" << std::setw(3) << std::setfill(
'0') << lo;
297 filename.str(), serpar,
305 read(file_xml,
"/WilsonRitzEigen/InputParams", header);
308 QDPIO::cerr <<
"Caught Exception reading header: " << e << std::endl;
315 read(file_xml,
"/WilsonRitzEigen/lambda_hi", lambda_hi);
318 QDPIO::cerr <<
"Caught Exception reading lambda_hi: " << e << std::endl;
324 QDPIO::cout <<
"Requested " << Neig <<
" eigenpairs but only " << header.
ritz_params.
Neig <<
" were computed. Will only read " << header.
ritz_params.
Neig <<
" pairs" << std::endl;
332 lambda_lo.resize(neig_to_load);
333 eigv_lo.resize(neig_to_load);
337 if( eig_index != lo) {
338 QDPIO::cerr <<
"Error: index and eig_index dont match lo = " << lo <<
" eig_index = " << eig_index << std::endl;
343 lambda_lo[eig_index] = lambda_lo_tmp;
344 eigv_lo[eig_index] = eigv_tmp;
354 multi1d<LatticeFermion>& eigv_lo, Real& lambda_hi,
359 std::ostringstream xml_filename;
360 xml_filename << filename_stem <<
".xml" ;
362 QDPIO::cout <<
"Attempting to open " << xml_filename.str() << std::endl;
364 XMLReader
reader(xml_filename.str());
367 XMLReader paramtop(
reader,
"/Eigenvalues");
368 read(paramtop,
"lambda_lo", lambda_lo);
369 read(paramtop,
"lambda_hi", lambda_hi);
372 QDPIO::cerr <<
"Caught exception : " << e << std::endl;
376 if ( lambda_lo.size() != Neig ) {
377 QDPIO::cerr <<
"Mismatch in no of low eigenvalues. Neig = " << Neig <<
378 "but read " << lambda_lo.size() << std::endl;
382 eigv_lo.resize(lambda_lo.size());
384 for(
int evec = 0; evec < lambda_lo.size(); evec++) {
387 std::ostringstream filename;
388 filename << filename_stem <<
"_" << std::setw(3) << std::setfill(
'0') << evec;
389 QDPIO::cout <<
"Attempting to open " << filename.str() << std::endl;
396 QDPIO::cerr <<
"Caught exception " << e << std::endl;
Primary include file for CHROMA library code.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams ¶m)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
void readSzinFerm(LatticeFermion &q, const std::string &file)
Read a SZIN fermion. This is a simple memory dump reader.
void readEigenSzin(multi1d< Real > &lambda_lo, multi1d< LatticeFermion > &eigv_lo, Real &lambda_hi, const int Neig, const std::string &filename_stem)
void readEigenPair(Real &lambda_lo, int &eig_index, LatticeFermion &eigv, const std::string &filename, QDP_serialparallel_t serpar, XMLReader &file_xml)
void readEigen(ChromaWilsonRitz_t &header, multi1d< Real > &lambda_lo, multi1d< LatticeFermion > &eigv_lo, Real &lambda_hi, const std::string &filename_stem, int Neig, QDP_serialparallel_t serpar)
void writeEigen(const ChromaWilsonRitz_t &header, multi1d< Real > &lambda_lo, multi1d< LatticeFermion > &eigv_lo, Real &lambda_hi, QDP_serialparallel_t serpar)
Handle< FermBC< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
Asqtad Staggered-Dirac operator.
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
push(xml_out,"Condensates")
Read an old SZIN-style (checkerboarded) lattice Dirac fermion.
Struct for the overall application.
EigenIO_t eigen_io_params
Struct for dumping the eigenvalues/vectors.
EigenVecType eigen_filefmt
QDP_volfmt_t eigen_volfmt
Struct for parameters needed for a Ritz KS type solve.