CHROMA
qprop_io.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Routines associated with Chroma propagator IO
3  */
4 
5 #include "chromabase.h"
6 #include "io/param_io.h"
7 #include "io/qprop_io.h"
8 
11 
12 namespace Chroma
13 {
14 
15  // Given a fermion action in std::string form, return the Mass
16  Real getMass(const GroupXML_t& fermact)
17  {
18  //
19  // Initialize fermion action
20  //
21  std::istringstream xml_s(fermact.xml);
22  XMLReader fermacttop(xml_s);
23  XMLReader top(fermacttop, fermact.path);
24 
25  Real Mass;
26 
27  try
28  {
29  if (top.count("Mass") != 0)
30  {
31  read(top, "Mass", Mass);
32  }
33  else if (top.count("Kappa") != 0)
34  {
35  Real Kappa;
36  read(top, "Kappa", Kappa);
37  Mass = kappaToMass(Kappa); // Convert Kappa to Mass
38  }
39  else if (top.count("m_q") != 0)
40  {
41  read(top, "m_q", Mass);
42  }
43  else
44  {
45  QDPIO::cerr << "Neither Mass nor Kappa found" << std::endl;
46  throw std::string("Neither Mass nor Kappa found");
47  }
48  }
49  catch (const std::string& e)
50  {
51  QDPIO::cerr << "Error reading fermact: " << e << std::endl;
52  throw e;
53  }
54 
55  return Mass;
56  }
57 
58 
59  // Given a fermion action in std::string form, return the boundary
60  /* HACK - THIS DEFINITELY NEEDS IMPROVEMENT */
61  multi1d<int> getFermActBoundary(const GroupXML_t& fermact)
62  {
63  //
64  // Initialize fermion action
65  //
66  std::istringstream xml_s(fermact.xml);
67  XMLReader fermacttop(xml_s);
68  XMLReader top(fermacttop, fermact.path);
69 
70  multi1d<int> boundary;
71 
72  // Throw exception if boundary not found
73 // try
74  {
75  if (top.count("FermState/FermionBC/boundary") != 0)
76  {
77  read(top, "FermState/FermionBC/boundary", boundary);
78  }
79  else if (top.count("FermionBC/boundary") != 0)
80  {
81  read(top, "FermionBC/boundary", boundary);
82  }
83  else if (top.count("boundary") != 0)
84  {
85  read(top, "boundary", boundary);
86  }
87  else
88  {
89  std::ostringstream os;
90  os << __func__ << ": Warning: neither FermionBC group nor boundary found - throwing exception. If this is not caught the code will exit" << std::endl;
91  QDPIO::cerr << os.str();
92  throw os.str();
93  }
94  }
95 // catch (const std::string& e)
96 // {
97 // QDPIO::cerr << "Error reading fermact: " << e << std::endl;
98 // throw e;
99 // }
100 
101  if (boundary.size() != Nd)
102  {
103  QDPIO::cerr << __func__ << ": boundary is not the expected length = Nd" << std::endl;
104  QDP_abort(1);
105  }
106 
107  return boundary;
108  }
109 
110 
111 
112  // Initialize header with default values
114  {
115  j_decay = -1;
116  t_source = -1;
117  }
118 
119  // Given a prop source xml in std::string form, return the t_srce
120  multi1d<int> PropSourceConst_t::getTSrce() const
121  {
122  //
123  // Initialize source xml
124  //
125  std::istringstream xml_s(source.xml);
126  XMLReader sourcetop(xml_s);
127 
128  multi1d<int> t_srce;
129  multi1d<int> t_source;
130 
131  try
132  {
133  XMLReader top(sourcetop, source.path);
134 
135  read(top, "t_srce", t_srce);
136  }
137  catch (const std::string& e)
138  {
139  try
140  {
141  XMLReader top(sourcetop, source.path);
142 
143  read(top, "t_source", t_source);
144  t_srce.resize(Nd);
145  t_srce[Nd-1] = t_source[0];
146  for(int i=0;i<Nd-1;i++)
147  t_srce[i] = 0;
148  }
149  catch (const std::string& e)
150  {
151  QDPIO::cerr << "Error reading source: " << e << std::endl;
152  throw e;
153  }
154  }
155 
156  return t_srce;
157  }
158 
159  // Given a prop source xml in std::string form, return the Momentum
160  // works with momentum sources
161  multi1d<int> PropSourceConst_t::getMom() const
162  {
163  //
164  // Initialize source xml
165  //
166  std::istringstream xml_s(source.xml);
167  XMLReader sourcetop(xml_s);
168 
169  multi1d<int> t_srce;
170 
171  try
172  {
173  XMLReader top(sourcetop, source.path);
174 
175  read(top, "mom", t_srce);
176  }
177  catch (const std::string& e)
178  {
179  QDPIO::cerr << "Error reading source: " << e << std::endl;
180  throw e;
181  }
182 
183  return t_srce;
184  }
185 
186 
187  // Initialize header with default values
189  {
190  j_decay = -1;
191  }
192 
193 
194  // Initialize header with default values
196  {
197  j_decay = -1;
198  }
199 
200 
201  // Initialize header with default values
203  {
204  j_decay = -1;
205  t_sink = -1;
206  sink_mom.resize(Nd-1);
207  sink_mom = 0;
208  }
209 
210 
211  // Initialize header with default values
213  {
214  obsvP = true;
215  // Create an document with an empty state info tag
216  }
217 
218  // Initialize header with default values
220  {
221  }
222 
223 
224  // Initialize header with default values
226  {
227  sparseP = false;
228  Dirac_basis = true;
229  forward_props.resize(3);
230  }
231 
232 
233  // Initialize header with default values
235  {
236  Dirac_basis = true;
237  forward_props.resize(3);
238  }
239 
240 
241  // Anonymous namespace
242  namespace
243  {
244  //! V5 Source header read
245  /*! This routine is SOLELY for backwards compatibility. It should go. */
246  void readV5(XMLReader& xml, const std::string& path, PropSourceConst_t& header)
247  {
248  XMLReader paramtop(xml, path);
249 
250  int version;
251  read(paramtop, "version", version);
252 
253  read(paramtop, "source_type", header.source.id);
254 
255  std::string wave_state;
256  read(paramtop, "wave_state", wave_state);
257  if (wave_state != "S_WAVE")
258  {
259  throw std::string("version 5 only supports S_WAVE");
260  }
261 
262  multi1d<int> t_srce;
263  read(paramtop, "j_decay", header.j_decay);
264  read(paramtop, "t_source", t_srce);
265 
266  if (header.source.id == "SHELL_SOURCE")
267  {
268  XMLReader shelltop(paramtop, "ShellSource");
269 
270  std::string wvf_kind;
271  Real wvf_param;
272  int wvfIntPar;
273  {
274  XMLReader smeartop(shelltop, "SourceSmearingParam");
275 
276  read(smeartop, "wvf_kind", wvf_kind);
277  read(smeartop, "wvf_param", wvf_param);
278  read(smeartop, "wvfIntPar", wvfIntPar);
279  }
280 
281  int laplace_power;
282  read(shelltop, "laplace_power", laplace_power);
283  if (laplace_power != 0)
284  throw std::string("only laplace_power=0 supported");
285 
286  Real link_smear_fact;
287  int link_smear_num;
288  read(shelltop, "link_smear_fact", link_smear_fact);
289  read(shelltop, "link_smear_num", link_smear_num);
290 
291  int disp_length;
292  int disp_dir;
293  read(shelltop, "disp_length", disp_length);
294  read(shelltop, "disp_dir", disp_dir);
295 
296  XMLReader xml_readback;
297  {
298  XMLBufferWriter xml_tmp;
299  push(xml_tmp, "Param");
300  write(xml_tmp, "version", 6);
301  push(xml_tmp, "Source");
302  write(xml_tmp, "version", 2);
303  write(xml_tmp, "SourceType", header.source.id);
304 
305  {
306  push(xml_tmp, "SmearingParam");
307  write(xml_tmp, "wvf_kind", wvf_kind);
308  write(xml_tmp, "wvf_param", wvf_param);
309  write(xml_tmp, "wvfIntPar", wvfIntPar);
310  write(xml_tmp, "no_smear_dir", header.j_decay);
311  pop(xml_tmp);
312  }
313 
314  {
315  push(xml_tmp, "Displacement");
316  write(xml_tmp, "DisplacementType", SimpleQuarkDisplacementEnv::getName());
317 
318  write(xml_tmp, "disp_length", disp_length);
319  write(xml_tmp, "disp_dir", disp_dir);
320 
321  pop(xml_tmp); // Displacement
322  }
323 
324  {
325  push(xml_tmp, "LinkSmearing");
326  write(xml_tmp, "LinkSmearingType", APELinkSmearingEnv::getName());
327  write(xml_tmp, "link_smear_num", link_smear_num);
328  write(xml_tmp, "link_smear_fact", link_smear_fact);
329  write(xml_tmp, "no_smear_dir", header.j_decay);
330  pop(xml_tmp);
331  }
332 
333  write(xml_tmp, "t_srce", t_srce);
334  write(xml_tmp, "j_decay", header.j_decay);
335 
336  pop(xml_tmp); // Source
337  pop(xml_tmp); // Param
338 
339  QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
340 
341  xml_readback.open(xml_tmp);
342  }
343 
344  // Recurse back in to re-read
345  read(xml_readback, "/Param", header);
346  }
347  else if (header.source.id == "POINT_SOURCE")
348  {
349  XMLReader xml_readback;
350  {
351  XMLBufferWriter xml_tmp;
352  push(xml_tmp, "Param");
353  write(xml_tmp, "version", 6);
354  push(xml_tmp, "Source");
355  write(xml_tmp, "version", 1);
356  write(xml_tmp, "SourceType", header.source.id);
357 
358  write(xml_tmp, "t_srce", t_srce);
359  write(xml_tmp, "j_decay", header.j_decay);
360 
361  pop(xml_tmp); // Source
362  pop(xml_tmp); // Param
363 
364  QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
365 
366  xml_readback.open(xml_tmp);
367  }
368 
369  // Recurse back in to re-read
370  read(xml_readback, "/Param", header);
371  }
372  else if (header.source.id == "WALL_SOURCE")
373  {
374  XMLReader xml_readback;
375  {
376  XMLBufferWriter xml_tmp;
377  push(xml_tmp, "Param");
378  write(xml_tmp, "version", 6);
379  push(xml_tmp, "Source");
380  write(xml_tmp, "version", 1);
381  write(xml_tmp, "SourceType", header.source.id);
382 
383  write(xml_tmp, "t_source", t_srce[header.j_decay]);
384  write(xml_tmp, "j_decay", header.j_decay);
385 
386  pop(xml_tmp); // Source
387  pop(xml_tmp); // Param
388 
389  QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
390 
391  xml_readback.open(xml_tmp);
392  }
393 
394  // Recurse back in to re-read
395  read(xml_readback, "/Param", header);
396  }
397  else if (header.source.id == "RAND_Z2_WALL_SOURCE")
398  {
399  XMLReader xml_readback;
400  {
401  XMLBufferWriter xml_tmp;
402  push(xml_tmp, "Param");
403  write(xml_tmp, "version", 6);
404  push(xml_tmp, "Source");
405  write(xml_tmp, "version", 1);
406  write(xml_tmp, "SourceType", header.source.id);
407 
408  write(xml_tmp, "t_source", t_srce[header.j_decay]);
409  write(xml_tmp, "j_decay", header.j_decay);
410 
411  pop(xml_tmp); // Source
412  pop(xml_tmp); // Param
413 
414  QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
415 
416  xml_readback.open(xml_tmp);
417  }
418 
419  // Recurse back in to re-read
420  read(xml_readback, "/Param", header);
421  }
422  else
423  {
424  std::ostringstream os;
425  os << "Unsupported source type= " << header.source.id
426  << " in file= " << __FILE__
427  << " at line= " << __LINE__
428  << std::endl;
429  throw os.str();
430  }
431  }
432 
433 
434  //! V4 Sink header read
435  /*! This routine is SOLELY for backwards compatibility. It should go. */
436  void readV4(XMLReader& xml, const std::string& path, PropSinkSmear_t& header)
437  {
438  XMLReader paramtop(xml, path);
439 
440  int version;
441  read(paramtop, "version", version);
442 
443  read(paramtop, "sink_type", header.sink.id);
444 
445  std::string wave_state;
446  read(paramtop, "wave_state", wave_state);
447  if (wave_state != "S_WAVE")
448  {
449  throw std::string("version 4 only supports S_WAVE");
450  }
451 
452  read(paramtop, "j_decay", header.j_decay);
453 
454  if (header.sink.id == "SHELL_SINK")
455  {
456  XMLReader shelltop(paramtop, "ShellSink");
457 
458  std::string wvf_kind;
459  Real wvf_param;
460  int wvfIntPar;
461  {
462  XMLReader smeartop(shelltop, "SinkSmearingParam");
463 
464  read(smeartop, "wvf_kind", wvf_kind);
465  read(smeartop, "wvf_param", wvf_param);
466  read(smeartop, "wvfIntPar", wvfIntPar);
467  }
468 
469  int laplace_power;
470  read(shelltop, "laplace_power", laplace_power);
471  if (laplace_power != 0)
472  throw std::string("only laplace_power=0 supported");
473 
474  Real link_smear_fact;
475  int link_smear_num;
476  read(shelltop, "link_smear_fact", link_smear_fact);
477  read(shelltop, "link_smear_num", link_smear_num);
478 
479  int disp_length;
480  int disp_dir;
481  read(shelltop, "disp_length", disp_length);
482  read(shelltop, "disp_dir", disp_dir);
483 
484  XMLReader xml_readback;
485  {
486  XMLBufferWriter xml_tmp;
487  push(xml_tmp, "Param");
488  write(xml_tmp, "version", 6);
489  push(xml_tmp, "Sink");
490  write(xml_tmp, "version", 2);
491  write(xml_tmp, "SinkType", header.sink.id);
492 
493  {
494  push(xml_tmp, "SmearingParam");
495  write(xml_tmp, "wvf_kind", wvf_kind);
496  write(xml_tmp, "wvf_param", wvf_param);
497  write(xml_tmp, "wvfIntPar", wvfIntPar);
498  write(xml_tmp, "no_smear_dir", header.j_decay);
499  pop(xml_tmp);
500  }
501 
502  {
503  push(xml_tmp, "Displacement");
504  write(xml_tmp, "DisplacementType", SimpleQuarkDisplacementEnv::getName());
505 
506  write(xml_tmp, "disp_length", disp_length);
507  write(xml_tmp, "disp_dir", disp_dir);
508 
509  pop(xml_tmp); // Displacement
510  }
511 
512  {
513  push(xml_tmp, "LinkSmearing");
514  write(xml_tmp, "LinkSmearingType", APELinkSmearingEnv::getName());
515  write(xml_tmp, "link_smear_num", link_smear_num);
516  write(xml_tmp, "link_smear_fact", link_smear_fact);
517  write(xml_tmp, "no_smear_dir", header.j_decay);
518  pop(xml_tmp);
519  }
520 
521  pop(xml_tmp); // Sink
522  pop(xml_tmp); // Param
523 
524  QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
525 
526  xml_readback.open(xml_tmp);
527  }
528 
529  // Recurse back in to re-read
530  read(xml_readback, "/Param", header);
531  }
532  else if (header.sink.id == "POINT_SINK")
533  {
534  XMLReader xml_readback;
535  {
536  XMLBufferWriter xml_tmp;
537  push(xml_tmp, "Param");
538  write(xml_tmp, "version", 6);
539  push(xml_tmp, "Sink");
540  write(xml_tmp, "version", 1);
541  write(xml_tmp, "SinkType", header.sink.id);
542 
543  write(xml_tmp, "j_decay", header.j_decay);
544 
545  pop(xml_tmp); // Sink
546  pop(xml_tmp); // Param
547 
548  QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
549 
550  xml_readback.open(xml_tmp);
551  }
552 
553  // Recurse back in to re-read
554  read(xml_readback, "/Param", header);
555  }
556  else if (header.sink.id == "WALL_SINK")
557  {
558  XMLReader xml_readback;
559  {
560  XMLBufferWriter xml_tmp;
561  push(xml_tmp, "Param");
562  write(xml_tmp, "version", 6);
563  push(xml_tmp, "Sink");
564  write(xml_tmp, "version", 1);
565  write(xml_tmp, "SinkType", header.sink.id);
566 
567  pop(xml_tmp); // Sink
568  pop(xml_tmp); // Param
569 
570  QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
571 
572  xml_readback.open(xml_tmp);
573  }
574 
575  // Recurse back in to re-read
576  read(xml_readback, "/Param", header);
577  }
578  else
579  {
580  std::ostringstream os;
581  os << "Unsupported sink type= " << header.sink.id
582  << " in file= " << __FILE__
583  << " at line= " << __LINE__
584  << std::endl;
585  throw os.str();
586  }
587  }
588  }
589 
590 
591 
592  // Source header read
593  void read(XMLReader& xml, const std::string& path, PropSourceConst_t& header)
594  {
595  XMLReader paramtop(xml, path);
596 
597  int version;
598  read(paramtop, "version", version);
599 
600  try
601  {
602  switch (version)
603  {
604  case 5:
605  readV5(xml, path, header);
606  break;
607 
608  case 6:
609  {
610  header.source = readXMLGroup(paramtop, "Source", "SourceType");
611 
612  XMLReader xml_tmp(paramtop, "Source");
613  read(xml_tmp, "j_decay", header.j_decay);
614  if (xml_tmp.count("t_source") != 0)
615  {
616  read(xml_tmp, "t_source", header.t_source);
617  }
618  else if (xml_tmp.count("t_srce") != 0)
619  {
620  multi1d<int> t_srce;
621  read(xml_tmp, "t_srce", t_srce);
622  if (t_srce.size() != Nd)
623  {
624  throw std::string("t_srce not expected size");
625  }
626  header.t_source = t_srce[header.j_decay];
627  }
628  else
629  {
630  throw std::string("neither t_source nor t_srce found");
631  }
632  }
633  break;
634 
635  default:
636  /**************************************************************************/
637  QDPIO::cerr << "PropSourceConst parameter version " << version
638  << " unsupported." << std::endl;
639  QDP_abort(1);
640  }
641  }
642  catch (const std::string& e)
643  {
644  QDPIO::cerr << "PropSourceConst: Error reading source: " << e << std::endl;
645  QDP_abort(1);
646  }
647  }
648 
649 
650  // Source header read
651  void read(XMLReader& xml, const std::string& path, PropSourceSmear_t& header)
652  {
653  XMLReader paramtop(xml, path);
654 
655  int version;
656  read(paramtop, "version", version);
657 
658  switch (version)
659  {
660  case 6:
661  {
662  header.source = readXMLGroup(paramtop, "Source", "SourceType");
663 
664  XMLReader xml_tmp(paramtop, "Source");
665  read(xml_tmp, "j_decay", header.j_decay);
666  }
667  break;
668 
669  default:
670  /**************************************************************************/
671  QDPIO::cerr << "PropSourceSmear parameter version " << version
672  << " unsupported." << std::endl;
673  QDP_abort(1);
674  }
675  }
676 
677 
678  // Source header read
679  void read(XMLReader& xml, const std::string& path, PropSinkSmear_t& header)
680  {
681  XMLReader paramtop(xml, path);
682 
683  int version;
684  read(paramtop, "version", version);
685 
686  try
687  {
688  switch (version)
689  {
690  case 4:
691  readV4(xml, path, header);
692  break;
693 
694  case 5:
695  {
696  header.sink = readXMLGroup(paramtop, "Sink", "SinkType");
697 
698  XMLReader xml_tmp(paramtop, "Sink");
699  read(xml_tmp, "j_decay", header.j_decay);
700  }
701  break;
702 
703  default:
704  /**************************************************************************/
705  QDPIO::cerr << "PropSinkSmear parameter version " << version
706  << " unsupported." << std::endl;
707  QDP_abort(1);
708  }
709  }
710  catch (const std::string& e)
711  {
712  QDPIO::cerr << "PropSinkSmear: Error reading sink: " << e << std::endl;
713  QDP_abort(1);
714  }
715 
716  }
717 
718 
719  //! SeqSource header reader
720  void read(XMLReader& xml, const std::string& path, SeqSource_t& param)
721  {
722  XMLReader paramtop(xml, path);
723 
724  int version;
725  read(paramtop, "version", version);
726 
727  switch (version)
728  {
729  case 1:
730  {
731  XMLReader xml_readback;
732  {
733  XMLBufferWriter xml_tmp;
734  push(xml_tmp, "Param");
735  write(xml_tmp, "version", 2);
736  push(xml_tmp, "SeqSource");
737  write(xml_tmp, "version", 1);
738  std::string seq_src;
739  read(paramtop, "seq_src", seq_src);
740  write(xml_tmp, "SeqSourceType", seq_src);
741 
742  read(paramtop, "sink_mom", param.sink_mom);
743  write(xml_tmp, "sink_mom", param.sink_mom);
744 
745  read(paramtop, "t_sink", param.t_sink);
746  write(xml_tmp, "t_sink", param.t_sink);
747 
748  write(xml_tmp, "j_decay", Nd-1);
749 
750  pop(xml_tmp); // Source
751  pop(xml_tmp); // Param
752 
753  QDPIO::cout << "seqsrc_xml = XX" << xml_tmp.printCurrentContext() << "XX" << std::endl;
754 
755  xml_readback.open(xml_tmp);
756  }
757 
758  // Recurse back in to re-read
759  read(xml_readback, "/Param", param);
760  }
761  break;
762 
763  case 2:
764  {
765  param.seqsrc = readXMLGroup(paramtop, "SeqSource", "SeqSourceType");
766 
767  XMLReader xml_tmp(paramtop, "SeqSource");
768  read(xml_tmp, "t_sink", param.t_sink);
769  read(xml_tmp, "sink_mom", param.sink_mom);
770  read(xml_tmp, "j_decay", param.j_decay);
771  }
772  break;
773 
774  default:
775  QDPIO::cerr << "SeqSource parameter version " << version
776  << " unsupported." << std::endl;
777  QDP_abort(1);
778  }
779 
780  }
781 
782 
783  // Forward propagator header read
784  void read(XMLReader& xml, const std::string& path, ChromaProp_t& param)
785  {
786  XMLReader paramtop(xml, path);
787 
788  int version;
789  read(paramtop, "version", version);
790 
791  multi1d<int> boundary;
792 
794  param.obsvP = true;
795 
796  switch (version)
797  {
798  /**************************************************************************/
799  case 4:
800  {
801  // In V4 the fermion action specific stuff is within the <Param> tag and not
802  // in a <FermionAction> tag beneath <Param>
803  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
804  read(paramtop, "boundary", boundary);
805 
806  XMLBufferWriter xml_out;
807  push(xml_out,"FermionAction");
808  xml_out << paramtop;
809  pop(xml_out);
810 
811  XMLReader xml_inn(xml_out);
812  param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
813  }
814  break;
815 
816  /**************************************************************************/
817  case 5:
818  {
819  // In this modified version of v4, the fermion action specific stuff
820  // goes into a <FermionAction> tag beneath <Param>
821  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
822  read(paramtop, "boundary", boundary);
823 
824  XMLReader xml_tmp(paramtop, "FermionAction");
825 
826  XMLBufferWriter xml_out;
827  push(xml_out,"FermionAction");
828  xml_out << xml_tmp;
829  write(xml_out, "boundary", boundary);
830  pop(xml_out);
831 
832  XMLReader xml_inn(xml_out);
833  param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
834  }
835  break;
836 
837  /**************************************************************************/
838  case 6:
839  {
840  bool nonRelProp;
841  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
842  if (nonRelProp)
844 
845  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
846  read(paramtop, "boundary", boundary);
847 
848  XMLReader xml_tmp(paramtop, "FermionAction");
849 
850  XMLBufferWriter xml_out;
851  push(xml_out,"FermionAction");
852  xml_out << xml_tmp;
853  write(xml_out, "boundary", boundary);
854  pop(xml_out);
855 
856  XMLReader xml_inn(xml_out);
857  param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
858  }
859  break;
860 
861  /**************************************************************************/
862  case 7:
863  {
864  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
865  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
866 
867  bool nonRelProp;
868  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
869  if (nonRelProp)
871 
872  if (paramtop.count("obsvP") != 0)
873  {
874  read(paramtop, "obsvP", param.obsvP);
875  }
876 
877  if (paramtop.count("boundary") != 0)
878  {
879  QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << std::endl;
880  QDP_abort(1);
881  }
882  }
883  break;
884 
885  case 8:
886  {
887  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
888 
889  bool nonRelProp;
890  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
891  if (nonRelProp)
893 
894  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
895  read(paramtop, "obsvP", param.obsvP);
896 
897  if (paramtop.count("boundary") != 0)
898  {
899  QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << std::endl;
900  QDP_abort(1);
901  }
902  }
903  break;
904 
905  case 9:
906  case 10:
907  {
908  // NOTE: now version 10 and 9 are identical. Version 10 use to read
909  // numRetries, but that functionality has been removed and the
910  // param is ignored.
911  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
912 
913  read(paramtop, "quarkSpinType", param.quarkSpinType); // which quark spins to compute
914  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
915  read(paramtop, "obsvP", param.obsvP);
916 
917  if (paramtop.count("boundary") != 0)
918  {
919  QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << std::endl;
920  QDP_abort(1);
921  }
922  }
923  break;
924 
925  default:
926  /**************************************************************************/
927  QDPIO::cerr << "ChromaProp parameter version " << version
928  << " unsupported." << std::endl;
929  QDP_abort(1);
930  }
931 
932  }
933 
934 
935  // Forward propagator header read
936  void read(XMLReader& xml, const std::string& path, ChromaMultiProp_t& param)
937  {
938  XMLReader paramtop(xml, path);
939 
940  int version;
941  read(paramtop, "version", version);
942 
944  multi1d<int> boundary;
945 
946  switch (version)
947  {
948  /**************************************************************************/
949  case 5: // Backward compatibility with non Multi ChromaProp_t
950  /**************************************************************************/
951  {
952  read(paramtop, "MultiMasses", param.MultiMasses);
953 
954  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
955  read(paramtop, "boundary", boundary);
956 
957  XMLReader xml_tmp(paramtop, "FermionAction");
958 
959  XMLBufferWriter xml_out;
960  push(xml_out,"FermionAction");
961  xml_out << xml_tmp;
962  write(xml_out, "boundary", boundary);
963  pop(xml_out);
964 
965  XMLReader xml_inn(xml_out);
966  param.fermact = readXMLGroup(xml_inn, "FermionAction", "FermAct");
967  }
968  break;
969 
970  /**************************************************************************/
971  case 6: // Backward compatibility with non Multi ChromaProp_t
972  /**************************************************************************/
973  {
974  read(paramtop, "MultiMasses", param.MultiMasses);
975 
976  bool nonRelProp;
977  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
978  if (nonRelProp)
980 
981  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
982  read(paramtop, "boundary", boundary);
983 
984  XMLReader xml_tmp(paramtop, "FermionAction");
985 
986  XMLBufferWriter xml_out;
987  push(xml_out,"FermionAction");
988  xml_out << xml_tmp;
989  write(xml_out, "boundary", boundary);
990  pop(xml_out);
991 
992  XMLReader xml_inn(xml_out);
993  param.fermact = readXMLGroup(xml_inn, "FermionAction", "FermAct");
994  }
995  break;
996 
997  /**************************************************************************/
998  case 7:
999  /**************************************************************************/
1000  {
1001  read(paramtop, "MultiMasses", param.MultiMasses);
1002 
1003  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
1004  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
1005 
1006  bool nonRelProp;
1007  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
1008  if (nonRelProp)
1010 
1011  if (paramtop.count("boundary") != 0)
1012  {
1013  QDPIO::cerr << "ChromaMultiProp: paranoia check - found a misplaced boundary" << std::endl;
1014  QDP_abort(1);
1015  }
1016  }
1017  break;
1018 
1019  /* Compatibility with non MultiQprop */
1020  case 8:
1021  {
1022  read(paramtop, "MultiMasses", param.MultiMasses);
1023 
1024  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
1025  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
1026 
1027  bool nonRelProp;
1028  read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
1029  if (nonRelProp)
1031  }
1032  break;
1033 
1034 
1035  /* Compatibility with non MultiQprop */
1036  case 9:
1037  {
1038  read(paramtop, "MultiMasses", param.MultiMasses);
1039 
1040  param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
1041  param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
1042 
1043  read(paramtop, "quarkSpinType", param.quarkSpinType); // quark spin components
1044  }
1045  break;
1046 
1047  default:
1048  /**************************************************************************/
1049  QDPIO::cerr << "ChromaMultiProp parameter version " << version
1050  << " unsupported." << std::endl;
1051  QDP_abort(1);
1052  }
1053 
1054 // // Sanity check. No of residuals must be same as no of masses
1055 // if ( param.MultiMasses.size() != param.invParam.RsdCG.size() ) {
1056 // QDPIO::cerr << "Number of Masses in param.MultiMasses ("
1057 // << param.MultiMasses.size()
1058 // << ") differs from no of RsdCGs in param.invParam.RsdCG ("
1059 // << param.invParam.RsdCG.size() << ")" << std::endl;
1060 //
1061 // QDP_abort(1);
1062 // }
1063 
1064  }
1065 
1066 
1067  //-------------- HACK ----------------//
1068  // Fake gauge header reader. Need a proper solution
1069  void readGaugeHeader(XMLReader& paramtop, const std::string& path, std::string& gauge_header)
1070  {
1071  // Need to fix this and get proper headers
1072  if (paramtop.count("Config_info") > 0)
1073  {
1074  XMLReader xml_tmp(paramtop, "Config_info");
1075  std::ostringstream os;
1076  xml_tmp.printCurrentContext(os);
1077  gauge_header = os.str();
1078  }
1079  else
1080  {
1081  XMLBufferWriter xml_tmp;
1082  push(xml_tmp, "Config_info");
1083  pop(xml_tmp);
1084  gauge_header = xml_tmp.str();
1085  }
1086 
1087  }
1088 
1089 
1090  //=================================================================================
1091  // Propagator header readers and writers
1092 
1093  // MakeSourceProp reader
1094  void read(XMLReader& xml, const std::string& path, MakeSourceProp_t& param)
1095  {
1096  XMLReader paramtop(xml, path);
1097 
1098  read(paramtop, "PropSource", param.source_header);
1099  readGaugeHeader(paramtop, "Config_info", param.gauge_header);
1100  }
1101 
1102 
1103  // Propagator reader
1104  void read(XMLReader& xml, const std::string& path, Propagator_t& param)
1105  {
1106  XMLReader paramtop(xml, path);
1107 
1108  read(paramtop, "ForwardProp", param.prop_header);
1109  read(paramtop, "PropSource", param.source_header);
1110  readGaugeHeader(paramtop, "Config_info", param.gauge_header);
1111  }
1112 
1113 
1114  // ForwardProp reader
1115  void read(XMLReader& xml, const std::string& path, ForwardProp_t& param)
1116  {
1117  XMLReader paramtop(xml, path);
1118 
1119  read(paramtop, "PropSink", param.sink_header);
1120  read(paramtop, "ForwardProp", param.prop_header);
1121  read(paramtop, "PropSource", param.source_header);
1122  readGaugeHeader(paramtop, "Config_info", param.gauge_header);
1123  }
1124 
1125 
1126  // SequentialSource header reader
1127  void read(XMLReader& xml, const std::string& path, SequentialSource_t& param)
1128  {
1129  XMLReader paramtop(xml, path);
1130 
1131  read(paramtop, "SeqSourceSinkSmear", param.sink_header);
1132  read(paramtop, "SeqSource", param.seqsource_header);
1133  read(paramtop, "ForwardProps", param.forward_props);
1134  readGaugeHeader(paramtop, "Config_info", param.gauge_header);
1135  }
1136 
1137 
1138  // SequentialProp header reader
1139  void read(XMLReader& xml, const std::string& path, SequentialProp_t& param)
1140  {
1141  XMLReader paramtop(xml, path);
1142 
1143  read(paramtop, "SeqProp", param.seqprop_header);
1144  read(paramtop, "SeqSourceSinkSmear", param.sink_header);
1145  read(paramtop, "SeqSource", param.seqsource_header);
1146  read(paramtop, "ForwardProps", param.forward_props);
1147  readGaugeHeader(paramtop, "Config_info", param.gauge_header);
1148  }
1149 
1150 
1151  //! Source/sink spin indices
1152  void read(XMLReader& xml, const std::string& path, QQQSpinIndices_t& input)
1153  {
1154  XMLReader inputtop(xml, path);
1155 
1156  read(inputtop, "source", input.source);
1157  read(inputtop, "sink", input.sink);
1158  }
1159 
1160 
1161  // Initialize header with default values
1163  {
1164  Dirac_basis = true;
1165  forward_props.resize(2);
1166  }
1167 
1168 
1169  //! QQDiquark header reader
1170  void read(XMLReader& xml, const std::string& path, QQDiquark_t& param)
1171  {
1172  XMLReader paramtop(xml, path);
1173 
1174  int version;
1175  read(paramtop, "version", version);
1176 
1177  switch (version)
1178  {
1179  case 1:
1180  break;
1181 
1182  default:
1183  QDPIO::cerr << "QQDiquark parameter version " << version
1184  << " unsupported." << std::endl;
1185  QDP_abort(1);
1186  }
1187 
1188  read(paramtop, "Dirac_basis", param.Dirac_basis);
1189  read(paramtop, "ForwardProps", param.forward_props);
1190  if (param.forward_props.size() != 2)
1191  {
1192  QDPIO::cerr << "QQDiquark: unexpected number of forward_props = "
1193  << param.forward_props.size() << std::endl;
1194  QDP_abort(1);
1195  }
1196  }
1197 
1198 
1199  //! QQQBarcomp header reader
1200  void read(XMLReader& xml, const std::string& path, QQQBarcomp_t& param)
1201  {
1202  XMLReader paramtop(xml, path);
1203 
1204  int version = 1;
1205  if (paramtop.count("version") != 0)
1206  read(paramtop, "version", version);
1207 
1208  switch (version)
1209  {
1210  case 1:
1211  param.sparseP = false;
1212  param.Dirac_basis = false;
1213  param.forward_props.resize(3);
1214  read(paramtop, "Propagator1", param.forward_props[0]);
1215  read(paramtop, "Propagator2", param.forward_props[1]);
1216  read(paramtop, "Propagator3", param.forward_props[2]);
1217  break;
1218 
1219  case 2:
1220  param.sparseP = false;
1221  read(paramtop, "Dirac_basis", param.Dirac_basis);
1222  read(paramtop, "ForwardProps", param.forward_props);
1223  break;
1224 
1225  case 3:
1226  read(paramtop, "sparseP", param.sparseP);
1227  read(paramtop, "Dirac_basis", param.Dirac_basis);
1228  read(paramtop, "ForwardProps", param.forward_props);
1229  break;
1230 
1231  default:
1232  /**************************************************************************/
1233  QDPIO::cerr << "QQQBarcomp parameter version " << version
1234  << " unsupported." << std::endl;
1235  QDP_abort(1);
1236  }
1237 
1238  if (param.sparseP)
1239  {
1240  read(paramtop, "SpinIndices", param.spin_indices);
1241  }
1242 
1243  if (param.forward_props.size() != 3)
1244  {
1245  QDPIO::cerr << "QQQBarcomp: unexpected number of forward_props = "
1246  << param.forward_props.size() << std::endl;
1247  QDP_abort(1);
1248  }
1249  }
1250 
1251 
1252  //! QQbarMescomp header reader
1253  void read(XMLReader& xml, const std::string& path, QQbarMescomp_t& param)
1254  {
1255  XMLReader paramtop(xml, path);
1256 
1257  int version = 2;
1258 
1259  switch (version)
1260  {
1261  /**************************************************************************/
1262  case 2:
1263  read(paramtop, "Dirac_basis", param.Dirac_basis);
1264  read(paramtop, "ForwardProps", param.forward_props);
1265  break;
1266 
1267  default:
1268  /**************************************************************************/
1269  QDPIO::cerr << "QQbarMescomp parameter version " << version
1270  << " unsupported." << std::endl;
1271  QDP_abort(1);
1272  }
1273 
1274  if (param.forward_props.size() != 2)
1275  {
1276  QDPIO::cerr << "QQbarMescomp: unexpected number of forward_props = "
1277  << param.forward_props.size() << std::endl;
1278  QDP_abort(1);
1279  }
1280  }
1281 
1282 
1283 
1284 
1285  //---------------------------------------------------------------------------
1286  // Source header writer
1287  void write(XMLWriter& xml, const std::string& path, const PropSourceConst_t& header)
1288  {
1289  push(xml, path);
1290 
1291  int version = 6;
1292  write(xml, "version", version);
1293  xml << header.source.xml;
1294  write(xml, "j_decay", header.j_decay); // I think these two are duplicates of what
1295  write(xml, "t_source", header.t_source); // is in header.source
1296 
1297  pop(xml);
1298  }
1299 
1300 
1301  // Source header writer
1302  void write(XMLWriter& xml, const std::string& path, const PropSourceSmear_t& header)
1303  {
1304  push(xml, path);
1305 
1306  int version = 6;
1307  write(xml, "version", version);
1308  xml << header.source.xml;
1309  write(xml, "j_decay", header.j_decay);
1310 
1311  pop(xml);
1312  }
1313 
1314 
1315  // Source header writer
1316  void write(XMLWriter& xml, const std::string& path, const PropSinkSmear_t& header)
1317  {
1318  push(xml, path);
1319 
1320  int version = 5;
1321  write(xml, "version", version);
1322  xml << header.sink.xml;
1323  write(xml, "j_decay", header.j_decay);
1324 
1325  pop(xml);
1326  }
1327 
1328 
1329  // Write propagator inversion parameters
1330  void write(XMLWriter& xml, const std::string& path, const ChromaProp_t& header)
1331  {
1332  push(xml, path);
1333 
1334  int version = 9;
1335  write(xml, "version", version);
1336  write(xml, "quarkSpinType", header.quarkSpinType);
1337  write(xml, "obsvP", header.obsvP); // new - measured 5D stuff
1338  xml << header.fermact.xml;
1339  xml << header.invParam.xml;
1340 
1341  pop(xml);
1342  }
1343 
1344  // Write propagator inversion parameters
1345  void write(XMLWriter& xml, const std::string& path, const ChromaMultiProp_t& header)
1346  {
1347  push(xml, path);
1348 
1349  int version = 8;
1350  write(xml, "version", version);
1351  write(xml, "quarkSpinType", header.quarkSpinType);
1352  write(xml, "MultiMasses", header.MultiMasses);
1353  xml << header.fermact.xml;
1354  xml << header.invParam.xml;
1355 
1356  pop(xml);
1357  }
1358 
1359 
1360  //! SeqSource header writer
1361  void write(XMLWriter& xml, const std::string& path, const SeqSource_t& param)
1362  {
1363  push(xml, path);
1364 
1365  int version = 2;
1366  write(xml, "version", version);
1367  xml << param.seqsrc.xml;
1368 
1369  pop(xml);
1370  }
1371 
1372 
1373  // MakeSourceProp writer
1374  void write(XMLWriter& xml, const std::string& path, const MakeSourceProp_t& param)
1375  {
1376  push(xml, path);
1377 
1378  int version = 1;
1379  write(xml, "version", version);
1380  write(xml, "PropSource", param.source_header);
1381  write(xml, "Config_info", param.gauge_header);
1382 
1383  pop(xml);
1384  }
1385 
1386 
1387  // Propagator writer
1388  void write(XMLWriter& xml, const std::string& path, const Propagator_t& param)
1389  {
1390  push(xml, path);
1391 
1392  int version = 1;
1393  write(xml, "version", version);
1394  write(xml, "ForwardProp", param.prop_header);
1395  write(xml, "PropSource", param.source_header);
1396  write(xml, "Config_info", param.gauge_header);
1397 
1398  pop(xml);
1399  }
1400 
1401 
1402  // ForwardProp writer
1403  void write(XMLWriter& xml, const std::string& path, const ForwardProp_t& param)
1404  {
1405 // if( path != "." )
1406  push(xml, path);
1407 
1408  int version = 1;
1409  write(xml, "version", version);
1410  write(xml, "PropSink", param.sink_header);
1411  write(xml, "ForwardProp", param.prop_header);
1412  write(xml, "PropSource", param.source_header);
1413  write(xml, "Config_info", param.gauge_header);
1414 
1415 // if( path != "." )
1416  pop(xml);
1417  }
1418 
1419 
1420  //! SequentialSource header writer
1421  void write(XMLWriter& xml, const std::string& path, const SequentialSource_t& param)
1422  {
1423 // if( path != "." )
1424  push(xml, path);
1425 
1426  int version = 1;
1427  write(xml, "version", version);
1428  write(xml, "SeqSourceSinkSmear", param.sink_header);
1429  write(xml, "SeqSource", param.seqsource_header);
1430  write(xml, "ForwardProps", param.forward_props);
1431  write(xml, "Config_info", param.gauge_header);
1432 
1433 // if( path != "." )
1434  pop(xml);
1435  }
1436 
1437 
1438  //! SequentialProp header writer
1439  void write(XMLWriter& xml, const std::string& path, const SequentialProp_t& param)
1440  {
1441 // if( path != "." )
1442  push(xml, path);
1443 
1444  int version = 1;
1445  write(xml, "version", version);
1446  write(xml, "SeqProp", param.seqprop_header);
1447  write(xml, "SeqSourceSinkSmear", param.sink_header);
1448  write(xml, "SeqSource", param.seqsource_header);
1449  write(xml, "ForwardProps", param.forward_props);
1450  write(xml, "Config_info", param.gauge_header);
1451 
1452 // if( path != "." )
1453  pop(xml);
1454  }
1455 
1456 
1457  //! Source/sink spin indices
1458  void write(XMLWriter& xml, const std::string& path, const QQQSpinIndices_t& input)
1459  {
1460  push(xml, path);
1461 
1462  write(xml, "source", input.source);
1463  write(xml, "sink", input.sink);
1464 
1465  pop(xml);
1466  }
1467 
1468 
1469  //! QQDiquark header writer
1470  void write(XMLWriter& xml, const std::string& path, const QQDiquark_t& param)
1471  {
1472  if( path != "." )
1473  push(xml, path);
1474 
1475  int version = 1;
1476  write(xml, "version", version);
1477  write(xml, "Dirac_basis", param.Dirac_basis);
1478  write(xml, "ForwardProps", param.forward_props);
1479 
1480  if( path != "." )
1481  pop(xml);
1482  }
1483 
1484 
1485  //! QQQBarcomp header writer
1486  void write(XMLWriter& xml, const std::string& path, const QQQBarcomp_t& param)
1487  {
1488  if( path != "." )
1489  push(xml, path);
1490 
1491  int version = 3;
1492  write(xml, "version", version);
1493  write(xml, "sparseP", param.sparseP);
1494  write(xml, "Dirac_basis", param.Dirac_basis);
1495  if (param.sparseP)
1496  {
1497  write(xml, "SpinIndices", param.spin_indices);
1498  }
1499  write(xml, "ForwardProps", param.forward_props);
1500 
1501  if( path != "." )
1502  pop(xml);
1503  }
1504 
1505 
1506  //! QQbarMescomp header writer
1507  void write(XMLWriter& xml, const std::string& path, const QQbarMescomp_t& param)
1508  {
1509  if( path != "." )
1510  push(xml, path);
1511 
1512  int version = 2;
1513  write(xml, "version", version);
1514  write(xml, "Dirac_basis", param.Dirac_basis);
1515  write(xml, "ForwardProps", param.forward_props);
1516 
1517  if( path != "." )
1518  pop(xml);
1519  }
1520 
1521 
1522 
1523  // Write a Chroma propagator
1524  /*
1525  * \param file_xml file header ( Read )
1526  * \param record_xml xml holding propagator info ( Read )
1527  * \param quark_prop propagator ( Read )
1528  * \param file path ( Read )
1529  * \param volfmt either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
1530  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1531  */
1532  void writeQprop(XMLBufferWriter& file_xml,
1533  XMLBufferWriter& record_xml, const LatticePropagator& quark_prop,
1534  const std::string& file,
1535  QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
1536  {
1537  QDPFileWriter to(file_xml,file,volfmt,serpar,QDPIO_OPEN);
1538  write(to,record_xml,quark_prop);
1539  close(to);
1540  }
1541 
1542 
1543  // Write a Chroma propagator
1544  /*
1545  * \param file_xml file header ( Read )
1546  * \param header structure holding propagator info ( Read )
1547  * \param quark_prop propagator ( Read )
1548  * \param file path ( Read )
1549  * \param volfmt either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
1550  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1551  */
1552  void writeQprop(XMLBufferWriter& file_xml,
1553  const ChromaProp_t& header, const LatticePropagator& quark_prop,
1554  const std::string& file,
1555  QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
1556  {
1557  XMLBufferWriter record_xml;
1558  write(record_xml, "Propagator", header);
1559  writeQprop(file_xml, record_xml, quark_prop, file, volfmt, serpar);
1560  }
1561 
1562 
1563 
1564 
1565  // Read a Chroma propagator
1566  /*
1567  * \param file_xml file header ( Write )
1568  * \param record_xml xml holding propagator info ( Write )
1569  * \param quark_prop propagator ( Write )
1570  * \param file path ( Read )
1571  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1572  */
1573  void readQprop(XMLReader& file_xml,
1574  XMLReader& record_xml, LatticePropagator& quark_prop,
1575  const std::string& file,
1576  QDP_serialparallel_t serpar)
1577  {
1578  QDPFileReader to(file_xml,file,serpar);
1579  read(to,record_xml,quark_prop);
1580  close(to);
1581  }
1582 
1583  // Read a Chroma propagator
1584  /*
1585  * \param file_xml file header ( Write )
1586  * \param header structure holding propagator info ( Write )
1587  * \param quark_prop propagator ( Write )
1588  * \param file path ( Read )
1589  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1590  */
1591  void readQprop(XMLReader& file_xml,
1592  ChromaProp_t& header, LatticePropagator& quark_prop,
1593  const std::string& file,
1594  QDP_serialparallel_t serpar)
1595  {
1596  XMLReader record_xml;
1597  readQprop(file_xml, record_xml, quark_prop, file, serpar);
1598  read(record_xml, "/Propagator", header); // extract header from xml
1599  }
1600 
1601 
1602 
1603 
1604  // Write a Chroma Fermion Field (eg prop_component)
1605  /*
1606  * \param file_xml file header ( Read )
1607  * \param record_xml xml holding propagator info ( Read )
1608  * \param fermion fermion field( Read )
1609  * \param file path ( Read )
1610  * \param volfmt either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
1611  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1612  */
1613  void writeFermion(XMLBufferWriter& file_xml,
1614  XMLBufferWriter& record_xml, const LatticeFermion& fermion,
1615  const std::string& file,
1616  QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
1617  {
1618  QDPFileWriter to(file_xml,file,volfmt,serpar,QDPIO_OPEN);
1619  write(to,record_xml,fermion);
1620  close(to);
1621  }
1622 
1623  // Read a Chroma Fermion Field
1624  /*
1625  * \param file_xml file header ( Write )
1626  * \param record_xml xml holding propagator info ( Write )
1627  * \param fermion The Fermion ( Write )
1628  * \param file path ( Read )
1629  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
1630  */
1631  void readFermion(XMLReader& file_xml,
1632  XMLReader& record_xml,
1633  LatticeFermion& fermion,
1634  const std::string& file,
1635  QDP_serialparallel_t serpar)
1636  {
1637  QDPFileReader to(file_xml,file,serpar);
1638  read(to,record_xml,fermion);
1639  close(to);
1640  }
1641 
1642 } // end namespace Chroma
1643 
Primary include file for CHROMA library code.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Real kappaToMass(const Real &Kappa)
Convert a Kappa to a mass.
Definition: param_io.cc:12
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
multi1d< int > t_srce
Nd
Definition: meslate.cc:74
std::string getName()
Return the name.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
Real getMass(const GroupXML_t &fermact)
Given a fermion action in std::string form, return the Mass.
Definition: qprop_io.cc:16
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
void readQprop(XMLReader &file_xml, XMLReader &record_xml, LatticePropagator &quark_prop, const std::string &file, QDP_serialparallel_t serpar)
Read a Chroma propagator.
Definition: qprop_io.cc:1573
void writeQprop(XMLBufferWriter &file_xml, XMLBufferWriter &record_xml, const LatticePropagator &quark_prop, const std::string &file, QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
Write a Chroma propagator.
Definition: qprop_io.cc:1532
multi1d< int > getFermActBoundary(const GroupXML_t &fermact)
Given a fermion action in std::string form, return the boundary.
Definition: qprop_io.cc:61
pop(xml_out)
void readFermion(XMLReader &file_xml, XMLReader &record_xml, LatticeFermion &fermion, const std::string &file, QDP_serialparallel_t serpar)
Definition: qprop_io.cc:1631
void writeFermion(XMLBufferWriter &file_xml, XMLBufferWriter &record_xml, const LatticeFermion &fermion, const std::string &file, QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
Definition: qprop_io.cc:1613
void readGaugeHeader(XMLReader &paramtop, const std::string &path, std::string &gauge_header)
Definition: qprop_io.cc:1069
::std::string string
Definition: gtest.h:1979
Various parameter structs and reader/writers.
Routines associated with Chroma propagator IO.
Simple quark displacement.
Multi-propagator parameters.
Definition: qprop_io.h:61
QuarkSpinType quarkSpinType
Definition: qprop_io.h:63
GroupXML_t fermact
String holding XML of the FermionAction section.
Definition: qprop_io.h:66
multi1d< Real > MultiMasses
Definition: qprop_io.h:69
Propagator parameters.
Definition: qprop_io.h:75
GroupXML_t invParam
Definition: qprop_io.h:84
GroupXML_t fermact
Definition: qprop_io.h:80
QuarkSpinType quarkSpinType
Definition: qprop_io.h:77
Mega structure holding a full forward sink-smeared prop.
Definition: qprop_io.h:120
ChromaProp_t prop_header
Definition: qprop_io.h:122
PropSinkSmear_t sink_header
Definition: qprop_io.h:121
PropSourceConst_t source_header
Definition: qprop_io.h:123
std::string gauge_header
Definition: qprop_io.h:124
Hold group xml and type id.
Mega structure holding a propagator source.
Definition: qprop_io.h:103
std::string gauge_header
Definition: qprop_io.h:105
PropSourceConst_t source_header
Definition: qprop_io.h:104
Sink-smearing parameters.
Definition: qprop_io.h:51
Propagator source construction parameters.
Definition: qprop_io.h:27
multi1d< int > getMom() const
Definition: qprop_io.cc:161
multi1d< int > getTSrce() const
Definition: qprop_io.cc:120
Source-smearing parameters.
Definition: qprop_io.h:42
Mega structure holding a full forward prop (not sink smeared)
Definition: qprop_io.h:111
ChromaProp_t prop_header
Definition: qprop_io.h:112
std::string gauge_header
Definition: qprop_io.h:114
PropSourceConst_t source_header
Definition: qprop_io.h:113
Mega structure holding QQ diquark object.
Definition: qprop_io.h:171
multi1d< ForwardProp_t > forward_props
Definition: qprop_io.h:174
Mega structure holding QQQ props.
Definition: qprop_io.h:180
multi1d< ForwardProp_t > forward_props
Definition: qprop_io.h:185
multi1d< QQQSpinIndices_t > spin_indices
Definition: qprop_io.h:182
Hold source and sink spin indices for a sparse QQQ file.
Definition: qprop_io.h:163
multi1d< int > sink
Definition: qprop_io.h:165
multi1d< int > source
Definition: qprop_io.h:164
Mega structure holding QQbar props.
Definition: qprop_io.h:191
multi1d< ForwardProp_t > forward_props
Definition: qprop_io.h:194
Sequential source parameters.
Definition: qprop_io.h:90
multi1d< int > sink_mom
Definition: qprop_io.h:95
GroupXML_t seqsrc
Definition: qprop_io.h:93
Mega structure holding a full sequential prop.
Definition: qprop_io.h:140
ChromaProp_t seqprop_header
Definition: qprop_io.h:141
PropSinkSmear_t sink_header
Definition: qprop_io.h:142
multi1d< ForwardProp_t > forward_props
Definition: qprop_io.h:144
std::string gauge_header
Definition: qprop_io.h:145
SeqSource_t seqsource_header
Definition: qprop_io.h:143
Mega structure holding a full sequential source.
Definition: qprop_io.h:130
PropSinkSmear_t sink_header
Definition: qprop_io.h:131
multi1d< ForwardProp_t > forward_props
Definition: qprop_io.h:133
SeqSource_t seqsource_header
Definition: qprop_io.h:132
std::string gauge_header
Definition: qprop_io.h:134