CHROMA
readszinferm_w.cc
Go to the documentation of this file.
1 /*!
2  * @file
3  * @brief Read an old SZIN-style (checkerboarded) lattice Dirac fermion
4  */
5 
6 #include "chromabase.h"
7 #include "io/readszinferm_w.h"
8 
9 #include "qdp_util.h" // from QDP++
10 
11 namespace Chroma {
12 
13 //! Read a SZIN fermion. This is a simple memory dump reader.
14 /*!
15  * \ingroup io
16  *
17  * \param q lattice fermion ( Modify )
18  * \param file path ( Read )
19  */
20 
21 void readSzinFerm(LatticeFermion& q, const std::string& file)
22 {
23  BinaryFileReader cfg_in(file);
24 
25 #if 1
26  multi1d<DFermion> sitebuf_prec(Layout::vol()); // Buffer for a fermion
27  multi1d<Fermion> sitebuf(Layout::vol());
28 
29  read(cfg_in, sitebuf_prec, Layout::vol());
30 
31  /* Downcast here unfortunately Fermion s(DFermion x) doesn't work
32  only DFermion s(Fermion x) */
33  /* However, since I am not doing any site peeking, perhaps this will
34  be OK */
35 
36  for(int site=0; site < Layout::vol(); site++) {
37  DFermion site_tmp_d = sitebuf_prec[site];
38  Fermion site_tmp_r;
39 
40  for(int spin=0; spin < Ns; spin++) {
41  DColorVector d_col_vec;
42  ColorVector col_vec;
43 
44  d_col_vec = peekSpin(site_tmp_d, spin);
45  for(int color=0; color < Nc; color++) {
46  DComplex elem = peekColor(d_col_vec, color);
47  Double elem_re = real(elem);
48  Double elem_im = imag(elem);
49 
50  Complex elem_r = cmplx(Real(elem_re), Real(elem_im));
51  pokeColor(col_vec, elem_r, color);
52  }
53  pokeSpin(site_tmp_r, col_vec, spin);
54  }
55  sitebuf[site] = site_tmp_r;
56  }
57  // sitebuf_prec no longer needed. Free up memory
58  sitebuf_prec.resize(0);
59 
60  /* Now get out of lexicographic order */
61  multi1d<int> lattsize_cb = Layout::lattSize();
62  lattsize_cb[0] /= 2; // checkerboard in the x-direction in szin
63 
64  int index = 0;
65  for(int cb=0; cb < 2; ++cb)
66  {
67  for(int sitecb=0; sitecb < Layout::vol()/2; ++sitecb)
68  {
69  multi1d<int> coord = crtesn(sitecb, lattsize_cb);
70 
71  // construct the checkerboard offset
72  int sum = 0;
73  for(int m=1; m<Nd; m++) {
74  sum += coord[m];
75  }
76  // The true lattice x-coord
77  coord[0] = 2*coord[0] + ((sum + cb) & 1);
78 
79  pokeSite(q, sitebuf[index++], coord);
80 
81  }
82  }
83 
84 #endif
85 
86  cfg_in.close();
87 }
88 
89 } // end namespace Chroma
Primary include file for CHROMA library code.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void readSzinFerm(LatticeFermion &q, const std::string &file)
Read a SZIN fermion. This is a simple memory dump reader.
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
int cb
Definition: invbicg.cc:120
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Double sum
Definition: qtopcor.cc:37
Read an old SZIN-style (checkerboarded) lattice Dirac fermion.
#define index(c)