git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13891 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2015-08-18 22:54:48 +00:00
parent adabfc38a6
commit 6da9e4c217
2 changed files with 17 additions and 2 deletions

View File

@ -70,6 +70,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
} else break;
}
if (nvalues == 0) error->all(FLERR,"No values in fix ave/time command");
options(narg,arg);
// parse values until one isn't recognized
@ -468,6 +470,8 @@ FixAveTime::~FixAveTime()
}
}
delete [] format_user;
memory->destroy(which);
memory->destroy(argindex);
memory->destroy(value2index);
@ -690,7 +694,7 @@ void FixAveTime::invoke_scalar(bigint ntimestep)
if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT,ntimestep);
for (i = 0; i < nvalues; i++) fprintf(fp," %g",vector_total[i]/norm);
for (i = 0; i < nvalues; i++) fprintf(fp,format,vector_total[i]/norm);
fprintf(fp,"\n");
fflush(fp);
if (overwrite) {
@ -888,7 +892,7 @@ void FixAveTime::invoke_vector(bigint ntimestep)
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrows);
for (i = 0; i < nrows; i++) {
fprintf(fp,"%d",i+1);
for (j = 0; j < nvalues; j++) fprintf(fp," %g",array_total[i][j]/norm);
for (j = 0; j < nvalues; j++) fprintf(fp,format,array_total[i][j]/norm);
fprintf(fp,"\n");
}
fflush(fp);
@ -1006,6 +1010,8 @@ void FixAveTime::options(int narg, char **arg)
noff = 0;
offlist = NULL;
overwrite = 0;
format_user = NULL;
format = (char *) " %g";
title1 = NULL;
title2 = NULL;
title3 = NULL;
@ -1056,6 +1062,14 @@ void FixAveTime::options(int narg, char **arg)
} else if (strcmp(arg[iarg],"overwrite") == 0) {
overwrite = 1;
iarg += 1;
} else if (strcmp(arg[iarg],"format") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
delete [] format_user;
int n = strlen(arg[iarg+1]) + 2;
format_user = new char[n];
sprintf(format_user," %s",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;

View File

@ -53,6 +53,7 @@ class FixAveTime : public Fix {
int ave,nwindow,startstep,mode;
int noff,overwrite;
int *offlist;
char *format,*format_user;
char *title1,*title2,*title3;
long filepos;