diff --git a/src/KSPACE/remap.cpp b/src/KSPACE/remap.cpp index c99bbb2562..6caaa9fe2c 100644 --- a/src/KSPACE/remap.cpp +++ b/src/KSPACE/remap.cpp @@ -241,7 +241,7 @@ struct remap_plan_3d *remap_3d_create_plan( struct remap_plan_3d *plan; struct extent_3d *inarray, *outarray; 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 @@ -465,14 +465,14 @@ struct remap_plan_3d *remap_3d_create_plan( int *commringlist = (int *) malloc(maxcommsize*sizeof(int)); int commringlen = 0; - for (int i = 0; i < nrecv; i++) { + for (i = 0; i < nrecv; i++) { commringlist[i] = plan->recv_proc[i]; commringlen++; } - for (int i = 0; i < nsend; i++) { + for (i = 0; i < nsend; i++) { int foundentry = 0; - for (int j=0;jsend_proc[i]) foundentry = 1; if (!foundentry) { commringlist[commringlen] = plan->send_proc[i]; @@ -483,12 +483,12 @@ struct remap_plan_3d *remap_3d_create_plan( // sort initial commringlist int swap = 0; - for (int c = 0 ; c < (commringlen - 1); c++) { - for (int d = 0 ; d < commringlen - c - 1; d++) { - if (commringlist[d] > commringlist[d+1]) { - swap = commringlist[d]; - commringlist[d] = commringlist[d+1]; - commringlist[d+1] = swap; + for (i = 0 ; i < (commringlen - 1); i++) { + for (j = 0 ; j < commringlen - i - 1; j++) { + if (commringlist[j] > commringlist[j+1]) { + swap = commringlist[j]; + commringlist[j] = commringlist[j+1]; + commringlist[j+1] = swap; } } } @@ -502,12 +502,12 @@ struct remap_plan_3d *remap_3d_create_plan( while (commringappend) { int newcommringlen = commringlen; commringappend = 0; - for (int i=0;i commringlist[d+1]) { - swap = commringlist[d]; - commringlist[d] = commringlist[d+1]; - commringlist[d+1] = swap; + for (i = 0 ; i < ( commringlen - 1 ); i++) { + for (j = 0 ; j < commringlen - i - 1; j++) { + if (commringlist[j] > commringlist[j+1]) { + swap = commringlist[j]; + commringlist[j] = commringlist[j+1]; + commringlist[j+1] = swap; } } } diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index eda1838a5a..611f2a8ea8 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -1028,7 +1028,7 @@ std::pair EIMPotentialFileReader::get_pair(const std:: return std::make_pair(b, a); } -char * EIMPotentialFileReader::next_line(FILE * fp) { +char *EIMPotentialFileReader::next_line(FILE * fp) { // concatenate lines if they end with '&' // strip comments after '#' int n = 0; @@ -1058,7 +1058,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) { } while (n == 0 || concat) { - char *ptr = fgets(&line[n], MAXLINE - n, fp); + ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { // EOF @@ -1089,7 +1089,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) { void EIMPotentialFileReader::parse(FILE * fp) { - char * line = nullptr; + char *line = nullptr; bool found_global = false; while ((line = next_line(fp))) { diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 3cd4f5dbc8..da6785fc4a 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -329,7 +329,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : pstyle = ANISO; 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_flag[i] = 0; } @@ -551,7 +551,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : // set pstat_flag pstat_flag = 0; - for (int i = 0; i < 3; i++) + for (i = 0; i < 3; i++) if (p_flag[i]) pstat_flag = 1; if (pcouple == XYZ || (dimension == 2 && pcouple == XY)) pstyle = ISO; diff --git a/src/RIGID/fix_rigid_nh_small.cpp b/src/RIGID/fix_rigid_nh_small.cpp index 0f1e813234..cc7ea24c34 100644 --- a/src/RIGID/fix_rigid_nh_small.cpp +++ b/src/RIGID/fix_rigid_nh_small.cpp @@ -705,7 +705,7 @@ void FixRigidNHSmall::final_integrate() if (pstat_flag) { 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]; akin_t += b->mass*(b->vcm[0]*b->vcm[0] + b->vcm[1]*b->vcm[1] + 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); 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; 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]; @@ -941,7 +941,7 @@ double FixRigidNHSmall::compute_scalar() ke_t = 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; quat = body[i].quat; ke_t += body[i].mass * (vcm[0]*vcm[0] + vcm[1]*vcm[1] + diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 14bd9f7a55..b7e9dd3902 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -192,7 +192,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : pcouple = NONE; 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_flag[i] = 0; } @@ -367,7 +367,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // error check and further setup for Molecule template if (onemols) { - for (int i = 0; i < nmol; i++) { + for (i = 0; i < nmol; i++) { if (onemols[i]->xflag == 0) error->all(FLERR,"Fix rigid/small molecule must have coordinates"); if (onemols[i]->typeflag == 0) @@ -385,7 +385,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // set pstat_flag pstat_flag = 0; - for (int i = 0; i < 3; i++) + for (i = 0; i < 3; i++) if (p_flag[i]) pstat_flag = 1; 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; bigint atomone = 0; - for (int i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { if (bodyown[i] >= 0) one++; if (bodytag[i] > 0) atomone++; } @@ -978,7 +978,7 @@ void FixRigidSmall::compute_forces_and_torques() // include Langevin thermostat forces and torques if (langflag) { - for (int ibody = 0; ibody < nlocal_body; ibody++) { + for (ibody = 0; ibody < nlocal_body; ibody++) { fcm = body[ibody].fcm; fcm[0] += langextra[ibody][0]; fcm[1] += langextra[ibody][1]; @@ -1163,7 +1163,7 @@ int FixRigidSmall::dof(int tgroup) // 2 = # of particles in rigid body, disregarding temperature group 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; // 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); maxextent = sqrt(maxextent); if (onemols) { - for (int i = 0; i < nmol; i++) + for (i = 0; i < nmol; i++) maxextent = MAX(maxextent,onemols[i]->maxextent); } } @@ -1741,7 +1741,7 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf, double rsqfar = 0.0; - for (int i = 0; i < n; i++) { + for (i = 0; i < n; i++) { m = hash.find(in[i].bodyID)->second; xown = in[iclose[m]].x; x = in[i].x; @@ -1761,7 +1761,7 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf, OutRvous *out = (OutRvous *) 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; out[i].ilocal = in[i].ilocal; 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 = 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'); values[0] = strtok(buf," \t\n\r\f"); diff --git a/src/USER-OMP/fix_rigid_nh_omp.cpp b/src/USER-OMP/fix_rigid_nh_omp.cpp index 5a1e6ca25e..ae6cb92cee 100644 --- a/src/USER-OMP/fix_rigid_nh_omp.cpp +++ b/src/USER-OMP/fix_rigid_nh_omp.cpp @@ -234,8 +234,6 @@ void FixRigidNHOMP::initial_integrate(int vflag) void FixRigidNHOMP::compute_forces_and_torques() { - int ibody; - double * const * _noalias const x = atom->x; const dbl3_t * _noalias const f = (dbl3_t *) atom->f[0]; 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); #if defined(_OPENMP) -#pragma omp parallel for LMP_DEFAULT_NONE private(ibody) schedule(static) +#pragma omp parallel for LMP_DEFAULT_NONE schedule(static) #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][1] = all[ibody][1] + langextra[ibody][1]; fcm[ibody][2] = all[ibody][2] + langextra[ibody][2]; @@ -388,9 +386,9 @@ void FixRigidNHOMP::compute_forces_and_torques() if (id_gravity) { #if defined(_OPENMP) -#pragma omp parallel for LMP_DEFAULT_NONE private(ibody) schedule(static) +#pragma omp parallel for LMP_DEFAULT_NONE schedule(static) #endif - for (ibody = 0; ibody < nbody; ibody++) { + for (int ibody = 0; ibody < nbody; ibody++) { fcm[ibody][0] += gvec[0]*masstotal[ibody]; fcm[ibody][1] += gvec[1]*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 const int nlocal = atom->nlocal; - int i; #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 - for (i = 0; i < nlocal; i++) { + for (int i = 0; i < nlocal; i++) { const int ibody = body[i]; if (ibody < 0) continue; @@ -829,12 +826,11 @@ void FixRigidNHOMP::set_v_thr() // set v of each atom const int nlocal = atom->nlocal; - int i; #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 - for (i = 0; i < nlocal; i++) { + for (int i = 0; i < nlocal; i++) { const int ibody = body[i]; if (ibody < 0) continue;