ave/correlate: strange non-formatted data appended to output file

Hi,
I am using the ave/correlate fix with “ave running overwrite”. The correlation seems OK but some non-formatted data is appended to the output file (see below). Note that the line starting with 10000 is replicated a few times, with quite different numbers. Is this just a problem related to mpi or I should be worried about some bug?
Thanks
Stefano

Maybe the file needs to be truncated in overwrite mode,
in case the new version is shorter than the old.

Try adding the 2nd overwrite if clause in fix_ave_correlate.cpp:

// output result to file

if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat);
for (i = 0; i < nrepeat; i++) {
fprintf(fp,"%d %d %d",i+1,inevery,count[i]);
if (count[i])
for (j = 0; j < npair; j++)
fprintf(fp," %g",prefactor
corr[i][j]/count[i]);
else
for (j = 0; j < npair; j++)
fprintf(fp," 0.0");
fprintf(fp,"\n");
}
fflush(fp);
if (overwrite) { // add these lines
long fileend = ftell(fp);
ftruncate(fileno(fp),fileend);
}
}

You also need #include “unistd.h” at the top.
If that fixes the issue, I’ll post a patch.

Steve