add support for appending to files to fix ave/time
This commit is contained in:
@ -28,7 +28,7 @@ Syntax
|
|||||||
v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
|
v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
* zero or more keyword/arg pairs may be appended
|
* zero or more keyword/arg pairs may be appended
|
||||||
* keyword = *mode* or *file* or *ave* or *start* or *off* or *overwrite* or *format* or *title1* or *title2* or *title3*
|
* keyword = *mode* or *file* or *append* or *ave* or *start* or *off* or *overwrite* or *format* or *title1* or *title2* or *title3*
|
||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
@ -45,6 +45,8 @@ Syntax
|
|||||||
M = value # from 1 to Nvalues
|
M = value # from 1 to Nvalues
|
||||||
*file* arg = filename
|
*file* arg = filename
|
||||||
filename = name of file to output time averages to
|
filename = name of file to output time averages to
|
||||||
|
*append* arg = filename
|
||||||
|
filename = name of file to append time averages to
|
||||||
*overwrite* arg = none = overwrite output file with only latest output
|
*overwrite* arg = none = overwrite output file with only latest output
|
||||||
*format* arg = string
|
*format* arg = string
|
||||||
string = C-style format string
|
string = C-style format string
|
||||||
@ -270,16 +272,21 @@ are effectively constant or are simply current values (e.g., they are
|
|||||||
being written to a file with other time-averaged values for purposes
|
being written to a file with other time-averaged values for purposes
|
||||||
of creating well-formatted output).
|
of creating well-formatted output).
|
||||||
|
|
||||||
The *file* keyword allows a filename to be specified. Every *Nfreq*
|
.. versionadded:: TBD
|
||||||
steps, one quantity or vector of quantities is written to the file for
|
new keyword *append*
|
||||||
each input value specified in the fix ave/time command. For *mode* =
|
|
||||||
scalar, this means a single line is written each time output is
|
The *file* or *append* keywords allow a filename to be specified. If
|
||||||
performed. Thus the file ends up to be a series of lines, i.e. one
|
*file* is used, then the filename is overwritten if it already exists.
|
||||||
column of numbers for each input value. For *mode* = vector, an array
|
If *append* is used, then the filename is appended to if it already
|
||||||
of numbers is written each time output is performed. The number of rows
|
exists, or created if it does not exist. Every *Nfreq* steps, one
|
||||||
is the length of the input vectors, and the number of columns is the
|
quantity or vector of quantities is written to the file for each input
|
||||||
number of values. Thus the file ends up to be a series of these array
|
value specified in the fix ave/time command. For *mode* = scalar, this
|
||||||
sections.
|
means a single line is written each time output is performed. Thus the
|
||||||
|
file ends up to be a series of lines, i.e. one column of numbers for
|
||||||
|
each input value. For *mode* = vector, an array of numbers is written
|
||||||
|
each time output is performed. The number of rows is the length of the
|
||||||
|
input vectors, and the number of columns is the number of values. Thus
|
||||||
|
the file ends up to be a series of these array sections.
|
||||||
|
|
||||||
.. versionadded:: 4May2022
|
.. versionadded:: 4May2022
|
||||||
|
|
||||||
|
|||||||
@ -1033,11 +1033,13 @@ void FixAveTime::options(int iarg, int narg, char **arg)
|
|||||||
// optional args
|
// optional args
|
||||||
|
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"file") == 0) {
|
if ((strcmp(arg[iarg],"file") == 0) || (strcmp(arg[iarg],"append") == 0)) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
|
if (iarg+2 > narg)
|
||||||
|
utils::missing_cmd_args(FLERR, std::string("fix ave/time ")+arg[iarg], error);
|
||||||
yaml_flag = utils::strmatch(arg[iarg+1],"\\.[yY][aA]?[mM][lL]$");
|
yaml_flag = utils::strmatch(arg[iarg+1],"\\.[yY][aA]?[mM][lL]$");
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
fp = fopen(arg[iarg+1],"w");
|
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
||||||
|
else fp = fopen(arg[iarg+1],"a");
|
||||||
if (fp == nullptr)
|
if (fp == nullptr)
|
||||||
error->one(FLERR,"Cannot open fix ave/time file {}: {}",
|
error->one(FLERR,"Cannot open fix ave/time file {}: {}",
|
||||||
arg[iarg+1], utils::getsyserror());
|
arg[iarg+1], utils::getsyserror());
|
||||||
|
|||||||
Reference in New Issue
Block a user