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

This commit is contained in:
sjplimp
2016-08-03 16:09:38 +00:00
parent 56502c7c09
commit 38226b8086
11 changed files with 284 additions and 86 deletions

View File

@ -45,7 +45,6 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) :
nevery = force->inumeric(FLERR,arg[3]);
if (nevery <= 0) error->all(FLERR,"Illegal dump local command");
size_one = nfield = narg-5;
pack_choice = new FnPtrPack[nfield];
vtype = new int[nfield];
@ -78,11 +77,14 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) :
format_default[0] = '\0';
for (int i = 0; i < size_one; i++) {
if (vtype[i] == INT) format_default = strcat(format_default,"%d ");
else format_default = strcat(format_default,"%g ");
if (vtype[i] == INT) strcat(format_default,"%d ");
else if (vtype[i] == DOUBLE) strcat(format_default,"%g ");
vformat[i] = NULL;
}
format_column_user = new char*[size_one];
for (int i = 0; i < size_one; i++) format_column_user[i] = NULL;
// setup column string
int n = 0;
@ -122,6 +124,9 @@ DumpLocal::~DumpLocal()
for (int i = 0; i < size_one; i++) delete [] vformat[i];
delete [] vformat;
for (int i = 0; i < size_one; i++) delete [] format_column_user[i];
delete [] format_column_user;
delete [] columns;
delete [] label;
}
@ -133,9 +138,11 @@ void DumpLocal::init_style()
if (sort_flag && sortcol == 0)
error->all(FLERR,"Dump local cannot sort by atom ID");
// format = copy of default or user-specified line format
delete [] format;
char *str;
if (format_user) str = format_user;
if (format_line_user) str = format_line_user;
else str = format_default;
int n = strlen(str) + 1;
@ -143,14 +150,31 @@ void DumpLocal::init_style()
strcpy(format,str);
// tokenize the format string and add space at end of each format element
// if user-specified int/float format exists, use it instead
// if user-specified column format exists, use it instead
// lo priority = line, medium priority = int/float, hi priority = column
char *ptr;
for (int i = 0; i < size_one; i++) {
if (i == 0) ptr = strtok(format," \0");
else ptr = strtok(NULL," \0");
if (ptr == NULL) error->all(FLERR,"Dump_modify format line is too short");
delete [] vformat[i];
vformat[i] = new char[strlen(ptr) + 2];
strcpy(vformat[i],ptr);
if (format_column_user[i]) {
vformat[i] = new char[strlen(format_column_user[i]) + 2];
strcpy(vformat[i],format_column_user[i]);
} else if (vtype[i] == INT && format_int_user) {
vformat[i] = new char[strlen(format_int_user) + 2];
strcpy(vformat[i],format_int_user);
} else if (vtype[i] == DOUBLE && format_float_user) {
vformat[i] = new char[strlen(format_float_user) + 2];
strcpy(vformat[i],format_float_user);
} else {
vformat[i] = new char[strlen(ptr) + 2];
strcpy(vformat[i],ptr);
}
vformat[i] = strcat(vformat[i]," ");
}