hide repetitive code use a macro
This commit is contained in:
@ -390,34 +390,23 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
if (!input->variable->equalstyle(vvar))
|
if (!input->variable->equalstyle(vvar))
|
||||||
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", vstr);
|
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", vstr);
|
||||||
|
|
||||||
if (xstr) {
|
#define SETUP_XYZ_VAR(str,var) \
|
||||||
xvar = input->variable->find(xstr);
|
if (str) { \
|
||||||
if (xvar < 0) {
|
var = input->variable->find(str); \
|
||||||
input->variable->internal_create(xstr,0.0);
|
if (var < 0) { \
|
||||||
xvar = input->variable->find(xstr);
|
input->variable->internal_create(str, 0.0); \
|
||||||
}
|
var = input->variable->find(str); \
|
||||||
if (!input->variable->internalstyle(xvar))
|
} \
|
||||||
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", xstr);
|
if (!input->variable->internalstyle(var)) \
|
||||||
}
|
error->all(FLERR, Error::NOLASTLINE, \
|
||||||
if (ystr) {
|
"Variable {} for create_atoms is invalid style", str); \
|
||||||
yvar = input->variable->find(ystr);
|
|
||||||
if (yvar < 0) {
|
|
||||||
input->variable->internal_create(ystr,0.0);
|
|
||||||
yvar = input->variable->find(ystr);
|
|
||||||
}
|
|
||||||
if (!input->variable->internalstyle(yvar))
|
|
||||||
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", ystr);
|
|
||||||
}
|
|
||||||
if (zstr) {
|
|
||||||
zvar = input->variable->find(zstr);
|
|
||||||
if (zvar < 0) {
|
|
||||||
input->variable->internal_create(zstr,0.0);
|
|
||||||
zvar = input->variable->find(zstr);
|
|
||||||
}
|
|
||||||
if (!input->variable->internalstyle(zvar))
|
|
||||||
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", zstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SETUP_XYZ_VAR(xstr, xvar);
|
||||||
|
SETUP_XYZ_VAR(ystr, yvar);
|
||||||
|
SETUP_XYZ_VAR(zstr, zvar);
|
||||||
}
|
}
|
||||||
|
#undef SETUP_XYZ_VAR
|
||||||
|
|
||||||
// require non-none lattice be defined for BOX or REGION styles
|
// require non-none lattice be defined for BOX or REGION styles
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user