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

This commit is contained in:
sjplimp 2011-01-07 21:42:19 +00:00
parent beabb5e05a
commit 140cdf9485
52 changed files with 417 additions and 220 deletions

View File

@ -17,6 +17,7 @@
#include "stdlib.h"
#include "atom_vec_ellipsoid.h"
#include "lmptype.h"
#include "math_extra.h"
#include "atom.h"
#include "force.h"
@ -62,6 +63,8 @@ void AtomVecEllipsoid::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_colloid.h"
#include "lmptype.h"
#include "atom.h"
#include "force.h"
#include "domain.h"
@ -58,6 +59,8 @@ void AtomVecColloid::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_dipole.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -57,6 +58,8 @@ void AtomVecDipole::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -15,6 +15,7 @@
#include "stdlib.h"
#include "string.h"
#include "atom_vec_granular.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -80,6 +81,8 @@ void AtomVecGranular::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -484,18 +484,20 @@ void FixPour::pre_exchange()
}
}
// set tag # of new particles beyond all previous atoms
// reset global natoms
// set tag # of new particles beyond all previous atoms
// if global map exists, reset it now instead of waiting for comm
// since deleting atoms messes up ghosts
if (atom->tag_enable) {
atom->tag_extend();
if (nnear - nprevious > 0) {
atom->natoms += nnear - nprevious;
if (atom->map_style) {
atom->nghost = 0;
atom->map_init();
atom->map_set();
if (atom->tag_enable) {
atom->tag_extend();
if (atom->map_style) {
atom->nghost = 0;
atom->map_init();
atom->map_set();
}
}
}

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_angle.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -59,6 +60,8 @@ void AtomVecAngle::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_bond.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -59,6 +60,8 @@ void AtomVecBond::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_full.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -59,6 +60,8 @@ void AtomVecFull::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_molecular.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -59,6 +60,8 @@ void AtomVecMolecular::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -18,6 +18,7 @@
#include "float.h"
#include "stdlib.h"
#include "atom_vec_peri.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -60,7 +61,9 @@ void AtomVecPeri::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
type = atom->type = (int *)

View File

@ -300,12 +300,12 @@ void FixPeriNeigh::setup(int vflag)
if (screen) {
fprintf(screen,"Peridynamic bonds:\n");
fprintf(screen," total # of bonds = %d\n",nall);
fprintf(screen," bonds/atom = %g\n",nall/atom->natoms);
fprintf(screen," bonds/atom = %g\n",(double)nall/atom->natoms);
}
if (logfile) {
fprintf(logfile,"Peridynamic bonds:\n");
fprintf(logfile," total # of bonds = %d\n",nall);
fprintf(logfile," bonds/atom = %g\n",nall/atom->natoms);
fprintf(logfile," bonds/atom = %g\n",(double)nall/atom->natoms);
}
}
}

View File

