CHROMA
kyugauge_io.cc
Go to the documentation of this file.
1 
2 /*! \file
3  * \brief Read/write a Kentucky gauge configuration
4  */
5 
6 #include "chromabase.h"
7 #include "io/kyugauge_io.h"
8 
9 namespace Chroma {
10 
11 
12 //! Read a Kentucky gauge configuration
13 /*!
14  * \ingroup io
15  *
16  * \param u gauge configuration ( Modify )
17  * \param cfg_file path ( Read )
18  */
19 
20 void readKYU(multi1d<LatticeColorMatrix>& u, const std::string& cfg_file)
21 {
22  START_CODE();
23 
24  if (Nc != 3)
25  {
26  QDPIO::cerr << "readKYU - only supports Nc=3" << std::endl;
27  QDP_abort(1);
28  }
29 
30  BinaryFileReader cfg_in(cfg_file);
31 
32  /* According to Shao Jing the UK config format is:
33 
34  u( nxyzt, nri, nc, nc, nd )
35 
36  in the Fortran way -- so that means nxyzt changes fastest.
37 
38  and nxyzt goes as x + (y-1)*nx + ...
39  so that x changes fastest than y than z than t.
40 
41  The words are d.p. -- 8 bytes -- or REAL64
42  */
43  LatticeRealD re, im;
44 
45  for(int mu=0; mu < Nd; ++mu)
46  for(int col=0; col < 3; ++col)
47  for(int row=0; row < 3; ++row)
48  {
49  read(cfg_in, re);
50  read(cfg_in, im);
51 
52  pokeColor(u[mu],
53  cmplx(LatticeReal(re),LatticeReal(im)),
54  row, col);
55  }
56 
57  cfg_in.close();
58 
59  END_CODE();
60 }
61 
62 
63 //! Write a Kentucky gauge configuration
64 /*!
65  * \ingroup io
66  *
67  * \param u gauge configuration ( Read )
68  * \param cfg_file path ( Read )
69  */
70 
71 void writeKYU(const multi1d<LatticeColorMatrix>& u, const std::string& cfg_file)
72 {
73  START_CODE();
74 
75  if (Nc != 3)
76  {
77  QDPIO::cerr << "writeKYU - only supports Nc=3" << std::endl;
78  QDP_abort(1);
79  }
80 
81  BinaryFileWriter cfg_out(cfg_file);
82 
83  /* According to Shao Jing the UK config format is:
84 
85  u( nxyzt, nri, nc, nc, nd )
86 
87  in the Fortran way -- so that means nxyzt changes fastest.
88 
89  and nxyzt goes as x + (y-1)*nx + ...
90  so that x changes fastest than y than z than t.
91 
92  The words are d.p. -- 8 bytes -- or REAL64
93  */
94  LatticeComplexD lc;
95  LatticeRealD re, im;
96 
97  for(int mu=0; mu < Nd; ++mu)
98  for(int col=0; col < 3; ++col)
99  for(int row=0; row < 3; ++row)
100  {
101  lc = peekColor(u[mu], row, col);
102  re = real(lc);
103  im = imag(lc);
104 
105  write(cfg_out, re);
106  write(cfg_out, im);
107  }
108 
109  cfg_out.close();
110 
111  END_CODE();
112 }
113 
114 
115 } // end namespace Chroma
Primary include file for CHROMA library code.
int mu
Definition: cool.cc:24
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 writeKYU(const multi1d< LatticeColorMatrix > &u, const std::string &cfg_file)
Write a Kentucky gauge configuration.
Definition: kyugauge_io.cc:71
void readKYU(multi1d< LatticeColorMatrix > &u, const std::string &cfg_file)
Read a Kentucky gauge configuration.
Definition: kyugauge_io.cc:20
Read/write a KYU gauge configuration.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
multi1d< LatticeComplex > lc(Ncb)
START_CODE()
::std::string string
Definition: gtest.h:1979