added debug flag

This commit is contained in:
Dave Goodwin 2007-02-17 10:48:09 +00:00
parent 3f6403c4e8
commit 616eaba372
11 changed files with 24 additions and 21 deletions

View file

@ -36,9 +36,9 @@ extern "C" {
return Cabinet<XML_Node>::cabinet(true)->add(x);
}
int DLL_EXPORT xml_get_XML_File(const char* file) {
int DLL_EXPORT xml_get_XML_File(const char* file, int debug) {
try {
XML_Node* x = get_XML_File(string(file));
XML_Node* x = get_XML_File(string(file), debug);
return Cabinet<XML_Node>::cabinet(false)->add(x);
}
catch (CanteraError) { return -1; }
@ -87,9 +87,9 @@ extern "C" {
catch (CanteraError) { return -1; }
}
int DLL_EXPORT xml_preprocess_and_build(int i, const char* file) {
int DLL_EXPORT xml_preprocess_and_build(int i, const char* file, int debug) {
try {
get_CTML_Tree(_xml(i), string(file));
get_CTML_Tree(_xml(i), string(file), debug);
return 0;
}
catch (CanteraError) { return -1; }

View file

@ -6,13 +6,13 @@
extern "C" {
int DLL_IMPORT xml_new(const char* name);
int DLL_IMPORT xml_get_XML_File(const char* file);
int DLL_IMPORT xml_get_XML_File(const char* file, int debug = 0);
int DLL_IMPORT xml_del(int i);
int DLL_IMPORT xml_clear();
int DLL_IMPORT xml_copy(int i);
int DLL_IMPORT xml_assign(int i, int j);
int DLL_IMPORT xml_build(int i, const char* file);
int DLL_IMPORT xml_preprocess_and_build(int i, const char* file);
int DLL_IMPORT xml_preprocess_and_build(int i, const char* file, int debug);
int DLL_IMPORT xml_attrib(int i, const char* key, char* value);
int DLL_IMPORT xml_addAttrib(int i, const char* key, const char* value);
int DLL_IMPORT xml_addComment(int i, const char* comment);

View file

@ -23,7 +23,7 @@ class Interface(SurfacePhase, Kinetics):
See: SurfacePhase, Kinetics, importInterface
"""
def __init__(self, src="", root=None, phases=[]):
def __init__(self, src="", root=None, phases=[], debug = 0):
"""
src - CTML or CTI input file name. If more than one phase is
defined in the file, src should be specified as 'filename\#id'
@ -53,7 +53,7 @@ class Interface(SurfacePhase, Kinetics):
# an already-built XML tree. Enable preprocessing if the film
# is a .cti file instead of XML.
if src and not root:
root = XML.XML_Node(name = 'doc', src = fn, preprocess = 1)
root = XML.XML_Node(name = 'doc', src = fn, preprocess = 1, debug = debug)
# If an 'id' tag was specified, find the node in the tree with
# that tag

View file

@ -10,7 +10,7 @@ import exceptions
class XML_Node:
"""A node in an XML tree."""
def __init__(self, name="--", src="", wrap=0, root=None, preprocess=0):
def __init__(self, name="--", src="", wrap=0, root=None, preprocess=0, debug=0):
"""
Return an instance representing a node in an XML tree.
@ -32,7 +32,7 @@ class XML_Node:
# create an XML tree by parsing a file, and possibly
# preprocessing it first
elif src:
self._xml_id = _cantera.xml_get_XML_File(src)
self._xml_id = _cantera.xml_get_XML_File(src, debug)
self.wrap = 1 # disable deleting
# create a new empty node

View file

@ -10,21 +10,21 @@ import XML
__revision__ = "$Id$"
def importPhase(file, name = '', loglevel = 0):
def importPhase(file, name = '', loglevel = 0, debug = 0):
"""Import one phase from an input file. If 'name' is specified, the
phase definition with this name will be imported, otherwise the first
phase definition in the file will be imported. If 'loglevel' is set to
a positive integer, additional information will be printed or written
to log files about the details of the object constructed.
"""
return importPhases(file, [name], loglevel)[0]
return importPhases(file, [name], loglevel, debug)[0]
def importPhases(file, names = [], loglevel = 0):
def importPhases(file, names = [], loglevel = 0, debug = 0):
"""Import multiple phases from one file. The phase names should be
entered as a list of strings. See: importPhase """
s = []
for nm in names:
s.append(solution.Solution(src=file,id=nm,loglevel=loglevel))
s.append(solution.Solution(src=file,id=nm,loglevel=loglevel,debug=debug))
return s
def importInterface(file, name = '', phases = []):

View file

@ -26,7 +26,7 @@ class Solution(ThermoPhase, Kinetics, Transport):
"""
def __init__(self, src="", id="", loglevel = 0):
def __init__(self, src="", id="", loglevel = 0, debug = 0):
self.ckin = 0
self._owner = 0
@ -35,7 +35,8 @@ class Solution(ThermoPhase, Kinetics, Transport):
ff = os.path.splitext(fname)
if src:
root = XML.XML_Node(name = 'doc', src = src, preprocess = 1)
root = XML.XML_Node(name = 'doc', src = src,
preprocess = 1, debug = debug)
if id:
s = root.child(id = id)

View file

@ -14,9 +14,10 @@ static PyObject*
py_xml_get_XML_File(PyObject *self, PyObject *args)
{
char* file;
if (!PyArg_ParseTuple(args, "s:xml_get_XML_File", &file))
int debug;
if (!PyArg_ParseTuple(args, "si:xml_get_XML_File", &file, &debug))
return NULL;
int n = xml_get_XML_File(file);
int n = xml_get_XML_File(file, debug);
if (n < 0) return reportError(n);
PyObject* pn = Py_BuildValue("i",n);
return pn;

View file

@ -319,7 +319,7 @@ namespace Cantera {
/*!
* @param file String containing the relative or absolute file name
*/
XML_Node* get_XML_File(std::string file);
XML_Node* get_XML_File(std::string file, int debug = 0);
/// Close a Cantera input file.
/*!

View file

@ -246,7 +246,7 @@ namespace Cantera {
m_models["CK_Multi"] = CK_Multicomponent;
m_models["CK_Mix"] = CK_MixtureAveraged;
m_models["User"] = cUserTransport;
m_models["None"] = 0;
m_models["None"] = None;
}
/**

View file

@ -1,2 +1,3 @@
#define IEEE_8087
#define Arith_Kind_ASL 1
#define NANCHECK

View file

@ -75,7 +75,7 @@ int main(int argc, char** argv) {
try {
XML_Node *xc = new XML_Node();
string path = findInputFile(infile);
ctml::get_CTML_Tree(xc, path);
ctml::get_CTML_Tree(xc, path, 0);
XML_Node *xd = new XML_Node();
xc->copy(xd);
ofstream tout;