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