Skip to content

Commit

Permalink
Eliminate compiler warnings issued by Visual Studio 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jul 31, 2016
1 parent 92ae2bd commit 4582e72
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 62 deletions.
2 changes: 1 addition & 1 deletion include/cantera/thermo/ThermoPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class ThermoPhase : public Phase
* @returns the current value of the Heat of Formation at 298K
* and 1 bar
*/
doublereal Hf298SS(const int k) const {
doublereal Hf298SS(const size_t k) const {
return m_spthermo->reportOneHf298(k);
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void Application::setDefaultDirectories()
pythonpath += ";";
pythonpath.append(old_pythonpath);
}
putenv(pythonpath.c_str());
_putenv(pythonpath.c_str());
}

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/equil/MultiPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
strt = false;
}

} catch (CanteraError& err) {
} catch (CanteraError&) {
if (!strt) {
strt = true;
} else {
Expand Down Expand Up @@ -599,7 +599,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
if (dta < 100.0) {
strt = false;
}
} catch (CanteraError& err) {
} catch (CanteraError&) {
if (!strt) {
strt = true;
} else {
Expand Down
64 changes: 32 additions & 32 deletions src/equil/vcs_rxnadj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
{
size_t iphDel = npos;
size_t k = 0;
char ANOTE[128];
std::string ANOTE;
if (m_debug_print_lvl >= 2) {
plogf(" ");
for (int j = 0; j < 82; j++) {
Expand All @@ -46,12 +46,12 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)

// LOOP OVER THE FORMATION REACTIONS
for (size_t irxn = 0; irxn < m_numRxnRdc; ++irxn) {
sprintf(ANOTE, "Normal Calc");
ANOTE = "Normal Calc";

size_t kspec = m_indexRxnToSpecies[irxn];
if (m_speciesStatus[kspec] == VCS_SPECIES_ZEROEDPHASE) {
m_deltaMolNumSpecies[kspec] = 0.0;
sprintf(ANOTE, "ZeroedPhase: Phase is artificially zeroed");
ANOTE = "ZeroedPhase: Phase is artificially zeroed";
} else if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
if (m_molNumSpecies_old[kspec] == 0.0 && (!m_SSPhase[kspec])) {
// MULTISPECIES PHASE WITH total moles equal to zero
Expand All @@ -70,27 +70,26 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
m_deltaMolNumSpecies[kspec] = m_totalMolNum * VCS_SMALL_MULTIPHASE_SPECIES;
if (m_speciesStatus[kspec] == VCS_SPECIES_STOICHZERO) {
m_deltaMolNumSpecies[kspec] = 0.0;
sprintf(ANOTE, "MultSpec (%s): Species not born due to STOICH/PHASEPOP even though DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("MultSpec (%s): Species not born due to STOICH/PHASEPOP even though DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
} else {
m_deltaMolNumSpecies[kspec] = m_totalMolNum * VCS_SMALL_MULTIPHASE_SPECIES * 10.0;
sprintf(ANOTE, "MultSpec (%s): small species born again DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("MultSpec (%s): small species born again DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
}
} else {
sprintf(ANOTE, "MultSpec (%s):still dead, no phase pop, even though DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("MultSpec (%s):still dead, no phase pop, even though DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
m_deltaMolNumSpecies[kspec] = 0.0;
if (Vphase->exists() > 0 && trphmoles > 0.0) {
m_deltaMolNumSpecies[kspec] = m_totalMolNum * VCS_SMALL_MULTIPHASE_SPECIES * 10.;
sprintf(ANOTE,
"MultSpec (%s): birthed species because it was zero in a small existing phase with DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("MultSpec (%s): birthed species because it was zero in a small existing phase with DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
}
}
} else {
sprintf(ANOTE, "MultSpec (%s): still dead DG = %11.3E", vcs_speciesType_string(m_speciesStatus[kspec], 15),
m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("MultSpec (%s): still dead DG = %11.3E",
vcs_speciesType_string(m_speciesStatus[kspec], 15), m_deltaGRxn_new[irxn]);
m_deltaMolNumSpecies[kspec] = 0.0;
}
} else {
Expand All @@ -100,7 +99,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
// bother if superconvergence has already been achieved in this
// mode.
if (fabs(m_deltaGRxn_new[irxn]) <= m_tolmaj2) {
sprintf(ANOTE, "Skipped: superconverged DG = %11.3E", m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("Skipped: superconverged DG = %11.3E", m_deltaGRxn_new[irxn]);
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec]);
plogf(" %12.4E %12.4E %12.4E | %s\n",
Expand All @@ -113,7 +112,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
// Don't calculate for minor or nonexistent species if their
// values are to be decreasing anyway.
if ((m_speciesStatus[kspec] != VCS_SPECIES_MAJOR) && (m_deltaGRxn_new[irxn] >= 0.0)) {
sprintf(ANOTE, "Skipped: IC = %3d and DG >0: %11.3E", m_speciesStatus[kspec], m_deltaGRxn_new[irxn]);
ANOTE = fmt::sprintf("Skipped: IC = %3d and DG >0: %11.3E",
m_speciesStatus[kspec], m_deltaGRxn_new[irxn]);
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec]);
plogf(" %12.4E %12.4E %12.4E | %s\n",
Expand Down Expand Up @@ -148,8 +148,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_useActCoeffJac) {
double s_old = s;
s = vcs_Hessian_diag_adj(irxn, s_old);
sprintf(ANOTE, "Normal calc: diag adjusted from %g "
"to %g due to act coeff", s_old, s);
ANOTE = fmt::sprintf("Normal calc: diag adjusted from %g "
"to %g due to act coeff", s_old, s);
}

m_deltaMolNumSpecies[kspec] = -m_deltaGRxn_new[irxn] / s;
Expand All @@ -160,14 +160,14 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
double negChangeComp = -stoicC * m_deltaMolNumSpecies[kspec];
if (negChangeComp > m_molNumSpecies_old[j]) {
if (m_molNumSpecies_old[j] > 0.0) {
sprintf(ANOTE, "Delta damped from %g "
"to %g due to component %lu (%10s) going neg", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[j] / stoicC, j, m_speciesName[j].c_str());
ANOTE = fmt::sprintf("Delta damped from %g "
"to %g due to component %d (%10s) going neg", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[j] / stoicC, j, m_speciesName[j]);
m_deltaMolNumSpecies[kspec] = -m_molNumSpecies_old[j] / stoicC;
} else {
sprintf(ANOTE, "Delta damped from %g "
"to %g due to component %lu (%10s) zero", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[j] / stoicC, j, m_speciesName[j].c_str());
ANOTE = fmt::sprintf("Delta damped from %g "
"to %g due to component %d (%10s) zero", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[j] / stoicC, j, m_speciesName[j]);
m_deltaMolNumSpecies[kspec] = 0.0;
}
}
Expand All @@ -176,9 +176,9 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
// Implement a damping term that limits m_deltaMolNumSpecies
// to the size of the mole number
if (-m_deltaMolNumSpecies[kspec] > m_molNumSpecies_old[kspec]) {
sprintf(ANOTE, "Delta damped from %g "
"to %g due to %s going negative", m_deltaMolNumSpecies[kspec], -m_molNumSpecies_old[kspec],
m_speciesName[kspec].c_str());
ANOTE = fmt::sprintf("Delta damped from %g "
"to %g due to %s going negative", m_deltaMolNumSpecies[kspec], -m_molNumSpecies_old[kspec],
m_speciesName[kspec]);
m_deltaMolNumSpecies[kspec] = -m_molNumSpecies_old[kspec];
}
} else {
Expand Down Expand Up @@ -231,8 +231,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
// having all of the mole numbers of that phases. it
// seems that we can suggest a zero of the species
// and the code will recover.
sprintf(ANOTE, "Delta damped from %g to %g due to delete %s", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[kspec], m_speciesName[kspec].c_str());
ANOTE = fmt::sprintf("Delta damped from %g to %g due to delete %s", m_deltaMolNumSpecies[kspec],
-m_molNumSpecies_old[kspec], m_speciesName[kspec]);
m_deltaMolNumSpecies[kspec] = -m_molNumSpecies_old[kspec];
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec]);
Expand All @@ -256,10 +256,10 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
kSpecial = k;

if (k != kspec) {
sprintf(ANOTE, "Delete component SS phase %lu named %s - SS phases only", iphDel,
m_speciesName[k].c_str());
ANOTE = fmt::sprintf("Delete component SS phase %d named %s - SS phases only",
iphDel, m_speciesName[k]);
} else {
sprintf(ANOTE, "Delete this SS phase %lu - SS components only", iphDel);
ANOTE = fmt::sprintf("Delete this SS phase %d - SS components only", iphDel);
}
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec]);
Expand Down
2 changes: 1 addition & 1 deletion src/equil/vcs_solve_TP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit)
return -1;
}
solve_tp_inner(iti, it1, uptodate_minors, allMinorZeroedSpecies,
forceComponentCalc, stage, printDetails, ANOTE);
forceComponentCalc, stage, printDetails > 0, ANOTE);
lec = false;
} else if (stage == EQUILIB_CHECK) {
// EQUILIBRIUM CHECK FOR MAJOR SPECIES
Expand Down
18 changes: 10 additions & 8 deletions src/numerics/BandMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ int BandMatrix::factor()
ct_dgbtrf(nRows(), nColumns(), nSubDiagonals(), nSuperDiagonals(),
ludata.data(), ldim(), ipiv().data(), info);
#else
long int nu = nSuperDiagonals();
long int nl = nSubDiagonals();
int smu = nu + nl;
info = bandGBTRF(m_lu_col_ptrs.data(), nColumns(), nu, nl, smu, m_ipiv.data());
long int nu = static_cast<long int>(nSuperDiagonals());
long int nl = static_cast<long int>(nSubDiagonals());
long int smu = nu + nl;
info = bandGBTRF(m_lu_col_ptrs.data(), static_cast<long int>(nColumns()),
nu, nl, smu, m_ipiv.data());
#endif
// if info = 0, LU decomp succeeded.
if (info == 0) {
Expand Down Expand Up @@ -275,11 +276,12 @@ int BandMatrix::solve(doublereal* b, size_t nrhs, size_t ldb)
nSuperDiagonals(), nrhs, ludata.data(), ldim(),
ipiv().data(), b, ldb, info);
#else
long int nu = nSuperDiagonals();
long int nl = nSubDiagonals();
int smu = nu + nl;
long int nu = static_cast<long int>(nSuperDiagonals());
long int nl = static_cast<long int>(nSubDiagonals());
long int smu = nu + nl;
double** a = m_lu_col_ptrs.data();
bandGBTRS(a, nColumns(), smu, nl, m_ipiv.data(), b);
bandGBTRS(a, static_cast<long int>(nColumns()), smu, nl, m_ipiv.data(),
b);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/numerics/CVodesIntegrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CVodesIntegrator::~CVodesIntegrator()
N_VDestroy_Serial(m_abstol);
}
if (m_yS) {
N_VDestroyVectorArray_Serial(m_yS, m_np);
N_VDestroyVectorArray_Serial(m_yS, static_cast<sd_size_t>(m_np));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/oneD/Sim1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void Sim1D::solve(int loglevel, bool refine_grid)

while (new_points > 0) {
size_t istep = 0;
size_t nsteps = m_steps[istep];
int nsteps = m_steps[istep];

bool ok = false;
if (loglevel > 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1)
if (m_do_multicomponent) {
for (size_t j = j0; j < j1; j++) {
double dz = z(j+1) - z(j);
for (double k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
doublereal sum = 0.0;
for (size_t m = 0; m < m_nsp; m++) {
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
Expand All @@ -513,13 +513,13 @@ void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1)
double wtm = m_wtm[j];
double rho = density(j);
double dz = z(j+1) - z(j);
for (double k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
m_flux(k,j) = m_wt[k]*(rho*m_diff[k+m_nsp*j]/wtm);
m_flux(k,j) *= (X(x,k,j) - X(x,k,j+1))/dz;
sum -= m_flux(k,j);
}
// correction flux to insure that \sum_k Y_k V_k = 0.
for (double k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
m_flux(k,j) += sum*Y(x,k,j);
}
}
Expand Down Expand Up @@ -704,7 +704,7 @@ void StFlow::restore(const XML_Node& dom, doublereal* soln, int loglevel)
getFloatArray(dom, x, false, "", "energy_enabled");
if (x.size() == nPoints()) {
for (size_t i = 0; i < x.size(); i++) {
m_do_energy[i] = x[i];
m_do_energy[i] = (x[i] != 0);
}
} else if (!x.empty()) {
throw CanteraError("StFlow::restore", "energy_enabled is length {}"
Expand All @@ -716,7 +716,7 @@ void StFlow::restore(const XML_Node& dom, doublereal* soln, int loglevel)
getFloatArray(dom, x, false, "", "species_enabled");
if (x.size() == m_nsp) {
for (size_t i = 0; i < x.size(); i++) {
m_do_species[i] = x[i];
m_do_species[i] = (x[i] != 0);
}
} else if (!x.empty()) {
// This may occur when restoring from a mechanism with a different
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/MolalityVPSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (NotImplementedError& e) {
} catch (NotImplementedError&) {
b.write(" heat capacity c_v <not implemented>\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/MolarityIonicVPSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ std::string MolarityIonicVPSSTP::report(bool show_thermo, doublereal threshold)
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (NotImplementedError& e) {
} catch (NotImplementedError&) {
b.write(" heat capacity c_v <not implemented>\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/PureFluidPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ std::string PureFluidPhase::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (NotImplementedError& e) {
} catch (NotImplementedError&) {
b.write(" heat capacity c_v <not implemented>\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/ThermoPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ std::string ThermoPhase::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.5g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (NotImplementedError& err) {
} catch (NotImplementedError&) {
b.write(" heat capacity c_v <not implemented> \n");
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/general/test_matrices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ class BandMatrixTest : public testing::Test
A1.resize(6, 1, 2); // one lower, two upper
A2.resize(6, 2, 1); // two lower, one upper
// main diagonal
for (size_t i = 0; i < 6; i++) {
for (int i = 0; i < 6; i++) {
A1(i, i) = i + 1;
A2(i, i) = i + 1;
}

// first subdiagonal and superdiagonal
for (size_t i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++) {
A1(i+1, i) = 2 * i + 1;
A1(i, i+1) = i * i;
A2(i+1, i) = 2 * i + 1;
A2(i, i+1) = i * i;
}

// second subdiagonal and superdiagonal
for (size_t i = 0; i < 4; i++) {
A1(i, i+2) = - static_cast<int>(i + 3);
A2(i+2, i) = - static_cast<int>(i + 1);
for (int i = 0; i < 4; i++) {
A1(i, i+2) = - i - 3;
A2(i+2, i) = - i - 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test_problems/cathermo/testWaterTP/testWaterSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int main()
Hset += deltaH;
try {
w->setState_HP(Hset, OneAtm);
} catch (CanteraError& err) {
} catch (CanteraError&) {
printf(" %10g, -> Failed to converge, beyond the spinodal probably \n\n", Hset);
break;
}
Expand Down

0 comments on commit 4582e72

Please sign in to comment.