From 3d6ac732ad59db0a2c02ff62182a67518dcda4f0 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 10 Mar 2014 15:45:25 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11616 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/atom.cpp | 2 +- src/dump.cpp | 2 +- src/dump_image.cpp | 8 ++++---- src/fix_move.cpp | 9 ++++++--- src/fix_nh.cpp | 15 ++++++++++----- src/molecule.cpp | 4 ++-- src/neigh_respa.cpp | 12 ++++++------ src/procmap.cpp | 2 +- src/read_data.cpp | 4 ++-- src/read_restart.cpp | 4 ++-- src/universe.cpp | 2 +- src/variable.cpp | 4 ++-- src/write_data.cpp | 6 +++--- src/write_restart.cpp | 2 +- 14 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index a850c66f58..2280943a33 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -620,7 +620,7 @@ int Atom::count_words(const char *line) strcpy(copy,line); char *ptr; - if (ptr = strchr(copy,'#')) *ptr = '\0'; + if ((ptr = strchr(copy,'#'))) *ptr = '\0'; if (strtok(copy," \t\n\r\f") == NULL) { memory->destroy(copy); diff --git a/src/dump.cpp b/src/dump.cpp index a94ba4af92..878304addf 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -105,7 +105,7 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) multiname = NULL; char *ptr; - if (ptr = strchr(filename,'%')) { + if ((ptr = strchr(filename,'%'))) { if (strstr(style,"mpiio")) error->all(FLERR, "Dump file MPI-IO output not allowed with % in filename"); diff --git a/src/dump_image.cpp b/src/dump_image.cpp index c7bfd868d4..1c2326b474 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -969,14 +969,14 @@ int DumpImage::modify_param(int narg, char **arg) int ncount = 1; char *nextptr; char *ptr = arg[2]; - while (nextptr = strchr(ptr,'/')) { + while ((nextptr = strchr(ptr,'/'))) { ptr = nextptr + 1; ncount++; } char **ptrs = new char*[ncount+1]; ncount = 0; ptrs[ncount++] = strtok(arg[2],"/"); - while (ptrs[ncount++] = strtok(NULL,"/")); + while ((ptrs[ncount++] = strtok(NULL,"/"))); ncount--; // assign each of ncount colors in round-robin fashion to types @@ -1029,14 +1029,14 @@ int DumpImage::modify_param(int narg, char **arg) int ncount = 1; char *nextptr; char *ptr = arg[2]; - while (nextptr = strchr(ptr,'/')) { + while ((nextptr = strchr(ptr,'/'))) { ptr = nextptr + 1; ncount++; } char **ptrs = new char*[ncount+1]; ncount = 0; ptrs[ncount++] = strtok(arg[2],"/"); - while (ptrs[ncount++] = strtok(NULL,"/")); + while ((ptrs[ncount++] = strtok(NULL,"/"))); ncount--; // assign each of ncount colors in round-robin fashion to types diff --git a/src/fix_move.cpp b/src/fix_move.cpp index ca0f84cdca..c39646fee0 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -752,7 +752,7 @@ void FixMove::final_integrate() for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (xflag) + if (xflag) { if (rmass) { dtfm = dtf / rmass[i]; v[i][0] += dtfm * f[i][0]; @@ -760,8 +760,9 @@ void FixMove::final_integrate() dtfm = dtf / mass[type[i]]; v[i][0] += dtfm * f[i][0]; } + } - if (yflag) + if (yflag) { if (rmass) { dtfm = dtf / rmass[i]; v[i][1] += dtfm * f[i][1]; @@ -769,8 +770,9 @@ void FixMove::final_integrate() dtfm = dtf / mass[type[i]]; v[i][1] += dtfm * f[i][1]; } + } - if (zflag) + if (zflag) { if (rmass) { dtfm = dtf / rmass[i]; v[i][2] += dtfm * f[i][2]; @@ -778,6 +780,7 @@ void FixMove::final_integrate() dtfm = dtf / mass[type[i]]; v[i][2] += dtfm * f[i][2]; } + } } } } diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index 0d456cd04e..a63f3d322b 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -1534,20 +1534,22 @@ double FixNH::compute_vector(int n) n -= ilen; } else if (pstyle == ANISO) { ilen = 3; - if (n < ilen) + if (n < ilen) { if (p_flag[n]) return p_hydro*(volume-vol0) / (pdim*nktv2p); else return 0.0; + } n -= ilen; } else { ilen = 6; - if (n < ilen) + if (n < ilen) { if (n > 2) return 0.0; else if (p_flag[n]) return p_hydro*(volume-vol0) / (pdim*nktv2p); else return 0.0; + } n -= ilen; } @@ -1558,17 +1560,19 @@ double FixNH::compute_vector(int n) n -= ilen; } else if (pstyle == ANISO) { ilen = 3; - if (n < ilen) + if (n < ilen) { if (p_flag[n]) return 0.5*omega_dot[n]*omega_dot[n]*omega_mass[n]; else return 0.0; + } n -= ilen; } else { ilen = 6; - if (n < ilen) + if (n < ilen) { if (p_flag[n]) return 0.5*omega_dot[n]*omega_dot[n]*omega_mass[n]; else return 0.0; + } n -= ilen; } @@ -2139,7 +2143,7 @@ void FixNH::nh_omega_dot() if (deviatoric_flag) compute_deviatoric(); mtk_term1 = 0.0; - if (mtk_flag) + if (mtk_flag) { if (pstyle == ISO) { mtk_term1 = tdof * boltz * t_current; mtk_term1 /= pdim * atom->natoms; @@ -2150,6 +2154,7 @@ void FixNH::nh_omega_dot() mtk_term1 += mvv_current[i]; mtk_term1 /= pdim * atom->natoms; } + } for (int i = 0; i < 3; i++) if (p_flag[i]) { diff --git a/src/molecule.cpp b/src/molecule.cpp index ea1fa6b73a..3fe25e6195 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -313,7 +313,7 @@ void Molecule::read(int flag) // trim anything from '#' onward // if line is blank, continue - if (ptr = strchr(line,'#')) *ptr = '\0'; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; if (strspn(line," \t\n\r") == strlen(line)) continue; // search line for header keywords and set corresponding variable @@ -1325,7 +1325,7 @@ int Molecule::parse(char *line, char **words, int max) int nwords = 0; words[nwords++] = strtok(line," \t\n\r\f"); - while (ptr = strtok(NULL," \t\n\r\f")) { + while ((ptr = strtok(NULL," \t\n\r\f"))) { if (nwords < max) words[nwords] = ptr; nwords++; } diff --git a/src/neigh_respa.cpp b/src/neigh_respa.cpp index 239db4b249..91f85de6ea 100644 --- a/src/neigh_respa.cpp +++ b/src/neigh_respa.cpp @@ -131,7 +131,7 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -309,7 +309,7 @@ void Neighbor::respa_nsq_newton(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -478,7 +478,7 @@ void Neighbor::respa_bin_no_newton(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -651,7 +651,7 @@ void Neighbor::respa_bin_newton(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -695,7 +695,7 @@ void Neighbor::respa_bin_newton(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -873,7 +873,7 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; diff --git a/src/procmap.cpp b/src/procmap.cpp index 6703b08d25..b24e59421b 100644 --- a/src/procmap.cpp +++ b/src/procmap.cpp @@ -291,7 +291,7 @@ void ProcMap::custom_grid(char *cfile, int nprocs, if (!fgets(line,MAXLINE,fp)) error->one(FLERR,"Unexpected end of custom file"); while (1) { - if (ptr = strchr(line,'#')) *ptr = '\0'; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; if (strspn(line," \t\n\r") != strlen(line)) break; if (!fgets(line,MAXLINE,fp)) error->one(FLERR,"Unexpected end of custom file"); diff --git a/src/read_data.cpp b/src/read_data.cpp index 44def025df..5f3633ddbd 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -619,7 +619,7 @@ void ReadData::header() // trim anything from '#' onward // if line is blank, continue - if (ptr = strchr(line,'#')) *ptr = '\0'; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; if (strspn(line," \t\n\r") == strlen(line)) continue; // allow special fixes first chance to match and process the line @@ -1556,7 +1556,7 @@ void ReadData::skip_lines(bigint n) void ReadData::parse_coeffs(char *line, const char *addstr, int dupflag) { char *ptr; - if (ptr = strchr(line,'#')) *ptr = '\0'; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; narg = 0; char *word = strtok(line," \t\n\r\f"); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 978b2d2bc9..aeeec98e26 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -549,7 +549,7 @@ void ReadRestart::file_search(char *infile, char *outfile) char *pattern = new char[strlen(filename) + 16]; - if (ptr = strchr(filename,'%')) { + if ((ptr = strchr(filename,'%'))) { *ptr = '\0'; sprintf(pattern,"%s%s%s",filename,"base",ptr+1); *ptr = '%'; @@ -574,7 +574,7 @@ void ReadRestart::file_search(char *infile, char *outfile) DIR *dp = opendir(dirname); if (dp == NULL) error->one(FLERR,"Cannot open dir to search for restart file"); - while (ep = readdir(dp)) { + while ((ep = readdir(dp))) { if (strstr(ep->d_name,begin) != ep->d_name) continue; if ((ptr = strstr(&ep->d_name[nbegin],end)) == NULL) continue; if (strlen(end) == 0) ptr = ep->d_name + strlen(ep->d_name); diff --git a/src/universe.cpp b/src/universe.cpp index 35d8f2cf24..d1665599cf 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -100,7 +100,7 @@ void Universe::reorder(char *style, char *arg) if (!fgets(line,MAXLINE,fp)) error->one(FLERR,"Unexpected end of -reorder file"); while (1) { - if (ptr = strchr(line,'#')) *ptr = '\0'; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; if (strspn(line," \t\n\r") != strlen(line)) break; if (!fgets(line,MAXLINE,fp)) error->one(FLERR,"Unexpected end of -reorder file"); diff --git a/src/variable.cpp b/src/variable.cpp index a6f5c69158..b13b4d9515 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -4088,7 +4088,7 @@ int VarReader::read_scalar(char *str) else n = strlen(str); if (n == 0) break; // end of file str[n-1] = '\0'; // strip newline - if (ptr = strchr(str,'#')) *ptr = '\0'; // strip comment + if ((ptr = strchr(str,'#'))) *ptr = '\0'; // strip comment if (strtok(str," \t\n\r\f") == NULL) continue; // skip if blank n = strlen(str) + 1; break; @@ -4131,7 +4131,7 @@ int VarReader::read_peratom() else n = strlen(str); if (n == 0) break; // end of file str[n-1] = '\0'; // strip newline - if (ptr = strchr(str,'#')) *ptr = '\0'; // strip comment + if ((ptr = strchr(str,'#'))) *ptr = '\0'; // strip comment if (strtok(str," \t\n\r\f") == NULL) continue; // skip if blank n = strlen(str) + 1; break; diff --git a/src/write_data.cpp b/src/write_data.cpp index c3b038ee41..899edacdc2 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -65,7 +65,7 @@ void WriteData::command(int narg, char **arg) int n = strlen(arg[0]) + 16; char *file = new char[n]; - if (ptr = strchr(arg[0],'*')) { + if ((ptr = strchr(arg[0],'*'))) { *ptr = '\0'; sprintf(file,"%s" BIGINT_FORMAT "%s",arg[0],update->ntimestep,ptr+1); } else strcpy(file,arg[0]); @@ -152,11 +152,11 @@ void WriteData::write(char *file) // sum up bond,angle counts // may be different than atom->nbonds,nangles if broken/turned-off - if (atom->molecular == 1 && atom->nbonds || atom->nbondtypes) { + if (atom->molecular == 1 && (atom->nbonds || atom->nbondtypes)) { nbonds_local = atom->avec->pack_bond(NULL); MPI_Allreduce(&nbonds_local,&nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world); } - if (atom->molecular == 1 && atom->nangles || atom->nangletypes) { + if (atom->molecular == 1 && (atom->nangles || atom->nangletypes)) { nangles_local = atom->avec->pack_angle(NULL); MPI_Allreduce(&nangles_local,&nangles,1,MPI_LMP_BIGINT,MPI_SUM,world); } diff --git a/src/write_restart.cpp b/src/write_restart.cpp index 422462c2bd..5c5bd066ed 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -89,7 +89,7 @@ void WriteRestart::command(int narg, char **arg) int n = strlen(arg[0]) + 16; char *file = new char[n]; - if (ptr = strchr(arg[0],'*')) { + if ((ptr = strchr(arg[0],'*'))) { *ptr = '\0'; sprintf(file,"%s" BIGINT_FORMAT "%s",arg[0],update->ntimestep,ptr+1); } else strcpy(file,arg[0]);