Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gaugeConfig.cpp
Go to the documentation of this file.
1 
14 #include "gaugeConfig.h"
15 
16 #include "commonParameters.h"
17 #include "communicator.h"
18 #include "bridgeIO.h"
19 using Bridge::vout;
20 
21 #include "field.h"
22 #include "mat_SU_N.h"
23 
24 #include "fieldIO.h"
25 #include "fieldIO_Text.h"
26 #include "fieldIO_Text_4x4x4x8.h"
27 #include "fieldIO_Binary.h"
29 #include "fieldIO_Fortran.h"
30 #include "fieldIO_LIME.h"
31 #include "fieldIO_LIME_MPIIO.h"
32 #include "io_format.h"
33 #include "io_format_gauge.h"
34 
35 const std::string GaugeConfig::class_name = "GaugeConfig";
36 
37 //====================================================================
38 GaugeConfig::GaugeConfig(const string& type)
39  : m_prefix(), m_postfix(), m_vl(CommonParameters::Vlevel()), m_fieldio()
40 {
41  if (type == "Text") {
43  } else if (type == "Text_4x4x4x8") {
45  } else if (type == "Binary") {
47  } else if (type == "Fortran_JLQCD") {
49  } else if (type == "Fortran_ILDG") {
51  } else if (type == "ILDG") {
53  } else if (type == "Binary_Parallel") {
55  } else if (type == "ILDG_Parallel") {
57  } else {
58  vout.crucial("GaugeConfig: unsupported type \"%s\".\n", type.c_str());
59  abort();
60  }
61 }
62 
63 
64 //====================================================================
66 {
67  if (m_fieldio) delete m_fieldio;
68  m_fieldio = 0;
69 }
70 
71 
72 //====================================================================
73 string GaugeConfig::config_filename(const int confnum)
74 {
75  const size_t filename_len = 256;
76  char buf[filename_len];
77 
78  snprintf(buf, filename_len, "%s%06d%s", m_prefix.c_str(), confnum, m_postfix.c_str());
79 
80  return string(buf);
81 }
82 
83 
84 //====================================================================
85 void GaugeConfig::read_file(Field *u, const string& filename)
86 {
87  if (!m_fieldio) {
88  vout.crucial("GaugeConfig::read_config(): FieldIO not set.");
89  abort();
90  }
91 
92  m_fieldio->read_file(u, filename);
93 }
94 
95 
96 //====================================================================
97 void GaugeConfig::write_file(Field *u, const string& filename)
98 {
99  if (!m_fieldio) {
100  vout.crucial("GaugeConfig::read_config(): FieldIO not set.");
101  abort();
102  }
103 
104  m_fieldio->write_file(u, filename);
105 }
106 
107 
108 //====================================================================
109 void GaugeConfig::read_config(Field *U, int confnum)
110 {
111  return read_file(U, config_filename(confnum));
112 }
113 
114 
115 //====================================================================
116 void GaugeConfig::write_config(Field *U, int confnum)
117 {
118  return write_file(U, config_filename(confnum));
119 }
120 
121 
122 //====================================================================
123 //============================================================END=====
static const std::string class_name
Definition: gaugeConfig.h:59
BridgeIO vout
Definition: bridgeIO.cpp:207
virtual ~GaugeConfig()
Definition: gaugeConfig.cpp:65
FieldIO_LIME class for file I/O of Field data in LIME format.
Definition: fieldIO_LIME.h:87
FieldIO * m_fieldio
Definition: gaugeConfig.h:97
Container of Field-type object.
Definition: field.h:37
FieldIO_Text class for file I/O of Field data in plain text format.
Definition: fieldIO_Text.h:33
GaugeConfig(const string &type)
Definition: gaugeConfig.cpp:38
const Format * ILDG
Definition: io_format.cpp:28
string m_prefix
Definition: gaugeConfig.h:95
FieldIO_Fortran class for file I/O of Field data in Fortran binary format.
FieldIO_Binary_Parallel class for file I/O of Field data in binary format using MPI parallel I/O...
FieldIO_Text class for file I/O of Field data in plain text format.
Common parameter class: provides parameters as singleton.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
const Format * JLQCD
Definition: io_format.cpp:29
void write_file(Field *u, const string &filename)
Definition: gaugeConfig.cpp:97
string m_postfix
Definition: gaugeConfig.h:95
void write_config(Field *U, int confnum)
FieldIO_Binary class for file I/O of Field data in binary format.
virtual void read_file(Field *v, std::string)=0
read data from file.
virtual void write_file(Field *v, std::string)=0
write data to file.
FieldIO_LIME_MPIIO class for file I/O of Field data in LIME format.
void read_config(Field *U, int confnum)
void read_file(Field *u, const string &filename)
Definition: gaugeConfig.cpp:85
string config_filename(const int)
Definition: gaugeConfig.cpp:73