CHROMA
readszinqprop_w.cc
Go to the documentation of this file.
1 /*!
2  * @file
3  * @brief Read an old SZIN-style (checkerboarded) quark propagator
4  */
5 
6 #include "chromabase.h"
7 #include "io/readszinqprop_w.h"
8 
9 #include "qdp_util.h" // from QDP++
10 
11 #include <iostream>
12 #include <string>
13 #include <sstream>
14 
15 namespace Chroma {
16 
17 //! Read a SZIN propagator file. This is a simple memory dump reader.
18 /*!
19  * \ingroup io
20  *
21  * \param xml xml reader holding prop info ( Modify )
22  * \param q propagator ( Modify )
23  * \param file path ( Read )
24  */
25 
26 void readSzinQprop(XMLReader& xml, LatticePropagator& q, const std::string& file)
27 {
28  BinaryFileReader cfg_in(file);
29 
30  //
31  // Read propagator field
32  //
33  multi1d<int> lattsize_cb = Layout::lattSize();
34  Real Kappa;
35 
36  lattsize_cb[0] /= 2; // checkerboard in the x-direction in szin
37 
38  // Read Kappa
39  read(cfg_in, Kappa);
40 
41  // Read prop
42  LatticePropagator q_old;
43 
44  for(int cb=0; cb < 2; ++cb)
45  {
46  for(int sitecb=0; sitecb < Layout::vol()/2; ++sitecb)
47  {
48  multi1d<int> coord = crtesn(sitecb, lattsize_cb);
49 
50  // construct the checkerboard offset
51  int sum = 0;
52  for(int m=1; m<Nd; m++)
53  sum += coord[m];
54 
55  // The true lattice x-coord
56  coord[0] = 2*coord[0] + ((sum + cb) & 1);
57 
58  read(cfg_in, q_old, coord); // Read in a site propagator
59  }
60  }
61 
62  q = transpose(q_old); // take the transpose
63 
64  cfg_in.close();
65 
66 
67  // Now, set up the XML header. Do this by first making a buffer
68  // writer that is then used to make the reader
69  XMLBufferWriter xml_buf;
70 
71  push(xml_buf, "szin_prop");
72  write(xml_buf,"Kappa",Kappa);
73  pop(xml_buf);
74 
75  try
76  {
77  // Temporary XLC failure workaround
78 #if 0
79  xml.open(xml_buf);
80 #else
81  const std::string bufcontent=xml_buf.str() + "\n";
82  std::istringstream is(bufcontent);
83  xml.open(is);
84 #endif
85 
86  }
87  catch(const std::string& e)
88  {
89  QDP_error_exit("Error in readszinqprop: %s",e.c_str());
90  }
91 
92 }
93 
94 //! Write a SZIN propagator file. This is a simple memory dump writer.
95 /*!
96  * \ingroup io
97  *
98  * \param q propagator ( Read )
99  * \param file path ( Read )
100  * \param kappa kappa value (Read)
101  */
102 
103 void writeSzinQprop(const LatticePropagator& q, const std::string& file,
104  const Real kappa)
105 {
106  BinaryFileWriter cfg_out(file);
107 
108  //
109  // Read propagator field
110  //
111  multi1d<int> lattsize_cb = Layout::lattSize();
112 
113  lattsize_cb[0] /= 2; // checkerboard in the x-direction in szin
114 
115  // Write Kappa
116  write(cfg_out, kappa);
117 
118  // Write prop
119  LatticePropagator q_old = transpose(q); // take the transpose
120 
121  for(int cb=0; cb < 2; ++cb)
122  {
123  for(int sitecb=0; sitecb < Layout::vol()/2; ++sitecb)
124  {
125  multi1d<int> coord = crtesn(sitecb, lattsize_cb);
126 
127  // construct the checkerboard offset
128  int sum = 0;
129  for(int m=1; m<Nd; m++)
130  sum += coord[m];
131 
132  // The true lattice x-coord
133  coord[0] = 2*coord[0] + ((sum + cb) & 1);
134 
135  write(cfg_out, q_old, coord); // write out a single site
136  }
137  }
138 
139  cfg_out.close();
140 }
141 
142 } // end namespace Chroma
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.
void readSzinQprop(XMLReader &xml, LatticePropagator &q, const std::string &file)
Read a SZIN propagator file. This is a simple memory dump reader.
void writeSzinQprop(const LatticePropagator &q, const std::string &file, const Real kappa)
Write a SZIN propagator file. This is a simple memory dump writer.
static int m[4]
Definition: make_seeds.cc:16
multi1d< int > coord(Nd)
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
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)
void transpose(multi2d< LatticeColorVector > &dist_rep, const multi2d< LatticeColorVector > &prop_rep)
Take transpose of a matrix in (explicit) spin space.
push(xml_out,"Condensates")
pop(xml_out)
int cb
Definition: invbicg.cc:120
::std::string string
Definition: gtest.h:1979
int kappa
Definition: pade_trln_w.cc:112
Double sum
Definition: qtopcor.cc:37
Read a SZIN propagator.