Unverified Commit ca6920be authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #907 from akohlmey/dump_maxfile

Implement 'dump_modify maxfiles' feature
parents 3440b1a2 77e04a92
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ dump_modify dump-ID keyword values ... :pre
dump-ID = ID of dump to modify :ulb,l
one or more keyword/value pairs may be appended :l
these keywords apply to various dump styles :l
keyword = {append} or {at} or {buffer} or {delay} or {element} or {every} or {fileper} or {first} or {flush} or {format} or {image} or {label} or {nfile} or {pad} or {precision} or {region} or {scale} or {sort} or {thresh} or {unwrap} :l
keyword = {append} or {at} or {buffer} or {delay} or {element} or {every} or {fileper} or {first} or {flush} or {format} or {image} or {label} or {maxfiles} or {nfile} or {pad} or {precision} or {region} or {scale} or {sort} or {thresh} or {unwrap} :l
  {append} arg = {yes} or {no}
  {at} arg = N
    N = index of frame written upon first dump
@@ -37,6 +37,8 @@ keyword = {append} or {at} or {buffer} or {delay} or {element} or {every} or {fi
  {image} arg = {yes} or {no}
  {label} arg = string
    string = character string (e.g. BONDS) to use in header of dump local file
  {maxfiles} arg = Fmax
    Fmax = keep only the most recent {Fmax} snapshots (one snapshot per file)
  {nfile} arg = Nf
    Nf = write this many files, one from each of Nf processors
  {pad} arg = Nchar = # of characters to convert timestep to
@@ -364,6 +366,20 @@ e.g. BONDS or ANGLES.

:line

The {maxfiles} keyword can only be used when a '*' wildcard is
included in the dump file name, i.e. when writing a new file(s) for
each snapshot.  The specified {Fmax} is how many snapshots will be
kept.  Once this number is reached, the file(s) containing the oldest
snapshot is deleted before a new dump file is written.  If the
specified {Fmax} <= 0, then all files are retained.

This can be useful for debugging, especially if you don't know on what
timestep something bad will happen, e.g. when LAMMPS will exit with an
error.  You can dump every timestep, and limit the number of dump
files produced, even if you run for 1000s of steps.

:line

The {nfile} or {fileper} keywords can be used in conjunction with the
"%" wildcard character in the specified dump file name, for all dump
styles except the {dcd}, {image}, {movie}, {xtc}, and {xyz} styles
@@ -901,6 +917,7 @@ flush = yes
format = %d and %g for each integer or floating point value
image = no
label = ENTRIES
maxifiles = -1
nfile = 1
pad = 0
pbc = no
+10 −0
Original line number Diff line number Diff line
#ifndef _WIN32
#include <alloca.h>
#endif
#include "Function.h"
#include "ATC_Error.h"
#include "LammpsInterface.h"
@@ -59,7 +61,11 @@ namespace ATC {
  {
    string type = args[0];
    int narg = nargs -1;
#ifdef _WIN32
    double *dargs = (double *) _alloca(sizeof(double) * narg);
#endif
    double *dargs = (double *) alloca(sizeof(double) * narg);
#endif
    for (int i = 0; i < narg; ++i) dargs[i] = atof(args[i+1]);
  
    return function(type, narg, dargs);
@@ -193,7 +199,11 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = NULL;
  {
    string type = args[0];
    int narg = nargs -1;
#ifdef _WIN32
    double *dargs = (double *) _alloca(sizeof(double) * narg);
#else
    double *dargs = (double *) alloca(sizeof(double) * narg);
#endif
    for (int i = 0; i < narg; ++i) dargs[i] = atof(args[i+1]);
  
    return function(type, narg, dargs);
+13 −0
Original line number Diff line number Diff line
@@ -71,6 +71,19 @@ void DumpAtomGZ::openfile()
      sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
    }
    *ptr = '*';
    if (maxfiles > 0) {
      if (numfiles < maxfiles) {
        nameslist[numfiles] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[numfiles],filecurrent);
        ++numfiles;
      } else {
        remove(nameslist[fileidx]);
        delete[] nameslist[fileidx];
        nameslist[fileidx] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[fileidx],filecurrent);
        fileidx = (fileidx + 1) % maxfiles;
      }
    }
  }

  // each proc with filewriter = 1 opens a file
+13 −0
Original line number Diff line number Diff line
@@ -75,6 +75,19 @@ void DumpCFGGZ::openfile()
      sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
    }
    *ptr = '*';
    if (maxfiles > 0) {
      if (numfiles < maxfiles) {
        nameslist[numfiles] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[numfiles],filecurrent);
        ++numfiles;
      } else {
        remove(nameslist[fileidx]);
        delete[] nameslist[fileidx];
        nameslist[fileidx] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[fileidx],filecurrent);
        fileidx = (fileidx + 1) % maxfiles;
      }
    }
  }

  // each proc with filewriter = 1 opens a file
+13 −0
Original line number Diff line number Diff line
@@ -73,6 +73,19 @@ void DumpCustomGZ::openfile()
      sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
    }
    *ptr = '*';
    if (maxfiles > 0) {
      if (numfiles < maxfiles) {
        nameslist[numfiles] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[numfiles],filecurrent);
        ++numfiles;
      } else {
        remove(nameslist[fileidx]);
        delete[] nameslist[fileidx];
        nameslist[fileidx] = new char[strlen(filecurrent)+1];
        strcpy(nameslist[fileidx],filecurrent);
        fileidx = (fileidx + 1) % maxfiles;
      }
    }
  }

  // each proc with filewriter = 1 opens a file
Loading