git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5498 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2011-01-06 23:23:37 +00:00
parent 3cd5ef56fc
commit 01db59bea3
23 changed files with 83 additions and 54 deletions

View File

@ -431,7 +431,7 @@ void PRD::dephase()
timer->barrier_start(TIME_LOOP);
for (int i = 0; i < n_dephase; i++) {
int seed = static_cast<int> (random_dephase->uniform() * MAXINT32);
int seed = static_cast<int> (random_dephase->uniform() * MAXSMALLINT);
if (seed == 0) seed = 1;
velocity->create(temp_dephase,seed);
update->integrate->run(t_dephase);

View File

@ -67,9 +67,11 @@ DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
// allocate global array for atom coords
if (igroup == 0) natoms = static_cast<int> (atom->natoms);
else natoms = static_cast<int> (group->count(igroup));
if (natoms <= 0) error->all("Invalid natoms for dump xtc");
bigint n;
if (igroup == 0) n = static_cast<int> (atom->natoms);
else n = static_cast<int> (group->count(igroup));
if (n > MAXSMALLINT) error->all("Too many atoms for dump xtc");
natoms = n;
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");

View File

@ -604,7 +604,7 @@ bigint ComputeReduce::count(int m)
} else if (flavor[m] == LOCAL) {
bigint ncount = compute->size_local_rows;
bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&ncount,&ncountall,1,MPI_LMP_BIGINT,MPI_SUM,world);
return ncountall;
}
} else if (which[m] == FIX) {
@ -614,7 +614,7 @@ bigint ComputeReduce::count(int m)
} else if (flavor[m] == LOCAL) {
bigint ncount = fix->size_local_rows;
bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&ncount,&ncountall,1,MPI_LMP_BIGINT,MPI_SUM,world);
return ncountall;
}
} else if (which[m] == VARIABLE)

View File

