use platform functions for averaging fixes
This commit is contained in:
@ -29,7 +29,6 @@
|
||||
#include "variable.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -216,23 +215,23 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
iarg += 1;
|
||||
} else if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] format_user;
|
||||
delete[] format_user;
|
||||
format_user = utils::strdup(arg[iarg+1]);
|
||||
format = format_user;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title1;
|
||||
delete[] title1;
|
||||
title1 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title2;
|
||||
delete[] title2;
|
||||
title2 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title3;
|
||||
delete[] title3;
|
||||
title3 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
@ -348,18 +347,18 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (ferror(fp))
|
||||
error->one(FLERR,"Error writing file header");
|
||||
|
||||
filepos = ftell(fp);
|
||||
filepos = platform::ftell(fp);
|
||||
}
|
||||
|
||||
delete [] title1;
|
||||
delete [] title2;
|
||||
delete [] title3;
|
||||
delete[] title1;
|
||||
delete[] title2;
|
||||
delete[] title3;
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
// wait to do this until after file comment lines are printed
|
||||
|
||||
if (expand) {
|
||||
for (int i = 0; i < nargnew; i++) delete [] earg[i];
|
||||
for (int i = 0; i < nargnew; i++) delete[] earg[i];
|
||||
memory->sfree(earg);
|
||||
}
|
||||
|
||||
@ -407,11 +406,11 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixAveChunk::~FixAveChunk()
|
||||
{
|
||||
delete [] which;
|
||||
delete [] argindex;
|
||||
for (int i = 0; i < nvalues; i++) delete [] ids[i];
|
||||
delete [] ids;
|
||||
delete [] value2index;
|
||||
delete[] which;
|
||||
delete[] argindex;
|
||||
for (int i = 0; i < nvalues; i++) delete[] ids[i];
|
||||
delete[] ids;
|
||||
delete[] value2index;
|
||||
|
||||
if (fp && comm->me == 0) fclose(fp);
|
||||
|
||||
@ -438,7 +437,7 @@ FixAveChunk::~FixAveChunk()
|
||||
}
|
||||
}
|
||||
|
||||
delete [] idchunk;
|
||||
delete[] idchunk;
|
||||
which = nullptr;
|
||||
argindex = nullptr;
|
||||
ids = nullptr;
|
||||
@ -941,7 +940,7 @@ void FixAveChunk::end_of_step()
|
||||
|
||||
if (fp && comm->me == 0) {
|
||||
clearerr(fp);
|
||||
if (overwrite) fseek(fp,filepos,SEEK_SET);
|
||||
if (overwrite) platform::fseek(fp,filepos);
|
||||
double count = 0.0;
|
||||
for (m = 0; m < nchunk; m++) count += count_total[m];
|
||||
fprintf(fp,BIGINT_FORMAT " %d %g\n",ntimestep,nchunk,count);
|
||||
@ -1027,9 +1026,9 @@ void FixAveChunk::end_of_step()
|
||||
fflush(fp);
|
||||
|
||||
if (overwrite) {
|
||||
long fileend = ftell(fp);
|
||||
if ((fileend > 0) && (ftruncate(fileno(fp),fileend)))
|
||||
perror("Error while tuncating output");
|
||||
bigint fileend = platform::ftell(fp);
|
||||
if ((fileend > 0) && (platform::ftruncate(fp,fileend)))
|
||||
error->warning(FLERR,"Error while tuncating output: {}", utils::getsyserror());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user