diff --git a/include/cantera/base/XML_Writer.h b/include/cantera/base/XML_Writer.h index f9eb1bebb..4d65f061a 100644 --- a/include/cantera/base/XML_Writer.h +++ b/include/cantera/base/XML_Writer.h @@ -85,22 +85,22 @@ public: template void XML_writeVector(std::ostream& s, const std::string& indent, - const std::string& name, int vsize, iter v) { + const std::string& name, size_t vsize, iter v) { int ni; for (ni = 0; ni < _level; ni++) { s << _indent; } s << "<" << XML_filter(name) << "> "; - int n = vsize; - int n5 = n/5; - int i, j, k = 0; + size_t n = vsize; + size_t n5 = n/5; + size_t i, j, k = 0; for (j = 0; j < n5; j++) { for (i = 0; i < 5; i++) { - s << v[k] << (k < n - 1 ? ", " : ""); + s << v[k] << (k+1 < n ? ", " : ""); k++; } - if (j < n5-1) { + if (j+1 < n5) { s << std::endl; for (ni = 0; ni < _level; ni++) { s << _indent; @@ -108,7 +108,7 @@ public: } } for (i = k; i < n; i++) { - s << v[k] << (k < n - 1 ? ", " : ""); + s << v[k] << (k+1 < n ? ", " : ""); k++; } diff --git a/include/cantera/base/global.h b/include/cantera/base/global.h index 8c5de92ef..584e72380 100644 --- a/include/cantera/base/global.h +++ b/include/cantera/base/global.h @@ -171,7 +171,7 @@ void writelogf(const char* fmt,...); //! Write an end of line character to the screen and flush output void writelogendl(); -void writeline(char repeat, int count, +void writeline(char repeat, size_t count, bool endl_after=true, bool endl_before=false); //! @copydoc Application::Messages::logerror diff --git a/include/cantera/equil/vcs_solve.h b/include/cantera/equil/vcs_solve.h index 1a57848cb..62f4c22f1 100644 --- a/include/cantera/equil/vcs_solve.h +++ b/include/cantera/equil/vcs_solve.h @@ -1366,7 +1366,7 @@ private: void prneav() const; #endif - void checkDelta1(double* const ds, double* const delTPhMoles, int kspec); + void checkDelta1(double* const ds, double* const delTPhMoles, size_t kspec); //! Estimate equilibrium compositions /*! diff --git a/src/base/global.cpp b/src/base/global.cpp index 6d2ef2cfd..0d11bee13 100644 --- a/src/base/global.cpp +++ b/src/base/global.cpp @@ -68,7 +68,7 @@ void writelogendl() app()->writelogendl(); } -void writeline(char repeat, int count, bool endl_after, bool endl_before) +void writeline(char repeat, size_t count, bool endl_after, bool endl_before) { if (endl_before) { writelogendl(); diff --git a/src/equil/BasisOptimize.cpp b/src/equil/BasisOptimize.cpp index 694417994..273f4c2a6 100644 --- a/src/equil/BasisOptimize.cpp +++ b/src/equil/BasisOptimize.cpp @@ -404,7 +404,7 @@ static void print_stringTrunc(const char* str, int space, int alignment) ***********************************************************************/ { int i, ls=0, rs=0; - int len = strlen(str); + int len = static_cast(strlen(str)); if ((len) >= space) { for (i = 0; i < space; i++) { writelogf("%c", str[i]); diff --git a/src/equil/ChemEquil.cpp b/src/equil/ChemEquil.cpp index bf3717dfc..b917d0555 100644 --- a/src/equil/ChemEquil.cpp +++ b/src/equil/ChemEquil.cpp @@ -292,7 +292,7 @@ int ChemEquil::estimateElementPotentials(thermo_t& s, vector_fp& lambda_RT, if (DEBUG_MODE_ENABLED && ChemEquil_print_lvl > 0) { for (size_t m = 0; m < m_nComponents; m++) { - int isp = m_component[m]; + int isp = static_cast(m_component[m]); string nnn = s.speciesName(isp); writelogf("isp = %d, %s\n", isp, nnn.c_str()); } @@ -329,7 +329,7 @@ int ChemEquil::estimateElementPotentials(thermo_t& s, vector_fp& lambda_RT, if (DEBUG_MODE_ENABLED && ChemEquil_print_lvl > 0) { writelog(" id CompSpecies ChemPot EstChemPot Diff\n"); for (size_t m = 0; m < m_nComponents; m++) { - int isp = m_component[m]; + size_t isp = m_component[m]; double tmp = 0.0; string sname = s.speciesName(isp); for (size_t n = 0; n < m_mm; n++) { @@ -1567,8 +1567,8 @@ void ChemEquil::adjustEloc(thermo_t& s, vector_fp& elMolesGoal) s.getMoleFractions(DATA_PTR(m_molefractions)); size_t k; - int maxPosEloc = -1; - int maxNegEloc = -1; + size_t maxPosEloc = npos; + size_t maxNegEloc = npos; double maxPosVal = -1.0; double maxNegVal = -1.0; if (DEBUG_MODE_ENABLED && ChemEquil_print_lvl > 0) { diff --git a/src/equil/vcs_setMolesLinProg.cpp b/src/equil/vcs_setMolesLinProg.cpp index 39cbb99a0..dd95b5afb 100644 --- a/src/equil/vcs_setMolesLinProg.cpp +++ b/src/equil/vcs_setMolesLinProg.cpp @@ -21,12 +21,11 @@ static void printProgress(const vector &spName, const vector &soln, const vector &ff) { - int nsp = soln.size(); double sum = 0.0; plogf(" --- Summary of current progress:\n"); plogf(" --- Name Moles - SSGibbs \n"); plogf(" -------------------------------------------------------------------------------------\n"); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < soln.size(); k++) { plogf(" --- %20s %12.4g - %12.4g\n", spName[k].c_str(), soln[k], ff[k]); sum += soln[k] * ff[k]; } diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index 9f36f08ed..1ab1711d8 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -36,12 +36,12 @@ static int prnfm(void); /*****************************************************************************/ void VCS_SOLVE::checkDelta1(double* const dsLocal, - double* const delTPhMoles, int kspec) + double* const delTPhMoles, size_t kspec) { std::vector dchange(m_numPhases, 0.0); - for (int k = 0; k < kspec; k++) { + for (size_t k = 0; k < kspec; k++) { if (m_speciesUnknownType[k] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { - int iph = m_phaseID[k]; + size_t iph = m_phaseID[k]; dchange[iph] += dsLocal[k]; } } @@ -115,7 +115,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) solveFail = false; - int ll; // only used in DEBUG_MODE + size_t ll; // only used in DEBUG_MODE /* ****************************************************** */ /* **** Evaluate the elemental composition ****** */ /* ****************************************************** */ @@ -3167,8 +3167,8 @@ L_END_LOOP: * to conserve elements */ double sumMax = -1.0; - int iMax = -1; - int jMax = -1; + size_t iMax = npos; + size_t jMax = npos; for (size_t i = 0; i < m_numRxnTot; ++i) { k = m_indexRxnToSpecies[i]; double sum; diff --git a/src/equil/vcs_util.cpp b/src/equil/vcs_util.cpp index 07b649ae9..f0ac93736 100644 --- a/src/equil/vcs_util.cpp +++ b/src/equil/vcs_util.cpp @@ -164,7 +164,6 @@ double vcsUtil_gasConstant(int mu_units) const char* vcs_speciesType_string(int speciesStatus, int length) { - const char* sss; switch (speciesStatus) { case VCS_SPECIES_COMPONENT: return "Component Species"; diff --git a/src/thermo/RedlichKisterVPSSTP.cpp b/src/thermo/RedlichKisterVPSSTP.cpp index a0192af16..b571d9bbc 100644 --- a/src/thermo/RedlichKisterVPSSTP.cpp +++ b/src/thermo/RedlichKisterVPSSTP.cpp @@ -760,7 +760,6 @@ void RedlichKisterVPSSTP::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) #ifdef DEBUG_MODE void RedlichKisterVPSSTP::Vint(double& VintOut, double& voltsOut) { - int iA, iB, m; doublereal XA, XB; doublereal T = temperature(); doublereal RT = GasConstant * T; @@ -769,8 +768,8 @@ void RedlichKisterVPSSTP::Vint(double& VintOut, double& voltsOut) lnActCoeff_Scaled_.assign(m_kk, 0.0); for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; if (XA <= 1.0E-14) { @@ -780,7 +779,7 @@ void RedlichKisterVPSSTP::Vint(double& VintOut, double& voltsOut) XA = 1.0 - 1.0E-14; } - int N = m_N_ij[i]; + size_t N = m_N_ij[i]; vector_fp& he_vec = m_HE_m_ij[i]; vector_fp& se_vec = m_SE_m_ij[i]; double fac = 2.0 * XA - 1.0; @@ -790,7 +789,7 @@ void RedlichKisterVPSSTP::Vint(double& VintOut, double& voltsOut) double polykp1 = fac; double poly1mk = fac; - for (m = 0; m < N; m++) { + for (size_t m = 0; m < N; m++) { doublereal A_ge = he_vec[m] - T * se_vec[m]; Volts += A_ge * (polykp1 - (2.0 * XA * m * (1.0-XA)) / poly1mk); polykp1 *= fac;