@ -169,7 +169,7 @@ void CreateAtoms::command(int narg, char **arg)
// new total # of atoms
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&atom->natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&atom->natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
// print status
@ -185,8 +185,8 @@ void CreateAtoms::command(int narg, char **arg)
// if global map exists, reset it
// if a molecular system, set nspecial to 0 for new atoms
if (atom->natoms > MAXINT32) atom->tag_enable = 0;
if (atom->natoms <= MAXINT32) atom->tag_extend();
if (atom->natoms > MAXTAGINT) atom->tag_enable = 0;
if (atom->natoms <= MAXTAGINT) atom->tag_extend();
if (atom->map_style) {
atom->nghost = 0;

View File

@ -93,7 +93,7 @@ void DeleteAtoms::command(int narg, char **arg)
// set nghost to 0 so old ghosts of deleted atoms won't be mapped
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&atom->natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&atom->natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (atom->map_style) {
atom->nghost = 0;
atom->map_init();

View File

@ -341,7 +341,7 @@ void DeleteBonds::command(int narg, char **arg)
if (atom->avec->bonds_allow) {
bigint nbonds = 0;
for (i = 0; i < nlocal; i++) nbonds += atom->num_bond[i];
MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_UNSIGNED_LONG_LONG,
MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,
MPI_SUM,world);
if (force->newton_bond == 0) atom->nbonds /= 2;
}
@ -349,7 +349,7 @@ void DeleteBonds::command(int narg, char **arg)
if (atom->avec->angles_allow) {
bigint nangles = 0;
for (i = 0; i < nlocal; i++) nangles += atom->num_angle[i];
MPI_Allreduce(&nangles,&atom->nangles,1,MPI_UNSIGNED_LONG_LONG,
MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,
MPI_SUM,world);
if (force->newton_bond == 0) atom->nangles /= 3;
}
@ -358,7 +358,7 @@ void DeleteBonds::command(int narg, char **arg)
bigint ndihedrals = 0;
for (i = 0; i < nlocal; i++) ndihedrals += atom->num_dihedral[i];
MPI_Allreduce(&ndihedrals,&atom->ndihedrals,
1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
1,MPI_LMP_BIGINT,MPI_SUM,world);
if (force->newton_bond == 0) atom->ndihedrals /= 4;
}
@ -366,7 +366,7 @@ void DeleteBonds::command(int narg, char **arg)
bigint nimpropers = 0;
for (i = 0; i < nlocal; i++) nimpropers += atom->num_improper[i];
MPI_Allreduce(&nimpropers,&atom->nimpropers,
1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
1,MPI_LMP_BIGINT,MPI_SUM,world);
if (force->newton_bond == 0) atom->nimpropers /= 4;
}
@ -386,9 +386,9 @@ void DeleteBonds::command(int narg, char **arg)
for (m = 0; m < atom->num_bond[i]; m++)
if (atom->bond_type[i][m] > 0) bond_on++;
else bond_off++;
MPI_Allreduce(&bond_on,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&bond_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
bond_on = tmp;
MPI_Allreduce(&bond_off,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&bond_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
bond_off = tmp;
if (force->newton_bond == 0) {
bond_on /= 2;
@ -402,9 +402,9 @@ void DeleteBonds::command(int narg, char **arg)
for (m = 0; m < atom->num_angle[i]; m++)
if (atom->angle_type[i][m] > 0) angle_on++;
else angle_off++;
MPI_Allreduce(&angle_on,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&angle_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
angle_on = tmp;
MPI_Allreduce(&angle_off,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&angle_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
angle_off = tmp;
if (force->newton_bond == 0) {
angle_on /= 3;
@ -418,9 +418,9 @@ void DeleteBonds::command(int narg, char **arg)
for (m = 0; m < atom->num_dihedral[i]; m++)
if (atom->dihedral_type[i][m] > 0) dihedral_on++;
else dihedral_off++;
MPI_Allreduce(&dihedral_on,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&dihedral_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
dihedral_on = tmp;
MPI_Allreduce(&dihedral_off,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&dihedral_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
dihedral_off = tmp;
if (force->newton_bond == 0) {
dihedral_on /= 4;
@ -434,9 +434,9 @@ void DeleteBonds::command(int narg, char **arg)
for (m = 0; m < atom->num_improper[i]; m++)
if (atom->improper_type[i][m] > 0) improper_on++;
else improper_off++;
MPI_Allreduce(&improper_on,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&improper_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
improper_on = tmp;
MPI_Allreduce(&improper_off,&tmp,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&improper_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
improper_off = tmp;
if (force->newton_bond == 0) {
improper_on /= 4;

View File

@ -213,7 +213,7 @@ void DisplaceAtoms::command(int narg, char **arg)
bigint natoms;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (natoms != atom->natoms) {
char str[128];
sprintf(str,"Lost atoms via displace_atoms: original %lu current %lu",

View File

@ -379,7 +379,7 @@ void DisplaceBox::command(int narg, char **arg)
bigint natoms;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (natoms != atom->natoms) {
char str[128];
sprintf(str,"Lost atoms via displace_box: original %lu current %lu",

View File

@ -174,7 +174,7 @@ void Dump::init()
irregular = new Irregular(lmp);
bigint size = group->count(igroup);
if (size > MAXINT32) error->all("Too many atoms to dump sort");
if (size > MAXSMALLINT) error->all("Too many atoms to dump sort");
// set reorderflag = 1 if can simply reorder local atoms rather than sort
// criteria: sorting by ID, atom IDs are consecutive from 1 to Natoms

View File

@ -71,7 +71,7 @@ DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
bigint n;
if (igroup == 0) n = static_cast<int> (atom->natoms);
else n = static_cast<int> (group->count(igroup));
if (n > MAXINT32) error->all("Too many atoms for dump dcd");
if (n > MAXSMALLINT) error->all("Too many atoms for dump dcd");
natoms = n;
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");

View File

@ -86,7 +86,7 @@ void Finish::end(int flag)
// use actual natoms, in case atoms were lost
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen)

View File

@ -497,7 +497,7 @@ bigint Group::count(int igroup)
bigint nsingle = n;
bigint nall;
MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nsingle,&nall,1,MPI_LMP_BIGINT,MPI_SUM,world);
return nall;
}
@ -520,7 +520,7 @@ bigint Group::count(int igroup, int iregion)
bigint nsingle = n;
bigint nall;
MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nsingle,&nall,1,MPI_LMP_BIGINT,MPI_SUM,world);
return nall;
}

View File

@ -247,9 +247,9 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
error->all("No support for 8-byte unsigned integers");
int mpisize;
MPI_Type_size(MPI_UNSIGNED_LONG_LONG,&mpisize);
MPI_Type_size(MPI_LMP_BIGINT,&mpisize);
if (mpisize != 8)
error->all("MPI_UNSIGNED_LONG_LONG is not 8-byte data type");
error->all("MPI_LMP_BIGINT is not 8-byte data type");
// allocate input class now that MPI is fully setup

View File

@ -348,7 +348,7 @@ void *lammps_extract_variable(void *ptr, char *name, char *group)
int lammps_get_natoms(void *ptr)
{
LAMMPS *lmp = (LAMMPS *) ptr;
if (lmp->atom->natoms > MAXINT32) return 0;
if (lmp->atom->natoms > MAXSMALLINT) return 0;
int natoms = static_cast<int> (lmp->atom->natoms);
return natoms;
}
@ -362,7 +362,7 @@ void lammps_get_coords(void *ptr, double *coords)
// error if tags are not defined or not consecutive
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) return;
if (lmp->atom->natoms > MAXINT32) return;
if (lmp->atom->natoms > MAXSMALLINT) return;
int natoms = static_cast<int> (lmp->atom->natoms);
double *copy = new double[3*natoms];
@ -394,7 +394,7 @@ void lammps_put_coords(void *ptr, double *coords)
// error if no map defined by LAMMPS
if (lmp->atom->map_style == 0) return;
if (lmp->atom->natoms > MAXINT32) return;
if (lmp->atom->natoms > MAXSMALLINT) return;
int natoms = static_cast<int> (lmp->atom->natoms);
double **x = lmp->atom->x;

View File

@ -11,6 +11,23 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
// define integer data types used by LAMMPS and associated size limits
// smallint = variables for system on 1 processor (nlocal, etc)
// tagint = variables for atom IDs (tag)
// bigint = variables for total system and timesteps (natoms, ntimestep, etc)
// smallint must be an int, as defined by C compiler
// tagint can be 32-bit or 64-bit int, must be >= smallint
// bigint can be 32-bit or 64-bit int, must be >= smallint and >= tagint
// MAXSMALLINT = max value of a smallint
// MAXTAGINT = max value of a tagint
// MAXBIGINT = max value of a bigint
// MPI_LMP_TAGINT = MPI data type corresponding to tagint
// MPI_LMP_BIGINT = MPI data type corresponding to bigint
#ifndef LMP_LMPTYPE_H
#define LMP_LMPTYPE_H
@ -18,8 +35,18 @@
namespace LAMMPS_NS {
typedef uint64_t bigint;
#define MAXINT32 0x7FFFFFFF
// default settings: 4-byte smallint, 4-byte tagint, 8-byte bigint
typedef int smallint;
typedef int tagint;
typedef int64_t bigint;
#define MAXSMALLINT 0x7FFFFFFF
#define MAXTAGINT 0x7FFFFFFF
#define MAXBIGINT 0x7FFFFFFFFFFFFFFFL
#define MPI_LMP_TAGINT MPI_INT
#define MPI_LMP_BIGINT MPI_LONG_LONG
}

View File

@ -202,7 +202,7 @@ void Min::setup()
bigint ndofme = 3*atom->nlocal;
for (int m = 0; m < nextra_atom; m++)
ndofme += extra_peratom[m]*atom->nlocal;
MPI_Allreduce(&ndofme,&ndoftotal,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&ndofme,&ndoftotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
ndoftotal += nextra_global;
// setup domain, communication and neighboring

View File

@ -51,7 +51,7 @@ int MinCG::iterate(int maxiter)
// nlimit = max # of CG iterations before restarting
// set to ndoftotal unless too big
int nlimit = static_cast<int> (MIN(MAXINT32,ndoftotal));
int nlimit = static_cast<int> (MIN(MAXSMALLINT,ndoftotal));
// initialize working vectors

View File

@ -435,7 +435,7 @@ void ReadData::atoms()
// check that all atoms were assigned correctly
bigint tmp = atom->nlocal;
MPI_Allreduce(&tmp,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&tmp,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);
@ -568,7 +568,7 @@ void ReadData::bonds()
bigint sum;
bigint n = 0;
for (i = 0; i < nlocal; i++) n += atom->num_bond[i];
MPI_Allreduce(&n,&sum,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world);
int factor = 1;
if (!force->newton_bond) factor = 2;
@ -613,7 +613,7 @@ void ReadData::angles()
bigint sum;
bigint n = 0;
for (i = 0; i < nlocal; i++) n += atom->num_angle[i];
MPI_Allreduce(&n,&sum,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world);
int factor = 1;
if (!force->newton_bond) factor = 3;
@ -658,7 +658,7 @@ void ReadData::dihedrals()
bigint sum;
bigint n = 0;
for (i = 0; i < nlocal; i++) n += atom->num_dihedral[i];
MPI_Allreduce(&n,&sum,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world);
int factor = 1;
if (!force->newton_bond) factor = 4;
@ -704,7 +704,7 @@ void ReadData::impropers()
bigint sum;
bigint n = 0;
for (i = 0; i < nlocal; i++) n += atom->num_improper[i];
MPI_Allreduce(&n,&sum,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world);
int factor = 1;
if (!force->newton_bond) factor = 4;
@ -976,7 +976,7 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom,
int i,tmp1,tmp2,atom1,atom2,atom3,atom4;
char *eof;
if (atom->natoms > MAXINT32)
if (atom->natoms > MAXSMALLINT)
error->all("Molecular data file has too many atoms");
int natoms = static_cast<int> (atom->natoms);

View File

@ -293,7 +293,7 @@ void ReadRestart::command(int narg, char **arg)
bigint natoms;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);
@ -819,6 +819,6 @@ bigint ReadRestart::read_bigint()
{
bigint value;
if (me == 0) fread(&value,sizeof(bigint),1,fp);
MPI_Bcast(&value,1,MPI_UNSIGNED_LONG_LONG,0,world);
MPI_Bcast(&value,1,MPI_LMP_BIGINT,0,world);
return value;
}

View File

@ -129,16 +129,16 @@ void Replicate::command(int narg, char **arg)
// if molecular, N/Nbonds/etc cannot be > 2^31 else tags/counts invalid
double rep = nrep;
if (rep*old->natoms > MAXINT32) atom->tag_enable = 0;
if (rep*old->natoms > MAXSMALLINT) atom->tag_enable = 0;
if (atom->tag_enable == 0)
for (int i = 0; i < atom->nlocal; i++)
atom->tag[i] = 0;
if (atom->molecular) {
if (rep*old->natoms > MAXINT32 || rep*old->nbonds > MAXINT32 ||
rep*old->nangles > MAXINT32 || rep*old->ndihedrals > MAXINT32 ||
rep*old->nimpropers > MAXINT32)
if (rep*old->natoms > MAXBIGINT || rep*old->nbonds > MAXBIGINT ||
rep*old->nangles > MAXBIGINT || rep*old->ndihedrals > MAXBIGINT ||
rep*old->nimpropers > MAXBIGINT)
error->all("Too big a problem to replicate with molecular atom style");
}
@ -365,7 +365,7 @@ void Replicate::command(int narg, char **arg)
bigint natoms;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);

View File

@ -353,7 +353,7 @@ bigint Thermo::lost_check()
bigint ntotal;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&ntotal,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&ntotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (ntotal == atom->natoms) return ntotal;
// if not checking or already warned, just return

View File

@ -223,7 +223,7 @@ void Velocity::create(double t_desired, int seed)
// error check
if (atom->natoms > MAXINT32)
if (atom->natoms > MAXSMALLINT)
error->all("Too big a problem to use velocity create loop all");
if (atom->tag_enable == 0)
error->all("Cannot use velocity create loop all unless atoms have IDs");

View File

@ -122,7 +122,7 @@ void WriteRestart::write(char *file)
// if unequal and thermo lostflag is "error", don't write restart file
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&natoms,1,MPI_UNSIGNED_LONG_LONG,MPI_SUM,world);
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (natoms != atom->natoms && output->thermo->lostflag == ERROR)
error->all("Atom count is inconsistent, cannot write restart file");