mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 05:30:46 +01:00
Hadrons: better handling of automatic directory creation
This commit is contained in:
parent
2017e4e3b4
commit
f362c00739
@ -170,14 +170,8 @@ protected:
|
|||||||
{
|
{
|
||||||
ScidacWriter binWriter(evec[0]._grid->IsBoss());
|
ScidacWriter binWriter(evec[0]._grid->IsBoss());
|
||||||
XmlWriter xmlWriter("", "eigenPackPar");
|
XmlWriter xmlWriter("", "eigenPackPar");
|
||||||
std::string d = dirname(filename);
|
|
||||||
int status = mkdir(d);
|
|
||||||
|
|
||||||
if (status)
|
makeFileDir(filename, evec[0]._grid);
|
||||||
{
|
|
||||||
HADRONS_ERROR(Io, "cannot create directory '" + d
|
|
||||||
+ "' (status " + std::to_string(status) + ")");
|
|
||||||
}
|
|
||||||
xmlWriter.pushXmlString(record.operatorXml);
|
xmlWriter.pushXmlString(record.operatorXml);
|
||||||
xmlWriter.pushXmlString(record.solverXml);
|
xmlWriter.pushXmlString(record.solverXml);
|
||||||
binWriter.open(filename);
|
binWriter.open(filename);
|
||||||
@ -201,14 +195,8 @@ protected:
|
|||||||
ScidacWriter binWriter(evec._grid->IsBoss());
|
ScidacWriter binWriter(evec._grid->IsBoss());
|
||||||
XmlWriter xmlWriter("", "eigenPackPar");
|
XmlWriter xmlWriter("", "eigenPackPar");
|
||||||
VecRecord vecRecord;
|
VecRecord vecRecord;
|
||||||
std::string d = dirname(filename);
|
|
||||||
int status = mkdir(d);
|
|
||||||
|
|
||||||
if (status)
|
makeFileDir(filename, evec._grid);
|
||||||
{
|
|
||||||
HADRONS_ERROR(Io, "cannot create directory '" + d
|
|
||||||
+ "' (status " + std::to_string(status) + ")");
|
|
||||||
}
|
|
||||||
xmlWriter.pushXmlString(record.operatorXml);
|
xmlWriter.pushXmlString(record.operatorXml);
|
||||||
xmlWriter.pushXmlString(record.solverXml);
|
xmlWriter.pushXmlString(record.solverXml);
|
||||||
binWriter.open(filename);
|
binWriter.open(filename);
|
||||||
|
@ -158,3 +158,18 @@ std::string Hadrons::dirname(const std::string &s)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hadrons::makeFileDir(const std::string filename, GridBase *g)
|
||||||
|
{
|
||||||
|
if (g->IsBoss())
|
||||||
|
{
|
||||||
|
std::string dir = dirname(filename);
|
||||||
|
int status = mkdir(dir);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
HADRONS_ERROR(Io, "cannot create directory '" + dir
|
||||||
|
+ "' ( " + std::strerror(errno) + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -192,6 +192,7 @@ name + "." + std::to_string(vm().getTrajectory()) + "." + resultFileExt
|
|||||||
int mkdir(const std::string dirName);
|
int mkdir(const std::string dirName);
|
||||||
std::string basename(const std::string &s);
|
std::string basename(const std::string &s);
|
||||||
std::string dirname(const std::string &s);
|
std::string dirname(const std::string &s);
|
||||||
|
void makeFileDir(const std::string filename, GridBase *g);
|
||||||
|
|
||||||
// default Schur convention
|
// default Schur convention
|
||||||
#ifndef HADRONS_DEFAULT_SCHUR
|
#ifndef HADRONS_DEFAULT_SCHUR
|
||||||
|
@ -122,14 +122,7 @@ MACRO_REDIRECT(__VA_ARGS__, envTmpLat5, envTmpLat4)(__VA_ARGS__)
|
|||||||
#define saveResult(ioStem, name, result)\
|
#define saveResult(ioStem, name, result)\
|
||||||
if (env().getGrid()->IsBoss())\
|
if (env().getGrid()->IsBoss())\
|
||||||
{\
|
{\
|
||||||
std::string _dirname = dirname(ioStem);\
|
makeFileDir(ioStem, env().getGrid());\
|
||||||
int _status = mkdir(_dirname);\
|
|
||||||
\
|
|
||||||
if (_status)\
|
|
||||||
{\
|
|
||||||
HADRONS_ERROR(Io, "cannot create directory '" + _dirname \
|
|
||||||
+ "' (status " + std::to_string(_status) + ")");\
|
|
||||||
}\
|
|
||||||
{\
|
{\
|
||||||
ResultWriter _writer(RESULT_FILE_NAME(ioStem));\
|
ResultWriter _writer(RESULT_FILE_NAME(ioStem));\
|
||||||
write(_writer, name, result);\
|
write(_writer, name, result);\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user