better error checking

This commit is contained in:
Axel Kohlmeyer
2021-03-13 22:52:37 -05:00
parent 7936a6296f
commit 0cdd433eca
2 changed files with 5 additions and 3 deletions

View File

@ -99,6 +99,7 @@ void Group::assign(int narg, char **arg)
// clear mask of each atom assigned to this group // clear mask of each atom assigned to this group
if (strcmp(arg[1],"delete") == 0) { if (strcmp(arg[1],"delete") == 0) {
if (narg != 2) error->all(FLERR,"Illegal group command");
int igroup = find(arg[0]); int igroup = find(arg[0]);
if (igroup == -1) error->all(FLERR,"Could not find group delete group ID"); if (igroup == -1) error->all(FLERR,"Could not find group delete group ID");
if (igroup == 0) error->all(FLERR,"Cannot delete group all"); if (igroup == 0) error->all(FLERR,"Cannot delete group all");
@ -183,7 +184,8 @@ void Group::assign(int narg, char **arg)
} else if (strcmp(arg[1],"empty") == 0) { } else if (strcmp(arg[1],"empty") == 0) {
; // nothing to do here if (narg != 2) error->all(FLERR,"Illegal group command");
// nothing else to do here
// style = type, molecule, id // style = type, molecule, id
// add to group if atom matches type/molecule/id or condition // add to group if atom matches type/molecule/id or condition
@ -546,7 +548,7 @@ void Group::assign(const std::string &groupcmd)
add flagged atoms to a new or existing group add flagged atoms to a new or existing group
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Group::create(char *name, int *flag) void Group::create(const char *name, int *flag)
{ {
int i; int i;

View File

@ -32,7 +32,7 @@ class Group : protected Pointers {
~Group(); ~Group();
void assign(int, char **); // assign atoms to a group void assign(int, char **); // assign atoms to a group
void assign(const std::string &); // convenience function void assign(const std::string &); // convenience function
void create(char *, int *); // add flagged atoms to a group void create(const char *, int *); // add flagged atoms to a group
int find(const std::string &); // lookup name in list of groups int find(const std::string &); // lookup name in list of groups
int find_or_create(const char *); // lookup name or create new group int find_or_create(const char *); // lookup name or create new group
void write_restart(FILE *); void write_restart(FILE *);