@ -376,13 +376,14 @@ void PRD::command(int narg, char **arg)
neighbor->ndanger = ndanger;
if (me_universe == 0) {
char str[128];
sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n",
BIGINT_FORMAT);
if (universe->uscreen)
fprintf(universe->uscreen,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
fprintf(universe->uscreen,str,
timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms);
if (universe->ulogfile)
fprintf(universe->ulogfile,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
fprintf(universe->ulogfile,str,
timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms);
}

View File

@ -385,13 +385,14 @@ void TAD::command(int narg, char **arg)
neighbor->ndanger = ndanger;
if (me_universe == 0) {
char str[128];
sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n",
BIGINT_FORMAT);
if (universe->uscreen)
fprintf(universe->uscreen,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
fprintf(universe->uscreen,str,
timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms);
if (universe->ulogfile)
fprintf(universe->ulogfile,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
fprintf(universe->ulogfile,str,
timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms);
}

View File

@ -2315,9 +2315,11 @@ void FixSRD::parameterize()
// print SRD parameters
if (me == 0) {
char str[64];
sprintf(str," SRD/big particles = %s %s\n",BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) {
fprintf(screen,"SRD info:\n");
fprintf(screen," SRD/big particles = %lu %lu\n",nsrd,mbig);
fprintf(screen,str,nsrd,mbig);
fprintf(screen," big particle diameter max/min = %g %g\n",
maxbigdiam,minbigdiam);
fprintf(screen," SRD temperature & lamda = %g %g\n",
@ -2332,7 +2334,7 @@ void FixSRD::parameterize()
}
if (logfile) {
fprintf(logfile,"SRD info:\n");
fprintf(logfile," SRD/big particles = %lu %lu\n",nsrd,mbig);
fprintf(logfile,str,nsrd,mbig);
fprintf(logfile," big particle diameter max/min = %g %g\n",
maxbigdiam,minbigdiam);
fprintf(logfile," SRD temperature & lamda = %g %g\n",

View File

@ -44,7 +44,7 @@ elif (test $1 = 0) then
rm ../compute_temp_deform_eff.cpp
rm ../compute_temp_eff.cpp
rm ../compute_temp_region_eff.cpp
rm ../fix_langevin_eff.cpp ..
rm ../fix_langevin_eff.cpp
rm ../fix_nh_eff.cpp
rm ../fix_nve_eff.cpp
rm ../fix_nvt_eff.cpp
@ -61,7 +61,7 @@ elif (test $1 = 0) then
rm ../compute_temp_deform_eff.h
rm ../compute_temp_eff.h
rm ../compute_temp_region_eff.h
rm ../fix_langevin_eff.h ..
rm ../fix_langevin_eff.h
rm ../fix_nh_eff.h
rm ../fix_nve_eff.h
rm ../fix_nvt_eff.h

View File

@ -15,9 +15,9 @@
Contributing author: Andres Jaramillo-Botero (Caltech)
------------------------------------------------------------------------- */
#include "math.h"
#include "stdlib.h"
#include "atom_vec_electron.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -63,7 +63,9 @@ void AtomVecElectron::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
type = atom->type = (int *)
@ -102,7 +104,8 @@ void AtomVecElectron::grow_reset()
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
q = atom->q; eradius = atom->eradius; ervel = atom->ervel; erforce = atom->erforce;
q = atom->q;
eradius = atom->eradius; ervel = atom->ervel; erforce = atom->erforce;
}
/* ---------------------------------------------------------------------- */

View File

@ -268,10 +268,8 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) :
if (imd_trate < 1)
error->all("Illegal fix imd parameter. trate < 1.");
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");
bigint n = group->count(igroup);
if (n > MAXSMALLINT) error->all("Too many atoms for fix imd");
num_coords = static_cast<int> (n);
MPI_Comm_rank(world,&me);

View File

@ -67,11 +67,9 @@ DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
// allocate global array for atom coords
bigint n;
if (igroup == 0) n = static_cast<int> (atom->natoms);
else n = static_cast<int> (group->count(igroup));
bigint n = group->count(igroup);
if (n > MAXSMALLINT) error->all("Too many atoms for dump xtc");
natoms = n;
natoms = static_cast<int> (n);
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");
@ -136,8 +134,11 @@ void DumpXTC::openfile()
/* ---------------------------------------------------------------------- */
void DumpXTC::write_header(int n)
void DumpXTC::write_header(bigint nbig)
{
if (nbig > MAXSMALLINT) error->all("Too many atoms for dump xtc");
int n = nbig;
// all procs realloc coords if total count grew
if (n != natoms) {

View File

@ -48,7 +48,7 @@ class DumpXTC : public Dump {
void init_style();
int modify_param(int, char **);
void openfile();
void write_header(int);
void write_header(bigint);
int count();
void pack(int *);
void write_data(int, double *);

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_atomic.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -53,6 +54,8 @@ void AtomVecAtomic::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -13,6 +13,7 @@
#include "stdlib.h"
#include "atom_vec_charge.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -55,6 +56,8 @@ void AtomVecCharge::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");

View File

@ -14,6 +14,7 @@
#include "stdlib.h"
#include "string.h"
#include "atom_vec_hybrid.h"
#include "lmptype.h"
#include "atom.h"
#include "domain.h"
#include "modify.h"
@ -112,6 +113,8 @@ void AtomVecHybrid::grow(int n)
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT)
error->one("Per-processor system is too big");
// sub-styles perform all reallocation
// turn off nextra_grow so hybrid can do that once below

View File

@ -170,14 +170,18 @@ void CreateAtoms::command(int narg, char **arg)
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&atom->natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (atom->natoms < 0 || atom->natoms > MAXBIGINT)
error->all("Too many total atoms");
// print status
if (comm->me == 0) {
char str[32];
sprintf(str,"Created %s atoms\n",BIGINT_FORMAT);
if (screen)
fprintf(screen,"Created %lu atoms\n",atom->natoms-natoms_previous);
fprintf(screen,str,atom->natoms-natoms_previous);
if (logfile)
fprintf(logfile,"Created %lu atoms\n",atom->natoms-natoms_previous);
fprintf(logfile,str,atom->natoms-natoms_previous);
}
// reset simulation now that more atoms are defined

View File

@ -105,10 +105,11 @@ void DeleteAtoms::command(int narg, char **arg)
bigint ndelete = natoms_previous - atom->natoms;
if (comm->me == 0) {
if (screen) fprintf(screen,"Deleted %lu atoms, new total = %lu\n",
ndelete,atom->natoms);
if (logfile) fprintf(logfile,"Deleted %lu atoms, new total = %lu\n",
ndelete,atom->natoms);
char str[64];
sprintf(str,"Deleted %s atoms, new total = %s\n",
BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) fprintf(screen,str,ndelete,atom->natoms);
if (logfile) fprintf(logfile,str,ndelete,atom->natoms);
}
}

View File

@ -445,35 +445,35 @@ void DeleteBonds::command(int narg, char **arg)
}
if (comm->me == 0) {
if (screen) {
if (atom->avec->bonds_allow)
fprintf(screen," %lu total bonds, %lu turned on, %lu turned off\n",
atom->nbonds,bond_on,bond_off);
if (atom->avec->angles_allow)
fprintf(screen," %lu total angles, %lu turned on, %lu turned off\n",
atom->nangles,angle_on,angle_off);
if (atom->avec->dihedrals_allow)
fprintf(screen," %lu total dihedrals, %lu turned on, %lu turned off\n",
atom->ndihedrals,dihedral_on,dihedral_off);
if (atom->avec->impropers_allow)
fprintf(screen," %lu total impropers, %lu turned on, %lu turned off\n",
atom->nimpropers,improper_on,improper_off);
if (atom->avec->bonds_allow) {
char str[128];
sprintf(str," %s total bonds, %s turned on, %s turned off\n",
BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nbonds,bond_on,bond_off);
if (logfile) fprintf(logfile,str,atom->nbonds,bond_on,bond_off);
}
if (logfile) {
if (atom->avec->bonds_allow)
fprintf(logfile," %lu total bonds, %lu turned on, %lu turned off\n",
atom->nbonds,bond_on,bond_off);
if (atom->avec->angles_allow)
fprintf(logfile," %lu total angles, %lu turned on, %lu turned off\n",
atom->nangles,angle_on,angle_off);
if (atom->avec->dihedrals_allow)
fprintf(logfile," %lu total dihedrals, %lu turned on, "
"%lu turned off\n",
atom->ndihedrals,dihedral_on,dihedral_off);
if (atom->avec->impropers_allow)
fprintf(logfile," %lu total impropers, %lu turned on, "
"%lu turned off\n",
atom->nimpropers,improper_on,improper_off);
if (atom->avec->angles_allow) {
char str[128];
sprintf(str," %s total angles, %s turned on, %s turned off\n",
BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nangles,angle_on,angle_off);
if (logfile) fprintf(logfile,str,atom->nangles,angle_on,angle_off);
}
if (atom->avec->dihedrals_allow) {
char str[128];
sprintf(str," %s total dihedrals, %s turned on, %s turned off\n",
BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->ndihedrals,dihedral_on,dihedral_off);
if (logfile) fprintf(logfile,str,
atom->ndihedrals,dihedral_on,dihedral_off);
}
if (atom->avec->impropers_allow) {
char str[128];
sprintf(str," %s total impropers, %s turned on, %s turned off\n",
BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nimpropers,improper_on,improper_off);
if (logfile) fprintf(logfile,str,
atom->nimpropers,improper_on,improper_off);
}
}

View File

@ -215,9 +215,10 @@ void DisplaceAtoms::command(int narg, char **arg)
bigint nblocal = atom->nlocal;
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",
atom->natoms,natoms);
char fstr[64],str[128];
sprintf(fstr,"Lost atoms via displace_atoms: original %s current %s",
BIGINT_FORMAT,BIGINT_FORMAT);
sprintf(str,fstr,atom->natoms,natoms);
error->all(str);
}
}

View File

@ -381,9 +381,10 @@ void DisplaceBox::command(int narg, char **arg)
bigint nblocal = atom->nlocal;
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",
atom->natoms,natoms);
char fstr[64],str[128];
sprintf(fstr,"Lost atoms via displace_box: original %s current %s",
BIGINT_FORMAT,BIGINT_FORMAT);
sprintf(str,fstr,atom->natoms,natoms);
error->all(str);
}
}

