CHROMA
inline_rng.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline task to read and write RNG seed
3  */
4 
5 #include "chromabase.h"
8 
9 namespace Chroma
10 {
11  namespace InlineSetRNGEnv
12  {
13  namespace
14  {
15  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
16  const std::string& path)
17  {
18  return new InlineMeas(Params(xml_in, path));
19  }
20 
21  //! Local registration flag
22  bool registered = false;
23  }
24 
25  const std::string name = "SET_RNG";
26 
27  //! Register all the factories
28  bool registerAll()
29  {
30  bool success = true;
31  if (! registered)
32  {
33  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
34  registered = true;
35  }
36  return success;
37  }
38  // Param stuff
40 
41  Params::Params(XMLReader& xml_in, const std::string& path)
42  {
43  try
44  {
45  XMLReader paramtop(xml_in, path);
46 
47  if (paramtop.count("Frequency") == 1)
48  read(paramtop, "Frequency", frequency);
49  else
50  frequency = 1;
51 
52  // Parameters for source construction
53  read(paramtop, "RNG", ran_seed);
54  }
55  catch(const std::string& e)
56  {
57  QDPIO::cerr << __func__ << ": caught Exception reading XML: " << e << std::endl;
58  QDP_abort(1);
59  }
60  }
61 
62 
63  void
64  Params::writeXML(XMLWriter& xml_out, const std::string& path)
65  {
66  push(xml_out, path);
67 
68  // Parameters for source construction
69  write(xml_out, "RNG", ran_seed);
70 
71  pop(xml_out);
72  }
73 
74 
75  void
76  InlineMeas::operator()(unsigned long update_no, XMLWriter& xml_out)
77  {
78  START_CODE();
79 
80  push(xml_out, "SetRNG");
81  write(xml_out, "update_no", update_no);
82 
83  // Set the RNG seed
85  write(xml_out,"RNG", params.ran_seed);
86 
87  QDPIO::cout << name << ": ran successfully" << std::endl;
88 
89  pop(xml_out); // read_named_obj
90 
91  END_CODE();
92  }
93 
94  }
95 }
Inline measurement factory.
Primary include file for CHROMA library code.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
Definition: inline_rng.cc:76
static T & Instance()
Definition: singleton.h:432
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.
Inline task to read and write RNG seed.
void setrn(int iseed[4])
Definition: make_seeds.cc:38
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
Definition: inline_rng.cc:28
const std::string name
Definition: inline_rng.cc:25
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
Parameter structure.
Definition: inline_rng.h:22
void writeXML(XMLWriter &xml_out, const std::string &path)
Definition: inline_rng.cc:64