git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5502 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -35,9 +35,15 @@
|
|||||||
|
|
||||||
#define MAX_GROUP 32
|
#define MAX_GROUP 32
|
||||||
|
|
||||||
|
// these should match settings in src/lmptype.h
|
||||||
|
|
||||||
|
typedef int tagint;
|
||||||
|
typedef int64_t bigint;
|
||||||
|
|
||||||
// same as write_restart.cpp
|
// 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,
|
NEWTON_PAIR,NEWTON_BOND,XPERIODIC,YPERIODIC,ZPERIODIC,
|
||||||
BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21,
|
BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21,
|
||||||
ATOM_STYLE,NATOMS,NTYPES,
|
ATOM_STYLE,NATOMS,NTYPES,
|
||||||
@ -65,7 +71,8 @@ class Data {
|
|||||||
// global settings
|
// global settings
|
||||||
|
|
||||||
char *version;
|
char *version;
|
||||||
int ntimestep;
|
int size_smallint,size_tagint,size_bigint;
|
||||||
|
bigint ntimestep;
|
||||||
int nprocs;
|
int nprocs;
|
||||||
char *unit_style;
|
char *unit_style;
|
||||||
int dimension;
|
int dimension;
|
||||||
@ -79,8 +86,8 @@ class Data {
|
|||||||
int style_ellipsoid,style_full,style_granular;
|
int style_ellipsoid,style_full,style_granular;
|
||||||
int style_hybrid,style_molecular,style_peri;
|
int style_hybrid,style_molecular,style_peri;
|
||||||
|
|
||||||
uint64_t natoms;
|
bigint natoms;
|
||||||
uint64_t nbonds,nangles,ndihedrals,nimpropers;
|
bigint nbonds,nangles,ndihedrals,nimpropers;
|
||||||
int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
|
int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
|
||||||
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
|
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
|
||||||
int triclinic;
|
int triclinic;
|
||||||
@ -183,7 +190,8 @@ class Data {
|
|||||||
double *mass,*shape,*dipole;
|
double *mass,*shape,*dipole;
|
||||||
double *x,*y,*z,*vx,*vy,*vz;
|
double *x,*y,*z,*vx,*vy,*vz;
|
||||||
double *omegax,*omegay,*omegaz;
|
double *omegax,*omegay,*omegaz;
|
||||||
int *tag,*type,*mask,*image;
|
tagint *tag;
|
||||||
|
int *type,*mask,*image;
|
||||||
int *molecule;
|
int *molecule;
|
||||||
double *q,*mux,*muy,*muz,*radius,*density,*vfrac,*rmass;
|
double *q,*mux,*muy,*muz,*radius,*density,*vfrac,*rmass;
|
||||||
double *s0,*x0x,*x0y,*x0z;
|
double *s0,*x0x,*x0y,*x0z;
|
||||||
@ -287,7 +295,7 @@ int atom_peri(double *, Data &, int);
|
|||||||
int read_int(FILE *fp);
|
int read_int(FILE *fp);
|
||||||
double read_double(FILE *fp);
|
double read_double(FILE *fp);
|
||||||
char *read_char(FILE *fp);
|
char *read_char(FILE *fp);
|
||||||
uint64_t read_uint64(FILE *fp);
|
bigint read_bigint(FILE *fp);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// main program
|
// main program
|
||||||
@ -332,6 +340,14 @@ int main (int argc, char **argv)
|
|||||||
Data data;
|
Data data;
|
||||||
|
|
||||||
header(fp,data);
|
header(fp,data);
|
||||||
|
if (data.size_smallint != sizeof(int) ||
|
||||||
|
data.size_tagint != sizeof(tagint) ||
|
||||||
|
data.size_bigint != sizeof(bigint)) {
|
||||||
|
printf("ERROR: Data type sizes in restart file "
|
||||||
|
"are incompatible with restart2data.cpp\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
groups(fp);
|
groups(fp);
|
||||||
type_arrays(fp,data);
|
type_arrays(fp,data);
|
||||||
force_fields(fp,data);
|
force_fields(fp,data);
|
||||||
@ -434,8 +450,11 @@ void header(FILE *fp, Data &data)
|
|||||||
printf(" restart2data version = %s\n",version);
|
printf(" restart2data version = %s\n",version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (flag == SMALLINT) data.size_smallint = read_int(fp);
|
||||||
|
else if (flag == TAGINT) data.size_tagint = read_int(fp);
|
||||||
|
else if (flag == BIGINT) data.size_bigint = read_int(fp);
|
||||||
else if (flag == UNITS) data.unit_style = read_char(fp);
|
else if (flag == UNITS) data.unit_style = read_char(fp);
|
||||||
else if (flag == NTIMESTEP) data.ntimestep = read_int(fp);
|
else if (flag == NTIMESTEP) data.ntimestep = read_bigint(fp);
|
||||||
else if (flag == DIMENSION) data.dimension = read_int(fp);
|
else if (flag == DIMENSION) data.dimension = read_int(fp);
|
||||||
else if (flag == NPROCS) data.nprocs = read_int(fp);
|
else if (flag == NPROCS) data.nprocs = read_int(fp);
|
||||||
else if (flag == PROCGRID_0) data.px = read_int(fp);
|
else if (flag == PROCGRID_0) data.px = read_int(fp);
|
||||||
@ -478,18 +497,18 @@ void header(FILE *fp, Data &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (flag == NATOMS) data.natoms = read_uint64(fp);
|
else if (flag == NATOMS) data.natoms = read_bigint(fp);
|
||||||
else if (flag == NTYPES) data.ntypes = read_int(fp);
|
else if (flag == NTYPES) data.ntypes = read_int(fp);
|
||||||
else if (flag == NBONDS) data.nbonds = read_uint64(fp);
|
else if (flag == NBONDS) data.nbonds = read_bigint(fp);
|
||||||
else if (flag == NBONDTYPES) data.nbondtypes = read_int(fp);
|
else if (flag == NBONDTYPES) data.nbondtypes = read_int(fp);
|
||||||
else if (flag == BOND_PER_ATOM) data.bond_per_atom = read_int(fp);
|
else if (flag == BOND_PER_ATOM) data.bond_per_atom = read_int(fp);
|
||||||
else if (flag == NANGLES) data.nangles = read_uint64(fp);
|
else if (flag == NANGLES) data.nangles = read_bigint(fp);
|
||||||
else if (flag == NANGLETYPES) data.nangletypes = read_int(fp);
|
else if (flag == NANGLETYPES) data.nangletypes = read_int(fp);
|
||||||
else if (flag == ANGLE_PER_ATOM) data.angle_per_atom = read_int(fp);
|
else if (flag == ANGLE_PER_ATOM) data.angle_per_atom = read_int(fp);
|
||||||
else if (flag == NDIHEDRALS) data.ndihedrals = read_uint64(fp);
|
else if (flag == NDIHEDRALS) data.ndihedrals = read_bigint(fp);
|
||||||
else if (flag == NDIHEDRALTYPES) data.ndihedraltypes = read_int(fp);
|
else if (flag == NDIHEDRALTYPES) data.ndihedraltypes = read_int(fp);
|
||||||
else if (flag == DIHEDRAL_PER_ATOM) data.dihedral_per_atom = read_int(fp);
|
else if (flag == DIHEDRAL_PER_ATOM) data.dihedral_per_atom = read_int(fp);
|
||||||
else if (flag == NIMPROPERS) data.nimpropers = read_uint64(fp);
|
else if (flag == NIMPROPERS) data.nimpropers = read_bigint(fp);
|
||||||
else if (flag == NIMPROPERTYPES) data.nimpropertypes = read_int(fp);
|
else if (flag == NIMPROPERTYPES) data.nimpropertypes = read_int(fp);
|
||||||
else if (flag == IMPROPER_PER_ATOM) data.improper_per_atom = read_int(fp);
|
else if (flag == IMPROPER_PER_ATOM) data.improper_per_atom = read_int(fp);
|
||||||
else if (flag == BOXLO_0) data.xlo = read_double(fp);
|
else if (flag == BOXLO_0) data.xlo = read_double(fp);
|
||||||
@ -2599,11 +2618,19 @@ void Data::stats()
|
|||||||
printf(" Restart file version = %s\n",version);
|
printf(" Restart file version = %s\n",version);
|
||||||
printf(" Ntimestep = %d\n",ntimestep);
|
printf(" Ntimestep = %d\n",ntimestep);
|
||||||
printf(" Nprocs = %d\n",nprocs);
|
printf(" Nprocs = %d\n",nprocs);
|
||||||
printf(" Natoms = %lu\n",natoms);
|
if (size_bigint == 8) {
|
||||||
printf(" Nbonds = %lu\n",nbonds);
|
printf(" Natoms = %ld\n",natoms);
|
||||||
printf(" Nangles = %lu\n",nangles);
|
printf(" Nbonds = %ld\n",nbonds);
|
||||||
printf(" Ndihedrals = %lu\n",ndihedrals);
|
printf(" Nangles = %ld\n",nangles);
|
||||||
printf(" Nimpropers = %lu\n",nimpropers);
|
printf(" Ndihedrals = %ld\n",ndihedrals);
|
||||||
|
printf(" Nimpropers = %ld\n",nimpropers);
|
||||||
|
} else if (size_bigint == 4) {
|
||||||
|
printf(" Natoms = %d\n",natoms);
|
||||||
|
printf(" Nbonds = %d\n",nbonds);
|
||||||
|
printf(" Nangles = %d\n",nangles);
|
||||||
|
printf(" Ndihedrals = %d\n",ndihedrals);
|
||||||
|
printf(" Nimpropers = %d\n",nimpropers);
|
||||||
|
}
|
||||||
printf(" Unit style = %s\n",unit_style);
|
printf(" Unit style = %s\n",unit_style);
|
||||||
printf(" Atom style = %s\n",atom_style);
|
printf(" Atom style = %s\n",atom_style);
|
||||||
printf(" Pair style = %s\n",pair_style);
|
printf(" Pair style = %s\n",pair_style);
|
||||||
@ -2626,16 +2653,30 @@ void Data::stats()
|
|||||||
|
|
||||||
void Data::write(FILE *fp, FILE *fp2)
|
void Data::write(FILE *fp, FILE *fp2)
|
||||||
{
|
{
|
||||||
fprintf(fp,"LAMMPS data file from restart file: timestep = %d, procs = %d\n",
|
if (size_bigint == 8)
|
||||||
ntimestep,nprocs);
|
fprintf(fp,
|
||||||
|
"LAMMPS data file from restart file: timestep = %ld, procs = %d\n",
|
||||||
|
ntimestep,nprocs);
|
||||||
|
else
|
||||||
|
fprintf(fp,
|
||||||
|
"LAMMPS data file from restart file: timestep = %d, procs = %d\n",
|
||||||
|
ntimestep,nprocs);
|
||||||
|
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
|
|
||||||
fprintf(fp,"%lu atoms\n",natoms);
|
if (size_bigint == 8) {
|
||||||
if (nbonds) fprintf(fp,"%lu bonds\n",nbonds);
|
fprintf(fp,"%ld atoms\n",natoms);
|
||||||
if (nangles) fprintf(fp,"%lu angles\n",nangles);
|
if (nbonds) fprintf(fp,"%ld bonds\n",nbonds);
|
||||||
if (ndihedrals) fprintf(fp,"%lu dihedrals\n",ndihedrals);
|
if (nangles) fprintf(fp,"%ld angles\n",nangles);
|
||||||
if (nimpropers) fprintf(fp,"%lu impropers\n",nimpropers);
|
if (ndihedrals) fprintf(fp,"%ld dihedrals\n",ndihedrals);
|
||||||
|
if (nimpropers) fprintf(fp,"%ld impropers\n",nimpropers);
|
||||||
|
} else if (size_bigint == 4) {
|
||||||
|
fprintf(fp,"%d atoms\n",natoms);
|
||||||
|
if (nbonds) fprintf(fp,"%d bonds\n",nbonds);
|
||||||
|
if (nangles) fprintf(fp,"%d angles\n",nangles);
|
||||||
|
if (ndihedrals) fprintf(fp,"%d dihedrals\n",ndihedrals);
|
||||||
|
if (nimpropers) fprintf(fp,"%d impropers\n",nimpropers);
|
||||||
|
} else
|
||||||
|
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
|
|
||||||
@ -3484,10 +3525,9 @@ char *read_char(FILE *fp)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t read_uint64(FILE *fp)
|
bigint read_bigint(FILE *fp)
|
||||||
{
|
{
|
||||||
uint64_t value;
|
bigint value;
|
||||||
fread(&value,sizeof(uint64_t),1,fp);
|
fread(&value,sizeof(bigint),1,fp);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user