Changed: Introduce <console> for logging control.
This tag is prioritized so we get parallel logging up and running as early as possible.
This commit is contained in:
parent
b38a254a30
commit
9d1c9e0c73
@ -524,6 +524,8 @@ bool SIMbase::parse (const TiXmlElement* elem)
|
||||
result &= opt.parseEigSolTag(child);
|
||||
else if (!strcasecmp(elem->Value(),"postprocessing"))
|
||||
result &= this->parseOutputTag(child);
|
||||
else if (!strcasecmp(elem->Value(),"console"))
|
||||
result &= this->opt.parseConsoleTag(child);
|
||||
else if (!strcasecmp(elem->Value(),"discretization"))
|
||||
result &= opt.parseDiscretizationTag(child);
|
||||
|
||||
@ -550,7 +552,7 @@ int SIMbase::parseMaterialSet (const TiXmlElement* elem, int mindex)
|
||||
const char** SIMbase::getPrioritizedTags () const
|
||||
{
|
||||
// Tags to be parsed first, and in the order specified
|
||||
static const char* special[] = { "discretization", "geometry", 0 };
|
||||
static const char* special[] = { "console", "discretization", "geometry", 0 };
|
||||
return special;
|
||||
}
|
||||
|
||||
@ -832,7 +834,7 @@ int SIMbase::getLocalPatchIndex (int patchNo) const
|
||||
if (patchNo < 1 || (patchNo > nGlPatches && nGlPatches > 0))
|
||||
{
|
||||
std::cerr <<" *** SIMbase::getLocalPatchIndex: Patch number "<< patchNo
|
||||
<<" out of range [1,"<< nGlPatches <<"]"<< std::endl;
|
||||
<<" is out of range [1,"<< nGlPatches <<"]"<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
else if (myPatches.empty() || nProc == 1)
|
||||
@ -1799,7 +1801,7 @@ bool SIMbase::solveSystem (Vector& solution, int printSol,
|
||||
std::ofstream os(it->fname.c_str());
|
||||
os << std::setprecision(17);
|
||||
SystemMatrix* M = myEqSys->getMatrix(0);
|
||||
char matName[] = {'A'};
|
||||
char matName[] = "A";
|
||||
for (int i = 0; M; M = myEqSys->getMatrix(++i), ++matName[0])
|
||||
M->dump(os,it->format,matName); // label matrices as A,B,C,...
|
||||
}
|
||||
@ -1811,7 +1813,7 @@ bool SIMbase::solveSystem (Vector& solution, int printSol,
|
||||
std::ofstream os(it->fname.c_str());
|
||||
os << std::setprecision(17);
|
||||
SystemVector* c = myEqSys->getVector(0);
|
||||
char vecName[] = {'b'};
|
||||
char vecName[] = "b";
|
||||
for (int i = 0; c; c = myEqSys->getVector(++i), ++vecName[0])
|
||||
c->dump(os,it->format,vecName); // label vectors as b,c,d,...
|
||||
}
|
||||
|
@ -133,32 +133,6 @@ bool SIMoptions::parseOutputTag (const TiXmlElement* elem)
|
||||
utl::getAttribute(elem,"nw",nViz[2]);
|
||||
}
|
||||
|
||||
else if (!strcasecmp(elem->Value(),"logging")) {
|
||||
int pid = 0;
|
||||
#ifdef HAVE_MPI
|
||||
MPI_Comm_rank(MPI_COMM_WORLD,&pid);
|
||||
#endif
|
||||
utl::getAttribute(elem,"output_pid",printPid);
|
||||
if (printPid != -1 && printPid != IFEM::getOptions().printPid) {
|
||||
IFEM::getOptions().printPid = printPid;
|
||||
IFEM::cout.setPIDs(printPid,pid);
|
||||
if (printPid != pid)
|
||||
IFEM::cout.setNull();
|
||||
IFEM::cout <<"IFEM: Printing output from PID "<< printPid
|
||||
<<" to console."<< std::endl;
|
||||
}
|
||||
utl::getAttribute(elem,"output_prefix",log_prefix);
|
||||
if (!log_prefix.empty() && log_prefix != IFEM::getOptions().log_prefix) {
|
||||
if ((pid == 0 && printPid == -1) || pid == IFEM::getOptions().printPid)
|
||||
IFEM::cout <<"IFEM: Logging output to files with prefix "
|
||||
<< log_prefix << std::endl;
|
||||
IFEM::getOptions().log_prefix = log_prefix;
|
||||
char cPid[12];
|
||||
sprintf(cPid,"_p%04d.log",pid);
|
||||
IFEM::cout.addExtraLog(new std::ofstream(log_prefix+cPid));
|
||||
}
|
||||
}
|
||||
|
||||
else if (!strcasecmp(elem->Value(),"stride")) {
|
||||
const char* value = utl::getValue(elem,"stride");
|
||||
if (value) saveInc = atoi(value);
|
||||
@ -191,6 +165,38 @@ bool SIMoptions::parseOutputTag (const TiXmlElement* elem)
|
||||
}
|
||||
|
||||
|
||||
bool SIMoptions::parseConsoleTag (const TiXmlElement* elem)
|
||||
{
|
||||
if (!strcasecmp(elem->Value(),"logging")) {
|
||||
int pid = 0;
|
||||
#ifdef HAVE_MPI
|
||||
MPI_Comm_rank(MPI_COMM_WORLD,&pid);
|
||||
#endif
|
||||
utl::getAttribute(elem,"output_pid",printPid);
|
||||
if (printPid != -1 && printPid != IFEM::getOptions().printPid) {
|
||||
IFEM::getOptions().printPid = printPid;
|
||||
IFEM::cout.setPIDs(printPid,pid);
|
||||
if (printPid != pid)
|
||||
IFEM::cout.setNull();
|
||||
IFEM::cout <<"IFEM: Printing output from PID "<< printPid
|
||||
<<" to console."<< std::endl;
|
||||
}
|
||||
utl::getAttribute(elem,"output_prefix",log_prefix);
|
||||
if (!log_prefix.empty() && log_prefix != IFEM::getOptions().log_prefix) {
|
||||
if ((pid == 0 && printPid == -1) || pid == IFEM::getOptions().printPid)
|
||||
IFEM::cout <<"IFEM: Logging output to files with prefix "
|
||||
<< log_prefix << std::endl;
|
||||
IFEM::getOptions().log_prefix = log_prefix;
|
||||
char cPid[12];
|
||||
sprintf(cPid,"_p%04d.log",pid);
|
||||
IFEM::cout.addExtraLog(new std::ofstream(log_prefix+cPid));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SIMoptions::dumpHDF5 (const char* defaultName)
|
||||
{
|
||||
if (hdf5.empty()) return false;
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
//! \brief Defines the linear equation solver to be used.
|
||||
void setLinearSolver(const std::string& eqsolver);
|
||||
|
||||
//! \brief Parses a subelement of the \a console XML-tag.
|
||||
bool parseConsoleTag(const TiXmlElement* elem);
|
||||
//! \brief Parses a subelement of the \a discretization XML-tag.
|
||||
bool parseDiscretizationTag(const TiXmlElement* elem);
|
||||
//! \brief Parses a subelement of the \a eigensolver XML-tag.
|
||||
|
Loading…
Reference in New Issue
Block a user