19#ifndef HAVE_GETHOSTNAME
38 for(
int mu=1; mu <
Nd; ++mu)
40 for(
int nu=0; nu < mu; ++nu)
59 for(
int mu=0; mu <
Nd; ++mu)
74 for(
int i=1; i < d.
size(); ++i)
92 const int namelen = 128;
95 name[namelen-1] =
'\0';
100 time_t now = time(NULL);
102 char *tmp = ctime(&now);
103 int date_size = strlen(tmp);
104 char *datetime =
new(std::nothrow)
char[date_size+1];
105 if( datetime == 0x0 ) {
106 QDP_error_exit(
"Unable to allocate datetime in qdp_iogauge.cc\n");
109 strcpy(datetime,ctime(&now));
111 for(
int i=0; i < date_size; ++i)
112 if ( datetime[i] ==
'\n' )
125 std::ostringstream s;
142 read(paramtop,
"nrow", header.
nrow);
145 read(paramtop,
"link", header.
link);
157 read(paramtop,
"checksum", chk);
158 std::istringstream s(chk);
185 std::ostringstream s;
186 s.setf(std::ios_base::hex, std::ios_base::basefield);
188 write(xml,
"checksum", s.str());
220 const size_t max_line_length = 128;
230 cfg_in.
read(line, max_line_length);
233 if (line != std::string(
"BEGIN_HEADER"))
235 QDPIO::cerr <<
"Missing BEGIN_HEADER" << std::endl;
244 int lat_size_cnt = 0;
248 cfg_in.
read(line, max_line_length);
251 if (line == std::string(
"END_HEADER"))
break;
254 std::string::size_type off;
257 char tokenn[max_line_length];
258 if ( sscanf(line.c_str(),
"%s", tokenn) != 1 )
261 <<
": incorrectly parsed header line=XX" << line <<
"XX" << std::endl;
264 std::string token = tokenn;
267 off = line.find(
'=');
268 if ( off == std::string::npos )
271 <<
": incorrectly parsed header line=XX" << line <<
"XX" << std::endl;
274 off = line.find_first_not_of(
' ', off+1);
276 if ( off == std::string::npos )
285 value = line.substr(off, line.length()-off+1);
291 if ( token == std::string(
"DATATYPE") )
294 if (
value == std::string(
"4D_SU3_GAUGE_3x3") )
299 QDPIO::cerr << __func__ <<
": expecting Nc == 3" << std::endl;
303 else if (
value == std::string(
"4D_SU3_GAUGE") )
308 QDPIO::cerr << __func__ <<
": expecting Nc == 3" << std::endl;
312 else if (
value == std::string(
"4D_SU4_GAUGE") )
316 QDPIO::cerr << __func__ <<
": expecting Nc == 4" << std::endl;
323 <<
": unknown gauge type = XX" <<
value <<
"XX" << std::endl;
331 if ( sscanf(line.c_str(),
"PLAQUETTE = %lf", &dtmp) == 1 )
337 if ( sscanf(line.c_str(),
"LINK_TRACE = %lf", &dtmp) == 1 )
344 if ( sscanf(line.c_str(),
"CHECKSUM = %lx", &chk) == 1 )
350 if ( sscanf(line.c_str(),
"SEQUENCE_NUMBER = %d", &itmp) == 1 )
356 if ( token == std::string(
"ENSEMBLE_LABEL") )
362 if ( token == std::string(
"ENSEMBLE_ID") )
368 if ( token == std::string(
"CREATOR") )
374 if ( token == std::string(
"CREATOR_MACHINE") )
380 if ( token == std::string(
"CREATOR_HARDWARE") )
386 if ( token == std::string(
"CREATION_DATE") )
392 if ( token == std::string(
"ARCHIVE_DATE") )
398 if ( sscanf(line.c_str(),
"DIMENSION_%d = %d", &dd, &itmp) == 2 )
401 if (dd < 1 || dd >
Nd)
403 QDPIO::cerr << __func__ <<
": dimension number out of bounds" << std::endl;
407 header.
nrow[dd-1] = itmp;
412 if ( sscanf(line.c_str(),
"BOUNDARY_%d = %d", &dd, &itmp) == 2 )
415 if (dd < 1 || dd >
Nd)
417 QDPIO::cerr << __func__ <<
": dimension number out of bounds" << std::endl;
424 if( token == std::string(
"FLOATING_POINT") )
426 if(
value == std::string(
"IEEE32BIG") ||
value == std::string(
"IEEE32") )
430 else if(
value == std::string(
"IEEE64BIG") )
437 <<
": unknown floating point type = XX" <<
value <<
"XX" << std::endl;
446 if (lat_size_cnt !=
Nd)
448 QDPIO::cerr << __func__ <<
": did not find all the lattice sizes" << std::endl;
452 for(
int dd=0; dd <
Nd; ++dd)
455 QDPIO::cerr << __func__ <<
": archive lattice size does not agree with current size" << std::endl;
484void readArchiv(BinaryReader& cfg_in, multi1d<LatticeColorMatrix>& u,
485 n_uint32_t& checksum,
int mat_size,
int float_size);
508 QDPIO::cerr << __func__ <<
": checksum mismatch: new=" << checksum
509 <<
" header value= " << header.
checksum << std::endl;
514 mesplq(w_plaq, link, u);
517 QDPIO::cerr << __func__ <<
": plaquette out of bounds: new=" << w_plaq
518 <<
" header value= " << header.
w_plaq << std::endl;
524 QDPIO::cerr << __func__ <<
": link out of bounds: new=" << link
525 <<
" header value= " << header.
link << std::endl;
553 write(xml_buf,
"NERSC", header);
559 catch(
const std::string& e)
561 QDPIO:: cerr <<
"Error in readArchiv: " << e << std::endl;
613 std::ostringstream head;
615 head <<
"BEGIN_HEADER\n";
617 head <<
"CHECKSUM = ";
618 head.setf(std::ios_base::hex, std::ios_base::basefield);
619 head << header.
checksum << std::endl;
620 head.setf(std::ios_base::dec, std::ios_base::basefield);
621 head <<
"LINK_TRACE = " << header.
link <<
"\n"
622 <<
"PLAQUETTE = " << header.
w_plaq <<
"\n";
624 head <<
"DATATYPE = 4D_SU3_GAUGE\n"
625 <<
"HDR_VERSION = 1.0\n"
626 <<
"STORAGE_FORMAT = 1.0\n";
628 for(
int i=1; i <=
Nd; ++i)
631 for(
int i=0; i <
Nd; ++i)
633 head <<
"BOUNDARY_" << (i+1) <<
" = PERIODIC\n";
635 head <<
"BOUNDARY_" << (i+1) <<
" = ANTIPERIODIC\n";
638 QDPIO::cerr <<
"writeArchiv: unknown boundary type";
642 head <<
"ENSEMBLE_ID = " << header.
ensemble_id <<
"\n"
645 <<
"CREATOR = " << header.
creator <<
"\n"
649 <<
"FLOATING_POINT = IEEE32BIG\n";
651 head <<
"END_HEADER\n";
653 cfg_out.
writeArray(head.str().c_str(), 1, head.str().size());
677void writeArchiv(BinaryWriter& cfg_out,
const multi1d<LatticeColorMatrix>& u,
694 mesplq(w_plaq, link, u);
718 const std::string& cfg_file)
722 mesplq(w_plaq, link, u);
728 read(xml_in,
"/NERSC", header);
743 const std::string& cfg_file)
void close()
Closes the last file opened.
Binary file output class.
void close()
Closes the last file opened.
virtual void read(std::string &result, size_t nbytes)
Read some max number of characters - 1 upto and excluding a newline.
Binary writer base class.
virtual void writeArray(const char *output, size_t nbytes, size_t nmemb)
Write data from the primary node.
Writes XML metadata to a buffer.
void open(const std::string &filename)
Opens and reads an XML file.
Container for a multi-dimensional 1D array.
int size() const
Size of array.
void resize(int ns1)
Resize routine, call a templated resize, using *this to disambiguate.
OLattice< PScalar< PColorMatrix< RComplex< REAL >, Nc > > > LatticeColorMatrix
OScalar< PScalar< PScalar< RScalar< DOUBLE > > > > Double
UnaryReturn< C, FnSum >::Type_t sum(const QDPType< T, C > &s1)
OScalar = sum(source).
void readArchiv(BinaryReader &cfg_in, multi1d< LatticeColorMatrix > &u, n_uint32_t &checksum, int mat_size, int float_size)
Read a NERSC Gauge Connection Archive file.
ArchivGauge_t()
Initializes a NERSC Archive header with default values.
TextWriter & operator<<(TextWriter &txt, const std::string &output)
static void writeArchivHeader(BinaryWriter &cfg_out, const ArchivGauge_t &header)
Write a QCD (NERSC) Archive format gauge field.
void write(BinaryWriter &bin, const std::string &output)
static void readArchivHeader(BinaryReader &cfg_in, ArchivGauge_t &header)
Read a QCD (NERSC) Archive format gauge field header.
void writeArchiv(BinaryWriter &cfg_out, const multi1d< LatticeColorMatrix > &u, int mat_size)
Writes a NERSC Gauge Connection Archive gauge configuration file.
void read(BinaryReader &bin, std::string &input, size_t maxBytes)
bool toBool(const IScalar< T > &s)
QDP Boolean to bool primitive in conversion routine.
ArrayBiDirectionalMap shift
Definition of shift function object.
int NumSpins< RScalar< T > >::value
const multi1d< int > & lattSize()
Virtual grid (problem grid) lattice size.
int vol()
Total lattice volume.
StandardOutputStream cout
StandardOutputStream cerr
Yet another random number generator.
MakeReturn< UnaryNode< FnAdjoint, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnAdjoint >::Type_t >::Expression_t adj(const QDPExpr< T1, C1 > &l)
MakeReturn< UnaryNode< FnReal, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnReal >::Type_t >::Expression_t real(const QDPExpr< T1, C1 > &l)
MakeReturn< UnaryNode< FnFabs, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnFabs >::Type_t >::Expression_t fabs(const QDPExpr< T1, C1 > &l)
void QDP_error_exit(const char *format,...)
Simple error display and abort routine.
MakeReturn< UnaryNode< FnTrace, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnTrace >::Type_t >::Expression_t trace(const QDPExpr< T1, C1 > &l)
void push(XMLWriter &xml, const std::string &s)
Push a group name.
void pop(XMLWriter &xml)
Pop a group name.
void QDP_abort(int status)
Panic button.
n_uint32_t computeChecksum(const multi1d< LatticeColorMatrix > &u, int mat_size)
Compute simple NERSC-like checksum of a gauge field.
Primary include file for QDP.
int gethostname(char *, size_t)
NERSC Gauge Connection Archive gauge support.
NERSC Archive gauge field header.
std::string ensemble_label
std::string creation_date
std::string creator_hardware