git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13983 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -369,7 +369,7 @@ int Atom::next_prime(int n)
|
|||||||
if (nprime % 2 == 0) nprime++;
|
if (nprime % 2 == 0) nprime++;
|
||||||
int root = static_cast<int> (sqrt(1.0*n)) + 2;
|
int root = static_cast<int> (sqrt(1.0*n)) + 2;
|
||||||
|
|
||||||
while (nprime <= MAXSMALLINT) {
|
while (nprime < MAXSMALLINT) {
|
||||||
for (factor = 3; factor < root; factor++)
|
for (factor = 3; factor < root; factor++)
|
||||||
if (nprime % factor == 0) break;
|
if (nprime % factor == 0) break;
|
||||||
if (factor == root) return nprime;
|
if (factor == root) return nprime;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void AtomVecAtomic::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
|
|||||||
@ -117,7 +117,7 @@ void AtomVecBody::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
@ -158,7 +158,7 @@ void AtomVecBody::grow_reset()
|
|||||||
void AtomVecBody::grow_bonus()
|
void AtomVecBody::grow_bonus()
|
||||||
{
|
{
|
||||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||||
if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT)
|
if (nmax_bonus < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void AtomVecCharge::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
|
|||||||
@ -72,7 +72,7 @@ void AtomVecEllipsoid::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
@ -113,7 +113,7 @@ void AtomVecEllipsoid::grow_reset()
|
|||||||
void AtomVecEllipsoid::grow_bonus()
|
void AtomVecEllipsoid::grow_bonus()
|
||||||
{
|
{
|
||||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||||
if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT)
|
if (nmax_bonus < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||||
|
|||||||
@ -144,7 +144,7 @@ void AtomVecHybrid::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
// sub-styles perform all reallocation
|
// sub-styles perform all reallocation
|
||||||
|
|||||||
@ -80,7 +80,7 @@ void AtomVecLine::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
@ -123,7 +123,7 @@ void AtomVecLine::grow_reset()
|
|||||||
void AtomVecLine::grow_bonus()
|
void AtomVecLine::grow_bonus()
|
||||||
{
|
{
|
||||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||||
if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT)
|
if (nmax_bonus < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||||
|
|||||||
@ -84,7 +84,7 @@ void AtomVecSphere::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
|
|||||||
@ -81,7 +81,7 @@ void AtomVecTri::grow(int n)
|
|||||||
if (n == 0) grow_nmax();
|
if (n == 0) grow_nmax();
|
||||||
else nmax = n;
|
else nmax = n;
|
||||||
atom->nmax = nmax;
|
atom->nmax = nmax;
|
||||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
if (nmax < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
tag = memory->grow(atom->tag,nmax,"atom:tag");
|
||||||
@ -124,7 +124,7 @@ void AtomVecTri::grow_reset()
|
|||||||
void AtomVecTri::grow_bonus()
|
void AtomVecTri::grow_bonus()
|
||||||
{
|
{
|
||||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||||
if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT)
|
if (nmax_bonus < 0)
|
||||||
error->one(FLERR,"Per-processor system is too big");
|
error->one(FLERR,"Per-processor system is too big");
|
||||||
|
|
||||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||||
|
|||||||
@ -659,6 +659,7 @@ int Balance::shift()
|
|||||||
if (bdim[idim] == X) split = comm->xsplit;
|
if (bdim[idim] == X) split = comm->xsplit;
|
||||||
else if (bdim[idim] == Y) split = comm->ysplit;
|
else if (bdim[idim] == Y) split = comm->ysplit;
|
||||||
else if (bdim[idim] == Z) split = comm->zsplit;
|
else if (bdim[idim] == Z) split = comm->zsplit;
|
||||||
|
else continue;
|
||||||
|
|
||||||
// intial count and sum
|
// intial count and sum
|
||||||
|
|
||||||
|
|||||||
@ -414,6 +414,8 @@ void DeleteAtoms::delete_porosity(int narg, char **arg)
|
|||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
||||||
if (random->uniform() <= porosity_fraction) dlist[i] = 1;
|
if (random->uniform() <= porosity_fraction) dlist[i] = 1;
|
||||||
|
|
||||||
|
delete random;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -160,6 +160,7 @@ Dump::~Dump()
|
|||||||
} else {
|
} else {
|
||||||
if (filewriter) fclose(fp);
|
if (filewriter) fclose(fp);
|
||||||
}
|
}
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,10 +414,11 @@ void Dump::write()
|
|||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
if (filewriter && fp) pclose(fp);
|
if (filewriter && fp != NULL) pclose(fp);
|
||||||
} else {
|
} else {
|
||||||
if (filewriter && fp) fclose(fp);
|
if (filewriter && fp != NULL) fclose(fp);
|
||||||
}
|
}
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -681,7 +681,7 @@ void DumpImage::create_image()
|
|||||||
color = colorelement[itype];
|
color = colorelement[itype];
|
||||||
} else if (acolor == ATTRIBUTE) {
|
} else if (acolor == ATTRIBUTE) {
|
||||||
color = image->map_value2color(0,buf[m]);
|
color = image->map_value2color(0,buf[m]);
|
||||||
}
|
} else color = image->color2rgb("white");
|
||||||
|
|
||||||
if (adiam == NUMERIC) {
|
if (adiam == NUMERIC) {
|
||||||
diameter = adiamvalue;
|
diameter = adiamvalue;
|
||||||
@ -784,6 +784,9 @@ void DumpImage::create_image()
|
|||||||
} else if (acolor == ATTRIBUTE) {
|
} else if (acolor == ATTRIBUTE) {
|
||||||
color1 = image->map_value2color(0,bufcopy[atom1][0]);
|
color1 = image->map_value2color(0,bufcopy[atom1][0]);
|
||||||
color2 = image->map_value2color(0,bufcopy[atom2][0]);
|
color2 = image->map_value2color(0,bufcopy[atom2][0]);
|
||||||
|
} else {
|
||||||
|
color1 = image->color2rgb("white");
|
||||||
|
color2 = image->color2rgb("white");
|
||||||
}
|
}
|
||||||
} else if (bcolor == TYPE) {
|
} else if (bcolor == TYPE) {
|
||||||
itype = btype;
|
itype = btype;
|
||||||
|
|||||||
@ -823,7 +823,7 @@ void Finish::stats(int n, double *data,
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void mpi_timings(const char *label, Timer *t, enum Timer::ttype tt,
|
void mpi_timings(const char *label, Timer *t, enum Timer::ttype tt,
|
||||||
MPI_Comm world, const int nprocs, const int nthreads,
|
MPI_Comm world, const int nprocs, const int nthreads,
|
||||||
const int me, double time_loop, FILE *scr, FILE *log)
|
const int me, double time_loop, FILE *scr, FILE *log)
|
||||||
{
|
{
|
||||||
@ -876,7 +876,7 @@ static void mpi_timings(const char *label, Timer *t, enum Timer::ttype tt,
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef LMP_USER_OMP
|
#ifdef LMP_USER_OMP
|
||||||
static void omp_times(FixOMP *fix, const char *label, enum Timer::ttype which,
|
void omp_times(FixOMP *fix, const char *label, enum Timer::ttype which,
|
||||||
const int nthreads,FILE *scr, FILE *log)
|
const int nthreads,FILE *scr, FILE *log)
|
||||||
{
|
{
|
||||||
const char fmt[] = "%-8s|%- 12.5g|%- 12.5g|%- 12.5g|%6.1f |%6.2f\n";
|
const char fmt[] = "%-8s|%- 12.5g|%- 12.5g|%- 12.5g|%6.1f |%6.2f\n";
|
||||||
|
|||||||
@ -380,6 +380,8 @@ void FixAveAtom::end_of_step()
|
|||||||
nvalid = ntimestep+peratom_freq - (nrepeat-1)*nevery;
|
nvalid = ntimestep+peratom_freq - (nrepeat-1)*nevery;
|
||||||
modify->addstep_compute(nvalid);
|
modify->addstep_compute(nvalid);
|
||||||
|
|
||||||
|
if (array == NULL) return;
|
||||||
|
|
||||||
// average the final result for the Nfreq timestep
|
// average the final result for the Nfreq timestep
|
||||||
|
|
||||||
double repeat = nrepeat;
|
double repeat = nrepeat;
|
||||||
|
|||||||
@ -325,6 +325,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// print file comment lines
|
// print file comment lines
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (title1) fprintf(fp,"%s\n",title1);
|
if (title1) fprintf(fp,"%s\n",title1);
|
||||||
else fprintf(fp,"# Chunk-averaged data for fix %s and group %s\n",
|
else fprintf(fp,"# Chunk-averaged data for fix %s and group %s\n",
|
||||||
id,arg[1]);
|
id,arg[1]);
|
||||||
@ -350,6 +351,9 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
for (int i = 0; i < nvalues; i++) fprintf(fp," %s",arg[7+i]);
|
for (int i = 0; i < nvalues; i++) fprintf(fp," %s",arg[7+i]);
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
}
|
}
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing file header");
|
||||||
|
|
||||||
filepos = ftell(fp);
|
filepos = ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,6 +882,7 @@ void FixAveChunk::end_of_step()
|
|||||||
// output result to file
|
// output result to file
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||||
double count = 0.0;
|
double count = 0.0;
|
||||||
for (m = 0; m < nchunk; m++) count += count_total[m];
|
for (m = 0; m < nchunk; m++) count += count_total[m];
|
||||||
@ -959,11 +964,14 @@ void FixAveChunk::end_of_step()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing averaged chunk data");
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
long fileend = ftell(fp);
|
long fileend = ftell(fp);
|
||||||
ftruncate(fileno(fp),fileend);
|
if (fileend > 0) ftruncate(fileno(fp),fileend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -232,6 +232,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||||||
// print file comment lines
|
// print file comment lines
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (title1) fprintf(fp,"%s\n",title1);
|
if (title1) fprintf(fp,"%s\n",title1);
|
||||||
else fprintf(fp,"# Time-correlated data for fix %s\n",id);
|
else fprintf(fp,"# Time-correlated data for fix %s\n",id);
|
||||||
if (title2) fprintf(fp,"%s\n",title2);
|
if (title2) fprintf(fp,"%s\n",title2);
|
||||||
@ -264,6 +265,9 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
}
|
}
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing file header");
|
||||||
|
|
||||||
filepos = ftell(fp);
|
filepos = ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,6 +483,7 @@ void FixAveCorrelate::end_of_step()
|
|||||||
// output result to file
|
// output result to file
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||||
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat);
|
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat);
|
||||||
for (i = 0; i < nrepeat; i++) {
|
for (i = 0; i < nrepeat; i++) {
|
||||||
@ -491,10 +496,14 @@ void FixAveCorrelate::end_of_step()
|
|||||||
fprintf(fp," 0.0");
|
fprintf(fp," 0.0");
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
}
|
}
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing out correlation data");
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
long fileend = ftell(fp);
|
long fileend = ftell(fp);
|
||||||
ftruncate(fileno(fp),fileend);
|
if (fileend > 0) ftruncate(fileno(fp),fileend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -436,6 +436,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// print file comment lines
|
// print file comment lines
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (title1) fprintf(fp,"%s\n",title1);
|
if (title1) fprintf(fp,"%s\n",title1);
|
||||||
else fprintf(fp,"# Histogrammed data for fix %s\n",id);
|
else fprintf(fp,"# Histogrammed data for fix %s\n",id);
|
||||||
if (title2) fprintf(fp,"%s\n",title2);
|
if (title2) fprintf(fp,"%s\n",title2);
|
||||||
@ -443,6 +444,10 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
"Total-counts Missing-counts Min-value Max-value\n");
|
"Total-counts Missing-counts Min-value Max-value\n");
|
||||||
if (title3) fprintf(fp,"%s\n",title3);
|
if (title3) fprintf(fp,"%s\n",title3);
|
||||||
else fprintf(fp,"# Bin Coord Count Count/Total\n");
|
else fprintf(fp,"# Bin Coord Count Count/Total\n");
|
||||||
|
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing file header");
|
||||||
|
|
||||||
filepos = ftell(fp);
|
filepos = ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,6 +817,7 @@ void FixAveHisto::end_of_step()
|
|||||||
// output result to file
|
// output result to file
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||||
fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins,
|
fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins,
|
||||||
stats_total[0],stats_total[1],stats_total[2],stats_total[3]);
|
stats_total[0],stats_total[1],stats_total[2],stats_total[3]);
|
||||||
@ -822,10 +828,14 @@ void FixAveHisto::end_of_step()
|
|||||||
else
|
else
|
||||||
for (i = 0; i < nbins; i++)
|
for (i = 0; i < nbins; i++)
|
||||||
fprintf(fp,"%d %g %g %g\n",i+1,coord[i],0.0,0.0);
|
fprintf(fp,"%d %g %g %g\n",i+1,coord[i],0.0,0.0);
|
||||||
|
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing out histogram data");
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
long fileend = ftell(fp);
|
long fileend = ftell(fp);
|
||||||
ftruncate(fileno(fp),fileend);
|
if (fileend > 0) ftruncate(fileno(fp),fileend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -274,11 +274,11 @@ void FixAveHistoWeight::end_of_step()
|
|||||||
|
|
||||||
// atom attributes
|
// atom attributes
|
||||||
|
|
||||||
if (which[i] == X)
|
if (which[i] == X && weights != NULL)
|
||||||
bin_atoms_weights(&atom->x[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->x[0][j],3,weights,stride);
|
||||||
else if (which[i] == V)
|
else if (which[i] == V && weights != NULL)
|
||||||
bin_atoms_weights(&atom->v[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->v[0][j],3,weights,stride);
|
||||||
else if (which[i] == F)
|
else if (which[i] == F && weights != NULL)
|
||||||
bin_atoms_weights(&atom->f[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->f[0][j],3,weights,stride);
|
||||||
|
|
||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
@ -479,6 +479,7 @@ void FixAveHistoWeight::end_of_step()
|
|||||||
// output result to file
|
// output result to file
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||||
fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins,
|
fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins,
|
||||||
stats_total[0],stats_total[1],stats_total[2],stats_total[3]);
|
stats_total[0],stats_total[1],stats_total[2],stats_total[3]);
|
||||||
@ -489,10 +490,14 @@ void FixAveHistoWeight::end_of_step()
|
|||||||
else
|
else
|
||||||
for (i = 0; i < nbins; i++)
|
for (i = 0; i < nbins; i++)
|
||||||
fprintf(fp,"%d %g %g %g\n",i+1,coord[i],0.0,0.0);
|
fprintf(fp,"%d %g %g %g\n",i+1,coord[i],0.0,0.0);
|
||||||
|
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing out histogram data");
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
long fileend = ftell(fp);
|
long fileend = ftell(fp);
|
||||||
ftruncate(fileno(fp),fileend);
|
if (fileend > 0) ftruncate(fileno(fp),fileend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,6 +294,7 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// since array args may have been expanded to multiple vectors
|
// since array args may have been expanded to multiple vectors
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (title1) fprintf(fp,"%s\n",title1);
|
if (title1) fprintf(fp,"%s\n",title1);
|
||||||
else fprintf(fp,"# Time-averaged data for fix %s\n",id);
|
else fprintf(fp,"# Time-averaged data for fix %s\n",id);
|
||||||
if (title2) fprintf(fp,"%s\n",title2);
|
if (title2) fprintf(fp,"%s\n",title2);
|
||||||
@ -313,6 +314,9 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
}
|
}
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
}
|
}
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing file header");
|
||||||
|
|
||||||
filepos = ftell(fp);
|
filepos = ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,14 +696,19 @@ void FixAveTime::invoke_scalar(bigint ntimestep)
|
|||||||
// output result to file
|
// output result to file
|
||||||
|
|
||||||
if (fp && me == 0) {
|
if (fp && me == 0) {
|
||||||
|
clearerr(fp);
|
||||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||||
fprintf(fp,BIGINT_FORMAT,ntimestep);
|
fprintf(fp,BIGINT_FORMAT,ntimestep);
|
||||||
for (i = 0; i < nvalues; i++) fprintf(fp,format,vector_total[i]/norm);
|
for (i = 0; i < nvalues; i++) fprintf(fp,format,vector_total[i]/norm);
|
||||||
fprintf(fp,"\n");
|
fprintf(fp,"\n");
|
||||||
|
if (ferror(fp))
|
||||||
|
error->one(FLERR,"Error writing out time averaged data");
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
long fileend = ftell(fp);
|
long fileend = ftell(fp);
|
||||||
ftruncate(fileno(fp),fileend);
|
if (fileend > 0) ftruncate(fileno(fp),fileend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -301,6 +301,7 @@ void Group::assign(int narg, char **arg)
|
|||||||
tagint start,stop,delta;
|
tagint start,stop,delta;
|
||||||
|
|
||||||
for (int iarg = 2; iarg < narg; iarg++) {
|
for (int iarg = 2; iarg < narg; iarg++) {
|
||||||
|
delta = 1;
|
||||||
if (strchr(arg[iarg],':')) {
|
if (strchr(arg[iarg],':')) {
|
||||||
ptr = strtok(arg[iarg],":");
|
ptr = strtok(arg[iarg],":");
|
||||||
start = force->tnumeric(FLERR,ptr);
|
start = force->tnumeric(FLERR,ptr);
|
||||||
@ -308,11 +309,11 @@ void Group::assign(int narg, char **arg)
|
|||||||
stop = force->tnumeric(FLERR,ptr);
|
stop = force->tnumeric(FLERR,ptr);
|
||||||
ptr = strtok(NULL,":");
|
ptr = strtok(NULL,":");
|
||||||
if (ptr) delta = force->tnumeric(FLERR,ptr);
|
if (ptr) delta = force->tnumeric(FLERR,ptr);
|
||||||
else delta = 1;
|
|
||||||
} else {
|
} else {
|
||||||
start = stop = force->tnumeric(FLERR,arg[iarg]);
|
start = stop = force->tnumeric(FLERR,arg[iarg]);
|
||||||
delta = 1;
|
|
||||||
}
|
}
|
||||||
|
if (delta < 1)
|
||||||
|
error->all(FLERR,"Illegal range increment value");
|
||||||
|
|
||||||
// add to group if attribute matches value or sequence
|
// add to group if attribute matches value or sequence
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "lammps.h"
|
#include "lammps.h"
|
||||||
|
#include "universe.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
@ -79,6 +80,16 @@ void lammps_close(void *ptr)
|
|||||||
delete lmp;
|
delete lmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
get the numerical representation of the current LAMMPS version
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int lammps_version(void *ptr)
|
||||||
|
{
|
||||||
|
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||||
|
return atoi(lmp->universe->num_ver);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
process an input script in filename str
|
process an input script in filename str
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -27,6 +27,7 @@ extern "C" {
|
|||||||
void lammps_open(int, char **, MPI_Comm, void **);
|
void lammps_open(int, char **, MPI_Comm, void **);
|
||||||
void lammps_open_no_mpi(int, char **, void **);
|
void lammps_open_no_mpi(int, char **, void **);
|
||||||
void lammps_close(void *);
|
void lammps_close(void *);
|
||||||
|
int lammps_version(void *);
|
||||||
void lammps_file(void *, char *);
|
void lammps_file(void *, char *);
|
||||||
char *lammps_command(void *, char *);
|
char *lammps_command(void *, char *);
|
||||||
void lammps_free(void *);
|
void lammps_free(void *);
|
||||||
|
|||||||
@ -409,11 +409,13 @@ void Molecule::read(int flag)
|
|||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error check
|
// error checks
|
||||||
|
|
||||||
if (flag == 0) {
|
if (natoms < 1) error->all(FLERR,"No or invalid atom count in molecule file");
|
||||||
if (natoms == 0) error->all(FLERR,"No atom count in molecule file");
|
if (nbonds < 0) error->all(FLERR,"Invalid bond count in molecule file");
|
||||||
}
|
if (nangles < 0) error->all(FLERR,"Invalid angle count in molecule file");
|
||||||
|
if (ndihedrals < 0) error->all(FLERR,"Invalid dihedral count in molecule file");
|
||||||
|
if (nimpropers < 0) error->all(FLERR,"Invalid improper count in molecule file");
|
||||||
|
|
||||||
// count = vector for tallying bonds,angles,etc per atom
|
// count = vector for tallying bonds,angles,etc per atom
|
||||||
|
|
||||||
|
|||||||
@ -270,6 +270,7 @@ void RCB::compute(int dimension, int n, double **x, double *wt,
|
|||||||
valuemin = lo[dim];
|
valuemin = lo[dim];
|
||||||
valuemax = hi[dim];
|
valuemax = hi[dim];
|
||||||
first_iteration = 1;
|
first_iteration = 1;
|
||||||
|
indexlo = indexhi = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,7 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
buffer = new char[CHUNK*MAXLINE];
|
buffer = new char[CHUNK*MAXLINE];
|
||||||
narg = maxarg = 0;
|
narg = maxarg = 0;
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
|
fp = NULL;
|
||||||
|
|
||||||
// customize for new sections
|
// customize for new sections
|
||||||
// pointers to atom styles that store extra info
|
// pointers to atom styles that store extra info
|
||||||
@ -618,6 +619,7 @@ void ReadData::command(int narg, char **arg)
|
|||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (compressed) pclose(fp);
|
if (compressed) pclose(fp);
|
||||||
else fclose(fp);
|
else fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// done if this was 2nd pass
|
// done if this was 2nd pass
|
||||||
|
|||||||
@ -187,7 +187,10 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
|
|
||||||
// close header file if in multiproc mode
|
// close header file if in multiproc mode
|
||||||
|
|
||||||
if (multiproc && me == 0) fclose(fp);
|
if (multiproc && me == 0) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// read per-proc info
|
// read per-proc info
|
||||||
|
|
||||||
@ -263,7 +266,10 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me == 0) fclose(fp);
|
if (me == 0) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// input of multiple native files with procs <= files
|
// input of multiple native files with procs <= files
|
||||||
@ -311,6 +317,7 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] procfile;
|
delete [] procfile;
|
||||||
@ -412,7 +419,10 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filereader) fclose(fp);
|
if (filereader && fp != NULL) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
MPI_Comm_free(&clustercomm);
|
MPI_Comm_free(&clustercomm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +651,7 @@ void ReadRestart::file_search(char *infile, char *outfile)
|
|||||||
|
|
||||||
void ReadRestart::header(int incompatible)
|
void ReadRestart::header(int incompatible)
|
||||||
{
|
{
|
||||||
int xperiodic,yperiodic,zperiodic;
|
int xperiodic(-1),yperiodic(-1),zperiodic(-1);
|
||||||
|
|
||||||
// read flags and fields until flag = -1
|
// read flags and fields until flag = -1
|
||||||
|
|
||||||
@ -783,6 +793,9 @@ void ReadRestart::header(int incompatible)
|
|||||||
domain->boundary[2][0] = boundary[2][0];
|
domain->boundary[2][0] = boundary[2][0];
|
||||||
domain->boundary[2][1] = boundary[2][1];
|
domain->boundary[2][1] = boundary[2][1];
|
||||||
|
|
||||||
|
if (xperiodic < 0 || yperiodic < 0 || zperiodic < 0)
|
||||||
|
error->all(FLERR,"Illegal or unset periodicity in restart");
|
||||||
|
|
||||||
domain->periodicity[0] = domain->xperiodic = xperiodic;
|
domain->periodicity[0] = domain->xperiodic = xperiodic;
|
||||||
domain->periodicity[1] = domain->yperiodic = yperiodic;
|
domain->periodicity[1] = domain->yperiodic = yperiodic;
|
||||||
domain->periodicity[2] = domain->zperiodic = zperiodic;
|
domain->periodicity[2] = domain->zperiodic = zperiodic;
|
||||||
@ -1089,9 +1102,7 @@ void ReadRestart::magic_string()
|
|||||||
|
|
||||||
void ReadRestart::endian()
|
void ReadRestart::endian()
|
||||||
{
|
{
|
||||||
int endian;
|
int endian = read_int();
|
||||||
if (me == 0) fread(&endian,sizeof(int),1,fp);
|
|
||||||
MPI_Bcast(&endian,1,MPI_INT,0,world);
|
|
||||||
if (endian == ENDIAN) return;
|
if (endian == ENDIAN) return;
|
||||||
if (endian == ENDIANSWAP)
|
if (endian == ENDIANSWAP)
|
||||||
error->all(FLERR,"Restart file byte ordering is swapped");
|
error->all(FLERR,"Restart file byte ordering is swapped");
|
||||||
@ -1103,9 +1114,7 @@ void ReadRestart::endian()
|
|||||||
|
|
||||||
int ReadRestart::version_numeric()
|
int ReadRestart::version_numeric()
|
||||||
{
|
{
|
||||||
int vn;
|
int vn = read_int();
|
||||||
if (me == 0) fread(&vn,sizeof(int),1,fp);
|
|
||||||
MPI_Bcast(&vn,1,MPI_INT,0,world);
|
|
||||||
if (vn != VERSION_NUMERIC) return 1;
|
if (vn != VERSION_NUMERIC) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1117,7 +1126,8 @@ int ReadRestart::version_numeric()
|
|||||||
int ReadRestart::read_int()
|
int ReadRestart::read_int()
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
if (me == 0) fread(&value,sizeof(int),1,fp);
|
if ((me == 0) && (fread(&value,sizeof(int),1,fp) < sizeof(int)))
|
||||||
|
value = -1;
|
||||||
MPI_Bcast(&value,1,MPI_INT,0,world);
|
MPI_Bcast(&value,1,MPI_INT,0,world);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -1129,7 +1139,8 @@ int ReadRestart::read_int()
|
|||||||
bigint ReadRestart::read_bigint()
|
bigint ReadRestart::read_bigint()
|
||||||
{
|
{
|
||||||
bigint value;
|
bigint value;
|
||||||
if (me == 0) fread(&value,sizeof(bigint),1,fp);
|
if ((me == 0) && (fread(&value,sizeof(bigint),1,fp) < sizeof(bigint)))
|
||||||
|
value = -1;
|
||||||
MPI_Bcast(&value,1,MPI_LMP_BIGINT,0,world);
|
MPI_Bcast(&value,1,MPI_LMP_BIGINT,0,world);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -1141,7 +1152,8 @@ bigint ReadRestart::read_bigint()
|
|||||||
double ReadRestart::read_double()
|
double ReadRestart::read_double()
|
||||||
{
|
{
|
||||||
double value;
|
double value;
|
||||||
if (me == 0) fread(&value,sizeof(double),1,fp);
|
if ((me == 0) && (fread(&value,sizeof(double),1,fp) < sizeof(double)))
|
||||||
|
value = 0.0;
|
||||||
MPI_Bcast(&value,1,MPI_DOUBLE,0,world);
|
MPI_Bcast(&value,1,MPI_DOUBLE,0,world);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -1153,9 +1165,8 @@ double ReadRestart::read_double()
|
|||||||
|
|
||||||
char *ReadRestart::read_string()
|
char *ReadRestart::read_string()
|
||||||
{
|
{
|
||||||
int n;
|
int n = read_int();
|
||||||
if (me == 0) fread(&n,sizeof(int),1,fp);
|
if (n < 0) error->all(FLERR,"Illegal size string or corrupt restart");
|
||||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
|
||||||
char *value = new char[n];
|
char *value = new char[n];
|
||||||
if (me == 0) fread(value,sizeof(char),n,fp);
|
if (me == 0) fread(value,sizeof(char),n,fp);
|
||||||
MPI_Bcast(value,n,MPI_CHAR,0,world);
|
MPI_Bcast(value,n,MPI_CHAR,0,world);
|
||||||
@ -1164,22 +1175,22 @@ char *ReadRestart::read_string()
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
read vector of N ints from restart file and bcast them
|
read vector of N ints from restart file and bcast them
|
||||||
do not bcast them, caller does that if required
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ReadRestart::read_int_vec(int n, int *vec)
|
void ReadRestart::read_int_vec(int n, int *vec)
|
||||||
{
|
{
|
||||||
|
if (n < 0) error->all(FLERR,"Illegal size integer vector read requested");
|
||||||
if (me == 0) fread(vec,sizeof(int),n,fp);
|
if (me == 0) fread(vec,sizeof(int),n,fp);
|
||||||
MPI_Bcast(vec,n,MPI_INT,0,world);
|
MPI_Bcast(vec,n,MPI_INT,0,world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
read vector of N doubles from restart file and bcast them
|
read vector of N doubles from restart file and bcast them
|
||||||
do not bcast them, caller does that if required
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ReadRestart::read_double_vec(int n, double *vec)
|
void ReadRestart::read_double_vec(int n, double *vec)
|
||||||
{
|
{
|
||||||
|
if (n < 0) error->all(FLERR,"Illegal size double vector read requested");
|
||||||
if (me == 0) fread(vec,sizeof(double),n,fp);
|
if (me == 0) fread(vec,sizeof(double),n,fp);
|
||||||
MPI_Bcast(vec,n,MPI_DOUBLE,0,world);
|
MPI_Bcast(vec,n,MPI_DOUBLE,0,world);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,10 +141,16 @@ bigint ReaderNative::read_header(double box[3][3], int &triclinic,
|
|||||||
nwords = atom->count_words(labelline);
|
nwords = atom->count_words(labelline);
|
||||||
char **labels = new char*[nwords];
|
char **labels = new char*[nwords];
|
||||||
labels[0] = strtok(labelline," \t\n\r\f");
|
labels[0] = strtok(labelline," \t\n\r\f");
|
||||||
if (labels[0] == NULL) return 1;
|
if (labels[0] == NULL) {
|
||||||
|
delete[] labels;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
for (int m = 1; m < nwords; m++) {
|
for (int m = 1; m < nwords; m++) {
|
||||||
labels[m] = strtok(NULL," \t\n\r\f");
|
labels[m] = strtok(NULL," \t\n\r\f");
|
||||||
if (labels[m] == NULL) return 1;
|
if (labels[m] == NULL) {
|
||||||
|
delete[] labels;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// match each field with a column of per-atom data
|
// match each field with a column of per-atom data
|
||||||
|
|||||||
@ -118,13 +118,13 @@ void Run::command(int narg, char **arg)
|
|||||||
// error check
|
// error check
|
||||||
|
|
||||||
if (startflag) {
|
if (startflag) {
|
||||||
if (start < 0 || start > MAXBIGINT)
|
if (start < 0)
|
||||||
error->all(FLERR,"Invalid run command start/stop value");
|
error->all(FLERR,"Invalid run command start/stop value");
|
||||||
if (start > update->ntimestep)
|
if (start > update->ntimestep)
|
||||||
error->all(FLERR,"Run command start value is after start of run");
|
error->all(FLERR,"Run command start value is after start of run");
|
||||||
}
|
}
|
||||||
if (stopflag) {
|
if (stopflag) {
|
||||||
if (stop < 0 || stop > MAXBIGINT)
|
if (stop < 0)
|
||||||
error->all(FLERR,"Invalid run command start/stop value");
|
error->all(FLERR,"Invalid run command start/stop value");
|
||||||
if (stop < update->ntimestep + nsteps)
|
if (stop < update->ntimestep + nsteps)
|
||||||
error->all(FLERR,"Run command stop value is before end of run");
|
error->all(FLERR,"Run command stop value is before end of run");
|
||||||
@ -157,7 +157,7 @@ void Run::command(int narg, char **arg)
|
|||||||
update->nsteps = nsteps;
|
update->nsteps = nsteps;
|
||||||
update->firststep = update->ntimestep;
|
update->firststep = update->ntimestep;
|
||||||
update->laststep = update->ntimestep + nsteps;
|
update->laststep = update->ntimestep + nsteps;
|
||||||
if (update->laststep < 0 || update->laststep > MAXBIGINT)
|
if (update->laststep < 0 || update->laststep < update->firststep)
|
||||||
error->all(FLERR,"Too many timesteps");
|
error->all(FLERR,"Too many timesteps");
|
||||||
|
|
||||||
if (startflag) update->beginstep = start;
|
if (startflag) update->beginstep = start;
|
||||||
@ -195,7 +195,7 @@ void Run::command(int narg, char **arg)
|
|||||||
update->nsteps = nsteps;
|
update->nsteps = nsteps;
|
||||||
update->firststep = update->ntimestep;
|
update->firststep = update->ntimestep;
|
||||||
update->laststep = update->ntimestep + nsteps;
|
update->laststep = update->ntimestep + nsteps;
|
||||||
if (update->laststep < 0 || update->laststep > MAXBIGINT)
|
if (update->laststep < 0 || update->laststep < update->firststep)
|
||||||
error->all(FLERR,"Too many timesteps");
|
error->all(FLERR,"Too many timesteps");
|
||||||
|
|
||||||
if (startflag) update->beginstep = start;
|
if (startflag) update->beginstep = start;
|
||||||
|
|||||||
@ -378,7 +378,7 @@ bigint Thermo::lost_check()
|
|||||||
bigint ntotal;
|
bigint ntotal;
|
||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&ntotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&ntotal,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
if (ntotal < 0 || ntotal > MAXBIGINT)
|
if (ntotal < 0)
|
||||||
error->all(FLERR,"Too many total atoms");
|
error->all(FLERR,"Too many total atoms");
|
||||||
if (ntotal == atom->natoms) return ntotal;
|
if (ntotal == atom->natoms) return ntotal;
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "mpi.h"
|
#include "mpi.h"
|
||||||
|
#include "ctype.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
@ -25,13 +26,16 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
#define MAXLINE 256
|
#define MAXLINE 256
|
||||||
|
|
||||||
|
static char *date2num(const char *version);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
create & initialize the universe of processors in communicator
|
create & initialize the universe of processors in communicator
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Universe::Universe(LAMMPS *lmp, MPI_Comm communicator) : Pointers(lmp)
|
Universe::Universe(LAMMPS *lmp, MPI_Comm communicator) : Pointers(lmp)
|
||||||
{
|
{
|
||||||
version = (char *) LAMMPS_VERSION;
|
version = (const char *) LAMMPS_VERSION;
|
||||||
|
num_ver = date2num(version);
|
||||||
|
|
||||||
uworld = uorig = communicator;
|
uworld = uorig = communicator;
|
||||||
MPI_Comm_rank(uworld,&me);
|
MPI_Comm_rank(uworld,&me);
|
||||||
@ -57,6 +61,7 @@ Universe::~Universe()
|
|||||||
memory->destroy(procs_per_world);
|
memory->destroy(procs_per_world);
|
||||||
memory->destroy(root_proc);
|
memory->destroy(root_proc);
|
||||||
memory->destroy(uni2orig);
|
memory->destroy(uni2orig);
|
||||||
|
delete [] num_ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -194,3 +199,44 @@ int Universe::consistent()
|
|||||||
if (n == nprocs) return 1;
|
if (n == nprocs) return 1;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper function to convert the LAMMPS date string to a version id
|
||||||
|
// that can be used for both string and numerical comparisons
|
||||||
|
// where newer versions are larger than older ones.
|
||||||
|
|
||||||
|
char *date2num(const char *version)
|
||||||
|
{
|
||||||
|
int day,month,year;
|
||||||
|
day = month = year = 0;
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
|
||||||
|
day = atoi(version);
|
||||||
|
|
||||||
|
while (*version != '\0' && (isdigit(*version) || *version == ' '))
|
||||||
|
++version;
|
||||||
|
|
||||||
|
if (strncmp(version,"Jan",3) == 0) month = 1;
|
||||||
|
if (strncmp(version,"Feb",3) == 0) month = 2;
|
||||||
|
if (strncmp(version,"Mar",3) == 0) month = 3;
|
||||||
|
if (strncmp(version,"Apr",3) == 0) month = 4;
|
||||||
|
if (strncmp(version,"May",3) == 0) month = 5;
|
||||||
|
if (strncmp(version,"Jun",3) == 0) month = 6;
|
||||||
|
if (strncmp(version,"Jul",3) == 0) month = 7;
|
||||||
|
if (strncmp(version,"Aug",3) == 0) month = 8;
|
||||||
|
if (strncmp(version,"Sep",3) == 0) month = 9;
|
||||||
|
if (strncmp(version,"Oct",3) == 0) month = 10;
|
||||||
|
if (strncmp(version,"Nov",3) == 0) month = 11;
|
||||||
|
if (strncmp(version,"Dec",3) == 0) month = 12;
|
||||||
|
|
||||||
|
while (*version != '\0' && !isdigit(*version))
|
||||||
|
++version;
|
||||||
|
|
||||||
|
year = atoi(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ver = new char[10];
|
||||||
|
sprintf(ver,"%04d%02d%02d", year % 10000, month, day % 100);
|
||||||
|
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
|||||||
@ -21,7 +21,9 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class Universe : protected Pointers {
|
class Universe : protected Pointers {
|
||||||
public:
|
public:
|
||||||
char *version; // LAMMPS version string = date
|
const char *version; // LAMMPS version string = date
|
||||||
|
const char *num_ver; // numeric version id derived from version that
|
||||||
|
// can be used for string or numeric comparisons
|
||||||
|
|
||||||
MPI_Comm uworld; // communicator for entire universe
|
MPI_Comm uworld; // communicator for entire universe
|
||||||
int me,nprocs; // my place in universe
|
int me,nprocs; // my place in universe
|
||||||
|
|||||||
@ -262,8 +262,11 @@ void Variable::set(int narg, char **arg)
|
|||||||
|
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
FILE *fp = fopen("tmp.lammps.variable","w");
|
FILE *fp = fopen("tmp.lammps.variable","w");
|
||||||
|
if (fp == NULL)
|
||||||
|
error->one(FLERR,"Cannot open temporary file for world counter.");
|
||||||
fprintf(fp,"%d\n",universe->nworlds);
|
fprintf(fp,"%d\n",universe->nworlds);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int jvar = 0; jvar < nvar; jvar++)
|
for (int jvar = 0; jvar < nvar; jvar++)
|
||||||
@ -518,7 +521,7 @@ int Variable::next(int narg, char **arg)
|
|||||||
|
|
||||||
for (int iarg = 0; iarg < narg; iarg++) {
|
for (int iarg = 0; iarg < narg; iarg++) {
|
||||||
ivar = find(arg[iarg]);
|
ivar = find(arg[iarg]);
|
||||||
if (ivar == -1) error->all(FLERR,"Invalid variable in next command");
|
if (ivar < 0) error->all(FLERR,"Invalid variable in next command");
|
||||||
if (style[ivar] == ULOOP && style[find(arg[0])] == UNIVERSE) continue;
|
if (style[ivar] == ULOOP && style[find(arg[0])] == UNIVERSE) continue;
|
||||||
else if (style[ivar] == UNIVERSE && style[find(arg[0])] == ULOOP) continue;
|
else if (style[ivar] == UNIVERSE && style[find(arg[0])] == ULOOP) continue;
|
||||||
else if (style[ivar] != style[find(arg[0])])
|
else if (style[ivar] != style[find(arg[0])])
|
||||||
@ -614,6 +617,7 @@ int Variable::next(int narg, char **arg)
|
|||||||
fprintf(fp,"%d\n",nextindex+1);
|
fprintf(fp,"%d\n",nextindex+1);
|
||||||
//printf("WRITE %d %d\n",universe->me,nextindex+1);
|
//printf("WRITE %d %d\n",universe->me,nextindex+1);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
rename("tmp.lammps.variable.lock","tmp.lammps.variable");
|
rename("tmp.lammps.variable.lock","tmp.lammps.variable");
|
||||||
if (universe->uscreen)
|
if (universe->uscreen)
|
||||||
fprintf(universe->uscreen,
|
fprintf(universe->uscreen,
|
||||||
@ -716,7 +720,7 @@ int Variable::atomstyle(int ivar)
|
|||||||
char *Variable::pythonstyle(char *name, char *funcname)
|
char *Variable::pythonstyle(char *name, char *funcname)
|
||||||
{
|
{
|
||||||
int ivar = find(name);
|
int ivar = find(name);
|
||||||
if (ivar == -1) return NULL;
|
if (ivar < 0) return NULL;
|
||||||
if (style[ivar] != PYTHON) return NULL;
|
if (style[ivar] != PYTHON) return NULL;
|
||||||
if (strcmp(data[ivar][0],funcname) != 0) return NULL;
|
if (strcmp(data[ivar][0],funcname) != 0) return NULL;
|
||||||
return data[ivar][1];
|
return data[ivar][1];
|
||||||
@ -739,7 +743,7 @@ char *Variable::pythonstyle(char *name, char *funcname)
|
|||||||
char *Variable::retrieve(char *name)
|
char *Variable::retrieve(char *name)
|
||||||
{
|
{
|
||||||
int ivar = find(name);
|
int ivar = find(name);
|
||||||
if (ivar == -1) return NULL;
|
if (ivar < 0) return NULL;
|
||||||
if (which[ivar] >= num[ivar]) return NULL;
|
if (which[ivar] >= num[ivar]) return NULL;
|
||||||
|
|
||||||
if (eval_in_progress[ivar])
|
if (eval_in_progress[ivar])
|
||||||
@ -857,6 +861,11 @@ void Variable::compute_atom(int ivar, int igroup,
|
|||||||
collapse_tree(tree);
|
collapse_tree(tree);
|
||||||
} else vstore = reader[ivar]->fixstore->vstore;
|
} else vstore = reader[ivar]->fixstore->vstore;
|
||||||
|
|
||||||
|
if (result == NULL) {
|
||||||
|
eval_in_progress[ivar] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int groupbit = group->bitmask[igroup];
|
int groupbit = group->bitmask[igroup];
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
@ -1139,15 +1148,10 @@ double Variable::evaluate(char *str, Tree **tree)
|
|||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Variable evaluation before simulation box is defined");
|
"Variable evaluation before simulation box is defined");
|
||||||
|
|
||||||
n = strlen(word) - 2 + 1;
|
int icompute = modify->find_compute(word+2);
|
||||||
char *id = new char[n];
|
|
||||||
strcpy(id,&word[2]);
|
|
||||||
|
|
||||||
int icompute = modify->find_compute(id);
|
|
||||||
if (icompute < 0)
|
if (icompute < 0)
|
||||||
error->all(FLERR,"Invalid compute ID in variable formula");
|
error->all(FLERR,"Invalid compute ID in variable formula");
|
||||||
Compute *compute = modify->compute[icompute];
|
Compute *compute = modify->compute[icompute];
|
||||||
delete [] id;
|
|
||||||
|
|
||||||
// parse zero or one or two trailing brackets
|
// parse zero or one or two trailing brackets
|
||||||
// point i beyond last bracket
|
// point i beyond last bracket
|
||||||
@ -1366,14 +1370,9 @@ double Variable::evaluate(char *str, Tree **tree)
|
|||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Variable evaluation before simulation box is defined");
|
"Variable evaluation before simulation box is defined");
|
||||||
|
|
||||||
n = strlen(word) - 2 + 1;
|
int ifix = modify->find_fix(word+2);
|
||||||
char *id = new char[n];
|
|
||||||
strcpy(id,&word[2]);
|
|
||||||
|
|
||||||
int ifix = modify->find_fix(id);
|
|
||||||
if (ifix < 0) error->all(FLERR,"Invalid fix ID in variable formula");
|
if (ifix < 0) error->all(FLERR,"Invalid fix ID in variable formula");
|
||||||
Fix *fix = modify->fix[ifix];
|
Fix *fix = modify->fix[ifix];
|
||||||
delete [] id;
|
|
||||||
|
|
||||||
// parse zero or one or two trailing brackets
|
// parse zero or one or two trailing brackets
|
||||||
// point i beyond last bracket
|
// point i beyond last bracket
|
||||||
@ -1545,11 +1544,8 @@ double Variable::evaluate(char *str, Tree **tree)
|
|||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
} else if (strncmp(word,"v_",2) == 0) {
|
} else if (strncmp(word,"v_",2) == 0) {
|
||||||
n = strlen(word) - 2 + 1;
|
|
||||||
char *id = new char[n];
|
|
||||||
strcpy(id,&word[2]);
|
|
||||||
|
|
||||||
int ivar = find(id);
|
int ivar = find(word+2);
|
||||||
if (ivar < 0)
|
if (ivar < 0)
|
||||||
error->all(FLERR,"Invalid variable name in variable formula");
|
error->all(FLERR,"Invalid variable name in variable formula");
|
||||||
if (eval_in_progress[ivar])
|
if (eval_in_progress[ivar])
|
||||||
@ -1574,7 +1570,7 @@ double Variable::evaluate(char *str, Tree **tree)
|
|||||||
|
|
||||||
if (nbracket == 0 && style[ivar] != ATOM && style[ivar] != ATOMFILE) {
|
if (nbracket == 0 && style[ivar] != ATOM && style[ivar] != ATOMFILE) {
|
||||||
|
|
||||||
char *var = retrieve(id);
|
char *var = retrieve(word+2);
|
||||||
if (var == NULL)
|
if (var == NULL)
|
||||||
error->all(FLERR,"Invalid variable evaluation in variable formula");
|
error->all(FLERR,"Invalid variable evaluation in variable formula");
|
||||||
if (tree) {
|
if (tree) {
|
||||||
@ -1636,8 +1632,6 @@ double Variable::evaluate(char *str, Tree **tree)
|
|||||||
|
|
||||||
} else error->all(FLERR,"Mismatched variable in variable formula");
|
} else error->all(FLERR,"Mismatched variable in variable formula");
|
||||||
|
|
||||||
delete [] id;
|
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
// math/group/special function or atom value/vector or
|
// math/group/special function or atom value/vector or
|
||||||
// constant or thermo keyword
|
// constant or thermo keyword
|
||||||
@ -3745,7 +3739,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
|||||||
error->all(FLERR,"Invalid special function in variable formula");
|
error->all(FLERR,"Invalid special function in variable formula");
|
||||||
|
|
||||||
int ivar = find(args[0]);
|
int ivar = find(args[0]);
|
||||||
if (ivar == -1)
|
if (ivar < 0)
|
||||||
error->all(FLERR,"Variable ID in variable formula does not exist");
|
error->all(FLERR,"Variable ID in variable formula does not exist");
|
||||||
|
|
||||||
// SCALARFILE has single current value, read next one
|
// SCALARFILE has single current value, read next one
|
||||||
@ -3981,23 +3975,25 @@ void Variable::atom_vector(char *word, Tree **tree,
|
|||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
check if word matches a constant
|
check if word matches a constant
|
||||||
return 1 if yes, else 0
|
return 1 if yes, else 0
|
||||||
customize by adding a constant: PI
|
customize by adding a constant: PI, version
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Variable::is_constant(char *word)
|
int Variable::is_constant(char *word)
|
||||||
{
|
{
|
||||||
if (strcmp(word,"PI") == 0) return 1;
|
if (strcmp(word,"PI") == 0) return 1;
|
||||||
|
if (strcmp(word,"version") == 0) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
process a constant in formula
|
process a constant in formula
|
||||||
customize by adding a constant: PI
|
customize by adding a constant: PI, version
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
double Variable::constant(char *word)
|
double Variable::constant(char *word)
|
||||||
{
|
{
|
||||||
if (strcmp(word,"PI") == 0) return MY_PI;
|
if (strcmp(word,"PI") == 0) return MY_PI;
|
||||||
|
if (strcmp(word,"version") == 0) return atof(universe->num_ver);
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4344,17 +4340,11 @@ unsigned int Variable::data_mask(char *str)
|
|||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Variable evaluation before simulation box is defined");
|
"Variable evaluation before simulation box is defined");
|
||||||
|
|
||||||
n = strlen(word) - 2 + 1;
|
int icompute = modify->find_compute(word+2);
|
||||||
char *id = new char[n];
|
|
||||||
strcpy(id,&word[2]);
|
|
||||||
|
|
||||||
int icompute = modify->find_compute(id);
|
|
||||||
if (icompute < 0)
|
if (icompute < 0)
|
||||||
error->all(FLERR,"Invalid compute ID in variable formula");
|
error->all(FLERR,"Invalid compute ID in variable formula");
|
||||||
|
|
||||||
datamask &= modify->compute[icompute]->data_mask();
|
datamask &= modify->compute[icompute]->data_mask();
|
||||||
|
|
||||||
delete [] id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strncmp(word,"f_",2) == 0) && (i>0) && (!isalnum(str[i-1]))) {
|
if ((strncmp(word,"f_",2) == 0) && (i>0) && (!isalnum(str[i-1]))) {
|
||||||
@ -4362,19 +4352,15 @@ unsigned int Variable::data_mask(char *str)
|
|||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Variable evaluation before simulation box is defined");
|
"Variable evaluation before simulation box is defined");
|
||||||
|
|
||||||
n = strlen(word) - 2 + 1;
|
int ifix = modify->find_fix(word+2);
|
||||||
char *id = new char[n];
|
|
||||||
strcpy(id,&word[2]);
|
|
||||||
|
|
||||||
int ifix = modify->find_fix(id);
|
|
||||||
if (ifix < 0) error->all(FLERR,"Invalid fix ID in variable formula");
|
if (ifix < 0) error->all(FLERR,"Invalid fix ID in variable formula");
|
||||||
|
|
||||||
datamask &= modify->fix[ifix]->data_mask();
|
datamask &= modify->fix[ifix]->data_mask();
|
||||||
delete [] id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strncmp(word,"v_",2) == 0) && (i>0) && (!isalnum(str[i-1]))) {
|
if ((strncmp(word,"v_",2) == 0) && (i>0) && (!isalnum(str[i-1]))) {
|
||||||
int ivar = find(word);
|
int ivar = find(word+2);
|
||||||
|
if (ivar < 0) error->all(FLERR,"Invalid variable name in variable formula");
|
||||||
datamask &= data_mask(ivar);
|
datamask &= data_mask(ivar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4395,6 +4381,7 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :
|
|||||||
{
|
{
|
||||||
me = comm->me;
|
me = comm->me;
|
||||||
style = flag;
|
style = flag;
|
||||||
|
fp = NULL;
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(file,"r");
|
fp = fopen(file,"r");
|
||||||
@ -4403,7 +4390,7 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :
|
|||||||
sprintf(str,"Cannot open file variable file %s",file);
|
sprintf(str,"Cannot open file variable file %s",file);
|
||||||
error->one(FLERR,str);
|
error->one(FLERR,str);
|
||||||
}
|
}
|
||||||
} else fp = NULL;
|
}
|
||||||
|
|
||||||
// if atomfile-style variable, must store per-atom values read from file
|
// if atomfile-style variable, must store per-atom values read from file
|
||||||
// allocate a new fix STORE, so they persist
|
// allocate a new fix STORE, so they persist
|
||||||
@ -4441,7 +4428,10 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :
|
|||||||
|
|
||||||
VarReader::~VarReader()
|
VarReader::~VarReader()
|
||||||
{
|
{
|
||||||
if (me == 0) fclose(fp);
|
if (me == 0) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// check modify in case all fixes have already been deleted
|
// check modify in case all fixes have already been deleted
|
||||||
|
|
||||||
|
|||||||
@ -72,6 +72,7 @@ WriteRestart::WriteRestart(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
MPI_Comm_size(world,&nprocs);
|
MPI_Comm_size(world,&nprocs);
|
||||||
multiproc = 0;
|
multiproc = 0;
|
||||||
|
fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -308,7 +309,10 @@ void WriteRestart::write(char *file)
|
|||||||
// write PROCSPERFILE into new file
|
// write PROCSPERFILE into new file
|
||||||
|
|
||||||
if (multiproc) {
|
if (multiproc) {
|
||||||
if (me == 0) fclose(fp);
|
if (me == 0 && fp) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *multiname = new char[strlen(file) + 16];
|
char *multiname = new char[strlen(file) + 16];
|
||||||
char *ptr = strchr(file,'%');
|
char *ptr = strchr(file,'%');
|
||||||
@ -387,7 +391,10 @@ void WriteRestart::write(char *file)
|
|||||||
// MPI-IO output to single file
|
// MPI-IO output to single file
|
||||||
|
|
||||||
if (mpiioflag) {
|
if (mpiioflag) {
|
||||||
if (me == 0) fclose(fp);
|
if (me == 0 && fp) {
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
mpiio->openForWrite(file);
|
mpiio->openForWrite(file);
|
||||||
mpiio->write(headerOffset,send_size,buf);
|
mpiio->write(headerOffset,send_size,buf);
|
||||||
mpiio->close();
|
mpiio->close();
|
||||||
@ -415,6 +422,7 @@ void WriteRestart::write(char *file)
|
|||||||
write_double_vec(PERPROC,recv_size,buf);
|
write_double_vec(PERPROC,recv_size,buf);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MPI_Recv(&tmp,0,MPI_INT,fileproc,0,world,MPI_STATUS_IGNORE);
|
MPI_Recv(&tmp,0,MPI_INT,fileproc,0,world,MPI_STATUS_IGNORE);
|
||||||
@ -667,7 +675,7 @@ void WriteRestart::write_double(int flag, double value)
|
|||||||
write a flag and a char string (including NULL) into restart file
|
write a flag and a char string (including NULL) into restart file
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void WriteRestart::write_string(int flag, char *value)
|
void WriteRestart::write_string(int flag, const char *value)
|
||||||
{
|
{
|
||||||
int n = strlen(value) + 1;
|
int n = strlen(value) + 1;
|
||||||
fwrite(&flag,sizeof(int),1,fp);
|
fwrite(&flag,sizeof(int),1,fp);
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class WriteRestart : protected Pointers {
|
|||||||
void write_int(int, int);
|
void write_int(int, int);
|
||||||
void write_bigint(int, bigint);
|
void write_bigint(int, bigint);
|
||||||
void write_double(int, double);
|
void write_double(int, double);
|
||||||
void write_string(int, char *);
|
void write_string(int, const char *);
|
||||||
void write_int_vec(int, int, int *);
|
void write_int_vec(int, int, int *);
|
||||||
void write_double_vec(int, int, double *);
|
void write_double_vec(int, int, double *);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user