General commit
- nothing has changed really. just added commented-out writes that I was using
during the debug process
This commit is contained in:
parent
fdfebcec37
commit
86ff7e9314
3 changed files with 57 additions and 33 deletions
|
|
@ -30,9 +30,12 @@
|
|||
#include <ctime>
|
||||
|
||||
|
||||
#ifdef DEBUG_PATHS
|
||||
#undef DEBUG_PATHS
|
||||
#endif
|
||||
// These defines are needed for the windows Sleep() function
|
||||
// - comment them out if you don't want the Sleep function.
|
||||
//#ifdef WIN32
|
||||
//#include "Windows.h"
|
||||
//#include "Winbase.h"
|
||||
//#endif
|
||||
|
||||
using namespace Cantera;
|
||||
using namespace std;
|
||||
|
|
@ -87,7 +90,7 @@ namespace ctml {
|
|||
*
|
||||
* @ingroup inputfiles
|
||||
*/
|
||||
void ct2ctml(const char* const file, const int debug) {
|
||||
void ct2ctml(const char* file, const int debug) {
|
||||
|
||||
#ifdef HAS_NO_PYTHON
|
||||
/*
|
||||
|
|
@ -139,8 +142,9 @@ namespace ctml {
|
|||
}
|
||||
catch (...) {
|
||||
ierr = -10;
|
||||
if (debug > 0)
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
if (debug > 0) {
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -175,6 +179,9 @@ namespace ctml {
|
|||
ierr = -10;
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
}
|
||||
#else
|
||||
// This command works on windows machines if Windows.h and Winbase.h are included
|
||||
// Sleep(5000);
|
||||
#endif
|
||||
// show the contents of the log file on the screen
|
||||
try {
|
||||
|
|
@ -182,26 +189,28 @@ namespace ctml {
|
|||
string s = "";
|
||||
ifstream ferr("ct2ctml.log");
|
||||
if (ferr) {
|
||||
while (!ferr.eof()) {
|
||||
ferr.get(ch);
|
||||
s += ch;
|
||||
if (ch == '\n') {
|
||||
writelog(s);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
ferr.close();
|
||||
while (!ferr.eof()) {
|
||||
ferr.get(ch);
|
||||
s += ch;
|
||||
if (ch == '\n') {
|
||||
writelog(s);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
ferr.close();
|
||||
}
|
||||
else {
|
||||
if (debug > 0)
|
||||
writelog("cannot open ct2ctml.log for reading.\n");
|
||||
if (debug > 0) {
|
||||
writelog("cannot open ct2ctml.log for reading.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
writelog("ct2ctml: caught something \n");;
|
||||
}
|
||||
if (ierr != 0) {
|
||||
string msg = cmd;
|
||||
writelog("ct2ctml: throw cantera error \n");;
|
||||
throw CanteraError("ct2ctml",
|
||||
"could not convert input file to CTML.\n "
|
||||
"Command line was: \n" + msg);
|
||||
|
|
@ -240,12 +249,11 @@ namespace ctml {
|
|||
* @param file Name of the file
|
||||
* @param debug Turn on debugging printing
|
||||
*/
|
||||
void get_CTML_Tree(XML_Node* rootPtr, const std::string file, const int debug) {
|
||||
string ff, ext = "";
|
||||
|
||||
void get_CTML_Tree(Cantera::XML_Node* rootPtr, const std::string file, const int debug) {
|
||||
std::string ff, ext = "";
|
||||
|
||||
// find the input file on the Cantera search path
|
||||
string inname = findInputFile(file);
|
||||
std::string inname = findInputFile(file);
|
||||
#ifdef DEBUG_PATHS
|
||||
writelog("Found file: "+inname+"\n");
|
||||
#endif
|
||||
|
|
@ -260,12 +268,17 @@ namespace ctml {
|
|||
* Check whether or not the file is XML. If not, it will be first
|
||||
* processed with the preprocessor.
|
||||
*/
|
||||
string::size_type idot = inname.rfind('.');
|
||||
std::string::size_type idot = inname.rfind('.');
|
||||
if (idot != string::npos) {
|
||||
ext = inname.substr(idot, inname.size());
|
||||
}
|
||||
if (ext != ".xml" && ext != ".ctml") {
|
||||
ct2ctml(inname.c_str(), debug);
|
||||
try {
|
||||
ctml::ct2ctml(inname.c_str(), 1);
|
||||
}
|
||||
catch (...) {
|
||||
writelog("get_CTML_Tree: caught something \n");;
|
||||
}
|
||||
string ffull = inname.substr(0,idot) + ".xml";
|
||||
ff = "./" + getBaseName(ffull) + ".xml";
|
||||
#ifdef DEBUG_PATHS
|
||||
|
|
|
|||
|
|
@ -864,7 +864,7 @@ namespace ctml {
|
|||
*
|
||||
* @ingroup inputfiles
|
||||
*/
|
||||
void ct2ctml(const char* const file, const int debug = 0);
|
||||
void ct2ctml(const char* file, const int debug = 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,14 +31,16 @@
|
|||
#include "FactoryBase.h"
|
||||
#include "logger.h"
|
||||
|
||||
#undef DEBUG_PATHS
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <new>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
// RFB : If running multiple threads in a cpp application,
|
||||
|
|
@ -483,11 +485,11 @@ namespace Cantera {
|
|||
protected: //RFB Protected ctor access thru static member function Instance
|
||||
//! Constructor for class sets up the initial conditions
|
||||
Application() : /*linelen(0),*/ stop_on_error(false),
|
||||
tmp_dir("."), m_sleep("1")
|
||||
#if !defined( THREAD_SAFE_CANTERA )
|
||||
, pMessenger( new Messages() )
|
||||
#endif
|
||||
tmp_dir("."), m_sleep("1")
|
||||
{
|
||||
#if !defined( THREAD_SAFE_CANTERA )
|
||||
pMessenger = std::auto_ptr<Messages>(new Messages());
|
||||
#endif
|
||||
// if TMP or TEMP is set, use it for the temporary
|
||||
// directory
|
||||
char* ctmpdir = getenv("CANTERA_TMPDIR");
|
||||
|
|
@ -935,12 +937,14 @@ protected:
|
|||
}
|
||||
|
||||
XML_Node* get_XML_File(std::string file, int debug) {
|
||||
return app()->get_XML_File(file, debug) ;
|
||||
XML_Node* xtmp = app()->get_XML_File(file, debug) ;
|
||||
//writelog("get_XML_File: returned from app:get_XML_FILE " + int2str(int(xtmp)) + "\n");
|
||||
return xtmp;
|
||||
}
|
||||
|
||||
XML_Node* Application::get_XML_File(std::string file, int debug) {
|
||||
XML_LOCK();
|
||||
string path = "";
|
||||
std::string path = "";
|
||||
/*
|
||||
try {
|
||||
path = findInputFile(file);
|
||||
|
|
@ -1034,6 +1038,7 @@ protected:
|
|||
* the absolute pathname as the key for this map.
|
||||
*/
|
||||
ifstream s(ff.c_str());
|
||||
|
||||
XML_Node* x = new XML_Node("doc");
|
||||
if (s) {
|
||||
x->build(s);
|
||||
|
|
@ -1046,6 +1051,7 @@ protected:
|
|||
throw CanteraError("get_XML_File", estring);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the XML node pointer. At this point, we are sure that the
|
||||
* lookup operation in the return statement will return a valid
|
||||
|
|
@ -1590,7 +1596,12 @@ protected:
|
|||
// @see Logger.
|
||||
// @ingroup textlogs
|
||||
void setLogger(Logger* logwriter) {
|
||||
app()->setLogger(logwriter) ;
|
||||
try {
|
||||
app()->setLogger(logwriter) ;
|
||||
}
|
||||
catch (std::bad_alloc) {
|
||||
logwriter->error("bad alloc thrown by app()");
|
||||
}
|
||||
}
|
||||
|
||||
void Application::Messages::setLogger(Logger* _logwriter) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue