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

@ -201,13 +201,14 @@ void DumpAtomMPIIO::init_style()
if (image_flag == 0) size_one = 5; if (image_flag == 0) size_one = 5;
else size_one = 8; else size_one = 8;
// default format depends on image flags // format = copy of default or user-specified line format
// default depends on image flags
delete [] format; delete [] format;
if (format_user) { if (format_line_user) {
int n = strlen(format_user) + 2; int n = strlen(format_line_user) + 2;
format = new char[n]; format = new char[n];
strcpy(format,format_user); strcpy(format,format_line_user);
strcat(format,"\n"); strcat(format,"\n");
} else { } else {
char *str; char *str;

View File

@ -221,36 +221,46 @@ void DumpCustomMPIIO::write()
void DumpCustomMPIIO::init_style() void DumpCustomMPIIO::init_style()
{ {
// format = copy of default or user-specified line format
delete [] format; delete [] format;
char *str; char *str;
if (format_user) str = format_user; if (format_line_user) str = format_line_user;
else str = format_default; else str = format_default;
int n = strlen(str) + 1; int n = strlen(str) + 1;
format = new char[n]; format = new char[n];
strcpy(format,str); strcpy(format,str);
// default for element names = C
if (typenames == NULL) {
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[2];
strcpy(typenames[itype],"C");
}
}
// tokenize the format string and add space at end of each format element // 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; char *ptr;
for (int i = 0; i < size_one; i++) { for (int i = 0; i < size_one; i++) {
if (i == 0) ptr = strtok(format," \0"); if (i == 0) ptr = strtok(format," \0");
else ptr = strtok(NULL," \0"); else ptr = strtok(NULL," \0");
if (ptr == NULL) error->all(FLERR,"Dump_modify format string is too short"); if (ptr == NULL) error->all(FLERR,"Dump_modify format line is too short");
delete [] vformat[i]; 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 if (vtype[i] == BIGINT && format_bigint_user) {
vformat[i] = new char[strlen(format_bigint_user) + 2];
strcpy(vformat[i],format_bigint_user);
} else {
vformat[i] = new char[strlen(ptr) + 2];
strcpy(vformat[i],ptr);
}
vformat[i] = strcat(vformat[i]," "); vformat[i] = strcat(vformat[i]," ");
} }

View File

@ -220,9 +220,11 @@ void DumpXYZMPIIO::write()
void DumpXYZMPIIO::init_style() void DumpXYZMPIIO::init_style()
{ {
// format = copy of default or user-specified line format
delete [] format; delete [] format;
char *str; char *str;
if (format_user) str = format_user; if (format_line_user) str = format_line_user;
else str = format_default; else str = format_default;
int n = strlen(str) + 2; int n = strlen(str) + 2;

View File

@ -65,9 +65,16 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
first_flag = 0; first_flag = 0;
flush_flag = 1; flush_flag = 1;
format = NULL; format = NULL;
format_user = NULL;
format_default = NULL; format_default = NULL;
format_line_user = NULL;
format_float_user = NULL;
format_int_user = NULL;
format_bigint_user = NULL;
format_column_user = NULL;
clearstep = 0; clearstep = 0;
sort_flag = 0; sort_flag = 0;
append_flag = 0; append_flag = 0;
@ -140,7 +147,12 @@ Dump::~Dump()
delete [] format; delete [] format;
delete [] format_default; delete [] format_default;
delete [] format_user; delete [] format_line_user;
delete [] format_float_user;
delete [] format_int_user;
delete [] format_bigint_user;
// format_column_user is deallocated by child classes that use it
memory->destroy(buf); memory->destroy(buf);
memory->destroy(bufsort); memory->destroy(bufsort);
@ -805,14 +817,37 @@ void Dump::modify_params(int narg, char **arg)
} else if (strcmp(arg[iarg],"format") == 0) { } else if (strcmp(arg[iarg],"format") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
delete [] format_user;
format_user = NULL; if (strcmp(arg[iarg+1],"none") == 0) {
if (strcmp(arg[iarg+1],"none")) { delete [] format_line_user;
int n = strlen(arg[iarg+1]) + 1; delete [] format_int_user;
format_user = new char[n]; delete [] format_bigint_user;
strcpy(format_user,arg[iarg+1]); delete [] format_float_user;
format_line_user = NULL;
format_int_user = NULL;
format_bigint_user = NULL;
format_float_user = NULL;
// pass format none to child classes which may use it
// not an error if they don't
printf("CALL %d %s\n",narg-iarg,arg[iarg]);
int n = modify_param(narg-iarg,&arg[iarg]);
iarg += 2;
continue;
}
if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[iarg+1],"line") == 0) {
delete [] format_line_user;
int n = strlen(arg[iarg+2]) + 1;
format_line_user = new char[n];
strcpy(format_line_user,arg[iarg+2]);
iarg += 3;
} else { // pass other format options to child classes
int n = modify_param(narg-iarg,&arg[iarg]);
if (n == 0) error->all(FLERR,"Illegal dump_modify command");
iarg += n;
} }
iarg += 2;
} else if (strcmp(arg[iarg],"nfile") == 0) { } else if (strcmp(arg[iarg],"nfile") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");

View File

@ -77,9 +77,16 @@ class Dump : protected Pointers {
int sortorder; // ASCEND or DESCEND int sortorder; // ASCEND or DESCEND
char boundstr[9]; // encoding of boundary flags char boundstr[9]; // encoding of boundary flags
char *format_default; // default format string
char *format_user; // format string set by user
char *format; // format string for the file write char *format; // format string for the file write
char *format_default; // default format string
char *format_line_user; // user-specified format strings
char *format_float_user;
char *format_int_user;
char *format_bigint_user;
char **format_column_user;
FILE *fp; // file to write dump to FILE *fp; // file to write dump to
int size_one; // # of quantities for one atom int size_one; // # of quantities for one atom
int nme; // # of atoms in this dump from me int nme; // # of atoms in this dump from me

View File

@ -45,13 +45,14 @@ void DumpAtom::init_style()
if (image_flag == 0) size_one = 5; if (image_flag == 0) size_one = 5;
else size_one = 8; else size_one = 8;
// default format depends on image flags // format = copy of default or user-specified line format
// default depends on image flags
delete [] format; delete [] format;
if (format_user) { if (format_line_user) {
int n = strlen(format_user) + 2; int n = strlen(format_line_user) + 2;
format = new char[n]; format = new char[n];
strcpy(format,format_user); strcpy(format,format_line_user);
strcat(format,"\n"); strcat(format,"\n");
} else { } else {
char *str; char *str;

View File

@ -134,10 +134,14 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
dchoose = NULL; dchoose = NULL;
clist = NULL; clist = NULL;
// element names // default element name for all types = C
ntypes = atom->ntypes; ntypes = atom->ntypes;
typenames = NULL; typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[2];
strcpy(typenames[itype],"C");
}
// setup format strings // setup format strings
@ -154,6 +158,9 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
vformat[i] = NULL; 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 // setup column string
int n = 0; int n = 0;
@ -210,14 +217,15 @@ DumpCustom::~DumpCustom()
memory->destroy(dchoose); memory->destroy(dchoose);
memory->destroy(clist); memory->destroy(clist);
if (typenames) { for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
for (int i = 1; i <= ntypes; i++) delete [] typenames[i]; delete [] typenames;
delete [] typenames;
}
for (int i = 0; i < size_one; i++) delete [] vformat[i]; for (int i = 0; i < size_one; i++) delete [] vformat[i];
delete [] vformat; delete [] vformat;
for (int i = 0; i < size_one; i++) delete [] format_column_user[i];
delete [] format_column_user;
delete [] columns; delete [] columns;
} }
@ -225,35 +233,46 @@ DumpCustom::~DumpCustom()
void DumpCustom::init_style() void DumpCustom::init_style()
{ {
// format = copy of default or user-specified line format
delete [] format; delete [] format;
char *str; char *str;
if (format_user) str = format_user; if (format_line_user) str = format_line_user;
else str = format_default; else str = format_default;
int n = strlen(str) + 1; int n = strlen(str) + 1;
format = new char[n]; format = new char[n];
strcpy(format,str); strcpy(format,str);
// default for element names = C
if (typenames == NULL) {
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[2];
strcpy(typenames[itype],"C");
}
}
// tokenize the format string and add space at end of each format element // 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; char *ptr;
for (int i = 0; i < size_one; i++) { for (int i = 0; i < size_one; i++) {
if (i == 0) ptr = strtok(format," \0"); if (i == 0) ptr = strtok(format," \0");
else ptr = strtok(NULL," \0"); else ptr = strtok(NULL," \0");
if (ptr == NULL) error->all(FLERR,"Dump_modify format string is too short"); if (ptr == NULL) error->all(FLERR,"Dump_modify format line is too short");
delete [] vformat[i]; 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 if (vtype[i] == BIGINT && format_bigint_user) {
vformat[i] = new char[strlen(format_bigint_user) + 2];
strcpy(vformat[i],format_bigint_user);
} else {
vformat[i] = new char[strlen(ptr) + 2];
strcpy(vformat[i],ptr);
}
vformat[i] = strcat(vformat[i]," "); vformat[i] = strcat(vformat[i]," ");
} }
@ -1493,16 +1512,64 @@ int DumpCustom::modify_param(int narg, char **arg)
return 2; return 2;
} }
if (strcmp(arg[0],"element") == 0) { if (strcmp(arg[0],"format") == 0) {
if (narg < ntypes+1) if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
error->all(FLERR,"Dump modify element names do not match atom types");
if (typenames) { if (strcmp(arg[1],"none") == 0) {
for (int i = 1; i <= ntypes; i++) delete [] typenames[i]; // just clear format_column_user allocated by this dump child class
delete [] typenames; for (int i = 0; i < size_one; i++) {
typenames = NULL; delete [] format_column_user[i];
format_column_user[i] = NULL;
}
return 2;
} }
if (narg < 3) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[1],"int") == 0) {
delete [] format_int_user;
int n = strlen(arg[2]) + 1;
format_int_user = new char[n];
strcpy(format_int_user,arg[2]);
delete [] format_bigint_user;
n = strlen(format_int_user) + 8;
format_bigint_user = new char[n];
// replace "d" in format_int_user with bigint format specifier
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
char *ptr = strchr(format_int_user,'d');
if (ptr == NULL)
error->all(FLERR,
"Dump_modify int format does not contain d character");
char str[8];
sprintf(str,"%s",BIGINT_FORMAT);
*ptr = '\0';
sprintf(format_bigint_user,"%s%s%s",format_int_user,&str[1],ptr+1);
*ptr = 'd';
} else if (strcmp(arg[1],"float") == 0) {
delete [] format_float_user;
int n = strlen(arg[2]) + 1;
format_float_user = new char[n];
strcpy(format_float_user,arg[2]);
} else {
int i = force->inumeric(FLERR,arg[1]) - 1;
if (i < 0 || i >= size_one)
error->all(FLERR,"Illegal dump_modify command");
if (format_column_user[i]) delete [] format_column_user[i];
int n = strlen(arg[2]) + 1;
format_column_user[i] = new char[n];
strcpy(format_column_user[i],arg[2]);
}
return 3;
}
if (strcmp(arg[0],"element") == 0) {
if (narg < ntypes+1)
error->all(FLERR,"Dump_modify element names do not match atom types");
for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
delete [] typenames;
typenames = new char*[ntypes+1]; typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) { for (int itype = 1; itype <= ntypes; itype++) {
int n = strlen(arg[itype]) + 1; int n = strlen(arg[itype]) + 1;

View File

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

View File

@ -68,9 +68,11 @@ DumpXYZ::~DumpXYZ()
void DumpXYZ::init_style() void DumpXYZ::init_style()
{ {
// format = copy of default or user-specified line format
delete [] format; delete [] format;
char *str; char *str;
if (format_user) str = format_user; if (format_line_user) str = format_line_user;
else str = format_default; else str = format_default;
int n = strlen(str) + 2; int n = strlen(str) + 2;

View File

@ -180,6 +180,7 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
sprintf(format_bigint_one_def,"%%8%s",&bigint_format[1]); sprintf(format_bigint_one_def,"%%8%s",&bigint_format[1]);
sprintf(format_bigint_multi_def,"%%14%s",&bigint_format[1]); sprintf(format_bigint_multi_def,"%%14%s",&bigint_format[1]);
format_line_user = NULL;
format_float_user = NULL; format_float_user = NULL;
format_int_user = NULL; format_int_user = NULL;
format_bigint_user = NULL; format_bigint_user = NULL;
@ -195,7 +196,8 @@ Thermo::~Thermo()
deallocate(); deallocate();
// format strings // format strings
delete [] format_line_user;
delete [] format_float_user; delete [] format_float_user;
delete [] format_int_user; delete [] format_int_user;
delete [] format_bigint_user; delete [] format_bigint_user;
@ -225,22 +227,37 @@ void Thermo::init()
// add '/n' every 3 values if lineflag = MULTILINE // add '/n' every 3 values if lineflag = MULTILINE
// add trailing '/n' to last value // add trailing '/n' to last value
char *ptr; char *format_line = NULL;
if (format_line_user) {
int n = strlen(format_line_user) + 1;
format_line = new char[n];
strcpy(format_line,format_line_user);
}
char *ptr,*format_line_ptr;
for (i = 0; i < nfield; i++) { for (i = 0; i < nfield; i++) {
format[i][0] = '\0'; format[i][0] = '\0';
if (lineflag == MULTILINE && i % 3 == 0) strcat(format[i],"\n"); if (lineflag == MULTILINE && i % 3 == 0) strcat(format[i],"\n");
if (format_user[i]) ptr = format_user[i]; if (format_line) {
if (i == 0) format_line_ptr = strtok(format_line," \0");
else format_line_ptr = strtok(NULL," \0");
}
if (format_column_user[i]) ptr = format_column_user[i];
else if (vtype[i] == FLOAT) { else if (vtype[i] == FLOAT) {
if (format_float_user) ptr = format_float_user; if (format_float_user) ptr = format_float_user;
else if (format_line_user) ptr = format_line_ptr;
else if (lineflag == ONELINE) ptr = format_float_one_def; else if (lineflag == ONELINE) ptr = format_float_one_def;
else if (lineflag == MULTILINE) ptr = format_float_multi_def; else if (lineflag == MULTILINE) ptr = format_float_multi_def;
} else if (vtype[i] == INT) { } else if (vtype[i] == INT) {
if (format_int_user) ptr = format_int_user; if (format_int_user) ptr = format_int_user;
else if (format_line_user) ptr = format_line_ptr;
else if (lineflag == ONELINE) ptr = format_int_one_def; else if (lineflag == ONELINE) ptr = format_int_one_def;
else if (lineflag == MULTILINE) ptr = format_int_multi_def; else if (lineflag == MULTILINE) ptr = format_int_multi_def;
} else if (vtype[i] == BIGINT) { } else if (vtype[i] == BIGINT) {
if (format_bigint_user) ptr = format_bigint_user; if (format_bigint_user) ptr = format_bigint_user;
else if (format_line_user) ptr = format_line_ptr;
else if (lineflag == ONELINE) ptr = format_bigint_one_def; else if (lineflag == ONELINE) ptr = format_bigint_one_def;
else if (lineflag == MULTILINE) ptr = format_bigint_multi_def; else if (lineflag == MULTILINE) ptr = format_bigint_multi_def;
} }
@ -248,9 +265,10 @@ void Thermo::init()
n = strlen(format[i]); n = strlen(format[i]);
if (lineflag == ONELINE) sprintf(&format[i][n],"%s ",ptr); if (lineflag == ONELINE) sprintf(&format[i][n],"%s ",ptr);
else sprintf(&format[i][n],"%-8s = %s ",keyword[i],ptr); else sprintf(&format[i][n],"%-8s = %s ",keyword[i],ptr);
if (i == nfield-1) strcat(format[i],"\n");
} }
strcat(format[nfield-1],"\n");
delete [] format_line;
// find current ptr for each Compute ID // find current ptr for each Compute ID
@ -540,22 +558,50 @@ void Thermo::modify_params(int narg, char **arg)
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"format") == 0) { } else if (strcmp(arg[iarg],"format") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command");
if (strcmp(arg[iarg+1],"none") == 0) {
delete [] format_line_user;
delete [] format_int_user;
delete [] format_bigint_user;
delete [] format_float_user;
format_line_user = NULL;
format_int_user = NULL;
format_bigint_user = NULL;
format_float_user = NULL;
for (int i = 0; i < nfield_initial; i++) {
delete [] format_column_user[i];
format_column_user[i] = NULL;
}
iarg += 2;
continue;
}
if (iarg+3 > narg) error->all(FLERR,"Illegal thermo_modify command"); if (iarg+3 > narg) error->all(FLERR,"Illegal thermo_modify command");
if (strcmp(arg[iarg+1],"int") == 0) {
if (strcmp(arg[iarg+1],"line") == 0) {
delete [] format_line_user;
int n = strlen(arg[iarg+2]) + 1;
format_line_user = new char[n];
strcpy(format_line_user,arg[iarg+2]);
} else if (strcmp(arg[iarg+1],"int") == 0) {
if (format_int_user) delete [] format_int_user; if (format_int_user) delete [] format_int_user;
int n = strlen(arg[iarg+2]) + 1; int n = strlen(arg[iarg+2]) + 1;
format_int_user = new char[n]; format_int_user = new char[n];
strcpy(format_int_user,arg[iarg+2]); strcpy(format_int_user,arg[iarg+2]);
if (format_bigint_user) delete [] format_bigint_user; if (format_bigint_user) delete [] format_bigint_user;
n = strlen(format_int_user) + 3; n = strlen(format_int_user) + 8;
format_bigint_user = new char[n]; format_bigint_user = new char[n];
// replace "d" in format_int_user with bigint format specifier
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
char *ptr = strchr(format_int_user,'d'); char *ptr = strchr(format_int_user,'d');
if (ptr == NULL) if (ptr == NULL)
error->all(FLERR, error->all(FLERR,
"Thermo_modify int format does not contain d character"); "Thermo_modify int format does not contain d character");
char str[8];
sprintf(str,"%s",BIGINT_FORMAT);
*ptr = '\0'; *ptr = '\0';
sprintf(format_bigint_user,"%s%s%s",format_int_user, sprintf(format_bigint_user,"%s%s%s",format_int_user,&str[1],ptr+1);
BIGINT_FORMAT,ptr+1);
*ptr = 'd'; *ptr = 'd';
} else if (strcmp(arg[iarg+1],"float") == 0) { } else if (strcmp(arg[iarg+1],"float") == 0) {
if (format_float_user) delete [] format_float_user; if (format_float_user) delete [] format_float_user;
@ -566,10 +612,10 @@ void Thermo::modify_params(int narg, char **arg)
int i = force->inumeric(FLERR,arg[iarg+1]) - 1; int i = force->inumeric(FLERR,arg[iarg+1]) - 1;
if (i < 0 || i >= nfield_initial) if (i < 0 || i >= nfield_initial)
error->all(FLERR,"Illegal thermo_modify command"); error->all(FLERR,"Illegal thermo_modify command");
if (format_user[i]) delete [] format_user[i]; if (format_column_user[i]) delete [] format_column_user[i];
int n = strlen(arg[iarg+2]) + 1; int n = strlen(arg[iarg+2]) + 1;
format_user[i] = new char[n]; format_column_user[i] = new char[n];
strcpy(format_user[i],arg[iarg+2]); strcpy(format_column_user[i],arg[iarg+2]);
} }
iarg += 3; iarg += 3;
@ -594,8 +640,8 @@ void Thermo::allocate()
format = new char*[n]; format = new char*[n];
for (int i = 0; i < n; i++) format[i] = new char[32]; for (int i = 0; i < n; i++) format[i] = new char[32];
format_user = new char*[n]; format_column_user = new char*[n];
for (int i = 0; i < n; i++) format_user[i] = NULL; for (int i = 0; i < n; i++) format_column_user[i] = NULL;
field2index = new int[n]; field2index = new int[n];
argindex1 = new int[n]; argindex1 = new int[n];
@ -632,8 +678,8 @@ void Thermo::deallocate()
for (int i = 0; i < n; i++) delete [] format[i]; for (int i = 0; i < n; i++) delete [] format[i];
delete [] format; delete [] format;
for (int i = 0; i < n; i++) delete [] format_user[i]; for (int i = 0; i < n; i++) delete [] format_column_user[i];
delete [] format_user; delete [] format_column_user;
delete [] field2index; delete [] field2index;
delete [] argindex1; delete [] argindex1;

View File

@ -45,10 +45,13 @@ class Thermo : protected Pointers {
int nfield,nfield_initial; int nfield,nfield_initial;
int me; int me;
char **format,**format_user; char **format;
char *format_line_user;
char *format_float_user,*format_int_user,*format_bigint_user;
char **format_column_user;
char *format_float_one_def,*format_float_multi_def; char *format_float_one_def,*format_float_multi_def;
char *format_int_one_def,*format_int_multi_def; char *format_int_one_def,*format_int_multi_def;
char *format_float_user,*format_int_user,*format_bigint_user;
char format_multi[128]; char format_multi[128];
char format_bigint_one_def[8],format_bigint_multi_def[8]; char format_bigint_one_def[8],format_bigint_multi_def[8];