silence compiler warnings

This commit is contained in:
Axel Kohlmeyer
2021-04-23 16:19:57 -04:00
parent f759e6ffcf
commit ef858ae70f
13 changed files with 61 additions and 63 deletions

View File

@ -806,7 +806,6 @@ void EwaldDipole::slabcorr()
if (atom->torque) { if (atom->torque) {
double ffact = qscale * (-4.0*MY_PI/volume); double ffact = qscale * (-4.0*MY_PI/volume);
double **mu = atom->mu;
double **torque = atom->torque; double **torque = atom->torque;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
torque[i][0] += ffact * dipole_all * mu[i][1]; torque[i][0] += ffact * dipole_all * mu[i][1];

View File

@ -166,7 +166,7 @@ void MSMCG::compute(int eflag, int vflag)
// forward communicate charge density values to fill ghost grid points // forward communicate charge density values to fill ghost grid points
// compute direct sum interaction and then restrict to coarser grid // 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; if (!active_flag[n]) continue;
current_level = n; current_level = n;
gc[n]->forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO, 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 // prolongate energy/virial from coarser grid to finer grid
// reverse communicate from ghost grid points to get full sum // 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; if (!active_flag[n]) continue;
prolongation(n); prolongation(n);

View File

@ -191,7 +191,7 @@ void PairBuckCoulMSM::compute(int eflag, int vflag)
if (force->kspace->scalar_pressure_flag && vflag) { if (force->kspace->scalar_pressure_flag && vflag) {
for (i = 0; i < 3; i++) virial[i] += force->pair->eng_coul/3.0; 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][0] += ftmp[i][0];
f[i][1] += ftmp[i][1]; f[i][1] += ftmp[i][1];
f[i][2] += ftmp[i][2]; f[i][2] += ftmp[i][2];

View File

@ -506,40 +506,39 @@ void PairBuckLongCoulLong::compute(int eflag, int vflag)
if (order1 && (rsq < cut_coulsq)) { // coulombic if (order1 && (rsq < cut_coulsq)) { // coulombic
if (!ncoultablebits || rsq <= tabinnersq) { // series real space if (!ncoultablebits || rsq <= tabinnersq) { // series real space
double x = g_ewald*r; double x1 = g_ewald*r;
double s = qri*q[j], t = 1.0/(1.0+EWALD_P*x); double s = qri*q[j], t = 1.0/(1.0+EWALD_P*x1);
if (ni == 0) { if (ni == 0) {
s *= g_ewald*exp(-x*x); s *= g_ewald*exp(-x1*x1);
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s; force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x1)+EWALD_F*s;
if (eflag) ecoul = t; if (eflag) ecoul = t;
} } else { // special case
else { // special case double fc = s*(1.0-special_coul[ni])/r;
double f = s*(1.0-special_coul[ni])/r; s *= g_ewald*exp(-x1*x1);
s *= g_ewald*exp(-x*x); force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x1)+EWALD_F*s-fc;
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s-f; if (eflag) ecoul = t-fc;
if (eflag) ecoul = t-f;
} }
} // table real space } // table real space
else { else {
union_int_float_t t; union_int_float_t t;
t.f = rsq; t.f = rsq;
const int k = (t.i & ncoulmask) >> ncoulshiftbits; 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) { if (ni == 0) {
force_coul = qiqj*(ftable[k]+f*dftable[k]); force_coul = qiqj*(ftable[k]+fc*dftable[k]);
if (eflag) ecoul = qiqj*(etable[k]+f*detable[k]); if (eflag) ecoul = qiqj*(etable[k]+fc*detable[k]);
} }
else { // special case else { // special case
t.f = (1.0-special_coul[ni])*(ctable[k]+f*dctable[k]); t.f = (1.0-special_coul[ni])*(ctable[k]+fc*dctable[k]);
force_coul = qiqj*(ftable[k]+f*dftable[k]-t.f); force_coul = qiqj*(ftable[k]+fc*dftable[k]-t.f);
if (eflag) ecoul = qiqj*(etable[k]+f*detable[k]-t.f); if (eflag) ecoul = qiqj*(etable[k]+fc*detable[k]-t.f);
} }
} }
} else force_coul = ecoul = 0.0; } else force_coul = ecoul = 0.0;
if (rsq < cut_bucksqi[typej]) { // buckingham if (rsq < cut_bucksqi[typej]) { // buckingham
double rn = r2inv*r2inv*r2inv, double rn = r2inv*r2inv*r2inv;
expr = exp(-r*rhoinvi[typej]); double expr = exp(-r*rhoinvi[typej]);
if (order6) { // long-range if (order6) { // long-range
if (!ndisptablebits || rsq <= tabinnerdispsq) { if (!ndisptablebits || rsq <= tabinnerdispsq) {
double x2 = g2*rsq, a2 = 1.0/x2; double x2 = g2*rsq, a2 = 1.0/x2;

View File

@ -12,7 +12,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "lmppython.h" #include "lmppython.h"
#if LMP_PYTHON #if defined(LMP_PYTHON)
#include "python_impl.h" #include "python_impl.h"
#else #else
#include "error.h" #include "error.h"
@ -46,7 +46,7 @@ PythonInterface::~PythonInterface()
void Python::init() void Python::init()
{ {
#if LMP_PYTHON #if defined(LMP_PYTHON)
if (!impl) impl = new PythonImpl(lmp); if (!impl) impl = new PythonImpl(lmp);
#else #else
error->all(FLERR,"Python support missing! Compile with PYTHON package installed!"); error->all(FLERR,"Python support missing! Compile with PYTHON package installed!");
@ -55,7 +55,7 @@ void Python::init()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
bool Python::is_enabled() const { bool Python::is_enabled() const {
#if LMP_PYTHON #if defined(LMP_PYTHON)
return true; return true;
#else #else
return false; return false;

View File

@ -71,8 +71,8 @@ int mldivide3(const double m[3][3], const double *v, double *ans)
} }
for (unsigned j = i+1; j < 3; j++) { for (unsigned j = i+1; j < 3; j++) {
double m = aug[j][i]/aug[i][i]; double n = aug[j][i]/aug[i][i];
for (unsigned k=i+1; k<4; k++) aug[j][k]-=m*aug[i][k]; for (unsigned k=i+1; k<4; k++) aug[j][k]-=n*aug[i][k];
} }
} }

View File

@ -513,7 +513,7 @@ void Neighbor::init()
// print_pairwise_info() made use of requests // print_pairwise_info() made use of requests
// set of NeighLists now stores all needed info // set of NeighLists now stores all needed info
for (int i = 0; i < nrequest; i++) { for (i = 0; i < nrequest; i++) {
delete requests[i]; delete requests[i];
requests[i] = nullptr; requests[i] = nullptr;
} }
@ -2079,7 +2079,7 @@ void Neighbor::build(int topoflag)
if (style != Neighbor::NSQ) { if (style != Neighbor::NSQ) {
if (last_setup_bins < 0) setup_bins(); 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_setup(nall);
neigh_bin[i]->bin_atoms(); neigh_bin[i]->bin_atoms();
} }

View File

@ -818,9 +818,9 @@ void ReadDump::process_atoms()
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
memory->create(updateflag,nlocal,"read_dump:updateflag"); 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"); 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 // loop over new atoms
@ -918,7 +918,7 @@ void ReadDump::process_atoms()
if (trimflag) { if (trimflag) {
AtomVec *avec = atom->avec; AtomVec *avec = atom->avec;
int i = 0; i = 0;
while (i < nlocal) { while (i < nlocal) {
if (!updateflag[i]) { if (!updateflag[i]) {
avec->copy(nlocal-1,i,1); avec->copy(nlocal-1,i,1);

View File

@ -339,7 +339,7 @@ void ReadRestart::command(int narg, char **arg)
procfile, utils::getsyserror())); procfile, utils::getsyserror()));
} }
int flag,procsperfile; int procsperfile;
if (filereader) { if (filereader) {
utils::sfread(FLERR,&flag,sizeof(int),1,fp,nullptr,error); utils::sfread(FLERR,&flag,sizeof(int),1,fp,nullptr,error);
@ -704,7 +704,7 @@ void ReadRestart::header()
int procgrid[3]; int procgrid[3];
read_int(); read_int();
read_int_vec(3,procgrid); read_int_vec(3,procgrid);
int flag = 0; flag = 0;
if (comm->user_procgrid[0] != 0 && if (comm->user_procgrid[0] != 0 &&
procgrid[0] != comm->user_procgrid[0]) flag = 1; procgrid[0] != comm->user_procgrid[0]) flag = 1;
if (comm->user_procgrid[1] != 0 && if (comm->user_procgrid[1] != 0 &&

View File

@ -166,7 +166,7 @@ void Replicate::command(int narg, char **arg)
atom->molecules = (Molecule **) memory->smalloc((old->nmolecule)*sizeof(Molecule *), atom->molecules = (Molecule **) memory->smalloc((old->nmolecule)*sizeof(Molecule *),
"atom::molecules"); "atom::molecules");
atom->nmolecule = old->nmolecule; 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]; atom->molecules[i] = old->molecules[i];
memory->sfree(old->molecules); memory->sfree(old->molecules);
old->molecules = nullptr; old->molecules = nullptr;

View File

@ -100,7 +100,7 @@ char *TextFileReader::next_line(int nparams) {
if (nwords > 0) n = strlen(line); if (nwords > 0) n = strlen(line);
while (nwords == 0 || nwords < nparams) { while (nwords == 0 || nwords < nparams) {
char *ptr = fgets(&line[n], MAXLINE - n, fp); ptr = fgets(&line[n], MAXLINE - n, fp);
if (ptr == nullptr) { if (ptr == nullptr) {
// EOF // EOF

View File

@ -1008,8 +1008,8 @@ std::string utils::get_potential_file_path(const std::string &path) {
while (dirs.has_next()) { while (dirs.has_next()) {
auto pot = utils::path_basename(filepath); auto pot = utils::path_basename(filepath);
auto path = dirs.next(); auto dir = dirs.next();
filepath = utils::path_join(path, pot); filepath = utils::path_join(dir, pot);
if (utils::file_is_readable(filepath)) { if (utils::file_is_readable(filepath)) {
return filepath; return filepath;

View File

@ -1894,7 +1894,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
} else if (strncmp(word,"v_",2) == 0) { } else if (strncmp(word,"v_",2) == 0) {
int ivar = find(word+2); ivar = find(word+2);
if (ivar < 0) if (ivar < 0)
print_var_error(FLERR,fmt::format("Invalid variable reference " print_var_error(FLERR,fmt::format("Invalid variable reference "
"{} in variable formula",word),ivar); "{} 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 Variable::collapse_tree(Tree *tree)
{ {
double arg1,arg2; double arg1,arg2,arg3;
if (tree->type == VALUE) return tree->value; if (tree->type == VALUE) return tree->value;
if (tree->type == ATOMARRAY) return 0.0; 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"); error->one(FLERR,"Invalid math function in variable formula");
if (ivalue4 < ivalue1 || ivalue5 > ivalue2) if (ivalue4 < ivalue1 || ivalue5 > ivalue2)
error->one(FLERR,"Invalid math function in variable formula"); error->one(FLERR,"Invalid math function in variable formula");
bigint istep; bigint istep, offset;
if (update->ntimestep < ivalue1) istep = ivalue1; if (update->ntimestep < ivalue1) istep = ivalue1;
else if (update->ntimestep < ivalue2) { else if (update->ntimestep < ivalue2) {
if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) {
bigint offset = update->ntimestep - ivalue1; offset = update->ntimestep - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (update->ntimestep < ivalue2 && istep > ivalue4) if (update->ntimestep < ivalue2 && istep > ivalue4)
tree->value = ivalue4; tree->value = ivalue4;
} else { } else {
bigint offset = update->ntimestep - ivalue4; offset = update->ntimestep - ivalue4;
istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6;
if (istep > ivalue5) { if (istep > ivalue5) {
bigint offset = ivalue5 - ivalue1; offset = ivalue5 - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (istep > ivalue2) istep = MAXBIGINT; if (istep > ivalue2) istep = MAXBIGINT;
} }
@ -2828,8 +2828,8 @@ double Variable::collapse_tree(Tree *tree)
} }
if (tree->type == VDISPLACE) { if (tree->type == VDISPLACE) {
double arg1 = collapse_tree(tree->first); arg1 = collapse_tree(tree->first);
double arg2 = collapse_tree(tree->second); arg2 = collapse_tree(tree->second);
if (tree->first->type != VALUE || tree->second->type != VALUE) return 0.0; if (tree->first->type != VALUE || tree->second->type != VALUE) return 0.0;
tree->type = VALUE; tree->type = VALUE;
double delta = update->ntimestep - update->beginstep; double delta = update->ntimestep - update->beginstep;
@ -2838,9 +2838,9 @@ double Variable::collapse_tree(Tree *tree)
} }
if (tree->type == SWIGGLE) { if (tree->type == SWIGGLE) {
double arg1 = collapse_tree(tree->first); arg1 = collapse_tree(tree->first);
double arg2 = collapse_tree(tree->second); arg2 = collapse_tree(tree->second);
double arg3 = collapse_tree(tree->extra[0]); arg3 = collapse_tree(tree->extra[0]);
if (tree->first->type != VALUE || tree->second->type != VALUE || if (tree->first->type != VALUE || tree->second->type != VALUE ||
tree->extra[0]->type != VALUE) return 0.0; tree->extra[0]->type != VALUE) return 0.0;
tree->type = VALUE; tree->type = VALUE;
@ -2853,9 +2853,9 @@ double Variable::collapse_tree(Tree *tree)
} }
if (tree->type == CWIGGLE) { if (tree->type == CWIGGLE) {
double arg1 = collapse_tree(tree->first); arg1 = collapse_tree(tree->first);
double arg2 = collapse_tree(tree->second); arg2 = collapse_tree(tree->second);
double arg3 = collapse_tree(tree->extra[0]); arg3 = collapse_tree(tree->extra[0]);
if (tree->first->type != VALUE || tree->second->type != VALUE || if (tree->first->type != VALUE || tree->second->type != VALUE ||
tree->extra[0]->type != VALUE) return 0.0; tree->extra[0]->type != VALUE) return 0.0;
tree->type = VALUE; tree->type = VALUE;
@ -3134,19 +3134,19 @@ double Variable::eval_tree(Tree *tree, int i)
error->one(FLERR,"Invalid math function in variable formula"); error->one(FLERR,"Invalid math function in variable formula");
if (ivalue4 < ivalue1 || ivalue5 > ivalue2) if (ivalue4 < ivalue1 || ivalue5 > ivalue2)
error->one(FLERR,"Invalid math function in variable formula"); error->one(FLERR,"Invalid math function in variable formula");
bigint istep; bigint istep, offset;
if (update->ntimestep < ivalue1) istep = ivalue1; if (update->ntimestep < ivalue1) istep = ivalue1;
else if (update->ntimestep < ivalue2) { else if (update->ntimestep < ivalue2) {
if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) {
bigint offset = update->ntimestep - ivalue1; offset = update->ntimestep - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (update->ntimestep < ivalue2 && istep > ivalue4) if (update->ntimestep < ivalue2 && istep > ivalue4)
tree->value = ivalue4; tree->value = ivalue4;
} else { } else {
bigint offset = update->ntimestep - ivalue4; offset = update->ntimestep - ivalue4;
istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6;
if (istep > ivalue5) { if (istep > ivalue5) {
bigint offset = ivalue5 - ivalue1; offset = ivalue5 - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (istep > ivalue2) istep = MAXBIGINT; 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"); error->one(FLERR,"Invalid math function in variable formula");
if (ivalue4 < ivalue1 || ivalue5 > ivalue2) if (ivalue4 < ivalue1 || ivalue5 > ivalue2)
error->one(FLERR,"Invalid math function in variable formula"); error->one(FLERR,"Invalid math function in variable formula");
bigint istep; bigint istep, offset;
if (update->ntimestep < ivalue1) istep = ivalue1; if (update->ntimestep < ivalue1) istep = ivalue1;
else if (update->ntimestep < ivalue2) { else if (update->ntimestep < ivalue2) {
if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) { if (update->ntimestep < ivalue4 || update->ntimestep > ivalue5) {
bigint offset = update->ntimestep - ivalue1; offset = update->ntimestep - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (update->ntimestep < ivalue4 && istep > ivalue4) istep = ivalue4; if (update->ntimestep < ivalue4 && istep > ivalue4) istep = ivalue4;
} else { } else {
bigint offset = update->ntimestep - ivalue4; offset = update->ntimestep - ivalue4;
istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6; istep = ivalue4 + (offset/ivalue6)*ivalue6 + ivalue6;
if (istep > ivalue5) { if (istep > ivalue5) {
bigint offset = ivalue5 - ivalue1; offset = ivalue5 - ivalue1;
istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3; istep = ivalue1 + (offset/ivalue3)*ivalue3 + ivalue3;
if (istep > ivalue2) istep = MAXBIGINT; if (istep > ivalue2) istep = MAXBIGINT;
} }
@ -4107,9 +4107,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
Compute *compute = nullptr; Compute *compute = nullptr;
Fix *fix = nullptr; Fix *fix = nullptr;
int ivar = -1;
int index,nvec,nstride; int index,nvec,nstride;
char *ptr1,*ptr2; char *ptr1,*ptr2;
ivar = -1;
// argument is compute // argument is compute
@ -4387,7 +4387,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
if (narg != 1) if (narg != 1)
print_var_error(FLERR,"Invalid special function in variable formula",ivar); print_var_error(FLERR,"Invalid special function in variable formula",ivar);
int ivar = find(args[0]); ivar = find(args[0]);
if (ivar < 0) { if (ivar < 0) {
std::string mesg = "Variable ID '"; std::string mesg = "Variable ID '";
mesg += args[0]; mesg += args[0];
@ -4399,7 +4399,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
// save value in tree or on argstack // save value in tree or on argstack
if (style[ivar] == SCALARFILE) { if (style[ivar] == SCALARFILE) {
double value = atof(data[ivar][0]); value = atof(data[ivar][0]);
int done = reader[ivar]->read_scalar(data[ivar][0]); int done = reader[ivar]->read_scalar(data[ivar][0]);
if (done) remove(ivar); if (done) remove(ivar);