From 899f961d0d6d53b9e441d296f26c2e1603c023cb Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 7 May 2018 21:37:03 +0100 Subject: [PATCH] Hadrons: eigenvalue metadata saved with 16 significant digits --- extras/Hadrons/EigenPack.hpp | 47 +----------------------------------- extras/Hadrons/Global.hpp | 4 +++ lib/parallelIO/IldgIO.h | 12 ++++++--- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/extras/Hadrons/EigenPack.hpp b/extras/Hadrons/EigenPack.hpp index fc68a5ed..92901138 100644 --- a/extras/Hadrons/EigenPack.hpp +++ b/extras/Hadrons/EigenPack.hpp @@ -204,7 +204,7 @@ protected: vecRecord.index = index; vecRecord.eval = eval; LOG(Message) << "Writing eigenvector " << index << std::endl; - binWriter.writeScidacFieldRecord(evec, vecRecord); + binWriter.writeScidacFieldRecord(evec, vecRecord, DEFAULT_ASCII_PREC); binWriter.close(); } }; @@ -237,18 +237,6 @@ public: void readFine(const std::string fileStem, const bool multiFile, const int traj = -1) { - // std::string evecFineFilename, evalFineFilename; - // std::string evecCoarseFilename, evalCoarseFilename; - - // this->makeFilenames(evecFineFilename, evalFineFilename, - // fileStem + "_fine", traj); - // XmlReader xmlFineReader(evalFineFilename); - // LOG(Message) << "Reading " << this->eval.size() << " fine eigenvalues from '" - // << evalFineFilename << "'" << std::endl; - // Grid::read(xmlFineReader, "evals", this->eval); - // LOG(Message) << "Reading " << this->evec.size() << " fine eigenvectors from '" - // << evecFineFilename << "'" << std::endl; - // this->basicRead(this->evec, evecFineFilename, this->evec.size()); if (multiFile) { for(int k = 0; k < this->evec.size(); ++k) @@ -264,17 +252,6 @@ public: void readCoarse(const std::string fileStem, const bool multiFile, const int traj = -1) { - // std::string evecCoarseFilename, evalCoarseFilename; - - // this->makeFilenames(evecCoarseFilename, evalCoarseFilename, - // fileStem + "_coarse", traj); - // XmlReader xmlCoarseReader(evalCoarseFilename); - // LOG(Message) << "Reading " << evalCoarse.size() << " coarse eigenvalues from '" - // << evalCoarseFilename << "'" << std::endl; - // Grid::read(xmlCoarseReader, "evals", evalCoarse); - // LOG(Message) << "Reading " << evecCoarse.size() << " coarse eigenvectors from '" - // << evecCoarseFilename << "'" << std::endl; - // this->basicRead(evecCoarse, evecCoarseFilename, evecCoarse.size()); if (multiFile) { for(int k = 0; k < evecCoarse.size(); ++k) @@ -296,17 +273,6 @@ public: void writeFine(const std::string fileStem, const bool multiFile, const int traj = -1) { - // std::string evecFineFilename, evalFineFilename; - - // this->makeFilenames(evecFineFilename, evalFineFilename, - // fileStem + "_fine", traj); - // XmlWriter xmlFineWriter(evalFineFilename); - // LOG(Message) << "Writing " << this->eval.size() << " fine eigenvalues to '" - // << evalFineFilename << "'" << std::endl; - // Grid::write(xmlFineWriter, "evals", this->eval); - // LOG(Message) << "Writing " << this->evec.size() << " fine eigenvectors to '" - // << evecFineFilename << "'" << std::endl; - // this->basicWrite(evecFineFilename, this->evec, this->evec.size()); if (multiFile) { for(int k = 0; k < this->evec.size(); ++k) @@ -322,17 +288,6 @@ public: void writeCoarse(const std::string fileStem, const bool multiFile, const int traj = -1) { - // std::string evecCoarseFilename, evalCoarseFilename; - - // this->makeFilenames(evecCoarseFilename, evalCoarseFilename, - // fileStem + "_coarse", traj); - // XmlWriter xmlCoarseWriter(evalCoarseFilename); - // LOG(Message) << "Writing " << evalCoarse.size() << " coarse eigenvalues to '" - // << evalCoarseFilename << "'" << std::endl; - // Grid::write(xmlCoarseWriter, "evals", evalCoarse); - // LOG(Message) << "Writing " << evecCoarse.size() << " coarse eigenvectors to '" - // << evecCoarseFilename << "'" << std::endl; - // this->basicWrite(evecCoarseFilename, evecCoarse, evecCoarse.size()); if (multiFile) { for(int k = 0; k < evecCoarse.size(); ++k) diff --git a/extras/Hadrons/Global.hpp b/extras/Hadrons/Global.hpp index bc0be474..72fbdf80 100644 --- a/extras/Hadrons/Global.hpp +++ b/extras/Hadrons/Global.hpp @@ -39,6 +39,10 @@ See the full license in the file "LICENSE" in the top level distribution directo #define SITE_SIZE_TYPE size_t #endif +#ifndef DEFAULT_ASCII_PREC +#define DEFAULT_ASCII_PREC 16 +#endif + #define BEGIN_HADRONS_NAMESPACE \ namespace Grid {\ using namespace QCD;\ diff --git a/lib/parallelIO/IldgIO.h b/lib/parallelIO/IldgIO.h index 3eb55d7d..0bfa7b9e 100644 --- a/lib/parallelIO/IldgIO.h +++ b/lib/parallelIO/IldgIO.h @@ -340,10 +340,15 @@ class GridLimeWriter : public BinaryIO } template - void writeLimeObject(int MB,int ME,serialisable_object &object,std::string object_name,std::string record_name) + void writeLimeObject(int MB,int ME,serialisable_object &object,std::string object_name,std::string record_name, const unsigned int scientificPrec = 0) { XmlWriter WR("",""); + if (scientificPrec) + { + WR.scientificFormat(true); + WR.setPrecision(scientificPrec); + } write(WR,object_name,object); writeLimeObject(MB, ME, WR, object_name, record_name); } @@ -453,7 +458,8 @@ class ScidacWriter : public GridLimeWriter { // Write generic lattice field in scidac format //////////////////////////////////////////////// template - void writeScidacFieldRecord(Lattice &field,userRecord _userRecord) + void writeScidacFieldRecord(Lattice &field,userRecord _userRecord, + const unsigned int recordScientificPrec = 0) { GridBase * grid = field._grid; @@ -471,7 +477,7 @@ class ScidacWriter : public GridLimeWriter { ////////////////////////////////////////////// if ( this->boss_node ) { writeLimeObject(1,0,header ,std::string("FieldMetaData"),std::string(GRID_FORMAT)); // Open message - writeLimeObject(0,0,_userRecord,_userRecord.SerialisableClassName(),std::string(SCIDAC_RECORD_XML)); + writeLimeObject(0,0,_userRecord,_userRecord.SerialisableClassName(),std::string(SCIDAC_RECORD_XML), recordScientificPrec); writeLimeObject(0,0,_scidacRecord,_scidacRecord.SerialisableClassName(),std::string(SCIDAC_PRIVATE_RECORD_XML)); } // Collective call