From 44598112f8eb315833601eb7bfc71234ccf9bb5e Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 17 Dec 2008 16:56:43 +0000 Subject: [PATCH] More changes to exit() and added std:: to string in *.h --- Cantera/src/equil/ChemEquil.cpp | 9 +++++--- Cantera/src/equil/MultiPhaseEquil.cpp | 4 ++-- Cantera/src/equil/PropertyCalculator.h | 15 +++++++------- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 12 +++++------ Cantera/src/equil/vcs_elem_rearrange.cpp | 4 ++-- Cantera/src/equil/vcs_nondim.cpp | 6 +++--- Cantera/src/equil/vcs_prob.cpp | 25 ++++++++++++----------- Cantera/src/equil/vcs_report.cpp | 6 +++--- Cantera/src/equil/vcs_rxnadj.cpp | 4 ++-- Cantera/src/equil/vcs_solve.cpp | 10 ++++----- Cantera/src/equil/vcs_util.cpp | 3 ++- 11 files changed, 52 insertions(+), 46 deletions(-) diff --git a/Cantera/src/equil/ChemEquil.cpp b/Cantera/src/equil/ChemEquil.cpp index 5fb0117cc..5f871d25a 100755 --- a/Cantera/src/equil/ChemEquil.cpp +++ b/Cantera/src/equil/ChemEquil.cpp @@ -20,11 +20,11 @@ #endif #include -using namespace std; #include "ChemEquil.h" #include "DenseMatrix.h" +#include "ct_defs.h" #include "sort.h" #include "PropertyCalculator.h" #include "ctexceptions.h" @@ -32,7 +32,10 @@ using namespace std; #include "stringUtils.h" #include "MultiPhase.h" +using namespace std; + #include +#include int Cantera::ChemEquil_print_lvl = 0; //static char sbuf[1024]; @@ -705,14 +708,14 @@ namespace Cantera { t0 = t0 + dt; if (t0 <= tminPhase || t0 >= tmaxPhase) { printf("We shouldn't be here\n"); - exit(-1); + exit(EXIT_FAILURE); } if (loglevel > 0) { addLogEntry("new T estimate", t0); } if (t0 < 100.) { printf("t0 - we are here %g\n", t0); - exit(-1); + exit(EXIT_FAILURE); } s.setTemperature(t0); } diff --git a/Cantera/src/equil/MultiPhaseEquil.cpp b/Cantera/src/equil/MultiPhaseEquil.cpp index 9ea8355ca..8ce9d3fe3 100644 --- a/Cantera/src/equil/MultiPhaseEquil.cpp +++ b/Cantera/src/equil/MultiPhaseEquil.cpp @@ -882,7 +882,7 @@ namespace Cantera { FILE * FP = fopen(reportFile.c_str(), "w"); if (!FP) { printf("Failure to open file\n"); - exit(-1); + exit(EXIT_FAILURE); } double Temp = m_mix->temperature(); double pres = m_mix->pressure(); @@ -1018,7 +1018,7 @@ namespace Cantera { // fprintf(FP,"ERROR: incompatibility!\n"); // fclose(FP); // printf("ERROR: incompatibility!\n"); - // exit(-1); + // exit(EXIT_FAILURE); // } } #endif diff --git a/Cantera/src/equil/PropertyCalculator.h b/Cantera/src/equil/PropertyCalculator.h index be69dbe29..cb37cbcbb 100755 --- a/Cantera/src/equil/PropertyCalculator.h +++ b/Cantera/src/equil/PropertyCalculator.h @@ -12,6 +12,7 @@ #define CT_PROP_CALC_H #include "ct_defs.h" +#include namespace Cantera { @@ -24,7 +25,7 @@ namespace Cantera { public: virtual ~PropertyCalculator(){} virtual doublereal value(const M& s) =0; - virtual string symbol() =0; + virtual std::string symbol() =0; }; template @@ -33,7 +34,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.enthalpy_mass(); } - virtual string symbol() { return "H"; } + virtual std::string symbol() { return "H"; } }; template @@ -42,7 +43,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.entropy_mass(); } - virtual string symbol() { return "S"; } + virtual std::string symbol() { return "S"; } }; template @@ -51,7 +52,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.temperature(); } - virtual string symbol() { return "T"; } + virtual std::string symbol() { return "T"; } }; template @@ -60,7 +61,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.pressure(); } - virtual string symbol() { return "P"; } + virtual std::string symbol() { return "P"; } }; template @@ -69,7 +70,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.density(); } - virtual string symbol() { return "V"; } + virtual std::string symbol() { return "V"; } }; template @@ -78,7 +79,7 @@ namespace Cantera { virtual doublereal value(const M& s) { return s.intEnergy_mass(); } - virtual string symbol() { return "U"; } + virtual std::string symbol() { return "U"; } }; } diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index 7b121e4ac..effcfd64d 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -740,7 +740,7 @@ namespace VCSnonideal { FILE * FP = fopen(reportFile.c_str(), "w"); if (!FP) { plogf("Failure to open file\n"); - exit(-1); + exit(EXIT_FAILURE); } double Temp = m_mix->temperature(); double pres = m_mix->pressure(); @@ -878,7 +878,7 @@ namespace VCSnonideal { fprintf(FP,"ERROR: incompatibility!\n"); fclose(FP); plogf("ERROR: incompatibility!\n"); - exit(-1); + exit(EXIT_FAILURE); } } #endif @@ -1001,7 +1001,7 @@ namespace VCSnonideal { break; case cSurf: plogf("cSurf not handled yet\n"); - exit(-1); + exit(EXIT_FAILURE); case cStoichSubstance: VolPhase->m_eqnState = VCS_EOS_STOICH_SUB; break; @@ -1012,7 +1012,7 @@ namespace VCSnonideal { break; case cEdge: plogf("cEdge not handled yet\n"); - exit(-1); + exit(EXIT_FAILURE); case cIdealSolidSolnPhase0: case cIdealSolidSolnPhase1: case cIdealSolidSolnPhase2: @@ -1025,7 +1025,7 @@ namespace VCSnonideal { VolPhase->m_eqnState = VCS_EOS_UNK_CANTERA; if (!VolPhase->usingCanteraCalls()) { plogf("vcs functions asked for, but unimplemented\n"); - exit(-1); + exit(EXIT_FAILURE); } break; } @@ -1168,7 +1168,7 @@ namespace VCSnonideal { ts_ptr->SSStar_Model = VCS_SSSTAR_NOTHANDLED; if (!(ts_ptr->UseCanteraCalls )) { plogf("Cantera calls not being used -> exiting\n"); - exit(-1); + exit(EXIT_FAILURE); } } diff --git a/Cantera/src/equil/vcs_elem_rearrange.cpp b/Cantera/src/equil/vcs_elem_rearrange.cpp index 1a1edcd52..95e94feaa 100644 --- a/Cantera/src/equil/vcs_elem_rearrange.cpp +++ b/Cantera/src/equil/vcs_elem_rearrange.cpp @@ -117,7 +117,7 @@ namespace VCSnonideal { if (k == m_numElemConstraints) { plogf("vcs_elem_rearrange::Shouldn't be here. Algorithm misfired."); plogendl(); - exit(-1); + exit(EXIT_FAILURE); } /* @@ -228,7 +228,7 @@ namespace VCSnonideal { plogf("vcs_switch_elem_pos: ifunc = 0: inappropriate args: %d %d\n", ipos, jpos); plogendl(); - exit(-1); + exit(EXIT_FAILURE); } #endif /* diff --git a/Cantera/src/equil/vcs_nondim.cpp b/Cantera/src/equil/vcs_nondim.cpp index feabb6e24..16d44448d 100644 --- a/Cantera/src/equil/vcs_nondim.cpp +++ b/Cantera/src/equil/vcs_nondim.cpp @@ -49,7 +49,7 @@ namespace VCSnonideal { default: plogf("vcs_nondim_Farad error: unknown units: %d\n", mu_units); plogendl(); - exit(-1); + exit(EXIT_FAILURE); } return Farad; } @@ -85,7 +85,7 @@ namespace VCSnonideal { default: plogf("vcs_nondimMult_TP error: unknown units: %d\n", mu_units); plogendl(); - std::exit(-1); + exit(EXIT_FAILURE); } return rt; } @@ -278,7 +278,7 @@ namespace VCSnonideal { break; default: plogf("unknown units!"); - exit(-1); + exit(EXIT_FAILURE); } } diff --git a/Cantera/src/equil/vcs_prob.cpp b/Cantera/src/equil/vcs_prob.cpp index 4f8f705a6..6d1891b4c 100644 --- a/Cantera/src/equil/vcs_prob.cpp +++ b/Cantera/src/equil/vcs_prob.cpp @@ -22,6 +22,7 @@ #include "ThermoPhase.h" #include "MolalityVPSSTP.h" +#include #include using namespace std; @@ -59,21 +60,21 @@ namespace VCSnonideal { NSPECIES0 = nspecies; if (nspecies <= 0) { plogf("number of species is zero or neg\n"); - exit(-1); + exit(EXIT_FAILURE); } NE0 = ne; if (ne <= 0) { plogf("number of elements is zero or neg\n"); - exit(-1); + exit(EXIT_FAILURE); } NPHASE0 = NPhase; if (NPhase <= 0) { plogf("number of phases is zero or neg\n"); - exit(-1); + exit(EXIT_FAILURE); } if (nspecies < NPhase) { plogf("number of species is less than number of phases\n"); - exit(-1); + exit(EXIT_FAILURE); } m_gibbsSpecies.resize(nspecies, 0.0); @@ -95,7 +96,7 @@ namespace VCSnonideal { VCS_SPECIES_THERMO *ts_tmp = new VCS_SPECIES_THERMO(0, 0); if (ts_tmp == 0) { plogf("Failed to init a ts struct\n"); - exit(-1); + exit(EXIT_FAILURE); } SpeciesThermo[kspec] = ts_tmp; } @@ -163,7 +164,7 @@ namespace VCSnonideal { if (nspecies > NSPECIES0) { nspecies = NSPECIES0; plogf("shouldn't be here\n"); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -248,7 +249,7 @@ namespace VCSnonideal { plogf("\t\tPres = %g atm\n", pres_atm); } else { plogf("\tUnknown problem type\n"); - exit(-1); + exit(EXIT_FAILURE); } plogf("\n"); plogf(" Phase IDs of species\n"); @@ -409,7 +410,7 @@ namespace VCSnonideal { int VCS_PROB::addElement(const char *elNameNew, int elType, int elactive) { if (!elNameNew) { plogf("error: element must have a name\n"); - exit(-1); + exit(EXIT_FAILURE); } int nel = ne + 1; resizeElements(nel, 1); @@ -440,14 +441,14 @@ namespace VCSnonideal { * Need to expand the number of species here */ plogf("Shouldn't be here\n"); - exit(-1); + exit(EXIT_FAILURE); } double const *const *const fm = volPhase->getFormulaMatrix(); for (eVP = 0; eVP < volPhase->nElemConstraints(); eVP++) { e = volPhase->elemGlobalIndex(eVP); #ifdef DEBUG_MODE if (e < 0) { - std::exit(-1); + exit(EXIT_FAILURE); } #endif FormulaMatrix[e][kT] = fm[eVP][k]; @@ -471,7 +472,7 @@ namespace VCSnonideal { FILE * FP = fopen(reportFile.c_str(), "w"); if (!FP) { plogf("Failure to open file\n"); - exit(-1); + exit(EXIT_FAILURE); } double Temp = T; @@ -608,7 +609,7 @@ namespace VCSnonideal { fprintf(FP,"ERROR: incompatibility!\n"); fclose(FP); plogf("ERROR: incompatibility!\n"); - exit(-1); + exit(EXIT_FAILURE); } } #endif diff --git a/Cantera/src/equil/vcs_report.cpp b/Cantera/src/equil/vcs_report.cpp index f7ca08a9e..c6aab4ed4 100644 --- a/Cantera/src/equil/vcs_report.cpp +++ b/Cantera/src/equil/vcs_report.cpp @@ -151,7 +151,7 @@ namespace VCSnonideal { plogf(" Voltage = %14.7E", m_molNumSpecies_old[l] * molScale); } else { plogf("we have a problem\n"); - std::exit(-1); + exit(EXIT_FAILURE); } plogf("\n"); } @@ -261,7 +261,7 @@ namespace VCSnonideal { if (m_tPhaseMoles_old[iphase] != VPhase->totalMoles()) { if (! vcs_doubleEqual(m_tPhaseMoles_old[iphase], VPhase->totalMoles())) { plogf("We have a problem\n"); - exit(-1); + exit(EXIT_FAILURE); } } vcs_elabPhase(iphase, VCS_DATA_PTR(gaPhase)); @@ -352,7 +352,7 @@ namespace VCSnonideal { + lx - m_lnMnaughtSpecies[l] + eContrib; if (fabs(m_feSpecies_old[l] - tmp) > 1.0E-7) { plogf("\n\t\twe have a problem - doesn't add up\n"); - exit(-1); + exit(EXIT_FAILURE); } plogf(" %12.4E |", m_feSpecies_old[l]); if( m_lnMnaughtSpecies[l] != 0.0) { diff --git a/Cantera/src/equil/vcs_rxnadj.cpp b/Cantera/src/equil/vcs_rxnadj.cpp index ce93edf94..80e5e8301 100644 --- a/Cantera/src/equil/vcs_rxnadj.cpp +++ b/Cantera/src/equil/vcs_rxnadj.cpp @@ -304,7 +304,7 @@ namespace VCSnonideal { m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDSS; if (m_SSPhase[kspec] != 1) { printf("vcs_RxnStepSizes:: we shouldn't be here!\n"); - std::exit(-1); + exit(EXIT_FAILURE); } } #ifdef DEBUG_MODE @@ -587,7 +587,7 @@ namespace VCSnonideal { double hessActCoef = vcs_Hessian_actCoeff_diag(irxn); if (hessianDiag_Ideal <= 0.0) { plogf("vcs_Hessian_diag_adj::We shouldn't be here\n"); - exit(-1); + exit(EXIT_FAILURE); } if (hessActCoef >= 0.0) { diag += hessActCoef; diff --git a/Cantera/src/equil/vcs_solve.cpp b/Cantera/src/equil/vcs_solve.cpp index c1b067082..108d1dcbc 100644 --- a/Cantera/src/equil/vcs_solve.cpp +++ b/Cantera/src/equil/vcs_solve.cpp @@ -706,7 +706,7 @@ namespace VCSnonideal { m_elType[i] = VCS_ELEM_TYPE_CHARGENEUTRALITY; if (pub->m_elType[i] != VCS_ELEM_TYPE_CHARGENEUTRALITY) { plogf("we have an inconsistency!\n"); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -717,7 +717,7 @@ namespace VCSnonideal { if (fabs(m_elemAbundancesGoal[i]) > 1.0E-9) { plogf("Charge neutrality condition %s is signicantly nonzero, %g. Giving up\n", m_elementName[i].c_str(), m_elemAbundancesGoal[i]); - std::exit(-1); + exit(EXIT_FAILURE); } else { plogf("Charge neutrality condition %s not zero, %g. Setting it zero\n", m_elementName[i].c_str(), m_elemAbundancesGoal[i]); @@ -999,14 +999,14 @@ namespace VCSnonideal { if (! vcs_doubleEqual( pubPhase->electricPotential() , tmp)) { plogf("We have an inconsistency in voltage, %g, %g\n", pubPhase->electricPotential(), tmp); - std::exit(-1); + exit(EXIT_FAILURE); } } if (! vcs_doubleEqual( pub->mf[kT], vPhase->molefraction(k))) { plogf("We have an inconsistency in mole fraction, %g, %g\n", pub->mf[kT], vPhase->molefraction(k)); - std::exit(-1); + exit(EXIT_FAILURE); } if (pubPhase->speciesUnknownType(k) != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { sumMoles += pub->w[kT]; @@ -1015,7 +1015,7 @@ namespace VCSnonideal { if (! vcs_doubleEqual(sumMoles, vPhase->totalMoles())) { plogf("We have an inconsistency in total moles, %g %g\n", sumMoles, pubPhase->totalMoles()); - std::exit(-1); + exit(EXIT_FAILURE); } } diff --git a/Cantera/src/equil/vcs_util.cpp b/Cantera/src/equil/vcs_util.cpp index c35493e66..5c20b3356 100644 --- a/Cantera/src/equil/vcs_util.cpp +++ b/Cantera/src/equil/vcs_util.cpp @@ -16,6 +16,7 @@ #include "vcs_internal.h" #include +#include using namespace std; @@ -389,7 +390,7 @@ namespace VCSnonideal { default: plogf("vcs_gasConstant error: uknown units: %d\n", mu_units); - exit(-1); + exit(EXIT_FAILURE); } return r; }