CHROMA
gauge_io.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Routines associated with Chroma propagator gauge IO
3  */
4 
5 #include "chromabase.h"
6 #include "io/gauge_io.h"
7 
8 namespace Chroma {
9 
10 
11 // Read a Chroma propagator
12 /*
13  * \param file_xml xml reader holding config info ( Modify )
14  * \param record_xml xml reader holding config info ( Modify )
15  * \param u gauge configuration ( Modify )
16  * \param file path ( Read )
17  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
18  */
19 void readGauge(XMLReader& file_xml,
20  XMLReader& record_xml,
21  multi1d<LatticeColorMatrix>& u,
22  const std::string& file,
23  QDP_serialparallel_t serpar)
24 {
25  QDPFileReader to(file_xml,file,serpar);
26 
27  /*
28  * This is problematic - the size should
29  * come from the read - a resize. Currently, QDPIO does not
30  * support this
31  */
32 #if 0
33  multi1d<LatticeColorMatrixF> u_f(u.size());
34  read(to, record_xml, u_f); // Always read in single precision
35 #endif
36  read(to,record_xml,u);
37  if (to.bad())
38  {
39  QDPIO::cerr << __func__ << ": error reading file " << file << std::endl;
40  QDP_abort(1);
41  }
42 
43 #if 0
44  for(int mu=0; mu < u.size(); ++mu)
45  u[mu] = u_f[mu];
46 #endif
47  close(to);
48 }
49 
50 
51 // Write a Gauge field in QIO format
52 /*
53  * \param file_xml xml reader holding config info ( Modify )
54  * \param record_xml xml reader holding config info ( Modify )
55  * \param u gauge configuration ( Modify )
56  * \param file path ( Read )
57  * \param volfmt either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
58  * \param serpar either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
59  */
60 void writeGauge(XMLBufferWriter& file_xml,
61  XMLBufferWriter& record_xml,
62  const multi1d<LatticeColorMatrix>& u,
63  const std::string& file,
64  QDP_volfmt_t volfmt,
65  QDP_serialparallel_t serpar)
66 {
67  QDPFileWriter to(file_xml,file,volfmt,serpar,QDPIO_OPEN);
68  if (to.bad())
69  {
70  QDPIO::cerr << __func__ << ": error writing file " << file << std::endl;
71  QDP_abort(1);
72  }
73 
74 #if 0
75  multi1d<LatticeColorMatrixF> u_f(u.size());
76  for(int mu=0; mu < u.size(); ++mu)
77  u_f[mu] = u[mu];
78 
79  write(to,record_xml,u_f); // Always save in single precision!
80 #endif
81  write(to, record_xml, u); // Write in native precision
82  close(to);
83 }
84 
85 
86 } // end namespace Chroma
87 
88 
Primary include file for CHROMA library code.
int mu
Definition: cool.cc:24
Gauge reader/writers in QIO format.
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 readGauge(XMLReader &file_xml, XMLReader &record_xml, multi1d< LatticeColorMatrix > &u, const std::string &file, QDP_serialparallel_t serpar)
Read a gauge config in QIO format.
Definition: gauge_io.cc:19
void writeGauge(XMLBufferWriter &file_xml, XMLBufferWriter &record_xml, const multi1d< LatticeColorMatrix > &u, const std::string &file, QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
Write a gauge config in QIO format.
Definition: gauge_io.cc:60
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
::std::string string
Definition: gtest.h:1979