synchronize format handling and fix/compute/variable checking with dump custom
This commit is contained in:
@ -232,48 +232,36 @@ void DumpCustomMPIIO::init_style()
|
||||
// format = copy of default or user-specified line format
|
||||
|
||||
delete[] format;
|
||||
char *str;
|
||||
if (format_line_user)
|
||||
str = format_line_user;
|
||||
else
|
||||
str = format_default;
|
||||
|
||||
int n = strlen(str) + 1;
|
||||
format = new char[n];
|
||||
strcpy(format, str);
|
||||
if (format_line_user) format = utils::strdup(format_line_user);
|
||||
else format = utils::strdup(format_default);
|
||||
|
||||
// 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(nullptr, " \0");
|
||||
if (ptr == nullptr) error->all(FLERR, "Dump_modify format line is too short");
|
||||
auto words = utils::split_words(format);
|
||||
if ((int) words.size() < nfield)
|
||||
error->all(FLERR,"Dump_modify format line is too short");
|
||||
|
||||
int i=0;
|
||||
for (const auto &word : words) {
|
||||
delete[] vformat[i];
|
||||
|
||||
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] == Dump::INT && format_int_user) {
|
||||
vformat[i] = new char[strlen(format_int_user) + 2];
|
||||
strcpy(vformat[i], format_int_user);
|
||||
} else if (vtype[i] == Dump::DOUBLE && format_float_user) {
|
||||
vformat[i] = new char[strlen(format_float_user) + 2];
|
||||
strcpy(vformat[i], format_float_user);
|
||||
} else if (vtype[i] == Dump::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);
|
||||
}
|
||||
if (format_column_user[i])
|
||||
vformat[i] = utils::strdup(std::string(format_column_user[i]) + " ");
|
||||
else if (vtype[i] == Dump::INT && format_int_user)
|
||||
vformat[i] = utils::strdup(std::string(format_int_user) + " ");
|
||||
else if (vtype[i] == Dump::DOUBLE && format_float_user)
|
||||
vformat[i] = utils::strdup(std::string(format_float_user) + " ");
|
||||
else if (vtype[i] == Dump::BIGINT && format_bigint_user)
|
||||
vformat[i] = utils::strdup(std::string(format_bigint_user) + " ");
|
||||
else vformat[i] = utils::strdup(word + " ");
|
||||
|
||||
vformat[i] = strcat(vformat[i], " ");
|
||||
// remove trailing blank on last column's format
|
||||
if (i == nfield-1) vformat[i][strlen(vformat[i])-1] = '\0';
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
// setup boundary string
|
||||
@ -299,26 +287,22 @@ void DumpCustomMPIIO::init_style()
|
||||
// find current ptr for each compute,fix,variable
|
||||
// check that fix frequency is acceptable
|
||||
|
||||
int icompute;
|
||||
for (int i = 0; i < ncompute; i++) {
|
||||
icompute = modify->find_compute(id_compute[i]);
|
||||
if (icompute < 0) error->all(FLERR, "Could not find dump custom compute ID");
|
||||
compute[i] = modify->compute[icompute];
|
||||
for (i = 0; i < ncompute; i++) {
|
||||
compute[i] = modify->get_compute_by_id(id_compute[i]);
|
||||
if (!compute[i]) error->all(FLERR,"Could not find dump custom compute ID {}",id_compute[i]);
|
||||
}
|
||||
|
||||
int ifix;
|
||||
for (int i = 0; i < nfix; i++) {
|
||||
ifix = modify->find_fix(id_fix[i]);
|
||||
if (ifix < 0) error->all(FLERR, "Could not find dump custom fix ID");
|
||||
fix[i] = modify->fix[ifix];
|
||||
if (nevery % modify->fix[ifix]->peratom_freq)
|
||||
error->all(FLERR, "Dump custom and fix not computed at compatible times");
|
||||
for (i = 0; i < nfix; i++) {
|
||||
fix[i] = modify->get_fix_by_id(id_fix[i]);
|
||||
if (!fix[i]) error->all(FLERR,"Could not find dump custom fix ID {}", id_fix[i]);
|
||||
if (nevery % fix[i]->peratom_freq)
|
||||
error->all(FLERR,"Dump custom and fix not computed at compatible times");
|
||||
}
|
||||
|
||||
int ivariable;
|
||||
for (int i = 0; i < nvariable; i++) {
|
||||
ivariable = input->variable->find(id_variable[i]);
|
||||
if (ivariable < 0) error->all(FLERR, "Could not find dump custom variable name");
|
||||
for (i = 0; i < nvariable; i++) {
|
||||
int ivariable = input->variable->find(id_variable[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Could not find dump custom variable name {}", id_variable[i]);
|
||||
variable[i] = ivariable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user