mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Hadrons: eigenpack converter can do test reads
This commit is contained in:
parent
1982cc58dd
commit
6b559d68aa
@ -35,7 +35,7 @@ using namespace Hadrons;
|
|||||||
template <typename FOut, typename FIn>
|
template <typename FOut, typename FIn>
|
||||||
void convert(const std::string outFilename, const std::string inFilename,
|
void convert(const std::string outFilename, const std::string inFilename,
|
||||||
const unsigned int Ls, const bool rb, const unsigned int size,
|
const unsigned int Ls, const bool rb, const unsigned int size,
|
||||||
const bool multiFile)
|
const bool multiFile, const bool testRead)
|
||||||
{
|
{
|
||||||
assert(outFilename != inFilename);
|
assert(outFilename != inFilename);
|
||||||
|
|
||||||
@ -102,6 +102,7 @@ void convert(const std::string outFilename, const std::string inFilename,
|
|||||||
LOG(Message) << "Out type : " << typeName<FOut>() << std::endl;
|
LOG(Message) << "Out type : " << typeName<FOut>() << std::endl;
|
||||||
LOG(Message) << "#vectors : " << size << std::endl;
|
LOG(Message) << "#vectors : " << size << std::endl;
|
||||||
LOG(Message) << "Multifile : " << (multiFile ? "yes" : "no") << std::endl;
|
LOG(Message) << "Multifile : " << (multiFile ? "yes" : "no") << std::endl;
|
||||||
|
LOG(Message) << "Test read : " << (testRead ? "yes" : "no") << std::endl;
|
||||||
if (multiFile)
|
if (multiFile)
|
||||||
{
|
{
|
||||||
for(unsigned int k = 0; k < size; ++k)
|
for(unsigned int k = 0; k < size; ++k)
|
||||||
@ -112,6 +113,8 @@ void convert(const std::string outFilename, const std::string inFilename,
|
|||||||
LOG(Message) << "==== Converting vector " << k << std::endl;
|
LOG(Message) << "==== Converting vector " << k << std::endl;
|
||||||
LOG(Message) << "In : " << inV << std::endl;
|
LOG(Message) << "In : " << inV << std::endl;
|
||||||
LOG(Message) << "Out: " << outV << std::endl;
|
LOG(Message) << "Out: " << outV << std::endl;
|
||||||
|
// conversion
|
||||||
|
LOG(Message) << "-- Doing conversion" << std::endl;
|
||||||
makeFileDir(outV, gOut);
|
makeFileDir(outV, gOut);
|
||||||
binWriter.open(outV);
|
binWriter.open(outV);
|
||||||
binReader.open(inV);
|
binReader.open(inV);
|
||||||
@ -121,10 +124,20 @@ void convert(const std::string outFilename, const std::string inFilename,
|
|||||||
EigenPackIo::writeElement<FIn, FOut>(binWriter, bufIn, eval, k, &bufOut, &testIn);
|
EigenPackIo::writeElement<FIn, FOut>(binWriter, bufIn, eval, k, &bufOut, &testIn);
|
||||||
binWriter.close();
|
binWriter.close();
|
||||||
binReader.close();
|
binReader.close();
|
||||||
|
// read test
|
||||||
|
if (testRead)
|
||||||
|
{
|
||||||
|
LOG(Message) << "-- Test read" << std::endl;
|
||||||
|
binReader.open(outV);
|
||||||
|
EigenPackIo::readElement<FOut>(bufOut, eval, k, binReader);
|
||||||
|
binReader.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// conversion
|
||||||
|
LOG(Message) << "-- Doing conversion" << std::endl;
|
||||||
makeFileDir(outFilename, gOut);
|
makeFileDir(outFilename, gOut);
|
||||||
binWriter.open(outFilename);
|
binWriter.open(outFilename);
|
||||||
binReader.open(inFilename);
|
binReader.open(inFilename);
|
||||||
@ -137,6 +150,18 @@ void convert(const std::string outFilename, const std::string inFilename,
|
|||||||
}
|
}
|
||||||
binWriter.close();
|
binWriter.close();
|
||||||
binReader.close();
|
binReader.close();
|
||||||
|
// read test
|
||||||
|
if (testRead)
|
||||||
|
{
|
||||||
|
LOG(Message) << "-- Test read" << std::endl;
|
||||||
|
binReader.open(outFilename);
|
||||||
|
EigenPackIo::readHeader(record, binReader);
|
||||||
|
for(unsigned int k = 0; k < size; ++k)
|
||||||
|
{
|
||||||
|
EigenPackIo::readElement<FOut>(bufOut, eval, k, binReader);
|
||||||
|
}
|
||||||
|
binReader.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,11 +179,11 @@ int main(int argc, char *argv[])
|
|||||||
// parse command line
|
// parse command line
|
||||||
std::string outFilename, inFilename;
|
std::string outFilename, inFilename;
|
||||||
unsigned int size, Ls;
|
unsigned int size, Ls;
|
||||||
bool rb, multiFile;
|
bool rb, multiFile, testRead;
|
||||||
|
|
||||||
if (argc < 7)
|
if (argc < 8)
|
||||||
{
|
{
|
||||||
std::cerr << "usage: " << argv[0] << " <out eigenpack> <in eigenpack> <Ls> <red-black (0|1)> <#vector> <multifile (0|1)> [Grid options]";
|
std::cerr << "usage: " << argv[0] << " <out eigenpack> <in eigenpack> <Ls> <red-black {0|1}> <#vector> <multifile {0|1}> <test read {0|1}> [Grid options]";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -168,6 +193,7 @@ int main(int argc, char *argv[])
|
|||||||
rb = (std::string(argv[4]) != "0");
|
rb = (std::string(argv[4]) != "0");
|
||||||
size = std::stoi(std::string(argv[5]));
|
size = std::stoi(std::string(argv[5]));
|
||||||
multiFile = (std::string(argv[6]) != "0");
|
multiFile = (std::string(argv[6]) != "0");
|
||||||
|
testRead = (std::string(argv[7]) != "0");
|
||||||
|
|
||||||
// initialization
|
// initialization
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
@ -176,7 +202,7 @@ int main(int argc, char *argv[])
|
|||||||
// execution
|
// execution
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
convert<FOUT, FIN>(outFilename, inFilename, Ls, rb, size, multiFile);
|
convert<FOUT, FIN>(outFilename, inFilename, Ls, rb, size, multiFile, testRead);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user