#include #include #include #include #include #include #include #include using namespace std; CPS_START_NAMESPACE #if 1 const char *LatRngHeader::RNGString = #ifdef USE_C11_RNG #ifdef USE_C11_MT "LATTICE_RNG_C11_MT19937"; #elif (defined USE_C11_RANLUX) "LATTICE_RNG_C11_RANLUX48"; #else "LATTICE_RNG_C11_SITMO"; #endif #else "LATTICE_RNG_5D_4D"; #endif #endif /////////////////////////////////////////////////////////////////// // GCFheaderPar class members string elmSpacePar(string str) { const int i0(str.find_first_not_of(" ")); const int i1(str.find_last_not_of (" ")); if(i1 - i0>0){ return(str.substr(i0,i1-i0+1)); } else { return(str); } } bool GCFheaderPar::add(string key_eq_value) { const int eqp(key_eq_value.find("=")); if( eqp > 0 ) { const string key( elmSpacePar( key_eq_value.substr(0,eqp) ) ); const string val( elmSpacePar( key_eq_value.substr(eqp+1) ) ); headerMap.insert(GCFHMapParT::value_type(key,val)); return true; } else { return false; } } void GCFheaderPar::Show() const { cout << endl; for (GCFHMapParT::const_iterator iter = headerMap.begin(); iter != headerMap.end(); ++iter) { cout << iter->first << ":" << iter->second << endl; } cout << endl; }; string GCFheaderPar::asString( const string key ) { GCFHMapParT::const_iterator n(headerMap.find(key)); if (n == headerMap.end()) { cout << "header::asString key " << key << " not found. use Default." << endl; prevFound = false; return string(""); } else { prevFound = true; return ( n->second ); } } int GCFheaderPar::asInt( const string key ) { GCFHMapParT::const_iterator n(headerMap.find(key)); if (n == headerMap.end()) { cout << "header::asInt key "<second).c_str() , "%d ", &tmp); return ( tmp ); } } unsigned int GCFheaderPar::asHex( const string key ) { GCFHMapParT::const_iterator n(headerMap.find(key)); if (n == headerMap.end()) { cout << "header::asHex key "<second).c_str() , "%x ", &tmp); return ( tmp ); } } Float GCFheaderPar::asFloat( const string key ) { GCFHMapParT::const_iterator n(headerMap.find(key)); if (n == headerMap.end()) { cout << "header::asFloat key " << key << " not found. use Default." << endl; prevFound = false; return Float(0.0); } else { prevFound = true; float tmp; sscanf((n->second).c_str() , "%f ", &tmp); return ( (Float) tmp ); } } ///////////////////////////////////////////////////////////////////// // LatticeHeader members ///////////////////////////////////////////////////////////////////// void LatticeHeader::init(const QioArg & qio_arg, FP_FORMAT FileFormat, Float LinkTrace, Float Plaq) { hdr_version = "1.0"; recon_row_3 = qio_arg.ReconRow3; storage_format = "1.0"; for(int i=0;i<4;i++) dimension[i] = qio_arg.Nodes(i)*qio_arg.NodeSites(i); link_trace = LinkTrace; plaquette = Plaq; VRB.Result("LatticeHeader","init()","link_trace=%g plaquette=%g\n",LinkTrace,Plaq); for(int i=0;i<4;i++) boundary[i] = qio_arg.Bc(i); checksum = 0; // ensemble_id = "unspecified"; // ensemble_label = "unspecified"; // sequence_number = 0; #if TARGET == QCDOC creator = "RBC"; // getlogin() not supported on QCDOC yet creator_hardware = "QCDOC"; #elif TARGET == BGL creator = "RBC"; // getlogin() not supported on QCDOC yet creator_hardware = "BGL"; #elif TARGET == QCDSP creator = "RBC"; creator_hardware = "CU-QCDSP "; #else // creator = getlogin(); creator = "RBC"; creator_hardware = "CU-NOARCH "; #endif char buf[256]; #if TARGET == QCDOC strcpy(buf,"one rack"); // gethostname() not supported on QCDOC yet #else gethostname(buf,256); #endif creator_hardware += buf; // default archive time is current time struct timeval tp; gettimeofday(&tp,NULL); time_t ptm = tp.tv_sec; cout << "time = " << ptm << endl; archive_date = asctime(localtime(&ptm)); int i1( archive_date.find_last_not_of("\n")); archive_date = archive_date.substr(0,i1+1); creation_date = archive_date; floating_point = FileFormat; } void LatticeHeader::setHeader(const char * EnsembleId, const char * EnsembleLabel, const int SequenceNumber, const char *CreatorName, const char *CreatorHardware) { ensemble_id = EnsembleId; ensemble_label= EnsembleLabel; sequence_number = SequenceNumber; if (CreatorName) creator = CreatorName; if (CreatorHardware) creator_hardware = CreatorHardware; } void LatticeHeader::write(ostream & fout) { const char *fname="write(ostream&)"; fout.seekp(0,ios::beg); fout << "BEGIN_HEADER" << endl; fout << "HDR_VERSION = " << hdr_version << endl; if(recon_row_3) fout << "DATATYPE = 4D_SU3_GAUGE" << endl; else fout << "DATATYPE = 4D_SU3_GAUGE_3x3" << endl; fout << "STORAGE_FORMAT = " << storage_format << endl; for(int i=0;i<4;i++){ fout << "DIMENSION_" << i+1 << " = " << dimension[i] << endl ; } // just to keep the space and write it later fout << "LINK_TRACE = " << setprecision(10) << link_trace << endl; fout << "PLAQUETTE = " << setprecision(10) << plaquette << endl; for(int i=0;i<4;i++){ fout << "BOUNDARY_"<