View File

@ -253,6 +253,7 @@ void Dump::write()
// nme = # of dump lines this proc will contribute to dump
nme = count();
bigint bnme = nme;
// ntotal = total # of dump lines
// nmax = max # of dump lines on any proc
@ -260,21 +261,24 @@ void Dump::write()
int nmax;
if (multiproc) nmax = nme;
else {
MPI_Allreduce(&nme,&ntotal,1,MPI_INT,MPI_SUM,world);
MPI_Allreduce(&bnme,&ntotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
MPI_Allreduce(&nme,&nmax,1,MPI_INT,MPI_MAX,world);
}
// write timestep header
if (multiproc) write_header(nme);
if (multiproc) write_header(bnme);
else write_header(ntotal);
// this insures proc 0 can receive everyone's info
// insure proc 0 can receive everyone's info
// limit nmax*size_one to int since used as arg in MPI_Rsend() below
// pack my data into buf
// if sorting on IDs also request ID list from pack()
// sort buf as needed
if (nmax > maxbuf) {
if ((bigint) nmax * size_one > MAXSMALLINT)
error->all("Too much per-proc info for dump");
maxbuf = nmax;
memory->sfree(buf);
buf = (double *)

View File

@ -16,6 +16,7 @@
#include "stdio.h"
#include "pointers.h"
#include "lmptype.h"
namespace LAMMPS_NS {
@ -69,7 +70,7 @@ class Dump : protected Pointers {
double boxzlo,boxzhi;
double boxxy,boxxz,boxyz;
int ntotal; // # of per-atom lines in snapshot
bigint ntotal; // # of per-atom lines in snapshot
int reorderflag; // 1 if OK to reorder instead of sort
int ntotal_reorder; // # of atoms that must be in snapshot
int nme_reorder; // # of atoms I must own in snapshot
@ -91,7 +92,7 @@ class Dump : protected Pointers {
virtual void init_style() = 0;
virtual void openfile();
virtual int modify_param(int, char **) {return 0;}
virtual void write_header(int) = 0;
virtual void write_header(bigint) = 0;
virtual int count() = 0;
virtual void pack(int *) = 0;
virtual void write_data(int, double *) = 0;

View File

@ -123,7 +123,7 @@ int DumpAtom::modify_param(int narg, char **arg)
/* ---------------------------------------------------------------------- */
void DumpAtom::write_header(int ndump)
void DumpAtom::write_header(bigint ndump)
{
if (multiproc) (this->*header_choice)(ndump);
else if (me == 0) (this->*header_choice)(ndump);
@ -160,10 +160,10 @@ void DumpAtom::write_data(int n, double *mybuf)
/* ---------------------------------------------------------------------- */
void DumpAtom::header_binary(int ndump)
void DumpAtom::header_binary(bigint ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&ndump,sizeof(bigint),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
@ -180,10 +180,10 @@ void DumpAtom::header_binary(int ndump)
/* ---------------------------------------------------------------------- */
void DumpAtom::header_binary_triclinic(int ndump)
void DumpAtom::header_binary_triclinic(bigint ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&ndump,sizeof(bigint),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
@ -203,12 +203,12 @@ void DumpAtom::header_binary_triclinic(int ndump)
/* ---------------------------------------------------------------------- */
void DumpAtom::header_item(int ndump)
void DumpAtom::header_item(bigint ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,BIGINT_FORMAT_NL,ndump);
fprintf(fp,"ITEM: BOX BOUNDS\n");
fprintf(fp,"%g %g\n",boxxlo,boxxhi);
fprintf(fp,"%g %g\n",boxylo,boxyhi);
@ -218,12 +218,12 @@ void DumpAtom::header_item(int ndump)
/* ---------------------------------------------------------------------- */
void DumpAtom::header_item_triclinic(int ndump)
void DumpAtom::header_item_triclinic(bigint ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,BIGINT_FORMAT_NL,ndump);
fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n");
fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz);

View File

@ -36,17 +36,17 @@ class DumpAtom : public Dump {
void init_style();
int modify_param(int, char **);
void write_header(int);
void write_header(bigint);
int count();
void pack(int *);
void write_data(int, double *);
typedef void (DumpAtom::*FnPtrHeader)(int);
typedef void (DumpAtom::*FnPtrHeader)(bigint);
FnPtrHeader header_choice; // ptr to write header functions
void header_binary(int);
void header_binary_triclinic(int);
void header_item(int);
void header_item_triclinic(int);
void header_binary(bigint);
void header_binary_triclinic(bigint);
void header_item(bigint);
void header_item_triclinic(bigint);
typedef void (DumpAtom::*FnPtrPack)(int *);
FnPtrPack pack_choice; // ptr to pack functions

View File

@ -184,10 +184,12 @@ void DumpCFG::init_style()
/* ---------------------------------------------------------------------- */
void DumpCFG::write_header(int n)
void DumpCFG::write_header(bigint n)
{
if (me == 0 || multiproc) {
fprintf(fp,"Number of particles = %d\n", n);
char str[64];
sprintf(str,"Number of particles = %s\n",BIGINT_FORMAT);
fprintf(fp,str,n);
fprintf(fp,"A = 1.0 Angstrom (basic length-scale)\n");
fprintf(fp,"H0(1,1) = %g A\n",domain->xprd);
fprintf(fp,"H0(1,2) = 0 A \n");

View File

@ -38,7 +38,7 @@ class DumpCFG : public DumpCustom {
double **rbuf; // buf of data lines for data lines rearrangement
void init_style();
void write_header(int);
void write_header(bigint);
void write_data(int, double *);
int modify_param2(int, char **);

View File

@ -236,7 +236,7 @@ void DumpCustom::init_style()
/* ---------------------------------------------------------------------- */
void DumpCustom::write_header(int ndump)
void DumpCustom::write_header(bigint ndump)
{
if (multiproc) (this->*header_choice)(ndump);
else if (me == 0) (this->*header_choice)(ndump);
@ -244,10 +244,10 @@ void DumpCustom::write_header(int ndump)
/* ---------------------------------------------------------------------- */
void DumpCustom::header_binary(int ndump)
void DumpCustom::header_binary(bigint ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&ndump,sizeof(bigint),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
@ -264,10 +264,10 @@ void DumpCustom::header_binary(int ndump)
/* ---------------------------------------------------------------------- */
void DumpCustom::header_binary_triclinic(int ndump)
void DumpCustom::header_binary_triclinic(bigint ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&ndump,sizeof(bigint),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
@ -287,12 +287,12 @@ void DumpCustom::header_binary_triclinic(int ndump)
/* ---------------------------------------------------------------------- */
void DumpCustom::header_item(int ndump)
void DumpCustom::header_item(bigint ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,BIGINT_FORMAT_NL,ndump);
fprintf(fp,"ITEM: BOX BOUNDS\n");
fprintf(fp,"%g %g\n",boxxlo,boxxhi);
fprintf(fp,"%g %g\n",boxylo,boxyhi);
@ -302,12 +302,12 @@ void DumpCustom::header_item(int ndump)
/* ---------------------------------------------------------------------- */
void DumpCustom::header_item_triclinic(int ndump)
void DumpCustom::header_item_triclinic(bigint ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,BIGINT_FORMAT_NL,ndump);
fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n");
fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz);

View File

@ -70,7 +70,7 @@ class DumpCustom : public Dump {
// private methods
virtual void init_style();
virtual void write_header(int);
virtual void write_header(bigint);
int count();
void pack(int *);
virtual void write_data(int, double *);
@ -83,12 +83,12 @@ class DumpCustom : public Dump {
int modify_param(int, char **);
virtual int modify_param2(int, char **) {return 0;}
typedef void (DumpCustom::*FnPtrHeader)(int);
typedef void (DumpCustom::*FnPtrHeader)(bigint);
FnPtrHeader header_choice; // ptr to write header functions
void header_binary(int);
void header_binary_triclinic(int);
void header_item(int);
void header_item_triclinic(int);
void header_binary(bigint);
void header_binary_triclinic(bigint);
void header_item(bigint);
void header_item_triclinic(bigint);
typedef void (DumpCustom::*FnPtrData)(int, double *);
FnPtrData write_choice; // ptr to write data functions

View File

@ -68,11 +68,9 @@ DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
// allocate global array for atom coords
bigint n;
if (igroup == 0) n = static_cast<int> (atom->natoms);
else n = static_cast<int> (group->count(igroup));
bigint n = group->count(igroup);
if (n > MAXSMALLINT) error->all("Too many atoms for dump dcd");
natoms = n;
natoms = static_cast<int> (n);
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");
xf = &coords[0*natoms];
@ -124,7 +122,7 @@ void DumpDCD::openfile()
/* ---------------------------------------------------------------------- */
void DumpDCD::write_header(int n)
void DumpDCD::write_header(bigint n)
{
if (n != natoms) error->all("Dump dcd of non-matching # of atoms");

View File

@ -40,7 +40,7 @@ class DumpDCD : public Dump {
void init_style();
void openfile();
void write_header(int);
void write_header(bigint);
int count();
void pack(int *);
void write_data(int, double *);

View File

@ -187,13 +187,13 @@ int DumpLocal::modify_param(int narg, char **arg)
/* ---------------------------------------------------------------------- */
void DumpLocal::write_header(int ndump)
void DumpLocal::write_header(bigint ndump)
{
if (me == 0) {
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF %s\n",label);
fprintf(fp,"%d\n",ndump);
fprintf(fp,BIGINT_FORMAT_NL,ndump);
fprintf(fp,"ITEM: %s %s\n",label,columns);
}
}

View File

@ -55,7 +55,7 @@ class DumpLocal : public Dump {
void init_style();
int modify_param(int, char **);
void write_header(int);
void write_header(bigint);
int count();
void pack(int *);
void write_data(int, double *);

View File

@ -58,10 +58,10 @@ void DumpXYZ::init_style()
/* ---------------------------------------------------------------------- */
void DumpXYZ::write_header(int n)
void DumpXYZ::write_header(bigint n)
{
if (me == 0) {
fprintf(fp,"%d\n",n);
fprintf(fp,BIGINT_FORMAT_NL,n);
fprintf(fp,"Atoms\n");
}
}

View File

@ -31,7 +31,7 @@ class DumpXYZ : public Dump {
private:
void init_style();
void write_header(int);
void write_header(bigint);
int count();
void pack(int *);
void write_data(int, double *);

View File

@ -89,14 +89,11 @@ void Finish::end(int flag)
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen)
fprintf(screen,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
time_loop,nprocs,update->nsteps,natoms);
if (logfile)
fprintf(logfile,
"Loop time of %g on %d procs for %d steps with %lu atoms\n",
time_loop,nprocs,update->nsteps,natoms);
char str[128];
sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n",
BIGINT_FORMAT);
if (screen) fprintf(screen,str,time_loop,nprocs,update->nsteps,natoms);
if (logfile) fprintf(logfile,str,time_loop,nprocs,update->nsteps,natoms);
}
if (time_loop == 0.0) time_loop = 1.0;

View File

@ -322,22 +322,23 @@ void FixDeposit::pre_exchange()
// warn if not successful b/c too many attempts or no proc owned particle
if (comm->me == 0)
if (success == 0)
error->warning("Particle deposition was unsuccessful",0);
if (!success && comm->me == 0)
error->warning("Particle deposition was unsuccessful",0);
// set tag # of new particle beyond all previous atoms
// reset global natoms
// set tag # of new particle beyond all previous atoms
// if global map exists, reset it now instead of waiting for comm
// since deleting atoms messes up ghosts
if (success && atom->tag_enable) {
atom->tag_extend();
if (success) {
atom->natoms += 1;
if (atom->map_style) {
atom->nghost = 0;
atom->map_init();
atom->map_set();
if (atom->tag_enable) {
atom->tag_extend();
if (atom->map_style) {
atom->nghost = 0;
atom->map_init();
atom->map_set();
}
}
}

View File

@ -403,18 +403,17 @@ void FixOrientFCC::post_force(int vflag)
MPI_Allreduce(&maxcount,&max,1,MPI_INT,MPI_MAX,world);
if (me == 0) {
if (screen) {
fprintf(screen,"orient step %d: %lu atoms have %d neighbors\n",
update->ntimestep,atom->natoms,total);
char str[64];
sprintf(str,"orient step %%d: %s atoms have %%d neighbors\n",
BIGINT_FORMAT);
if (screen) fprintf(screen,str,update->ntimestep,atom->natoms,total);
if (logfile) fprintf(logfile,str,update->ntimestep,atom->natoms,total);
if (screen)
fprintf(screen," neighs: min = %d, max = %d, ave = %g\n",
min,max,ave);
}
if (logfile) {
fprintf(logfile,"orient step %d: %lu atoms have %d neighbors\n",
update->ntimestep,atom->natoms,total);
if (logfile)
fprintf(logfile," neighs: min = %d, max = %d, ave = %g\n",
min,max,ave);
}
}
}
}

View File

@ -241,15 +241,22 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
}
}
// check datatype sizes
// check datatype settings in lmptype.h
if (sizeof(bigint) != 8)
error->all("No support for 8-byte unsigned integers");
if (sizeof(smallint) != sizeof(int))
error->all("Smallint setting in lmptype.h is invalid");
if (sizeof(tagint) < sizeof(smallint))
error->all("Tagint setting in lmptype.h is invalid");
if (sizeof(bigint) < sizeof(tagint))
error->all("Bigint setting in lmptype.h is invalid");
int mpisize;
MPI_Type_size(MPI_LMP_TAGINT,&mpisize);
if (mpisize != sizeof(tagint))
error->all("MPI_LMP_TAGINT and tagint in lmptype.h are not compatible");
MPI_Type_size(MPI_LMP_BIGINT,&mpisize);
if (mpisize != 8)
error->all("MPI_LMP_BIGINT is not 8-byte data type");
if (mpisize != sizeof(bigint))
error->all("MPI_LMP_BIGINT and bigint in lmptype.h are not compatible");
// allocate input class now that MPI is fully setup

View File

@ -15,11 +15,12 @@
// 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)
// bigint = variables for total system (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
// NOTE: 64-bit tagint is not yet supported
// bigint can be 32-bit or 64-bit int, must be >= tagint
// MAXSMALLINT = max value of a smallint
// MAXTAGINT = max value of a tagint
@ -27,6 +28,8 @@
// MPI_LMP_TAGINT = MPI data type corresponding to tagint
// MPI_LMP_BIGINT = MPI data type corresponding to bigint
// NOTE: you may need to set MPI_LMP_BIGINT to MPI_LONG
// if your machine/MPI does not support "long long" data types
#ifndef LMP_LMPTYPE_H
#define LMP_LMPTYPE_H
@ -35,7 +38,8 @@
namespace LAMMPS_NS {
// default settings: 4-byte smallint, 4-byte tagint, 8-byte bigint
// default settings
// 32-bit smallint and tagint, 64-bit bigint
typedef int smallint;
typedef int tagint;
@ -48,6 +52,54 @@ typedef int64_t bigint;
#define MPI_LMP_TAGINT MPI_INT
#define MPI_LMP_BIGINT MPI_LONG_LONG
#define TAGINT_FORMAT "%d"
#define BIGINT_FORMAT "%ld"
#define TAGINT_FORMAT_NL "%d\n"
#define BIGINT_FORMAT_NL "%ld\n"
// for molecular problems that exceed 2 billion (2^31) atoms
// 32-bit smallint, 64-bit tagint and bigint
// NOTE: 64-bit tagint is not yet supported
/*
typedef int smallint;
typedef int64_t tagint;
typedef int64_t bigint;
#define MAXSMALLINT 0x7FFFFFFF
#define MAXTAGINT 0x7FFFFFFFFFFFFFFFL
#define MAXBIGINT 0x7FFFFFFFFFFFFFFFL
#define MPI_LMP_TAGINT MPI_LONG_LONG
#define MPI_LMP_BIGINT MPI_LONG_LONG
#define TAGINT_FORMAT "%ld"
#define BIGINT_FORMAT "%ld"
#define TAGINT_FORMAT_NL "%ld\n"
#define BIGINT_FORMAT_NL "%ld\n"
*/
// for machines that don't support 64-bit ints
// 32-bit smallint and tagint and bigint
/*
typedef int smallint;
typedef int tagint;
typedef int bigint;
#define MAXSMALLINT 0x7FFFFFFF
#define MAXTAGINT 0x7FFFFFFF
#define MAXBIGINT 0x7FFFFFFF
#define MPI_LMP_TAGINT MPI_INT
#define MPI_LMP_BIGINT MPI_INT
#define TAGINT_FORMAT "%d"
#define BIGINT_FORMAT "%d"
#define TAGINT_FORMAT_NL "%d\n"
#define BIGINT_FORMAT_NL "%d\n"
*/
}
#endif

View File

@ -336,11 +336,14 @@ void ReadData::header(int flag)
// search line for header keyword and set corresponding variable
if (strstr(line,"atoms")) sscanf(line,"%lu",&atom->natoms);
else if (strstr(line,"bonds")) sscanf(line,"%lu",&atom->nbonds);
else if (strstr(line,"angles")) sscanf(line,"%lu",&atom->nangles);
else if (strstr(line,"dihedrals")) sscanf(line,"%lu",&atom->ndihedrals);
else if (strstr(line,"impropers")) sscanf(line,"%lu",&atom->nimpropers);
if (strstr(line,"atoms")) sscanf(line,BIGINT_FORMAT,&atom->natoms);
else if (strstr(line,"bonds")) sscanf(line,BIGINT_FORMAT,&atom->nbonds);
else if (strstr(line,"angles")) sscanf(line,BIGINT_FORMAT,&atom->nangles);
else if (strstr(line,"dihedrals")) sscanf(line,BIGINT_FORMAT,
&atom->ndihedrals);
else if (strstr(line,"impropers")) sscanf(line,BIGINT_FORMAT,
&atom->nimpropers);
else if (strstr(line,"atom types")) sscanf(line,"%d",&atom->ntypes);
else if (strstr(line,"bond types")) sscanf(line,"%d",&atom->nbondtypes);
@ -365,6 +368,17 @@ void ReadData::header(int flag)
} else break;
}
// error check on total system size
if (atom->natoms < 0 || atom->natoms > MAXBIGINT ||
atom->nbonds < 0 || atom->nbonds > MAXBIGINT ||
atom->nangles < 0 || atom->nangles > MAXBIGINT ||
atom->ndihedrals < 0 || atom->ndihedrals > MAXBIGINT ||
atom->nimpropers < 0 || atom->nimpropers > MAXBIGINT) {
if (flag == 0) error->one("System in data file is too big");
else error->all("System in data file is too big");
}
// check that exiting string is a valid section keyword
parse_keyword(1,flag);
@ -438,8 +452,10 @@ void ReadData::atoms()
MPI_Allreduce(&tmp,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);
if (logfile) fprintf(logfile," %lu atoms\n",natoms);
char str[32];
sprintf(str," %s atoms\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,natoms);
if (logfile) fprintf(logfile,str,natoms);
}
if (natoms != atom->natoms) error->all("Did not assign all atoms correctly");
@ -529,8 +545,10 @@ void ReadData::velocities()
}
if (me == 0) {
if (screen) fprintf(screen," %lu velocities\n",natoms);
if (logfile) fprintf(logfile," %lu velocities\n",natoms);
char str[32];
sprintf(str," %s velocities\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,natoms);
if (logfile) fprintf(logfile,str,natoms);
}
}
@ -573,8 +591,10 @@ void ReadData::bonds()
if (!force->newton_bond) factor = 2;
if (me == 0) {
if (screen) fprintf(screen," %lu bonds\n",sum/factor);
if (logfile) fprintf(logfile," %lu bonds\n",sum/factor);
char str[32];
sprintf(str," %s bonds\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,sum/factor);
if (logfile) fprintf(logfile,str,sum/factor);
}
if (sum != factor*atom->nbonds) error->all("Bonds assigned incorrectly");
}
@ -618,8 +638,10 @@ void ReadData::angles()
if (!force->newton_bond) factor = 3;
if (me == 0) {
if (screen) fprintf(screen," %lu angles\n",sum/factor);
if (logfile) fprintf(logfile," %lu angles\n",sum/factor);
char str[32];
sprintf(str," %s angles\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,sum/factor);
if (logfile) fprintf(logfile,str,sum/factor);
}
if (sum != factor*atom->nangles) error->all("Angles assigned incorrectly");
}
@ -663,8 +685,10 @@ void ReadData::dihedrals()
if (!force->newton_bond) factor = 4;
if (me == 0) {
if (screen) fprintf(screen," %lu dihedrals\n",sum/factor);
if (logfile) fprintf(logfile," %lu dihedrals\n",sum/factor);
char str[32];
sprintf(str," %s dihedrals\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,sum/factor);
if (logfile) fprintf(logfile,str,sum/factor);
}
if (sum != factor*atom->ndihedrals)
error->all("Dihedrals assigned incorrectly");
@ -709,8 +733,10 @@ void ReadData::impropers()
if (!force->newton_bond) factor = 4;
if (me == 0) {
if (screen) fprintf(screen," %lu impropers\n",sum/factor);
if (logfile) fprintf(logfile," %lu impropers\n",sum/factor);
char str[32];
sprintf(str," %s impropers\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,sum/factor);
if (logfile) fprintf(logfile,str,sum/factor);
}
if (sum != factor*atom->nimpropers)
error->all("Impropers assigned incorrectly");

View File

@ -43,7 +43,8 @@ using namespace LAMMPS_NS;
// same as write_restart.cpp
enum{VERSION,UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
enum{VERSION,SMALLINT,TAGINT,BIGINT,
UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
NEWTON_PAIR,NEWTON_BOND,XPERIODIC,YPERIODIC,ZPERIODIC,
BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21,
ATOM_STYLE,NATOMS,NTYPES,
@ -296,28 +297,38 @@ void ReadRestart::command(int narg, char **arg)
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);
if (logfile) fprintf(logfile," %lu atoms\n",natoms);
char str[32];
sprintf(str," %s atoms\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,natoms);
if (logfile) fprintf(logfile,str,natoms);
}
if (natoms != atom->natoms) error->all("Did not assign all atoms correctly");
if (me == 0) {
if (atom->nbonds) {
if (screen) fprintf(screen," %lu bonds\n",atom->nbonds);
if (logfile) fprintf(logfile," %lu bonds\n",atom->nbonds);
char str[32];
sprintf(str," %s bonds\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nbonds);
if (logfile) fprintf(logfile,str,atom->nbonds);
}
if (atom->nangles) {
if (screen) fprintf(screen," %lu angles\n",atom->nangles);
if (logfile) fprintf(logfile," %lu angles\n",atom->nangles);
char str[32];
sprintf(str," %s angles\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nangles);
if (logfile) fprintf(logfile,str,atom->nangles);
}
if (atom->ndihedrals) {
if (screen) fprintf(screen," %lu dihedrals\n",atom->ndihedrals);
if (logfile) fprintf(logfile," %lu dihedrals\n",atom->ndihedrals);
char str[32];
sprintf(str," %s dihedrals\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->ndihedrals);
if (logfile) fprintf(logfile,str,atom->ndihedrals);
}
if (atom->nimpropers) {
if (screen) fprintf(screen," %lu impropers\n",atom->nimpropers);
if (logfile) fprintf(logfile," %lu impropers\n",atom->nimpropers);
char str[32];
sprintf(str," %s impropers\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nimpropers);
if (logfile) fprintf(logfile,str,atom->nimpropers);
}
}
@ -455,6 +466,21 @@ void ReadRestart::header()
version,universe->version);
}
delete [] version;
// check lmptype.h sizes, error if different
} else if (flag == SMALLINT) {
int size = read_int();
if (size != sizeof(smallint))
error->all("Smallint setting in lmptype.h is not compatible");
} else if (flag == TAGINT) {
int size = read_int();
if (size != sizeof(tagint))
error->all("Tagint setting in lmptype.h is not compatible");
} else if (flag == BIGINT) {
int size = read_int();
if (size != sizeof(bigint))
error->all("Bigint setting in lmptype.h is not compatible");
// reset unit_style only if different
// so that timestep,neighbor-skin are not changed
@ -465,7 +491,9 @@ void ReadRestart::header()
delete [] style;
} else if (flag == NTIMESTEP) {
update->ntimestep = read_int();
// placeholder until ntimestep is 8-bytes
bigint ntimestep = read_bigint();
update->ntimestep = static_cast<int> (ntimestep);
// set dimension from restart file

View File

@ -124,23 +124,25 @@ void Replicate::command(int narg, char **arg)
}
atom->create_avec(old->atom_style,nstyles,keywords);
// check that new problem size will not be too large
// if N > 2^31, turn off tags for existing and new atoms
// if molecular, N/Nbonds/etc cannot be > 2^31 else tags/counts invalid
double rep = nrep;
if (rep*old->natoms > MAXSMALLINT) atom->tag_enable = 0;
// check that new system will not be too large
// if molecular and N > MAXTAGINT, error
// if atomic and new N > MAXTAGINT, turn off tags for existing and new atoms
// new system cannot exceed MAXBIGINT
if (atom->molecular && (nrep*old->natoms < 0 || nrep*old->natoms > MAXTAGINT))
error->all("Replicated molecular system atom IDs are too big");
if (nrep*old->natoms < 0 || nrep*old->natoms > MAXTAGINT)
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 > 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");
}
if (nrep*old->natoms < 0 || nrep*old->natoms > MAXBIGINT ||
nrep*old->nbonds < 0 || nrep*old->nbonds > MAXBIGINT ||
nrep*old->nangles < 0 || nrep*old->nangles > MAXBIGINT ||
nrep*old->ndihedrals < 0 || nrep*old->ndihedrals > MAXBIGINT ||
nrep*old->nimpropers < 0 || nrep*old->nimpropers > MAXBIGINT)
error->all("Replicated system is too big");
// assign atom and topology counts in new class from old one
@ -368,8 +370,10 @@ void Replicate::command(int narg, char **arg)
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (me == 0) {
if (screen) fprintf(screen," %lu atoms\n",natoms);
if (logfile) fprintf(logfile," %lu atoms\n",natoms);
char str[32];
sprintf(str," %s atoms\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,natoms);
if (logfile) fprintf(logfile,str,natoms);
}
if (natoms != atom->natoms)
@ -377,20 +381,28 @@ void Replicate::command(int narg, char **arg)
if (me == 0) {
if (atom->nbonds) {
if (screen) fprintf(screen," %lu bonds\n",atom->nbonds);
if (logfile) fprintf(logfile," %lu bonds\n",atom->nbonds);
char str[32];
sprintf(str," %s bonds\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nbonds);
if (logfile) fprintf(logfile,str,atom->nbonds);
}
if (atom->nangles) {
if (screen) fprintf(screen," %lu angles\n",atom->nangles);
if (logfile) fprintf(logfile," %lu angles\n",atom->nangles);
char str[32];
sprintf(str," %s angles\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nangles);
if (logfile) fprintf(logfile,str,atom->nangles);
}
if (atom->ndihedrals) {
if (screen) fprintf(screen," %lu dihedrals\n",atom->ndihedrals);
if (logfile) fprintf(logfile," %lu dihedrals\n",atom->ndihedrals);
char str[32];
sprintf(str," %s dihedrals\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->ndihedrals);
if (logfile) fprintf(logfile,str,atom->ndihedrals);
}
if (atom->nimpropers) {
if (screen) fprintf(screen," %lu impropers\n",atom->nimpropers);
if (logfile) fprintf(logfile," %lu impropers\n",atom->nimpropers);
char str[32];
sprintf(str," %s impropers\n",BIGINT_FORMAT);
if (screen) fprintf(screen,str,atom->nimpropers);
if (logfile) fprintf(logfile,str,atom->nimpropers);
}
}

View File

@ -139,8 +139,13 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
format_float_multi_def = (char *) "%14.4f";
format_int_one_def = (char *) "%8d";
format_int_multi_def = (char *) "%14d";
format_bigint_one_def = (char *) "%8lu";
format_bigint_multi_def = (char *) "%14lu";
if (sizeof(bigint) == 8) {
format_bigint_one_def = (char *) "%8ld";
format_bigint_multi_def = (char *) "%14ld";
} else if (sizeof(bigint) == 4) {
format_bigint_one_def = (char *) "%8d";
format_bigint_multi_def = (char *) "%14d";
}
format_float_user = NULL;
format_int_user = NULL;
format_bigint_user = NULL;
@ -354,6 +359,7 @@ bigint Thermo::lost_check()
bigint ntotal;
bigint nblocal = atom->nlocal;
MPI_Allreduce(&nblocal,&ntotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (ntotal < 0 || ntotal > MAXBIGINT) error->all("Too many total atoms");
if (ntotal == atom->natoms) return ntotal;
// if not checking or already warned, just return
@ -364,15 +370,19 @@ bigint Thermo::lost_check()
// error message
if (lostflag == ERROR) {
char str[128];
sprintf(str,"Lost atoms: original %lu current %lu",atom->natoms,ntotal);
char fstr[64],str[64];
sprintf(fstr,
"Lost atoms: original %s current %s",BIGINT_FORMAT,BIGINT_FORMAT);
sprintf(str,fstr,atom->natoms,ntotal);
error->all(str);
}
// warning message
char str[128];
sprintf(str,"Lost atoms: original %lu current %lu",atom->natoms,ntotal);
char fstr[64],str[64];
sprintf(fstr,
"Lost atoms: original %s current %s",BIGINT_FORMAT,BIGINT_FORMAT);
sprintf(str,fstr,atom->natoms,ntotal);
if (me == 0) error->warning(str,0);
lostbefore = 1;
return ntotal;
@ -505,7 +515,10 @@ void Thermo::modify_params(int narg, char **arg)
if (ptr == NULL)
error->all("Thermo_modify int format does not contain d character");
*ptr = '\0';
sprintf(format_bigint_user,"%s%s%s",format_int_user,"lu",ptr+1);
if (sizeof(bigint) == 8)
sprintf(format_bigint_user,"%s%s%s",format_int_user,"ld",ptr+1);
else if (sizeof(bigint) == 4)
sprintf(format_bigint_user,"%s%s%s",format_int_user,"d",ptr+1);
*ptr = 'd';
} else if (strcmp(arg[iarg+1],"float") == 0) {
if (format_float_user) delete [] format_float_user;

View File

@ -68,7 +68,7 @@ class Thermo : protected Pointers {
// data used by routines that compute single values
int ivalue; // integer value to print
double dvalue; // dvalue = double value to print
double dvalue; // double value to print
bigint bivalue; // big integer value to print
int ifield; // which field in thermo output is being computed
int *field2index; // which compute,fix,variable calcs this field

View File

@ -42,7 +42,8 @@ using namespace LAMMPS_NS;
// same as read_restart.cpp and tools/restart2data.cpp
enum{VERSION,UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
enum{VERSION,SMALLINT,TAGINT,BIGINT,
UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
NEWTON_PAIR,NEWTON_BOND,XPERIODIC,YPERIODIC,ZPERIODIC,
BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21,
ATOM_STYLE,NATOMS,NTYPES,
@ -295,8 +296,13 @@ void WriteRestart::write(char *file)
void WriteRestart::header()
{
write_char(VERSION,universe->version);
write_int(SMALLINT,sizeof(smallint));
write_int(TAGINT,sizeof(tagint));
write_int(BIGINT,sizeof(bigint));
write_char(UNITS,update->unit_style);
write_int(NTIMESTEP,update->ntimestep);
// placeholder until ntimestep is 8-byte
bigint ntimestep = update->ntimestep;
write_bigint(NTIMESTEP,ntimestep);
write_int(DIMENSION,domain->dimension);
write_int(NPROCS,nprocs);
write_int(PROCGRID_0,comm->procgrid[0]);