From b44d840bfb55c015d107efbeb7c3e7816775b343 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 9 Mar 2011 21:19:59 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5774 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/dump.cpp | 17 +++++++++++++++-- src/dump.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index d082ac29d6..14a9e4288f 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -70,6 +70,7 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) clearstep = 0; sort_flag = 0; append_flag = 0; + padflag = 0; maxbuf = maxids = maxsort = maxproc = 0; buf = bufsort = NULL; @@ -359,8 +360,15 @@ void Dump::openfile() filecurrent = new char[strlen(filename) + 16]; char *ptr = strchr(filename,'*'); *ptr = '\0'; - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filename,update->ntimestep,ptr+1); + if (padflag == 0) + sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", + filename,update->ntimestep,ptr+1); + else { + char bif[8],pad[16]; + strcpy(bif,BIGINT_FORMAT); + sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); + sprintf(filecurrent,pad,filename,update->ntimestep,ptr+1); + } *ptr = '*'; } @@ -666,6 +674,11 @@ void Dump::modify_params(int narg, char **arg) strcpy(format_user,arg[iarg+1]); } iarg += 2; + } else if (strcmp(arg[iarg],"pad") == 0) { + if (iarg+2 > narg) error->all("Illegal dump_modify command"); + padflag = atoi(arg[iarg+1]); + if (padflag < 0) error->all("Illegal dump_modify command"); + iarg += 2; } else if (strcmp(arg[iarg],"sort") == 0) { if (iarg+2 > narg) error->all("Illegal dump_modify command"); if (strcmp(arg[iarg+1],"off") == 0) sort_flag = 0; diff --git a/src/dump.h b/src/dump.h index 0f50c20bfa..1dd7a6e5a9 100644 --- a/src/dump.h +++ b/src/dump.h @@ -36,7 +36,7 @@ class Dump : protected Pointers { Dump(class LAMMPS *, int, char **); virtual ~Dump(); void init(); - void write(); + virtual void write(); void modify_params(int, char **); virtual double memory_usage(); @@ -53,6 +53,7 @@ class Dump : protected Pointers { int flush_flag; // 0 if no flush, 1 if flush every dump int sort_flag; // 1 if sorted output int append_flag; // 1 if open file in append mode, 0 if not + int padflag; // timestep padding in filename int singlefile_opened; // 1 = one big file, already opened, else 0 int sortcol; // 0 to sort on ID, 1-N on columns int sortcolm1; // sortcol - 1