CHROMA
inline_qpropqio_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline measurement of qpropqio
3  *
4  * Form-factor measurements
5  */
6 
9 #include "meas/glue/mesplq.h"
10 #include "util/ft/sftmom.h"
11 #include "util/info/proginfo.h"
13 #include "io/qprop_io.h"
14 
15 namespace Chroma
16 {
17  namespace InlineQpropQIOEnv
18  {
19  namespace
20  {
21  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
22  const std::string& path)
23  {
24  return new InlineQpropQIO(InlineQpropQIOParams(xml_in, path));
25  }
26 
27  //! Local registration flag
28  bool registered = false;
29  }
30 
31  const std::string name = "QPROPQIO";
32 
33  //! Register all the factories
34  bool registerAll()
35  {
36  bool success = true;
37  if (! registered)
38  {
39  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
40  registered = true;
41  }
42  return success;
43  }
44  }
45 
46 
47  //! Propagator parameters
48  void read(XMLReader& xml, const std::string& path, InlineQpropQIOParams::Prop_t& input)
49  {
50  XMLReader inputtop(xml, path);
51 
52  read(inputtop, "prop_in_file", input.prop_in_file);
53  read(inputtop, "prop_out_file", input.prop_out_file);
54  read(inputtop, "prop_out_volfmt", input.prop_out_volfmt);
55  }
56 
57  //! Propagator parameters
58  void write(XMLWriter& xml, const std::string& path, const InlineQpropQIOParams::Prop_t& input)
59  {
60  push(xml, path);
61 
62  write(xml, "prop_in_file", input.prop_in_file);
63  write(xml, "prop_out_file", input.prop_out_file);
64  write(xml, "prop_out_volfmt", input.prop_out_volfmt);
65 
66  pop(xml);
67  }
68 
69 
70  // Reader for input parameters
71  void read(XMLReader& xml, const std::string& path, InlineQpropQIOParams::Param_t& param)
72  {
73  XMLReader paramtop(xml, path);
74 
75  int version;
76  read(paramtop, "version", version);
77 
78  switch (version)
79  {
80  case 1:
81  /**************************************************************************/
82  break;
83 
84  default :
85  /**************************************************************************/
86 
87  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
88  QDP_abort(1);
89  }
90  }
91 
92 
93  // Reader for input parameters
94  void write(XMLWriter& xml, const std::string& path, const InlineQpropQIOParams::Param_t& param)
95  {
96  push(xml, path);
97 
98  int version = 1;
99 
100  write(xml, "version", version);
101 
102  pop(xml);
103  }
104 
105 
106  // Param stuff
108 
110  {
111  try
112  {
113  XMLReader paramtop(xml_in, path);
114 
115  if (paramtop.count("Frequency") == 1)
116  read(paramtop, "Frequency", frequency);
117  else
118  frequency = 1;
119 
120  // Parameters for source construction
121  read(paramtop, "Param", param);
122 
123  // Read in the output propagator/source configuration info
124  read(paramtop, "Prop", prop);
125  }
126  catch(const std::string& e)
127  {
128  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
129  QDP_abort(1);
130  }
131  }
132 
133 
134  void
135  InlineQpropQIOParams::write(XMLWriter& xml_out, const std::string& path)
136  {
137  push(xml_out, path);
138 
139  // Parameters for source construction
140  Chroma::write(xml_out, "Param", param);
141 
142  // Write out the output propagator/source configuration info
143  Chroma::write(xml_out, "Prop", prop);
144 
145  pop(xml_out);
146  }
147 
148  //--------------------------------------------------------------
149 
150 
151  // Function call
152  void
153  InlineQpropQIO::operator()(unsigned long update_no,
154  XMLWriter& xml_out)
155  {
156  START_CODE();
157 
158  push(xml_out, "qpropqio");
159  write(xml_out, "update_no", update_no);
160 
161  QDPIO::cout << "QPROPQIO: propagator transformation utility" << std::endl;
162 
163  proginfo(xml_out); // Print out basic program info
164 
165  // Write out the input
166  params.write(xml_out, "Input");
167 
168 
169  /*
170  * Now read them thangs...
171  * NOTE: only SCIDAC format is allowed !!!
172  */
173  XMLReader prop_in_record_xml, prop_in_file_xml;
174  LatticePropagator prop;
175  readQprop(prop_in_file_xml, prop_in_record_xml, prop,
176  params.prop.prop_in_file, QDPIO_SERIAL);
177 
178  push(xml_out,"SciDAC_propagator");
179  write(xml_out, "File_xml", prop_in_file_xml);
180  write(xml_out, "Record_xml", prop_in_record_xml);
181  pop(xml_out);
182 
183  // Sanity check - write out the propagator (pion) correlator in the Nd-1 direction
184  {
185  // Initialize the slow Fourier transform phases
186  SftMom phases(0, true, Nd-1);
187 
188  multi1d<Double> prop_corr = sumMulti(localNorm2(prop),
189  phases.getSet());
190 
191  push(xml_out, "Prop_correlator");
192  write(xml_out, "prop_corr", prop_corr);
193  pop(xml_out);
194  }
195 
196  /*
197  * Now write them thangs...
198  */
199  {
200  XMLBufferWriter prop_out_file_xml;
201  prop_out_file_xml << prop_in_file_xml;
202 
203  XMLBufferWriter prop_out_record_xml;
204  prop_out_record_xml << prop_in_record_xml;
205 
206  // Write the source
207  writeQprop(prop_out_file_xml, prop_out_record_xml, prop,
209  QDPIO_SERIAL);
210  }
211 
212  pop(xml_out); // qpropqio
213 
214  QDPIO::cout << "QpropQIO ran successfully" << std::endl;
215 
216  END_CODE();
217  }
218 
219 }
Inline measurement factory.
Inline task for quark prop IO.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
InlineQpropQIOParams params
Fourier transform phase factor support.
Definition: sftmom.h:35
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
QDP volfmt enum.
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.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::map< std::string, SinkPropContainer_t > prop
Inline measurement of qpropqio.
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
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
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
Print out basic info about this program.
Routines associated with Chroma propagator IO.
Fourier transform phase factor support.
struct Chroma::InlineQpropQIOParams::Param_t param
void write(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineQpropQIOParams::Prop_t prop