simplify, reformat, and better error messages
This commit is contained in:
@ -1429,6 +1429,7 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||||
argindex[iarg] = argi.get_index1();
|
argindex[iarg] = argi.get_index1();
|
||||||
|
auto name = argi.get_name();
|
||||||
|
|
||||||
switch (argi.get_type()) {
|
switch (argi.get_type()) {
|
||||||
|
|
||||||
@ -1443,21 +1444,19 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
pack_choice[iarg] = &DumpCustom::pack_compute;
|
pack_choice[iarg] = &DumpCustom::pack_compute;
|
||||||
vtype[iarg] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
n = modify->find_compute(argi.get_name());
|
n = modify->find_compute(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump custom compute ID");
|
if (n < 0) error->all(FLERR,"Could not find dump custom compute ID: {}",name);
|
||||||
if (modify->compute[n]->peratom_flag == 0)
|
if (modify->compute[n]->peratom_flag == 0)
|
||||||
error->all(FLERR,"Dump custom compute does not compute per-atom info");
|
error->all(FLERR,"Dump custom compute {} does not compute per-atom info",name);
|
||||||
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
|
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump custom compute {} does not calculate per-atom vector",name);
|
||||||
"Dump custom compute does not calculate per-atom vector");
|
|
||||||
if (argi.get_dim() > 0 && modify->compute[n]->size_peratom_cols == 0)
|
if (argi.get_dim() > 0 && modify->compute[n]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump custom compute {} does not calculate per-atom array",name);
|
||||||
"Dump custom compute does not calculate per-atom array");
|
|
||||||
if (argi.get_dim() > 0 &&
|
if (argi.get_dim() > 0 &&
|
||||||
argi.get_index1() > modify->compute[n]->size_peratom_cols)
|
argi.get_index1() > modify->compute[n]->size_peratom_cols)
|
||||||
error->all(FLERR,"Dump custom compute vector is accessed out-of-range");
|
error->all(FLERR,"Dump custom compute {} vector is accessed out-of-range",name);
|
||||||
|
|
||||||
field2index[iarg] = add_compute(argi.get_name());
|
field2index[iarg] = add_compute(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// fix value = f_ID
|
// fix value = f_ID
|
||||||
@ -1467,19 +1466,19 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
pack_choice[iarg] = &DumpCustom::pack_fix;
|
pack_choice[iarg] = &DumpCustom::pack_fix;
|
||||||
vtype[iarg] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
n = modify->find_fix(argi.get_name());
|
n = modify->find_fix(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump custom fix ID");
|
if (n < 0) error->all(FLERR,"Could not find dump custom fix ID: {}",name);
|
||||||
if (modify->fix[n]->peratom_flag == 0)
|
if (modify->fix[n]->peratom_flag == 0)
|
||||||
error->all(FLERR,"Dump custom fix does not compute per-atom info");
|
error->all(FLERR,"Dump custom fix {} does not compute per-atom info",name);
|
||||||
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
|
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
|
||||||
error->all(FLERR,"Dump custom fix does not compute per-atom vector");
|
error->all(FLERR,"Dump custom fix {} does not compute per-atom vector",name);
|
||||||
if (argi.get_dim() > 0 && modify->fix[n]->size_peratom_cols == 0)
|
if (argi.get_dim() > 0 && modify->fix[n]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,"Dump custom fix does not compute per-atom array");
|
error->all(FLERR,"Dump custom fix {} does not compute per-atom array",name);
|
||||||
if (argi.get_dim() > 0 &&
|
if (argi.get_dim() > 0 &&
|
||||||
argi.get_index1() > modify->fix[n]->size_peratom_cols)
|
argi.get_index1() > modify->fix[n]->size_peratom_cols)
|
||||||
error->all(FLERR,"Dump custom fix vector is accessed out-of-range");
|
error->all(FLERR,"Dump custom fix {} vector is accessed out-of-range",name);
|
||||||
|
|
||||||
field2index[iarg] = add_fix(argi.get_name());
|
field2index[iarg] = add_fix(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// variable value = v_name
|
// variable value = v_name
|
||||||
@ -1488,12 +1487,12 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
pack_choice[iarg] = &DumpCustom::pack_variable;
|
pack_choice[iarg] = &DumpCustom::pack_variable;
|
||||||
vtype[iarg] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
n = input->variable->find(argi.get_name());
|
n = input->variable->find(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump custom variable name");
|
if (n < 0) error->all(FLERR,"Could not find dump custom variable name {}",name);
|
||||||
if (input->variable->atomstyle(n) == 0)
|
if (input->variable->atomstyle(n) == 0)
|
||||||
error->all(FLERR,"Dump custom variable is not atom-style variable");
|
error->all(FLERR,"Dump custom variable {} is not atom-style variable",name);
|
||||||
|
|
||||||
field2index[iarg] = add_variable(argi.get_name());
|
field2index[iarg] = add_variable(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom floating point value = d_ID
|
// custom per-atom floating point value = d_ID
|
||||||
@ -1503,14 +1502,14 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
vtype[iarg] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
tmp = -1;
|
tmp = -1;
|
||||||
n = atom->find_custom(argi.get_name(),tmp);
|
n = atom->find_custom(name,tmp);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
|
||||||
if (tmp != 1)
|
if (tmp != 1)
|
||||||
error->all(FLERR,"Custom per-atom property ID is not floating point");
|
error->all(FLERR,"Custom per-atom property ID {} is not floating point", name);
|
||||||
|
|
||||||
field2index[iarg] = add_custom(argi.get_name(),1);
|
field2index[iarg] = add_custom(name,1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom integer value = i_ID
|
// custom per-atom integer value = i_ID
|
||||||
@ -1520,14 +1519,14 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
vtype[iarg] = Dump::INT;
|
vtype[iarg] = Dump::INT;
|
||||||
|
|
||||||
tmp = -1;
|
tmp = -1;
|
||||||
n = atom->find_custom(argi.get_name(),tmp);
|
n = atom->find_custom(name,tmp);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
|
||||||
if (tmp != 0)
|
if (tmp != 0)
|
||||||
error->all(FLERR,"Custom per-atom property ID is not integer");
|
error->all(FLERR,"Custom per-atom property ID {} is not integer", name);
|
||||||
|
|
||||||
field2index[iarg] = add_custom(argi.get_name(),0);
|
field2index[iarg] = add_custom(name,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1648,7 +1647,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
else {
|
else {
|
||||||
iregion = domain->find_region(arg[1]);
|
iregion = domain->find_region(arg[1]);
|
||||||
if (iregion == -1)
|
if (iregion == -1)
|
||||||
error->all(FLERR,"Dump_modify region ID does not exist");
|
error->all(FLERR,"Dump_modify region ID {} does not exist",arg[1]);
|
||||||
delete[] idregion;
|
delete[] idregion;
|
||||||
idregion = utils::strdup(arg[1]);
|
idregion = utils::strdup(arg[1]);
|
||||||
}
|
}
|
||||||
@ -1679,8 +1678,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
|
// 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 == nullptr)
|
if (ptr == nullptr)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump_modify int format does not contain d character");
|
||||||
"Dump_modify int format does not contain d character");
|
|
||||||
char str[8];
|
char str[8];
|
||||||
sprintf(str,"%s",BIGINT_FORMAT);
|
sprintf(str,"%s",BIGINT_FORMAT);
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
@ -1703,7 +1701,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
if (strcmp(arg[0],"element") == 0) {
|
if (strcmp(arg[0],"element") == 0) {
|
||||||
if (narg < ntypes+1)
|
if (narg < ntypes+1)
|
||||||
error->all(FLERR,"Dump_modify element names do not match atom types");
|
error->all(FLERR,"Number of dump_modify element names does not match number of atom types");
|
||||||
|
|
||||||
for (int i = 1; i <= ntypes; i++) delete[] typenames[i];
|
for (int i = 1; i <= ntypes; i++) delete[] typenames[i];
|
||||||
delete[] typenames;
|
delete[] typenames;
|
||||||
@ -1850,6 +1848,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||||
argindex[nfield+nthresh] = argi.get_index1();
|
argindex[nfield+nthresh] = argi.get_index1();
|
||||||
|
auto name = argi.get_name();
|
||||||
|
|
||||||
switch (argi.get_type()) {
|
switch (argi.get_type()) {
|
||||||
|
|
||||||
@ -1862,23 +1861,20 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
case ArgInfo::COMPUTE:
|
case ArgInfo::COMPUTE:
|
||||||
thresh_array[nthresh] = COMPUTE;
|
thresh_array[nthresh] = COMPUTE;
|
||||||
n = modify->find_compute(argi.get_name());
|
n = modify->find_compute(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump modify compute ID");
|
if (n < 0) error->all(FLERR,"Could not find dump modify compute ID: {}",name);
|
||||||
|
|
||||||
if (modify->compute[n]->peratom_flag == 0)
|
if (modify->compute[n]->peratom_flag == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom info",name);
|
||||||
"Dump modify compute ID does not compute per-atom info");
|
|
||||||
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
|
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom vector",name);
|
||||||
"Dump modify compute ID does not compute per-atom vector");
|
|
||||||
if (argi.get_index1() > 0 && modify->compute[n]->size_peratom_cols == 0)
|
if (argi.get_index1() > 0 && modify->compute[n]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom array",name);
|
||||||
"Dump modify compute ID does not compute per-atom array");
|
|
||||||
if (argi.get_index1() > 0 &&
|
if (argi.get_index1() > 0 &&
|
||||||
argi.get_index1() > modify->compute[n]->size_peratom_cols)
|
argi.get_index1() > modify->compute[n]->size_peratom_cols)
|
||||||
error->all(FLERR,"Dump modify compute ID vector is not large enough");
|
error->all(FLERR,"Dump modify compute ID {} vector is not large enough",name);
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_compute(argi.get_name());
|
field2index[nfield+nthresh] = add_compute(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// fix value = f_ID
|
// fix value = f_ID
|
||||||
@ -1886,20 +1882,19 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
case ArgInfo::FIX:
|
case ArgInfo::FIX:
|
||||||
thresh_array[nthresh] = FIX;
|
thresh_array[nthresh] = FIX;
|
||||||
n = modify->find_fix(argi.get_name());
|
n = modify->find_fix(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump modify fix ID");
|
if (n < 0) error->all(FLERR,"Could not find dump modify fix ID: {}",name);
|
||||||
|
|
||||||
if (modify->fix[n]->peratom_flag == 0)
|
if (modify->fix[n]->peratom_flag == 0)
|
||||||
error->all(FLERR,"Dump modify fix ID does not compute per-atom info");
|
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom info",name);
|
||||||
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
|
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
|
||||||
error->all(FLERR,"Dump modify fix ID does not compute per-atom vector");
|
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom vector",name);
|
||||||
if (argi.get_index1() > 0 && modify->fix[n]->size_peratom_cols == 0)
|
if (argi.get_index1() > 0 && modify->fix[n]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,"Dump modify fix ID does not compute per-atom array");
|
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom array",name);
|
||||||
if (argi.get_index1() > 0 &&
|
if (argi.get_index1() > 0 && argi.get_index1() > modify->fix[n]->size_peratom_cols)
|
||||||
argi.get_index1() > modify->fix[n]->size_peratom_cols)
|
error->all(FLERR,"Dump modify fix ID {} vector is not large enough",name);
|
||||||
error->all(FLERR,"Dump modify fix ID vector is not large enough");
|
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_fix(argi.get_name());
|
field2index[nfield+nthresh] = add_fix(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// variable value = v_ID
|
// variable value = v_ID
|
||||||
@ -1907,12 +1902,12 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
case ArgInfo::VARIABLE:
|
case ArgInfo::VARIABLE:
|
||||||
thresh_array[nthresh] = VARIABLE;
|
thresh_array[nthresh] = VARIABLE;
|
||||||
n = input->variable->find(argi.get_name());
|
n = input->variable->find(name);
|
||||||
if (n < 0) error->all(FLERR,"Could not find dump modify variable name");
|
if (n < 0) error->all(FLERR,"Could not find dump modify variable name: {}",name);
|
||||||
if (input->variable->atomstyle(n) == 0)
|
if (input->variable->atomstyle(n) == 0)
|
||||||
error->all(FLERR,"Dump modify variable is not atom-style variable");
|
error->all(FLERR,"Dump modify variable {} is not atom-style variable",name);
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_variable(argi.get_name());
|
field2index[nfield+nthresh] = add_variable(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per atom floating point value = d_ID
|
// custom per atom floating point value = d_ID
|
||||||
@ -1920,12 +1915,11 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
case ArgInfo::DNAME:
|
case ArgInfo::DNAME:
|
||||||
thresh_array[nthresh] = DNAME;
|
thresh_array[nthresh] = DNAME;
|
||||||
tmp = -1;
|
tmp = -1;
|
||||||
n = atom->find_custom(argi.get_name(),tmp);
|
n = atom->find_custom(name,tmp);
|
||||||
if ((n < 0) || (tmp != 1))
|
if ((n < 0) || (tmp != 1))
|
||||||
error->all(FLERR,"Could not find dump modify "
|
error->all(FLERR,"Could not find dump modify custom atom floating point property ID: {}",name);
|
||||||
"custom atom floating point property ID");
|
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_custom(argi.get_name(),1);
|
field2index[nfield+nthresh] = add_custom(name,1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per atom integer value = i_ID
|
// custom per atom integer value = i_ID
|
||||||
@ -1933,16 +1927,15 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
case ArgInfo::INAME:
|
case ArgInfo::INAME:
|
||||||
thresh_array[nthresh] = INAME;
|
thresh_array[nthresh] = INAME;
|
||||||
tmp = -1;
|
tmp = -1;
|
||||||
n = atom->find_custom(argi.get_name(),tmp);
|
n = atom->find_custom(name,tmp);
|
||||||
if ((n < 0) || (tmp != 0))
|
if ((n < 0) || (tmp != 0))
|
||||||
error->all(FLERR,"Could not find dump modify "
|
error->all(FLERR,"Could not find dump modify custom atom integer property ID: {}",name);
|
||||||
"custom atom integer property ID");
|
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_custom(argi.get_name(),0);
|
field2index[nfield+nthresh] = add_custom(name,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error->all(FLERR,"Invalid dump_modify thresh attribute");
|
error->all(FLERR,"Invalid dump_modify thresh attribute: {}",name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user