More changes to exit() and added std:: to string in *.h

This commit is contained in:
Harry Moffat 2008-12-17 16:56:43 +00:00
parent ff6aff01aa
commit 44598112f8
11 changed files with 52 additions and 46 deletions

View file

@ -20,11 +20,11 @@
#endif
#include <vector>
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 <cstdio>
#include <cstdlib>
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);
}

View file

@ -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

View file

@ -12,6 +12,7 @@
#define CT_PROP_CALC_H
#include "ct_defs.h"
#include <string>
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<class M>
@ -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<class M>
@ -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<class M>
@ -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<class M>
@ -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<class M>
@ -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<class M>
@ -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"; }
};
}

View file

@ -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);
}
}

View file

@ -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
/*

View file

@ -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);
}
}

View file

@ -22,6 +22,7 @@
#include "ThermoPhase.h"
#include "MolalityVPSSTP.h"
#include <cstdlib>
#include <string>
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

View file

@ -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) {

View file

@ -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;

View file

@ -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);
}
}

View file

@ -16,6 +16,7 @@
#include "vcs_internal.h"
#include <string.h>
#include <cstdlib>
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;
}