From 3d96d0a674204d03042121b1e4ee28bb8d1549dd Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 25 Feb 2021 15:34:29 -0500 Subject: [PATCH] Fix wrong group name output in fix ave/chunk --- examples/VISCOSITY/profile.13Oct16.mp.2d.g++.1 | 2 +- examples/VISCOSITY/profile.13Oct16.nemd.2d.g++.1 | 2 +- examples/VISCOSITY/profile.13Oct16.wall.2d.g++.1 | 2 +- src/fix_ave_chunk.cpp | 15 ++++++++------- src/fix_ave_chunk.h | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/VISCOSITY/profile.13Oct16.mp.2d.g++.1 b/examples/VISCOSITY/profile.13Oct16.mp.2d.g++.1 index 64303827b5..a969bd5c0e 100644 --- a/examples/VISCOSITY/profile.13Oct16.mp.2d.g++.1 +++ b/examples/VISCOSITY/profile.13Oct16.mp.2d.g++.1 @@ -1,4 +1,4 @@ -# Chunk-averaged data for fix 5 and group file +# Chunk-averaged data for fix 5 and group all # Timestep Number-of-chunks Total-count # Chunk Coord1 Ncount vx 6000 20 800 diff --git a/examples/VISCOSITY/profile.13Oct16.nemd.2d.g++.1 b/examples/VISCOSITY/profile.13Oct16.nemd.2d.g++.1 index 463a549d5e..efa03b1192 100644 --- a/examples/VISCOSITY/profile.13Oct16.nemd.2d.g++.1 +++ b/examples/VISCOSITY/profile.13Oct16.nemd.2d.g++.1 @@ -1,4 +1,4 @@ -# Chunk-averaged data for fix 4 and group file +# Chunk-averaged data for fix 4 and group all # Timestep Number-of-chunks Total-count # Chunk Coord1 Ncount vx 10000 20 800 diff --git a/examples/VISCOSITY/profile.13Oct16.wall.2d.g++.1 b/examples/VISCOSITY/profile.13Oct16.wall.2d.g++.1 index 191496f0cd..06033fa883 100644 --- a/examples/VISCOSITY/profile.13Oct16.wall.2d.g++.1 +++ b/examples/VISCOSITY/profile.13Oct16.wall.2d.g++.1 @@ -1,4 +1,4 @@ -# Chunk-averaged data for fix 4 and group file +# Chunk-averaged data for fix 4 and group all # Timestep Number-of-chunks Total-count # Chunk Coord1 Ncount vx 10000 20 1020 diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index d13d46fc20..3b612aeb73 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -15,6 +15,7 @@ #include "arg_info.h" #include "atom.h" +#include "comm.h" #include "compute.h" #include "compute_chunk_atom.h" #include "domain.h" @@ -52,8 +53,6 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : { if (narg < 7) error->all(FLERR,"Illegal fix ave/chunk command"); - MPI_Comm_rank(world,&me); - nevery = utils::inumeric(FLERR,arg[3],false,lmp); nrepeat = utils::inumeric(FLERR,arg[4],false,lmp); nfreq = utils::inumeric(FLERR,arg[5],false,lmp); @@ -65,6 +64,8 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : global_freq = nfreq; no_change_box = 1; + char * group = arg[1]; + // expand args if any have wildcard character "*" int expand = 0; @@ -206,7 +207,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"file") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command"); - if (me == 0) { + if (comm->me == 0) { fp = fopen(arg[iarg+1],"w"); if (fp == nullptr) error->one(FLERR,fmt::format("Cannot open fix ave/chunk file {}: {}", @@ -328,11 +329,11 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : // print file comment lines - if (fp && me == 0) { + if (fp && comm->me == 0) { clearerr(fp); if (title1) fprintf(fp,"%s\n",title1); else fprintf(fp,"# Chunk-averaged data for fix %s and group %s\n", - id,arg[1]); + id, group); if (title2) fprintf(fp,"%s\n",title2); else fprintf(fp,"# Timestep Number-of-chunks Total-count\n"); if (title3) fprintf(fp,"%s\n",title3); @@ -423,7 +424,7 @@ FixAveChunk::~FixAveChunk() delete [] ids; delete [] value2index; - if (fp && me == 0) fclose(fp); + if (fp && comm->me == 0) fclose(fp); memory->destroy(varatom); memory->destroy(count_one); @@ -949,7 +950,7 @@ void FixAveChunk::end_of_step() // output result to file - if (fp && me == 0) { + if (fp && comm->me == 0) { clearerr(fp); if (overwrite) fseek(fp,filepos,SEEK_SET); double count = 0.0; diff --git a/src/fix_ave_chunk.h b/src/fix_ave_chunk.h index dac5761ae8..debab13165 100644 --- a/src/fix_ave_chunk.h +++ b/src/fix_ave_chunk.h @@ -36,7 +36,7 @@ class FixAveChunk : public Fix { double memory_usage(); private: - int me,nvalues; + int nvalues; int nrepeat,nfreq,irepeat; int normflag,scaleflag,overwrite,biasflag,colextra; bigint nvalid,nvalid_last;