improve some error messages in comm, domain and region.cpp
This commit is contained in:
32
src/comm.cpp
32
src/comm.cpp
@ -282,12 +282,12 @@ void Comm::init_exchange()
|
||||
|
||||
void Comm::modify_params(int narg, char **arg)
|
||||
{
|
||||
if (narg < 1) error->all(FLERR,"Illegal comm_modify command");
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "comm_modify", error);
|
||||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"mode") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "comm_modify mode", error);
|
||||
if (strcmp(arg[iarg+1],"single") == 0) {
|
||||
// need to reset cutghostuser when switching comm mode
|
||||
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
||||
@ -311,26 +311,27 @@ void Comm::modify_params(int narg, char **arg)
|
||||
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
||||
memory->destroy(cutusermulti);
|
||||
mode = Comm::MULTIOLD;
|
||||
} else error->all(FLERR,"Illegal comm_modify command");
|
||||
} else error->all(FLERR,"Unknown comm_modify mode argument: {}", arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"group") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "comm_modify group", error);
|
||||
bordergroup = group->find(arg[iarg+1]);
|
||||
if (bordergroup < 0)
|
||||
error->all(FLERR,"Invalid group in comm_modify command");
|
||||
if (bordergroup && (atom->firstgroupname == nullptr ||
|
||||
strcmp(arg[iarg+1],atom->firstgroupname) != 0))
|
||||
error->all(FLERR,"Comm_modify group != atom_modify first group");
|
||||
error->all(FLERR, "Invalid comm_modify keyword: group {} not found", arg[iarg+1]);
|
||||
if (atom->firstgroupname == nullptr)
|
||||
error->all(FLERR, "Invalid comm_modify keyword: atom_modify first command must be used");
|
||||
if (strcmp(arg[iarg+1],atom->firstgroupname) != 0)
|
||||
error->all(FLERR, "comm_modify group != atom_modify first group: {}", atom->firstgroupname);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"cutoff") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "comm_modify cutoff", error);
|
||||
if (mode == Comm::MULTI)
|
||||
error->all(FLERR, "Use cutoff/multi keyword to set cutoff in multi mode");
|
||||
if (mode == Comm::MULTIOLD)
|
||||
error->all(FLERR, "Use cutoff/multi/old keyword to set cutoff in multi mode");
|
||||
cutghostuser = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (cutghostuser < 0.0)
|
||||
error->all(FLERR,"Invalid cutoff in comm_modify command");
|
||||
error->all(FLERR,"Invalid cutoff {} in comm_modify command", arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"cutoff/multi") == 0) {
|
||||
int i,nlo,nhi;
|
||||
@ -355,7 +356,7 @@ void Comm::modify_params(int narg, char **arg)
|
||||
cut = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
cutghostuser = MAX(cutghostuser,cut);
|
||||
if (cut < 0.0)
|
||||
error->all(FLERR,"Invalid cutoff in comm_modify command");
|
||||
error->all(FLERR,"Invalid cutoff {} in comm_modify command", arg[iarg+2]);
|
||||
// collections use 1-based indexing externally and 0-based indexing internally
|
||||
for (i=nlo; i<=nhi; ++i)
|
||||
cutusermulti[i-1] = cut;
|
||||
@ -370,8 +371,7 @@ void Comm::modify_params(int narg, char **arg)
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR, "Cannot set cutoff/multi before simulation box is defined");
|
||||
const int ntypes = atom->ntypes;
|
||||
if (iarg+3 > narg)
|
||||
error->all(FLERR,"Illegal comm_modify command");
|
||||
if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "comm_modify cutoff/multi/old", error);
|
||||
if (cutusermultiold == nullptr) {
|
||||
memory->create(cutusermultiold,ntypes+1,"comm:cutusermultiold");
|
||||
for (i=0; i < ntypes+1; ++i)
|
||||
@ -381,7 +381,7 @@ void Comm::modify_params(int narg, char **arg)
|
||||
cut = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
cutghostuser = MAX(cutghostuser,cut);
|
||||
if (cut < 0.0)
|
||||
error->all(FLERR,"Invalid cutoff in comm_modify command");
|
||||
error->all(FLERR,"Invalid cutoff {} in comm_modify command", arg[iarg+2]);
|
||||
for (i=nlo; i<=nhi; ++i)
|
||||
cutusermultiold[i] = cut;
|
||||
iarg += 3;
|
||||
@ -391,10 +391,10 @@ void Comm::modify_params(int narg, char **arg)
|
||||
multi_reduce = 1;
|
||||
iarg += 1;
|
||||
} else if (strcmp(arg[iarg],"vel") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "comm_modify vel", error);
|
||||
ghost_velocity = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal comm_modify command");
|
||||
} else error->all(FLERR,"Unknown comm_modify keyword: {}", arg[iarg]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1744,7 +1744,7 @@ void Domain::set_lattice(int narg, char **arg)
|
||||
|
||||
void Domain::add_region(int narg, char **arg)
|
||||
{
|
||||
if (narg < 2) error->all(FLERR,"Illegal region command");
|
||||
if (narg < 2) utils::missing_cmd_args(FLERR, "region", error);
|
||||
|
||||
if (strcmp(arg[1],"delete") == 0) {
|
||||
delete_region(arg[0]);
|
||||
@ -1935,17 +1935,17 @@ void Domain::set_boundary(int narg, char **arg, int flag)
|
||||
|
||||
void Domain::set_box(int narg, char **arg)
|
||||
{
|
||||
if (narg < 1) error->all(FLERR,"Illegal box command");
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "box", error);
|
||||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"tilt") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal box command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "box tilt", error);
|
||||
if (strcmp(arg[iarg+1],"small") == 0) tiltsmall = 1;
|
||||
else if (strcmp(arg[iarg+1],"large") == 0) tiltsmall = 0;
|
||||
else error->all(FLERR,"Illegal box command");
|
||||
else error->all(FLERR,"Unknown box tilt argument: {}", arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal box command");
|
||||
} else error->all(FLERR,"Unknown box keyword: {}", arg[iarg]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -66,27 +66,27 @@ void Region::init()
|
||||
{
|
||||
if (xstr) {
|
||||
xvar = input->variable->find(xstr);
|
||||
if (xvar < 0) error->all(FLERR, "Variable name for region does not exist");
|
||||
if (xvar < 0) error->all(FLERR, "Variable {} for region does not exist", xstr);
|
||||
if (!input->variable->equalstyle(xvar))
|
||||
error->all(FLERR, "Variable for region is invalid style");
|
||||
error->all(FLERR, "Variable {} for region is invalid style", xstr);
|
||||
}
|
||||
if (ystr) {
|
||||
yvar = input->variable->find(ystr);
|
||||
if (yvar < 0) error->all(FLERR, "Variable name for region does not exist");
|
||||
if (yvar < 0) error->all(FLERR, "Variable {} for region does not exist", ystr);
|
||||
if (!input->variable->equalstyle(yvar))
|
||||
error->all(FLERR, "Variable for region is not equal style");
|
||||
error->all(FLERR, "Variable {} for region is not equal style", ystr);
|
||||
}
|
||||
if (zstr) {
|
||||
zvar = input->variable->find(zstr);
|
||||
if (zvar < 0) error->all(FLERR, "Variable name for region does not exist");
|
||||
if (zvar < 0) error->all(FLERR, "Variable {} for region does not exist", zstr);
|
||||
if (!input->variable->equalstyle(zvar))
|
||||
error->all(FLERR, "Variable for region is not equal style");
|
||||
error->all(FLERR, "Variable {} for region is not equal style", zstr);
|
||||
}
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0) error->all(FLERR, "Variable name for region does not exist");
|
||||
if (tvar < 0) error->all(FLERR, "Variable {} for region does not exist", tstr);
|
||||
if (!input->variable->equalstyle(tvar))
|
||||
error->all(FLERR, "Variable for region is not equal style");
|
||||
error->all(FLERR, "Variable {} for region is not equal style", tstr);
|
||||
}
|
||||
vel_timestep = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user