Added the "sleep" system command buf fix for the cygwin environment.

Added debugging printouts for the DEFINE DEBUG_PATH.
This commit is contained in:
Harry Moffat 2004-08-06 20:51:45 +00:00
parent 1b419e5a2d
commit c00e5fc343
2 changed files with 50 additions and 2 deletions

View file

@ -116,6 +116,9 @@ namespace ctml {
string cmd = pypath() + " " + path + "> ct2ctml.log 2>&1";
#else
string cmd = pypath() + " " + path + " &> ct2ctml.log";
#endif
#ifdef DEBUG_PATHS
cout << "ct2ctml: executing the command " << cmd << endl;
#endif
int ierr = 0;
try {
@ -125,6 +128,36 @@ namespace ctml {
ierr = -10;
}
/*
* HKM -> This next section may seem a bit weird. However,
* it is in response to an issue that arises when
* running cantera with cygwin, using cygwin's
* python intepreter. Basically, the xml file is
* written to the local directory by the last
* system command. Then, the xml file is read
* immediately after by an ifstream() c++
* command. Unfortunately, it seems that the
* directory info is not being synched fast enough
* so that the ifstream() read fails, even
* though the file is actually there. Putting in a
* sleep system call here fixes this problem. Also,
* having the xml file pre-existing fixes the
* problem as well. There may be more direct ways
* to fix this bug; however, I am not aware of them.
*/
#if defined(CYGWIN)
#ifdef DEBUG_PATHS
cout << "sleeping for 3 secs" << endl;
#endif
cmd = "sleep 3";
try {
ierr = system(cmd.c_str());
}
catch (...) {
ierr = -10;
}
#endif
try {
char ch=0;
string s = "";
@ -155,6 +188,7 @@ namespace ctml {
"could not convert input file to CTML\n "
"command line was: " + msg);
}
#ifndef DEBUG_PATHS
#ifdef WIN32
cmd = "cmd /C rm " + path;
#else
@ -163,6 +197,7 @@ namespace ctml {
system(cmd.c_str());
}
catch (...) { ; }
#endif
#endif
}

View file

@ -128,18 +128,29 @@ namespace Cantera {
* We will assume that we are trying to open a cti file.
* First, determine the name of the xml file, ff, derived from
* the cti file.
* In all cases, we will write the xml file to the current
* directory.
*/
string::size_type islash = path.rfind('/');
if (islash != string::npos)
ff = string("./")+path.substr(islash+1,idot-islash - 1) + ".xml";
else
else {
ff = string("./")+path.substr(0,idot) + ".xml";
}
#ifdef DEBUG_PATHS
cout << "get_XML_File(): Expected location of xml file = "
<< ff << endl;
#endif
/*
* Do a search of the existing XML trees to determine if we have
* already processed this file. If we have, return a pointer to
* the processed xml tree.
*/
if (app()->xmlfiles.find(ff) != app()->xmlfiles.end()) {
#ifdef DEBUG_PATHS
cout << "get_XML_File(): File, " << ff << ", was previously read."
<< " Retrieving the storred xml tree." << endl;
#endif
return __app->xmlfiles[ff];
}
/*
@ -164,7 +175,9 @@ namespace Cantera {
__app->xmlfiles[ff] = x;
}
else {
throw CanteraError("get_XML_File","cannot open "+ff+" for reading.");
string estring = "cannot open "+ff+" for reading.";
estring += "Note, this error indicates a possible configuration problem.";
throw CanteraError("get_XML_File", estring);
}
}
/*