silence compiler warnings by avoiding to shadow variables

This commit is contained in:
Axel Kohlmeyer
2021-04-24 18:29:57 -04:00
parent 4738337e47
commit 92a9994fd4
6 changed files with 46 additions and 50 deletions

View File

@ -241,7 +241,7 @@ struct remap_plan_3d *remap_3d_create_plan(
struct remap_plan_3d *plan; struct remap_plan_3d *plan;
struct extent_3d *inarray, *outarray; struct extent_3d *inarray, *outarray;
struct extent_3d in,out,overlap; struct extent_3d in,out,overlap;
int i,iproc,nsend,nrecv,ibuf,size,me,nprocs; int i,j,iproc,nsend,nrecv,ibuf,size,me,nprocs;
// query MPI info // query MPI info
@ -465,14 +465,14 @@ struct remap_plan_3d *remap_3d_create_plan(
int *commringlist = (int *) malloc(maxcommsize*sizeof(int)); int *commringlist = (int *) malloc(maxcommsize*sizeof(int));
int commringlen = 0; int commringlen = 0;
for (int i = 0; i < nrecv; i++) { for (i = 0; i < nrecv; i++) {
commringlist[i] = plan->recv_proc[i]; commringlist[i] = plan->recv_proc[i];
commringlen++; commringlen++;
} }
for (int i = 0; i < nsend; i++) { for (i = 0; i < nsend; i++) {
int foundentry = 0; int foundentry = 0;
for (int j=0;j<commringlen;j++) for (j = 0; j < commringlen;j++)
if (commringlist[j] == plan->send_proc[i]) foundentry = 1; if (commringlist[j] == plan->send_proc[i]) foundentry = 1;
if (!foundentry) { if (!foundentry) {
commringlist[commringlen] = plan->send_proc[i]; commringlist[commringlen] = plan->send_proc[i];
@ -483,12 +483,12 @@ struct remap_plan_3d *remap_3d_create_plan(
// sort initial commringlist // sort initial commringlist
int swap = 0; int swap = 0;
for (int c = 0 ; c < (commringlen - 1); c++) { for (i = 0 ; i < (commringlen - 1); i++) {
for (int d = 0 ; d < commringlen - c - 1; d++) { for (j = 0 ; j < commringlen - i - 1; j++) {
if (commringlist[d] > commringlist[d+1]) { if (commringlist[j] > commringlist[j+1]) {
swap = commringlist[d]; swap = commringlist[j];
commringlist[d] = commringlist[d+1]; commringlist[j] = commringlist[j+1];
commringlist[d+1] = swap; commringlist[j+1] = swap;
} }
} }
} }
@ -502,12 +502,12 @@ struct remap_plan_3d *remap_3d_create_plan(
while (commringappend) { while (commringappend) {
int newcommringlen = commringlen; int newcommringlen = commringlen;
commringappend = 0; commringappend = 0;
for (int i=0;i<commringlen;i++) { for (i = 0; i < commringlen; i++) {
for (int j=0;j<nprocs;j++) { for (j = 0; j < nprocs; j++) {
if (remap_3d_collide(&inarray[commringlist[i]], if (remap_3d_collide(&inarray[commringlist[i]],
&outarray[j],&overlap)) { &outarray[j],&overlap)) {
int alreadyinlist = 0; int alreadyinlist = 0;
for (int k=0;k<newcommringlen;k++) { for (int k = 0; k < newcommringlen; k++) {
if (commringlist[k] == j) { if (commringlist[k] == j) {
alreadyinlist = 1; alreadyinlist = 1;
} }
@ -520,7 +520,7 @@ struct remap_plan_3d *remap_3d_create_plan(
if (remap_3d_collide(&outarray[commringlist[i]], if (remap_3d_collide(&outarray[commringlist[i]],
&inarray[j],&overlap)) { &inarray[j],&overlap)) {
int alreadyinlist = 0; int alreadyinlist = 0;
for (int k=0;k<newcommringlen;k++) { for (int k = 0 ; k < newcommringlen; k++) {
if (commringlist[k] == j) alreadyinlist = 1; if (commringlist[k] == j) alreadyinlist = 1;
} }
if (!alreadyinlist) { if (!alreadyinlist) {
@ -535,12 +535,12 @@ struct remap_plan_3d *remap_3d_create_plan(
// sort the final commringlist // sort the final commringlist
for (int c = 0 ; c < ( commringlen - 1 ); c++) { for (i = 0 ; i < ( commringlen - 1 ); i++) {
for (int d = 0 ; d < commringlen - c - 1; d++) { for (j = 0 ; j < commringlen - i - 1; j++) {
if (commringlist[d] > commringlist[d+1]) { if (commringlist[j] > commringlist[j+1]) {
swap = commringlist[d]; swap = commringlist[j];
commringlist[d] = commringlist[d+1]; commringlist[j] = commringlist[j+1];
commringlist[d+1] = swap; commringlist[j+1] = swap;
} }
} }
} }

View File

@ -1028,7 +1028,7 @@ std::pair<std::string, std::string> EIMPotentialFileReader::get_pair(const std::
return std::make_pair(b, a); return std::make_pair(b, a);
} }
char * EIMPotentialFileReader::next_line(FILE * fp) { char *EIMPotentialFileReader::next_line(FILE * fp) {
// concatenate lines if they end with '&' // concatenate lines if they end with '&'
// strip comments after '#' // strip comments after '#'
int n = 0; int n = 0;
@ -1058,7 +1058,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) {
} }
while (n == 0 || concat) { while (n == 0 || concat) {
char *ptr = fgets(&line[n], MAXLINE - n, fp); ptr = fgets(&line[n], MAXLINE - n, fp);
if (ptr == nullptr) { if (ptr == nullptr) {
// EOF // EOF
@ -1089,7 +1089,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) {
void EIMPotentialFileReader::parse(FILE * fp) void EIMPotentialFileReader::parse(FILE * fp)
{ {
char * line = nullptr; char *line = nullptr;
bool found_global = false; bool found_global = false;
while ((line = next_line(fp))) { while ((line = next_line(fp))) {

View File

@ -329,7 +329,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
pstyle = ANISO; pstyle = ANISO;
dimension = domain->dimension; dimension = domain->dimension;
for (int i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
p_start[i] = p_stop[i] = p_period[i] = 0.0; p_start[i] = p_stop[i] = p_period[i] = 0.0;
p_flag[i] = 0; p_flag[i] = 0;
} }
@ -551,7 +551,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
// set pstat_flag // set pstat_flag
pstat_flag = 0; pstat_flag = 0;
for (int i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (p_flag[i]) pstat_flag = 1; if (p_flag[i]) pstat_flag = 1;
if (pcouple == XYZ || (dimension == 2 && pcouple == XY)) pstyle = ISO; if (pcouple == XYZ || (dimension == 2 && pcouple == XY)) pstyle = ISO;

View File

@ -705,7 +705,7 @@ void FixRigidNHSmall::final_integrate()
if (pstat_flag) { if (pstat_flag) {
akin_t = akin_r = 0.0; akin_t = akin_r = 0.0;
for (int ibody = 0; ibody < nlocal_body; ibody++) { for (ibody = 0; ibody < nlocal_body; ibody++) {
Body *b = &body[ibody]; Body *b = &body[ibody];
akin_t += b->mass*(b->vcm[0]*b->vcm[0] + b->vcm[1]*b->vcm[1] + akin_t += b->mass*(b->vcm[0]*b->vcm[0] + b->vcm[1]*b->vcm[1] +
b->vcm[2]*b->vcm[2]); b->vcm[2]*b->vcm[2]);
@ -856,7 +856,7 @@ void FixRigidNHSmall::nhc_press_integrate()
double tb_mass = kt / (p_freq_max * p_freq_max); double tb_mass = kt / (p_freq_max * p_freq_max);
q_b[0] = dimension * dimension * tb_mass; q_b[0] = dimension * dimension * tb_mass;
for (int i = 1; i < p_chain; i++) { for (i = 1; i < p_chain; i++) {
q_b[i] = tb_mass; q_b[i] = tb_mass;
f_eta_b[i] = q_b[i-1] * eta_dot_b[i-1] * eta_dot_b[i-1] - kt; f_eta_b[i] = q_b[i-1] * eta_dot_b[i-1] * eta_dot_b[i-1] - kt;
f_eta_b[i] /= q_b[i]; f_eta_b[i] /= q_b[i];
@ -941,7 +941,7 @@ double FixRigidNHSmall::compute_scalar()
ke_t = 0.0; ke_t = 0.0;
ke_q = 0.0; ke_q = 0.0;
for (int i = 0; i < nlocal_body; i++) { for (i = 0; i < nlocal_body; i++) {
vcm = body[i].vcm; vcm = body[i].vcm;
quat = body[i].quat; quat = body[i].quat;
ke_t += body[i].mass * (vcm[0]*vcm[0] + vcm[1]*vcm[1] + ke_t += body[i].mass * (vcm[0]*vcm[0] + vcm[1]*vcm[1] +

View File

@ -192,7 +192,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
pcouple = NONE; pcouple = NONE;
pstyle = ANISO; pstyle = ANISO;
for (int i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
p_start[i] = p_stop[i] = p_period[i] = 0.0; p_start[i] = p_stop[i] = p_period[i] = 0.0;
p_flag[i] = 0; p_flag[i] = 0;
} }
@ -367,7 +367,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
// error check and further setup for Molecule template // error check and further setup for Molecule template
if (onemols) { if (onemols) {
for (int i = 0; i < nmol; i++) { for (i = 0; i < nmol; i++) {
if (onemols[i]->xflag == 0) if (onemols[i]->xflag == 0)
error->all(FLERR,"Fix rigid/small molecule must have coordinates"); error->all(FLERR,"Fix rigid/small molecule must have coordinates");
if (onemols[i]->typeflag == 0) if (onemols[i]->typeflag == 0)
@ -385,7 +385,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
// set pstat_flag // set pstat_flag
pstat_flag = 0; pstat_flag = 0;
for (int i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (p_flag[i]) pstat_flag = 1; if (p_flag[i]) pstat_flag = 1;
if (pcouple == XYZ || (domain->dimension == 2 && pcouple == XY)) pstyle = ISO; if (pcouple == XYZ || (domain->dimension == 2 && pcouple == XY)) pstyle = ISO;
@ -451,7 +451,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
int one = 0; int one = 0;
bigint atomone = 0; bigint atomone = 0;
for (int i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (bodyown[i] >= 0) one++; if (bodyown[i] >= 0) one++;
if (bodytag[i] > 0) atomone++; if (bodytag[i] > 0) atomone++;
} }
@ -978,7 +978,7 @@ void FixRigidSmall::compute_forces_and_torques()
// include Langevin thermostat forces and torques // include Langevin thermostat forces and torques
if (langflag) { if (langflag) {
for (int ibody = 0; ibody < nlocal_body; ibody++) { for (ibody = 0; ibody < nlocal_body; ibody++) {
fcm = body[ibody].fcm; fcm = body[ibody].fcm;
fcm[0] += langextra[ibody][0]; fcm[0] += langextra[ibody][0];
fcm[1] += langextra[ibody][1]; fcm[1] += langextra[ibody][1];
@ -1163,7 +1163,7 @@ int FixRigidSmall::dof(int tgroup)
// 2 = # of particles in rigid body, disregarding temperature group // 2 = # of particles in rigid body, disregarding temperature group
memory->create(counts,nlocal_body+nghost_body,3,"rigid/small:counts"); memory->create(counts,nlocal_body+nghost_body,3,"rigid/small:counts");
for (int i = 0; i < nlocal_body+nghost_body; i++) for (i = 0; i < nlocal_body+nghost_body; i++)
counts[i][0] = counts[i][1] = counts[i][2] = 0; counts[i][0] = counts[i][1] = counts[i][2] = 0;
// tally counts from my owned atoms // tally counts from my owned atoms
@ -1630,7 +1630,7 @@ void FixRigidSmall::create_bodies(tagint *bodyID)
MPI_Allreduce(&rsqfar,&maxextent,1,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(&rsqfar,&maxextent,1,MPI_DOUBLE,MPI_MAX,world);
maxextent = sqrt(maxextent); maxextent = sqrt(maxextent);
if (onemols) { if (onemols) {
for (int i = 0; i < nmol; i++) for (i = 0; i < nmol; i++)
maxextent = MAX(maxextent,onemols[i]->maxextent); maxextent = MAX(maxextent,onemols[i]->maxextent);
} }
} }
@ -1741,7 +1741,7 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf,
double rsqfar = 0.0; double rsqfar = 0.0;
for (int i = 0; i < n; i++) { for (i = 0; i < n; i++) {
m = hash.find(in[i].bodyID)->second; m = hash.find(in[i].bodyID)->second;
xown = in[iclose[m]].x; xown = in[iclose[m]].x;
x = in[i].x; x = in[i].x;
@ -1761,7 +1761,7 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf,
OutRvous *out = (OutRvous *) OutRvous *out = (OutRvous *)
memory->smalloc(nout*sizeof(OutRvous),"rigid/small:out"); memory->smalloc(nout*sizeof(OutRvous),"rigid/small:out");
for (int i = 0; i < nout; i++) { for (i = 0; i < nout; i++) {
proclist[i] = in[i].me; proclist[i] = in[i].me;
out[i].ilocal = in[i].ilocal; out[i].ilocal = in[i].ilocal;
m = hash.find(in[i].bodyID)->second; m = hash.find(in[i].bodyID)->second;
@ -2493,7 +2493,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody)
// for which = 0, store all but inertia directly in body struct // for which = 0, store all but inertia directly in body struct
// for which = 1, store inertia tensor array, invert 3,4,5 values to Voigt // for which = 1, store inertia tensor array, invert 3,4,5 values to Voigt
for (int i = 0; i < nchunk; i++) { for (i = 0; i < nchunk; i++) {
next = strchr(buf,'\n'); next = strchr(buf,'\n');
values[0] = strtok(buf," \t\n\r\f"); values[0] = strtok(buf," \t\n\r\f");

View File

@ -234,8 +234,6 @@ void FixRigidNHOMP::initial_integrate(int vflag)
void FixRigidNHOMP::compute_forces_and_torques() void FixRigidNHOMP::compute_forces_and_torques()
{ {
int ibody;
double * const * _noalias const x = atom->x; double * const * _noalias const x = atom->x;
const dbl3_t * _noalias const f = (dbl3_t *) atom->f[0]; const dbl3_t * _noalias const f = (dbl3_t *) atom->f[0];
const double * const * const torque_one = atom->torque; const double * const * const torque_one = atom->torque;
@ -373,9 +371,9 @@ void FixRigidNHOMP::compute_forces_and_torques()
MPI_Allreduce(sum[0],all[0],6*nbody,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(sum[0],all[0],6*nbody,MPI_DOUBLE,MPI_SUM,world);
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE private(ibody) schedule(static) #pragma omp parallel for LMP_DEFAULT_NONE schedule(static)
#endif #endif
for (ibody = 0; ibody < nbody; ibody++) { for (int ibody = 0; ibody < nbody; ibody++) {
fcm[ibody][0] = all[ibody][0] + langextra[ibody][0]; fcm[ibody][0] = all[ibody][0] + langextra[ibody][0];
fcm[ibody][1] = all[ibody][1] + langextra[ibody][1]; fcm[ibody][1] = all[ibody][1] + langextra[ibody][1];
fcm[ibody][2] = all[ibody][2] + langextra[ibody][2]; fcm[ibody][2] = all[ibody][2] + langextra[ibody][2];
@ -388,9 +386,9 @@ void FixRigidNHOMP::compute_forces_and_torques()
if (id_gravity) { if (id_gravity) {
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE private(ibody) schedule(static) #pragma omp parallel for LMP_DEFAULT_NONE schedule(static)
#endif #endif
for (ibody = 0; ibody < nbody; ibody++) { for (int ibody = 0; ibody < nbody; ibody++) {
fcm[ibody][0] += gvec[0]*masstotal[ibody]; fcm[ibody][0] += gvec[0]*masstotal[ibody];
fcm[ibody][1] += gvec[1]*masstotal[ibody]; fcm[ibody][1] += gvec[1]*masstotal[ibody];
fcm[ibody][2] += gvec[2]*masstotal[ibody]; fcm[ibody][2] += gvec[2]*masstotal[ibody];
@ -628,12 +626,11 @@ void FixRigidNHOMP::set_xv_thr()
// set x and v of each atom // set x and v of each atom
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
int i;
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE private(i) reduction(+:v0,v1,v2,v3,v4,v5) #pragma omp parallel for LMP_DEFAULT_NONE reduction(+:v0,v1,v2,v3,v4,v5)
#endif #endif
for (i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
const int ibody = body[i]; const int ibody = body[i];
if (ibody < 0) continue; if (ibody < 0) continue;
@ -829,12 +826,11 @@ void FixRigidNHOMP::set_v_thr()
// set v of each atom // set v of each atom
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
int i;
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for LMP_DEFAULT_NONE private(i) reduction(+:v0,v1,v2,v3,v4,v5) #pragma omp parallel for LMP_DEFAULT_NONE reduction(+:v0,v1,v2,v3,v4,v5)
#endif #endif
for (i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
const int ibody = body[i]; const int ibody = body[i];
if (ibody < 0) continue; if (ibody < 0) continue;