diff --git a/Cantera/clib/src/ctonedim.cpp b/Cantera/clib/src/ctonedim.cpp index d05a78102..781fce6ba 100644 --- a/Cantera/clib/src/ctonedim.cpp +++ b/Cantera/clib/src/ctonedim.cpp @@ -1,3 +1,9 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + // Cantera includes #include "oneD/Sim1D.h" diff --git a/Cantera/clib/src/ctsurf.cpp b/Cantera/clib/src/ctsurf.cpp index 2e60e63cb..88ee78188 100755 --- a/Cantera/clib/src/ctsurf.cpp +++ b/Cantera/clib/src/ctsurf.cpp @@ -1,3 +1,8 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif // Cantera includes #include "SurfPhase.h" diff --git a/Cantera/clib/src/ctxml.cpp b/Cantera/clib/src/ctxml.cpp index 80bb168d1..56688a270 100644 --- a/Cantera/clib/src/ctxml.cpp +++ b/Cantera/clib/src/ctxml.cpp @@ -1,11 +1,3 @@ - -// Cantera includes -#include "ctml.h" -#include "importCTML.h" - -#include "Cabinet.h" -#include "Storage.h" - // Build as a DLL under Windows #ifdef WIN32 #define DLL_EXPORT __declspec(dllexport) @@ -15,6 +7,14 @@ #define DLL_EXPORT #endif +// Cantera includes +#include "ctml.h" +#include "importCTML.h" + +#include "Cabinet.h" +#include "Storage.h" + + // Values returned for error conditions #define ERR -999 #define DERR -999.999 diff --git a/Cantera/cxx/cxxutils.cpp b/Cantera/cxx/cxxutils.cpp index e4a731be9..ec70fc352 100644 --- a/Cantera/cxx/cxxutils.cpp +++ b/Cantera/cxx/cxxutils.cpp @@ -1,3 +1,9 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #include "ThermoPhase.h" #include diff --git a/Cantera/src/ReactionStoichMgr.cpp b/Cantera/src/ReactionStoichMgr.cpp index 64ebdd95d..a776d4990 100644 --- a/Cantera/src/ReactionStoichMgr.cpp +++ b/Cantera/src/ReactionStoichMgr.cpp @@ -1,3 +1,9 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #include "ReactionStoichMgr.h" #include "StoichManager.h" diff --git a/Cantera/src/ct2ctml.cpp b/Cantera/src/ct2ctml.cpp index d2ceb3143..ed9c5e6ad 100644 --- a/Cantera/src/ct2ctml.cpp +++ b/Cantera/src/ct2ctml.cpp @@ -8,6 +8,12 @@ // Copyright 2001 California Institute of Technology +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #include "ct_defs.h" #include "ctexceptions.h" #include diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index f558d916b..376bd425a 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -49,8 +49,9 @@ namespace Cantera { virtual ~Application() { map::iterator pos; for (pos = xmlfiles.begin(); pos != xmlfiles.end(); ++pos) { - delete pos->second; - pos->second = 0; + pos->second->unlock(); + delete pos->second; + pos->second = 0; } } vector inputDirs; @@ -152,6 +153,7 @@ namespace Cantera { XML_Node* x = new XML_Node("doc"); if (s) { x->build(s); + x->lock(); __app->xmlfiles[ff] = x; } else { @@ -171,12 +173,14 @@ namespace Cantera { map::iterator b = app()->xmlfiles.begin(), e = app()->xmlfiles.end(); for(; b != e; ++b) { + b->second->unlock(); delete b->second; __app->xmlfiles.erase(b->first); } } else if (app()->xmlfiles.find(file) != app()->xmlfiles.end()) { + __app->xmlfiles[file]->unlock(); delete __app->xmlfiles[file]; __app->xmlfiles.erase(file); } diff --git a/Cantera/src/oneD/Sim1D.cpp b/Cantera/src/oneD/Sim1D.cpp index 53ba565ab..25a7c46ef 100644 --- a/Cantera/src/oneD/Sim1D.cpp +++ b/Cantera/src/oneD/Sim1D.cpp @@ -1,3 +1,9 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + /** * @file Sim1D.cpp */ diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index 7d19d3628..03ff402a2 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -11,7 +11,11 @@ // Copyright 2002-3 California Institute of Technology - +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Inlet1D.h" diff --git a/Cantera/src/oneD/refine.cpp b/Cantera/src/oneD/refine.cpp index fe24607be..bb32b2a66 100644 --- a/Cantera/src/oneD/refine.cpp +++ b/Cantera/src/oneD/refine.cpp @@ -1,3 +1,9 @@ +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #include #include diff --git a/Cantera/src/phasereport.cpp b/Cantera/src/phasereport.cpp index e4a731be9..50843ad76 100644 --- a/Cantera/src/phasereport.cpp +++ b/Cantera/src/phasereport.cpp @@ -1,3 +1,10 @@ + +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #include "ThermoPhase.h" #include diff --git a/Cantera/src/xml.cpp b/Cantera/src/xml.cpp index 83c22a7e4..181b279e9 100755 --- a/Cantera/src/xml.cpp +++ b/Cantera/src/xml.cpp @@ -277,13 +277,16 @@ namespace Cantera { XML_Node::XML_Node(string nm, XML_Node* p, int n) : m_name(nm), m_parent(p), m_nchildren(0), - m_n(n), m_iscomment(false) { + m_n(n), m_iscomment(false), m_locked(false) { if (!p) m_root = this; else m_root = &p->root(); } XML_Node::~XML_Node() { + if (m_locked) + throw CanteraError("XML_Node::~XML_Node", + "attempt to delete locked XML_Node "+name()); int n = m_children.size(); for (int i = 0; i < n; i++) { if (m_children[i]) { diff --git a/Cantera/src/xml.h b/Cantera/src/xml.h index a0ad069b7..f6a407a5c 100755 --- a/Cantera/src/xml.h +++ b/Cantera/src/xml.h @@ -113,6 +113,10 @@ namespace Cantera { //return (m_childindex[ch] != 0); } bool hasAttrib(string a) const { + //cout << m_attribs.size() << endl; + // if (m_attribs.size() == 0) { + // cout << name() << " has zero length attribs " << endl; + // } return (m_attribs.find(a) != m_attribs.end()); } @@ -157,6 +161,8 @@ namespace Cantera { void setRoot(XML_Node& root) { m_root = &root; } void copyUnion(XML_Node *node_dest); void copy(XML_Node *node_dest); + void lock() {m_locked = true;} + void unlock() {m_locked = false; } private: void write_int(ostream& s, int level = 0) const; @@ -169,6 +175,7 @@ namespace Cantera { map m_attribs; XML_Node* m_parent; XML_Node* m_root; + bool m_locked; vector m_children; int m_nchildren; int m_n; diff --git a/examples/cxx/equil_example1.cpp b/examples/cxx/equil_example1.cpp index f2a7442e2..b47aab96d 100755 --- a/examples/cxx/equil_example1.cpp +++ b/examples/cxx/equil_example1.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Cantera.h" #include @@ -65,7 +70,7 @@ int equil_example1(int job) { // create a gas mixture, and set its state - IdealGasMix gas("silane.xml", "silane"); + IdealGasMix gas("silane.cti", "silane"); int nsp = gas.nSpecies(); int ntemps = 50; // number of temperatures @@ -114,6 +119,7 @@ int equil_example1(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/examples/cxx/examples.cpp b/examples/cxx/examples.cpp index 13ea8361d..60920bfeb 100755 --- a/examples/cxx/examples.cpp +++ b/examples/cxx/examples.cpp @@ -2,6 +2,12 @@ #include "Cantera.h" //#include "ctexceptions.h" +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + #define NUM_EXAMPLES 6 int kinetics_example1(int job); diff --git a/examples/cxx/flame1.cpp b/examples/cxx/flame1.cpp index e5163aefd..043bdb3bb 100644 --- a/examples/cxx/flame1.cpp +++ b/examples/cxx/flame1.cpp @@ -7,7 +7,7 @@ main() { // create the gas object - IdealGasMix gas("gri30.xml"); + IdealGasMix gas("gri30.cti"); doublereal temp = 500.0; doublereal pres = 2.0*OneAtm; gas.setState_TPX(temp, pres, "CH4:1.0, O2:2.0, N2:7.52"); diff --git a/examples/cxx/kinetics_example1.cpp b/examples/cxx/kinetics_example1.cpp index f07ad78ea..a23125e2e 100755 --- a/examples/cxx/kinetics_example1.cpp +++ b/examples/cxx/kinetics_example1.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "zerodim.h" #include "IdealGasMix.h" @@ -29,7 +34,7 @@ int kinetics_example1(int job) { try { cout << "Ignition simulation using class IdealGasMix " - << "with file gri30.inp." + << "with file gri30.cti." << endl; if (job >= 1) { @@ -44,7 +49,7 @@ int kinetics_example1(int job) { // create an ideal gas mixture that corresponds to GRI-Mech // 3.0 - IdealGasMix* gg = new IdealGasMix("gri30.xml", "gri30"); + IdealGasMix* gg = new IdealGasMix("gri30.cti", "gri30"); IdealGasMix& gas = *gg; // set the state @@ -121,6 +126,7 @@ int kinetics_example1(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/examples/cxx/kinetics_example2.cpp b/examples/cxx/kinetics_example2.cpp index c95963d63..136fafaa8 100755 --- a/examples/cxx/kinetics_example2.cpp +++ b/examples/cxx/kinetics_example2.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Cantera.h" #include "GRI30.h" @@ -109,6 +114,7 @@ int kinetics_example2(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/examples/cxx/rxnpath_example1.cpp b/examples/cxx/rxnpath_example1.cpp index eeb1a8d84..de4039b87 100755 --- a/examples/cxx/rxnpath_example1.cpp +++ b/examples/cxx/rxnpath_example1.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Cantera.h" #include "zerodim.h" @@ -80,7 +85,7 @@ int rxnpath_example1(int job) { try { - cout << "Reaction path diagram movies with file gri30mod.inp." << endl; + cout << "Reaction path diagram movies with file gri30.cti." << endl; if (job >= 1) { cout << "Generate reaction path diagrams following nitrogen\n" << "as a function of time for constant-pressure ignition of a\n" @@ -94,10 +99,10 @@ int rxnpath_example1(int job) { // create an ideal gas mixture that corresponds to GRI-Mech // 3.0 - IdealGasMix gas("gri30.xml", "gri30"); + IdealGasMix gas("gri30.cti", "gri30"); gas.setState_TPX(1001.0, OneAtm, "H2:2.0, O2:1.0, N2:4.0"); int nsp = gas.nSpecies(); - cout << "number of species = " << nsp << endl; + // create a reactor Reactor r; @@ -156,6 +161,7 @@ int rxnpath_example1(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/examples/cxx/transport_example1.cpp b/examples/cxx/transport_example1.cpp index c07c780b4..6e372d75d 100755 --- a/examples/cxx/transport_example1.cpp +++ b/examples/cxx/transport_example1.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Cantera.h" #include "transport.h" @@ -55,7 +60,7 @@ int transport_example1(int job) { // create a gas mixture, and set its state - IdealGasMix gas("gri30.xml", "gri30"); + IdealGasMix gas("gri30.cti", "gri30"); doublereal temp = 500.0; doublereal pres = 2.0*OneAtm; gas.setState_TPX(temp, pres, "H2:1.0, CH4:0.1"); @@ -105,6 +110,7 @@ int transport_example1(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/examples/cxx/transport_example2.cpp b/examples/cxx/transport_example2.cpp index 451b3457a..cd95bc23d 100755 --- a/examples/cxx/transport_example2.cpp +++ b/examples/cxx/transport_example2.cpp @@ -10,6 +10,11 @@ // ///////////////////////////////////////////////////////////// +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif #include "Cantera.h" #include "transport.h" @@ -56,7 +61,7 @@ int transport_example2(int job) { // create a gas mixture, and set its state - IdealGasMix gas("gri30.xml", "gri30"); + IdealGasMix gas("gri30.cti", "gri30"); doublereal temp = 2000.0; doublereal pres = 2.0*OneAtm; gas.setState_TPX(temp, pres, "H2:1.0, O2:0.5, CH4:0.1, N2:0.2"); @@ -107,6 +112,7 @@ int transport_example2(int job) { catch (CanteraError) { showErrors(cout); cout << " terminating... " << endl; + appdelete(); return -1; } } diff --git a/include/IdealGasMix.h b/include/IdealGasMix.h index 2ea300262..9e4665e7e 100644 --- a/include/IdealGasMix.h +++ b/include/IdealGasMix.h @@ -27,9 +27,7 @@ namespace Cantera { m_ok = buildSolutionFromXML(root, id, "phase", this, this); } - virtual ~IdealGasMix() { - delete m_r; - } + virtual ~IdealGasMix() {} bool operator!() { return !m_ok;} bool ready() { return m_ok; }