diff --git a/src/KSPACE/ewald_dipole.cpp b/src/KSPACE/ewald_dipole.cpp index 34c72dafc5..b918adede3 100644 --- a/src/KSPACE/ewald_dipole.cpp +++ b/src/KSPACE/ewald_dipole.cpp @@ -806,7 +806,6 @@ void EwaldDipole::slabcorr() if (atom->torque) { double ffact = qscale * (-4.0*MY_PI/volume); - double **mu = atom->mu; double **torque = atom->torque; for (int i = 0; i < nlocal; i++) { torque[i][0] += ffact * dipole_all * mu[i][1]; diff --git a/src/KSPACE/msm_cg.cpp b/src/KSPACE/msm_cg.cpp index 4c9384f13e..6123aedfb8 100644 --- a/src/KSPACE/msm_cg.cpp +++ b/src/KSPACE/msm_cg.cpp @@ -166,7 +166,7 @@ void MSMCG::compute(int eflag, int vflag) // forward communicate charge density values to fill ghost grid points // compute direct sum interaction and then restrict to coarser grid - for (int n=0; n<=levels-2; n++) { + for (n=0; n<=levels-2; n++) { if (!active_flag[n]) continue; current_level = n; gc[n]->forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO, @@ -209,7 +209,7 @@ void MSMCG::compute(int eflag, int vflag) // prolongate energy/virial from coarser grid to finer grid // reverse communicate from ghost grid points to get full sum - for (int n=levels-2; n>=0; n--) { + for (n=levels-2; n>=0; n--) { if (!active_flag[n]) continue; prolongation(n); diff --git a/src/KSPACE/pair_buck_coul_msm.cpp b/src/KSPACE/pair_buck_coul_msm.cpp index c7d237b161..c4ee5ce6f6 100644 --- a/src/KSPACE/pair_buck_coul_msm.cpp +++ b/src/KSPACE/pair_buck_coul_msm.cpp @@ -191,7 +191,7 @@ void PairBuckCoulMSM::compute(int eflag, int vflag) if (force->kspace->scalar_pressure_flag && vflag) { for (i = 0; i < 3; i++) virial[i] += force->pair->eng_coul/3.0; - for (int i = 0; i < nmax; i++) { + for (i = 0; i < nmax; i++) { f[i][0] += ftmp[i][0]; f[i][1] += ftmp[i][1]; f[i][2] += ftmp[i][2]; diff --git a/src/KSPACE/pair_buck_long_coul_long.cpp b/src/KSPACE/pair_buck_long_coul_long.cpp index f392179152..fa5b624462 100644 --- a/src/KSPACE/pair_buck_long_coul_long.cpp +++ b/src/KSPACE/pair_buck_long_coul_long.cpp @@ -506,40 +506,39 @@ void PairBuckLongCoulLong::compute(int eflag, int vflag) if (order1 && (rsq < cut_coulsq)) { // coulombic if (!ncoultablebits || rsq <= tabinnersq) { // series real space - double x = g_ewald*r; - double s = qri*q[j], t = 1.0/(1.0+EWALD_P*x); + double x1 = g_ewald*r; + double s = qri*q[j], t = 1.0/(1.0+EWALD_P*x1); if (ni == 0) { - s *= g_ewald*exp(-x*x); - force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s; + s *= g_ewald*exp(-x1*x1); + force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x1)+EWALD_F*s; if (eflag) ecoul = t; - } - else { // special case - double f = s*(1.0-special_coul[ni])/r; - s *= g_ewald*exp(-x*x); - force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s-f; - if (eflag) ecoul = t-f; + } else { // special case + double fc = s*(1.0-special_coul[ni])/r; + s *= g_ewald*exp(-x1*x1); + force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x1)+EWALD_F*s-fc; + if (eflag) ecoul = t-fc; } } // table real space else { union_int_float_t t; t.f = rsq; const int k = (t.i & ncoulmask) >> ncoulshiftbits; - double f = (rsq-rtable[k])*drtable[k], qiqj = qi*q[j]; + double fc = (rsq-rtable[k])*drtable[k], qiqj = qi*q[j]; if (ni == 0) { - force_coul = qiqj*(ftable[k]+f*dftable[k]); - if (eflag) ecoul = qiqj*(etable[k]+f*detable[k]); + force_coul = qiqj*(ftable[k]+fc*dftable[k]); + if (eflag) ecoul = qiqj*(etable[k]+fc*detable[k]); } else { // special case - t.f = (1.0-special_coul[ni])*(ctable[k]+f*dctable[k]); - force_coul = qiqj*(ftable[k]+f*dftable[k]-t.f); - if (eflag) ecoul = qiqj*(etable[k]+f*detable[k]-t.f); + t.f = (1.0-special_coul[ni])*(ctable[k]+fc*dctable[k]); + force_coul = qiqj*(ftable[k]+fc*dftable[k]-t.f); + if (eflag) ecoul = qiqj*(etable[k]+fc*detable[k]-t.f); } } } else force_coul = ecoul = 0.0; if (rsq < cut_bucksqi[typej]) { // buckingham - double rn = r2inv*r2inv*r2inv, - expr = exp(-r*rhoinvi[typej]); + double rn = r2inv*r2inv*r2inv; + double expr = exp(-r*rhoinvi[typej]); if (order6) { // long-range if (!ndisptablebits || rsq <= tabinnerdispsq) { double x2 = g2*rsq, a2 = 1.0/x2; diff --git a/src/lmppython.cpp b/src/lmppython.cpp index 209cfc1e31..742e912411 100644 --- a/src/lmppython.cpp +++ b/src/lmppython.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ #include "lmppython.h" -#if LMP_PYTHON +#if defined(LMP_PYTHON) #include "python_impl.h" #else #include "error.h" @@ -46,7 +46,7 @@ PythonInterface::~PythonInterface() void Python::init() { -#if LMP_PYTHON +#if defined(LMP_PYTHON) if (!impl) impl = new PythonImpl(lmp); #else error->all(FLERR,"Python support missing! Compile with PYTHON package installed!"); @@ -55,7 +55,7 @@ void Python::init() /* ---------------------------------------------------------------------- */ bool Python::is_enabled() const { -#if LMP_PYTHON +#if defined(LMP_PYTHON) return true; #else return false; diff --git a/src/math_extra.cpp b/src/math_extra.cpp index df74ad5be2..59e66242b3 100644 --- a/src/math_extra.cpp +++ b/src/math_extra.cpp @@ -71,8 +71,8 @@ int mldivide3(const double m[3][3], const double *v, double *ans) } for (unsigned j = i+1; j < 3; j++) { - double m = aug[j][i]/aug[i][i]; - for (unsigned k=i+1; k<4; k++) aug[j][k]-=m*aug[i][k]; + double n = aug[j][i]/aug[i][i]; + for (unsigned k=i+1; k<4; k++) aug[j][k]-=n*aug[i][k]; } } diff --git a/src/neighbor.cpp b/src/neighbor.cpp index ee4226f43e..eb4e89e692 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -513,7 +513,7 @@ void Neighbor::init() // print_pairwise_info() made use of requests // set of NeighLists now stores all needed info - for (int i = 0; i < nrequest; i++) { + for (i = 0; i < nrequest; i++) { delete requests[i]; requests[i] = nullptr; } @@ -2079,7 +2079,7 @@ void Neighbor::build(int topoflag) if (style != Neighbor::NSQ) { if (last_setup_bins < 0) setup_bins(); - for (int i = 0; i < nbin; i++) { + for (i = 0; i < nbin; i++) { neigh_bin[i]->bin_atoms_setup(nall); neigh_bin[i]->bin_atoms(); } diff --git a/src/read_dump.cpp b/src/read_dump.cpp index ddb793c629..d30bec4d36 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -818,9 +818,9 @@ void ReadDump::process_atoms() int nlocal = atom->nlocal; memory->create(updateflag,nlocal,"read_dump:updateflag"); - for (int i = 0; i < nlocal; i++) updateflag[i] = 0; + for (i = 0; i < nlocal; i++) updateflag[i] = 0; memory->create(newflag,nnew,"read_dump:newflag"); - for (int i = 0; i < nnew; i++) newflag[i] = 1; + for (i = 0; i < nnew; i++) newflag[i] = 1; // loop over new atoms @@ -918,7 +918,7 @@ void ReadDump::process_atoms() if (trimflag) { AtomVec *avec = atom->avec; - int i = 0; + i = 0; while (i < nlocal) { if (!updateflag[i]) { avec->copy(nlocal-1,i,1); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 2742dc5e4e..7d008b2518 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -339,7 +339,7 @@ void ReadRestart::command(int narg, char **arg) procfile, utils::getsyserror())); } - int flag,procsperfile; + int procsperfile; if (filereader) { utils::sfread(FLERR,&flag,sizeof(int),1,fp,nullptr,error); @@ -704,7 +704,7 @@ void ReadRestart::header() int procgrid[3]; read_int(); read_int_vec(3,procgrid); - int flag = 0; + flag = 0; if (comm->user_procgrid[0] != 0 && procgrid[0] != comm->user_procgrid[0]) flag = 1; if (comm->user_procgrid[1] != 0 && diff --git a/src/replicate.cpp b/src/replicate.cpp index 95bf615d04..12e3ad5cab 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -166,7 +166,7 @@ void Replicate::command(int narg, char **arg) atom->molecules = (Molecule **) memory->smalloc((old->nmolecule)*sizeof(Molecule *), "atom::molecules"); atom->nmolecule = old->nmolecule; - for (int i = 0; i < old->nmolecule; ++i) + for (i = 0; i < old->nmolecule; ++i) atom->molecules[i] = old->molecules[i]; memory->sfree(old->molecules); old->molecules = nullptr; diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index 7a6e914639..b0d5bef53e 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -100,7 +100,7 @@ char *TextFileReader::next_line(int nparams) { if (nwords > 0) n = strlen(line); while (nwords == 0 || nwords < nparams) { - char *ptr = fgets(&line[n], MAXLINE - n, fp); + ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { // EOF diff --git a/src/utils.cpp b/src/utils.cpp index e8f1c63606..0ff1d65633 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1008,8 +1008,8 @@ std::string utils::get_potential_file_path(const std::string &path) { while (dirs.has_next()) { auto pot = utils::path_basename(filepath); - auto path = dirs.next(); - filepath = utils::path_join(path, pot); + auto dir = dirs.next(); + filepath = utils::path_join(dir, pot); if (utils::file_is_readable(filepath)) { return filepath; diff --git a/src/variable.cpp b/src/variable.cpp index 3e93a33797..dc9a2dbee5 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -1894,7 +1894,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) } else if (strncmp(word,"v_",2) == 0) { - int ivar = find(word+2); + ivar = find(word+2); if (ivar < 0) print_var_error(FLERR,fmt::format("Invalid variable reference " "{} in variable formula",word),ivar); @@ -2338,7 +2338,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) double Variable::collapse_tree(Tree *tree) { - double arg1,arg2; + double arg1,arg2,arg3; if (tree->type == VALUE) return tree->value; if (tree->type == ATOMARRAY) return 0.0; @@ -2805,19 +2805,19 @@ double Variable::collapse_tree(Tree *tree) error->one(FLERR,"Invalid math function in variable formula"); if (ivalue4 < ivalue1 || ivalue5 > ivalue2) error->one(FLERR,"Invalid math function in variable formula"); - bigint istep; + bigint istep, offset; if (update->ntimestep < ivalue1) istep = ivalue1; else if (update->ntimestep < ivalue2) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { - bigint offset = update->ntimestep - ivalue1; + offset = update->ntimestep - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (update->ntimestep < ivalue2 && istep > ivalue4) tree->value = ivalue4; } else { - bigint offset = update->ntimestep - ivalue4; + offset = update->ntimestep - ivalue4; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; if (istep > ivalue5) { - bigint offset = ivalue5 - ivalue1; + offset = ivalue5 - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (istep > ivalue2) istep = MAXBIGINT; } @@ -2828,8 +2828,8 @@ double Variable::collapse_tree(Tree *tree) } if (tree->type == VDISPLACE) { - double arg1 = collapse_tree(tree->first); - double arg2 = collapse_tree(tree->second); + arg1 = collapse_tree(tree->first); + arg2 = collapse_tree(tree->second); if (tree->first->type != VALUE || tree->second->type != VALUE) return 0.0; tree->type = VALUE; double delta = update->ntimestep - update->beginstep; @@ -2838,9 +2838,9 @@ double Variable::collapse_tree(Tree *tree) } if (tree->type == SWIGGLE) { - double arg1 = collapse_tree(tree->first); - double arg2 = collapse_tree(tree->second); - double arg3 = collapse_tree(tree->extra[0]); + arg1 = collapse_tree(tree->first); + arg2 = collapse_tree(tree->second); + arg3 = collapse_tree(tree->extra[0]); if (tree->first->type != VALUE || tree->second->type != VALUE || tree->extra[0]->type != VALUE) return 0.0; tree->type = VALUE; @@ -2853,9 +2853,9 @@ double Variable::collapse_tree(Tree *tree) } if (tree->type == CWIGGLE) { - double arg1 = collapse_tree(tree->first); - double arg2 = collapse_tree(tree->second); - double arg3 = collapse_tree(tree->extra[0]); + arg1 = collapse_tree(tree->first); + arg2 = collapse_tree(tree->second); + arg3 = collapse_tree(tree->extra[0]); if (tree->first->type != VALUE || tree->second->type != VALUE || tree->extra[0]->type != VALUE) return 0.0; tree->type = VALUE; @@ -3134,19 +3134,19 @@ double Variable::eval_tree(Tree *tree, int i) error->one(FLERR,"Invalid math function in variable formula"); if (ivalue4 < ivalue1 || ivalue5 > ivalue2) error->one(FLERR,"Invalid math function in variable formula"); - bigint istep; + bigint istep, offset; if (update->ntimestep < ivalue1) istep = ivalue1; else if (update->ntimestep < ivalue2) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { - bigint offset = update->ntimestep - ivalue1; + offset = update->ntimestep - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (update->ntimestep < ivalue2 && istep > ivalue4) tree->value = ivalue4; } else { - bigint offset = update->ntimestep - ivalue4; + offset = update->ntimestep - ivalue4; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; if (istep > ivalue5) { - bigint offset = ivalue5 - ivalue1; + offset = ivalue5 - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (istep > ivalue2) istep = MAXBIGINT; } @@ -3716,18 +3716,18 @@ int Variable::math_function(char *word, char *contents, Tree **tree, error->one(FLERR,"Invalid math function in variable formula"); if (ivalue4 < ivalue1 || ivalue5 > ivalue2) error->one(FLERR,"Invalid math function in variable formula"); - bigint istep; + bigint istep, offset; if (update->ntimestep < ivalue1) istep = ivalue1; else if (update->ntimestep < ivalue2) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { - bigint offset = update->ntimestep - ivalue1; + offset = update->ntimestep - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (update->ntimestep < ivalue4 && istep > ivalue4) istep = ivalue4; } else { - bigint offset = update->ntimestep - ivalue4; + offset = update->ntimestep - ivalue4; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; if (istep > ivalue5) { - bigint offset = ivalue5 - ivalue1; + offset = ivalue5 - ivalue1; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; if (istep > ivalue2) istep = MAXBIGINT; } @@ -4107,9 +4107,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Compute *compute = nullptr; Fix *fix = nullptr; - int ivar = -1; int index,nvec,nstride; char *ptr1,*ptr2; + ivar = -1; // argument is compute @@ -4387,7 +4387,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree, if (narg != 1) print_var_error(FLERR,"Invalid special function in variable formula",ivar); - int ivar = find(args[0]); + ivar = find(args[0]); if (ivar < 0) { std::string mesg = "Variable ID '"; mesg += args[0]; @@ -4399,7 +4399,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree, // save value in tree or on argstack if (style[ivar] == SCALARFILE) { - double value = atof(data[ivar][0]); + value = atof(data[ivar][0]); int done = reader[ivar]->read_scalar(data[ivar][0]); if (done) remove(ivar);