diff --git a/src/EXTRA-FIX/fix_ave_correlate_long.cpp b/src/EXTRA-FIX/fix_ave_correlate_long.cpp index 6e4e26754f..1746c7f6f5 100644 --- a/src/EXTRA-FIX/fix_ave_correlate_long.cpp +++ b/src/EXTRA-FIX/fix_ave_correlate_long.cpp @@ -36,7 +36,6 @@ #include #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -260,11 +259,11 @@ FixAveCorrelateLong::FixAveCorrelateLong(LAMMPS * lmp, int narg, char **arg): fprintf(fp," %s*%s",arg[5+i],arg[5+j]); fprintf(fp,"\n"); } - filepos = ftell(fp); + filepos = platform::ftell(fp); } - delete [] title1; - delete [] title2; + delete[] title1; + delete[] title2; // allocate and initialize memory for calculated values and correlators @@ -319,11 +318,11 @@ FixAveCorrelateLong::FixAveCorrelateLong(LAMMPS * lmp, int narg, char **arg): FixAveCorrelateLong::~FixAveCorrelateLong() { - delete [] which; - delete [] argindex; - delete [] value2index; - for (int i = 0; i < nvalues; i++) delete [] ids[i]; - delete [] ids; + delete[] which; + delete[] argindex; + delete[] value2index; + for (int i = 0; i < nvalues; i++) delete[] ids[i]; + delete[] ids; memory->destroy(values); memory->destroy(shift); @@ -467,7 +466,7 @@ void FixAveCorrelateLong::end_of_step() evaluate(); if (fp && me == 0) { - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,"# Timestep: " BIGINT_FORMAT "\n", ntimestep); for (unsigned int i=0;idt*nevery); @@ -478,9 +477,9 @@ void FixAveCorrelateLong::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()); } } diff --git a/src/EXTRA-FIX/fix_ave_correlate_long.h b/src/EXTRA-FIX/fix_ave_correlate_long.h index b62c6aefcb..a31ae78217 100644 --- a/src/EXTRA-FIX/fix_ave_correlate_long.h +++ b/src/EXTRA-FIX/fix_ave_correlate_long.h @@ -66,7 +66,7 @@ class FixAveCorrelateLong : public Fix { FILE *fp; int type, startstep, overwrite; - long filepos; + bigint filepos; int npair; // number of correlation pairs to calculate double *values; diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index 1328a27376..36c9eaf6fc 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -29,7 +29,6 @@ #include "variable.h" #include -#include 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()); } } } diff --git a/src/fix_ave_chunk.h b/src/fix_ave_chunk.h index e7beed341f..69fdea0f06 100644 --- a/src/fix_ave_chunk.h +++ b/src/fix_ave_chunk.h @@ -61,7 +61,7 @@ class FixAveChunk : public Fix { class ComputeChunkAtom *cchunk; int lockforever; - long filepos; + bigint filepos; int maxvar; double *varatom; diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index 92b5ea3693..df6e33288e 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -30,7 +30,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -139,17 +138,17 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg): iarg += 1; } else if (strcmp(arg[iarg],"title1") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate 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/correlate 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/correlate command"); - delete [] title3; + delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal fix ave/correlate command"); @@ -256,18 +255,18 @@ FixAveCorrelate::FixAveCorrelate(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); } @@ -312,11 +311,11 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg): FixAveCorrelate::~FixAveCorrelate() { - delete [] which; - delete [] argindex; - delete [] value2index; - for (int i = 0; i < nvalues; i++) delete [] ids[i]; - delete [] ids; + delete[] which; + delete[] argindex; + delete[] value2index; + for (int i = 0; i < nvalues; i++) delete[] ids[i]; + delete[] ids; memory->destroy(values); memory->destroy(count); @@ -489,7 +488,7 @@ void FixAveCorrelate::end_of_step() if (fp && me == 0) { clearerr(fp); - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat); for (i = 0; i < nrepeat; i++) { fprintf(fp,"%d %d %d",i+1,i*nevery,count[i]); @@ -507,9 +506,9 @@ void FixAveCorrelate::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()); } } diff --git a/src/fix_ave_correlate.h b/src/fix_ave_correlate.h index d551ba7b92..6dde75c0d3 100644 --- a/src/fix_ave_correlate.h +++ b/src/fix_ave_correlate.h @@ -44,7 +44,7 @@ class FixAveCorrelate : public Fix { int type, ave, startstep, overwrite; double prefactor; - long filepos; + bigint filepos; int firstindex; // index in values ring of earliest time sample int lastindex; // index in values ring of latest time sample diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 92b03035b3..8c55337074 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -25,7 +25,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -168,7 +167,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : // if wildcard expansion occurred, free earg memory from expand_args() if (expand) { - for (int i = 0; i < nvalues; i++) delete [] earg[i]; + for (int i = 0; i < nvalues; i++) delete[] earg[i]; memory->sfree(earg); } @@ -434,12 +433,12 @@ FixAveHisto::FixAveHisto(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; // allocate and initialize memory for averaging @@ -502,18 +501,18 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : FixAveHisto::~FixAveHisto() { - delete [] which; - delete [] argindex; - delete [] value2index; - for (int i = 0; i < nvalues; i++) delete [] ids[i]; - delete [] ids; + delete[] which; + delete[] argindex; + delete[] value2index; + for (int i = 0; i < nvalues; i++) delete[] ids[i]; + delete[] ids; if (fp && me == 0) fclose(fp); - delete [] bin; - delete [] bin_total; - delete [] bin_all; - delete [] coord; + delete[] bin; + delete[] bin_total; + delete[] bin_all; + delete[] coord; memory->destroy(stats_list); memory->destroy(bin_list); memory->destroy(vector); @@ -817,7 +816,7 @@ void FixAveHisto::end_of_step() if (fp && me == 0) { clearerr(fp); - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins, stats_total[0],stats_total[1],stats_total[2],stats_total[3]); if (stats_total[0] != 0.0) @@ -833,9 +832,9 @@ void FixAveHisto::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()); } } } @@ -993,17 +992,17 @@ void FixAveHisto::options(int iarg, int narg, char **arg) iarg += 1; } else if (strcmp(arg[iarg],"title1") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo 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/histo 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/histo command"); - delete [] title3; + delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal fix ave/histo command"); diff --git a/src/fix_ave_histo.h b/src/fix_ave_histo.h index 0158d04377..ef64ad74ff 100644 --- a/src/fix_ave_histo.h +++ b/src/fix_ave_histo.h @@ -44,7 +44,7 @@ class FixAveHisto : public Fix { FILE *fp; double lo, hi, binsize, bininv; int kind, beyond, overwrite; - long filepos; + bigint filepos; double stats[4], stats_total[4], stats_all[4]; double **stats_list; diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 63321bf53e..7866490840 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -28,8 +28,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; @@ -472,7 +470,7 @@ void FixAveHistoWeight::end_of_step() if (fp && me == 0) { clearerr(fp); - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins, stats_total[0],stats_total[1],stats_total[2],stats_total[3]); if (stats_total[0] != 0.0) @@ -488,9 +486,9 @@ void FixAveHistoWeight::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()); } } } diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index da9cd89e5e..a3da6e6a3d 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -28,7 +28,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -274,18 +273,18 @@ FixAveTime::FixAveTime(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 < nvalues; i++) delete [] earg[i]; + for (int i = 0; i < nvalues; i++) delete[] earg[i]; memory->sfree(earg); } @@ -446,24 +445,24 @@ FixAveTime::~FixAveTime() } } - delete [] format_user; + delete[] format_user; - delete [] which; - delete [] argindex; - delete [] value2index; - delete [] offcol; - delete [] varlen; - for (int i = 0; i < nvalues; i++) delete [] ids[i]; - delete [] ids; + delete[] which; + delete[] argindex; + delete[] value2index; + delete[] offcol; + delete[] varlen; + for (int i = 0; i < nvalues; i++) delete[] ids[i]; + delete[] ids; - delete [] extlist; + delete[] extlist; if (fp && me == 0) fclose(fp); memory->destroy(column); - delete [] vector; - delete [] vector_total; + delete[] vector; + delete[] vector_total; memory->destroy(array); memory->destroy(array_total); memory->destroy(array_list); @@ -673,7 +672,7 @@ void FixAveTime::invoke_scalar(bigint ntimestep) if (fp && me == 0) { clearerr(fp); - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,BIGINT_FORMAT,ntimestep); for (i = 0; i < nvalues; i++) fprintf(fp,format,vector_total[i]/norm); fprintf(fp,"\n"); @@ -683,9 +682,9 @@ void FixAveTime::invoke_scalar(bigint ntimestep) 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()); } } } @@ -885,7 +884,7 @@ void FixAveTime::invoke_vector(bigint ntimestep) // output result to file if (fp && me == 0) { - if (overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) platform::fseek(fp,filepos); fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrows); for (i = 0; i < nrows; i++) { fprintf(fp,"%d",i+1); @@ -894,9 +893,9 @@ void FixAveTime::invoke_vector(bigint ntimestep) } 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()); } } } @@ -1066,23 +1065,23 @@ void FixAveTime::options(int iarg, int narg, char **arg) iarg += 1; } else if (strcmp(arg[iarg],"format") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time 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/spatial 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/spatial 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/spatial command"); - delete [] title3; + delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal fix ave/time command"); diff --git a/src/fix_ave_time.h b/src/fix_ave_time.h index 391a06f495..3a26dd6d70 100644 --- a/src/fix_ave_time.h +++ b/src/fix_ave_time.h @@ -54,7 +54,7 @@ class FixAveTime : public Fix { int *offlist; char *format, *format_user; char *title1, *title2, *title3; - long filepos; + bigint filepos; int norm, iwindow, window_limit; double *vector;