From c9495408a11e20054fe7b1020ece254c61119732 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 4 Jan 2011 21:08:27 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5472 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/MANYBODY/fix_qeq_comb.cpp | 2 +- src/MANYBODY/fix_qeq_comb.h | 3 ++- src/SRD/fix_srd.cpp | 28 ++++++++++++++-------------- src/USER-IMD/fix_imd.cpp | 15 +++++++-------- src/compute_reduce.cpp | 18 ++++++++++-------- src/compute_reduce.h | 3 ++- src/compute_reduce_region.cpp | 13 +++++++------ src/compute_reduce_region.h | 3 ++- src/dump.cpp | 2 +- src/dump_dcd.cpp | 9 ++++++--- src/fix_heat.cpp | 2 +- src/fix_momentum.cpp | 2 +- src/fix_recenter.cpp | 2 +- src/group.cpp | 19 +++++++++---------- src/group.h | 5 +++-- src/velocity.cpp | 4 ++-- 16 files changed, 69 insertions(+), 61 deletions(-) diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index dcc9c15dbc..b8f13964f9 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -119,7 +119,7 @@ void FixQEQComb::init() nlevels_respa = ((Respa *) update->integrate)->nlevels; ngroup = group->count(igroup); - if (ngroup == 0.0) error->all("Fix qeq/comb group has no atoms"); + if (ngroup == 0) error->all("Fix qeq/comb group has no atoms"); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/fix_qeq_comb.h b/src/MANYBODY/fix_qeq_comb.h index 76c694ef42..235b4c9c3e 100644 --- a/src/MANYBODY/fix_qeq_comb.h +++ b/src/MANYBODY/fix_qeq_comb.h @@ -22,6 +22,7 @@ FixStyle(qeq/comb,FixQEQComb) #include "stdio.h" #include "fix.h" +#include "lmptype.h" namespace LAMMPS_NS { @@ -40,7 +41,7 @@ class FixQEQComb : public Fix { int me,firstflag; double precision; int nlevels_respa; - double ngroup; + bigint ngroup; FILE *fp; class PairComb *comb; diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 6974738981..a59d105996 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -1075,7 +1075,7 @@ void FixSRD::vbin_unpack(double *buf, BinAve *vbin, int n, int *list) void FixSRD::collisions_single() { - int i,j,k,m,type,nbig,ibin,ibounce,inside,collide_flag; + int i,j,k,m,type,mbig,ibin,ibounce,inside,collide_flag; double dt,t_remain; double norm[3],xscoll[3],xbcoll[3],vsnew[3]; Big *big; @@ -1107,11 +1107,11 @@ void FixSRD::collisions_single() dt = dt_big; while (collide_flag) { - nbig = nbinbig[ibin]; - if (ibounce == 0) ncheck += nbig; + mbig = nbinbig[ibin]; + if (ibounce == 0) ncheck += mbig; collide_flag = 0; - for (m = 0; m < nbig; m++) { + for (m = 0; m < mbig; m++) { k = binbig[ibin][m]; big = &biglist[k]; j = big->index; @@ -1236,7 +1236,7 @@ void FixSRD::collisions_single() void FixSRD::collisions_multi() { - int i,j,k,m,type,nbig,ibin,ibounce,inside,jfirst,typefirst; + int i,j,k,m,type,mbig,ibin,ibounce,inside,jfirst,typefirst; double dt,t_remain,t_first; double norm[3],xscoll[3],xbcoll[3],vsnew[3]; double normfirst[3],xscollfirst[3],xbcollfirst[3]; @@ -1268,11 +1268,11 @@ void FixSRD::collisions_multi() dt = dt_big; while (1) { - nbig = nbinbig[ibin]; - if (ibounce == 0) ncheck += nbig; + mbig = nbinbig[ibin]; + if (ibounce == 0) ncheck += mbig; t_first = 0.0; - for (m = 0; m < nbig; m++) { + for (m = 0; m < mbig; m++) { k = binbig[ibin][m]; big = &biglist[k]; j = big->index; @@ -2236,9 +2236,9 @@ void FixSRD::parameterize() // particle counts - double nbig = 0.0; - if (bigexist) nbig = group->count(biggroup); - double nsrd = group->count(igroup); + bigint mbig = 0; + if (bigexist) mbig = group->count(biggroup); + bigint nsrd = group->count(igroup); // mass_big = total mass of all big particles @@ -2293,7 +2293,7 @@ void FixSRD::parameterize() else ncell = volsrd / (binsize3x*binsize3y); - srd_per_cell = nsrd / ncell; + srd_per_cell = (double) nsrd / ncell; // kinematic viscosity of SRD fluid // output in cm^2/sec units, converted by xxt2kmu @@ -2317,7 +2317,7 @@ void FixSRD::parameterize() if (me == 0) { if (screen) { fprintf(screen,"SRD info:\n"); - fprintf(screen," SRD/big particles = %g %g\n",nsrd,nbig); + fprintf(screen," SRD/big particles = %lu %lu\n",nsrd,mbig); fprintf(screen," big particle diameter max/min = %g %g\n", maxbigdiam,minbigdiam); fprintf(screen," SRD temperature & lamda = %g %g\n", @@ -2332,7 +2332,7 @@ void FixSRD::parameterize() } if (logfile) { fprintf(logfile,"SRD info:\n"); - fprintf(logfile," SRD/big particles = %g %g\n",nsrd,nbig); + fprintf(logfile," SRD/big particles = %lu %lu\n",nsrd,mbig); fprintf(logfile," big particle diameter max/min = %g %g\n", maxbigdiam,minbigdiam); fprintf(logfile," SRD temperature & lamda = %g %g\n", diff --git a/src/USER-IMD/fix_imd.cpp b/src/USER-IMD/fix_imd.cpp index ecf125250e..427d6ed496 100644 --- a/src/USER-IMD/fix_imd.cpp +++ b/src/USER-IMD/fix_imd.cpp @@ -230,7 +230,7 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) : imd_port = atoi(arg[3]); if (imd_port < 1024) - error->all("Illegal fix imd parameter. port < 1024."); + error->all("Illegal fix imd parameter: port < 1024"); /* default values for optional flags */ unwrap_flag = 0; @@ -259,7 +259,7 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) : } else if (0 == strcmp(arg[argsdone], "trate")) { imd_trate = atoi(arg[argsdone+1]); } else { - error->all("Unknown fix imd parameter."); + error->all("Unknown fix imd parameter"); } ++argsdone; ++argsdone; } @@ -268,12 +268,11 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) : if (imd_trate < 1) error->all("Illegal fix imd parameter. trate < 1."); - if (igroup == group->find("all")) { - num_coords = static_cast (atom->natoms); - } else { - num_coords = static_cast (group->count(igroup)); - if (num_coords <= 0) error->all("Invalid number of group atoms for 'fix imd'"); - } + bigint n; + if (igroup == group->find("all")) n = atom->natoms; + else n = group->count(igroup); + if (n > MAXINT32) error->all("Too many atoms for fix imd"); + num_coords = static_cast (n); MPI_Comm_rank(world,&me); diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index c3da812ba9..0e07f95dd1 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -14,6 +14,7 @@ #include "string.h" #include "stdlib.h" #include "compute_reduce.h" +#include "lmptype.h" #include "atom.h" #include "update.h" #include "domain.h" @@ -589,7 +590,7 @@ double ComputeReduce::compute_one(int m, int flag) /* ---------------------------------------------------------------------- */ -double ComputeReduce::count(int m) +bigint ComputeReduce::count(int m) { int vidx = value2index[m]; int aidx = argindex[m]; @@ -601,9 +602,9 @@ double ComputeReduce::count(int m) if (flavor[m] == PERATOM) { return group->count(igroup); } else if (flavor[m] == LOCAL) { - double ncount = compute->size_local_rows; - double ncountall; - MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); + bigint ncount = compute->size_local_rows; + bigint ncountall; + MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG,MPI_SUM,world); return ncountall; } } else if (which[m] == FIX) { @@ -611,15 +612,16 @@ double ComputeReduce::count(int m) if (flavor[m] == PERATOM) { return group->count(igroup); } else if (flavor[m] == LOCAL) { - double ncount = fix->size_local_rows; - double ncountall; - MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); + bigint ncount = fix->size_local_rows; + bigint ncountall; + MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG,MPI_SUM,world); return ncountall; } } else if (which[m] == VARIABLE) return group->count(igroup); - return 0.0; + bigint dummy = 0; + return dummy; } /* ---------------------------------------------------------------------- diff --git a/src/compute_reduce.h b/src/compute_reduce.h index 49242c04bd..c0d6a59765 100644 --- a/src/compute_reduce.h +++ b/src/compute_reduce.h @@ -21,6 +21,7 @@ ComputeStyle(reduce,ComputeReduce) #define LMP_COMPUTE_REDUCE_H #include "compute.h" +#include "lmptype.h" namespace LAMMPS_NS { @@ -53,7 +54,7 @@ class ComputeReduce : public Compute { Pair pairme,pairall; virtual double compute_one(int, int); - virtual double count(int); + virtual bigint count(int); void combine(double &, double, int); }; diff --git a/src/compute_reduce_region.cpp b/src/compute_reduce_region.cpp index d8071c2480..cc88ef0787 100644 --- a/src/compute_reduce_region.cpp +++ b/src/compute_reduce_region.cpp @@ -220,7 +220,7 @@ double ComputeReduceRegion::compute_one(int m, int flag) /* ---------------------------------------------------------------------- */ -double ComputeReduceRegion::count(int m) +bigint ComputeReduceRegion::count(int m) { int n = value2index[m]; int j = argindex[m]; @@ -235,8 +235,8 @@ double ComputeReduceRegion::count(int m) if (flavor[m] == PERATOM) { return group->count(igroup,iregion); } else if (flavor[m] == LOCAL) { - double ncount = compute->size_local_rows; - double ncountall; + bigint ncount = compute->size_local_rows; + bigint ncountall; MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); return ncountall; } @@ -245,13 +245,14 @@ double ComputeReduceRegion::count(int m) if (flavor[m] == PERATOM) { return group->count(igroup,iregion); } else if (flavor[m] == LOCAL) { - double ncount = fix->size_local_rows; - double ncountall; + bigint ncount = fix->size_local_rows; + bigint ncountall; MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); return ncountall; } } else if (which[m] == VARIABLE) return group->count(igroup,iregion); - return 0.0; + bigint dummy = 0; + return dummy; } diff --git a/src/compute_reduce_region.h b/src/compute_reduce_region.h index 30718ce85b..55249b0ef6 100644 --- a/src/compute_reduce_region.h +++ b/src/compute_reduce_region.h @@ -21,6 +21,7 @@ ComputeStyle(reduce/region,ComputeReduceRegion) #define LMP_COMPUTE_REDUCE_REGION_H #include "compute_reduce.h" +#include "lmptype.h" namespace LAMMPS_NS { @@ -31,7 +32,7 @@ class ComputeReduceRegion : public ComputeReduce { private: double compute_one(int, int); - double count(int); + bigint count(int); }; } diff --git a/src/dump.cpp b/src/dump.cpp index 02e316caf2..76708f01eb 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -173,7 +173,7 @@ void Dump::init() if (nprocs > 1 && irregular == NULL) irregular = new Irregular(lmp); - double size = group->count(igroup); + bigint size = group->count(igroup); if (size > MAXINT32) error->all("Too many atoms to dump sort"); // set reorderflag = 1 if can simply reorder local atoms rather than sort diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp index 6794cfbc64..222b8dc4be 100644 --- a/src/dump_dcd.cpp +++ b/src/dump_dcd.cpp @@ -22,6 +22,7 @@ #include "time.h" #include "string.h" #include "dump_dcd.h" +#include "lmptype.h" #include "domain.h" #include "atom.h" #include "update.h" @@ -67,9 +68,11 @@ DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) // allocate global array for atom coords - if (igroup == 0) natoms = static_cast (atom->natoms); - else natoms = static_cast (group->count(igroup)); - if (natoms <= 0) error->all("Invalid natoms for dump dcd"); + bigint n; + if (igroup == 0) n = static_cast (atom->natoms); + else n = static_cast (group->count(igroup)); + if (n > MAXINT32) error->all("Too many atoms for dump dcd"); + natoms = n; coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords"); xf = &coords[0*natoms]; diff --git a/src/fix_heat.cpp b/src/fix_heat.cpp index a6eda20678..450d0bb841 100644 --- a/src/fix_heat.cpp +++ b/src/fix_heat.cpp @@ -94,7 +94,7 @@ void FixHeat::init() // cannot have 0 atoms in group - if (group->count(igroup) == 0.0) error->all("Fix heat group has no atoms"); + if (group->count(igroup) == 0) error->all("Fix heat group has no atoms"); masstotal = group->mass(igroup); } diff --git a/src/fix_momentum.cpp b/src/fix_momentum.cpp index b01f752ec5..400f394c93 100644 --- a/src/fix_momentum.cpp +++ b/src/fix_momentum.cpp @@ -60,7 +60,7 @@ FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) : // cannot have 0 atoms in group - if (group->count(igroup) == 0.0) + if (group->count(igroup) == 0) error->all("Fix momentum group has no atoms"); } diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index e5f243597d..cd2b311c9a 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -91,7 +91,7 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : // cannot have 0 atoms in group - if (group->count(igroup) == 0.0) + if (group->count(igroup) == 0) error->all("Fix recenter group has no atoms"); } diff --git a/src/group.cpp b/src/group.cpp index de64c6615b..bd517d79e1 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -17,6 +17,7 @@ #include "string.h" #include "stdlib.h" #include "group.h" +#include "lmptype.h" #include "domain.h" #include "atom.h" #include "force.h" @@ -481,10 +482,9 @@ void Group::read_restart(FILE *fp) /* ---------------------------------------------------------------------- count atoms in group - compute in double precision in case system is huge ------------------------------------------------------------------------- */ -double Group::count(int igroup) +bigint Group::count(int igroup) { int groupbit = bitmask[igroup]; @@ -495,18 +495,17 @@ double Group::count(int igroup) for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) n++; - double nsingle = n; - double nall; - MPI_Allreduce(&nsingle,&nall,1,MPI_DOUBLE,MPI_SUM,world); + bigint nsingle = n; + bigint nall; + MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG,MPI_SUM,world); return nall; } /* ---------------------------------------------------------------------- count atoms in group and region - compute in double precision in case system is huge ------------------------------------------------------------------------- */ -double Group::count(int igroup, int iregion) +bigint Group::count(int igroup, int iregion) { int groupbit = bitmask[igroup]; Region *region = domain->regions[iregion]; @@ -519,9 +518,9 @@ double Group::count(int igroup, int iregion) for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) n++; - double nsingle = n; - double nall; - MPI_Allreduce(&nsingle,&nall,1,MPI_DOUBLE,MPI_SUM,world); + bigint nsingle = n; + bigint nall; + MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG,MPI_SUM,world); return nall; } diff --git a/src/group.h b/src/group.h index 46ed702cad..cc0938f4a0 100644 --- a/src/group.h +++ b/src/group.h @@ -16,6 +16,7 @@ #include "stdio.h" #include "pointers.h" +#include "lmptype.h" namespace LAMMPS_NS { @@ -34,8 +35,8 @@ class Group : protected Pointers { void write_restart(FILE *); void read_restart(FILE *); - double count(int); // count atoms in group - double count(int,int); // count atoms in group & region + bigint count(int); // count atoms in group + bigint count(int,int); // count atoms in group & region double mass(int); // total mass of atoms in group double mass(int,int); double charge(int); // total charge of atoms in group diff --git a/src/velocity.cpp b/src/velocity.cpp index a3f84537b6..0a9e944b08 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -536,7 +536,7 @@ void Velocity::zero_momentum() { // cannot have 0 atoms in group - if (group->count(igroup) == 0.0) + if (group->count(igroup) == 0) error->all("Cannot zero momentum of 0 atoms"); // compute velocity of center-of-mass of group @@ -569,7 +569,7 @@ void Velocity::zero_rotation() // cannot have 0 atoms in group - if (group->count(igroup) == 0.0) + if (group->count(igroup) == 0) error->all("Cannot zero momentum of 0 atoms"); // compute omega (angular velocity) of group around center-of-mass