git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11841 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2014-04-29 22:43:28 +00:00
parent ce8a12bbdc
commit f3e58c8d0a
3 changed files with 56 additions and 13 deletions

View File

@ -747,7 +747,14 @@ void Force::boundsbig(char *str, bigint nmax, bigint &nlo, bigint &nhi,
double Force::numeric(const char *file, int line, char *str)
{
if (!str)
error->all(file,line,"Expected floating point parameter "
"in input script or data file");
int n = strlen(str);
if (n == 0)
error->all(file,line,"Expected floating point parameter "
"in input script or data file");
for (int i = 0; i < n; i++) {
if (isdigit(str[i])) continue;
if (str[i] == '-' || str[i] == '+' || str[i] == '.') continue;
@ -767,7 +774,14 @@ double Force::numeric(const char *file, int line, char *str)
int Force::inumeric(const char *file, int line, char *str)
{
if (!str)
error->all(file,line,
"Expected integer parameter in input script or data file");
int n = strlen(str);
if (n == 0)
error->all(file,line,
"Expected integer parameter in input script or data file");
for (int i = 0; i < n; i++) {
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
error->all(file,line,
@ -785,14 +799,46 @@ int Force::inumeric(const char *file, int line, char *str)
bigint Force::bnumeric(const char *file, int line, char *str)
{
if (!str)
error->all(file,line,
"Expected integer parameter in input script or data file");
int n = strlen(str);
if (n == 0)
error->all(file,line,
"Expected integer parameter in input script or data file");
for (int i = 0; i < n; i++) {
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
error->all(file,line,
"Expected integer parameter in input script or data file");
}
return ATOLL(str);
return ATOBIGINT(str);
}
/* ----------------------------------------------------------------------
read a tag integer value from a string
generate an error if not a legitimate integer value
called by various commands to check validity of their arguments
------------------------------------------------------------------------- */
tagint Force::tnumeric(const char *file, int line, char *str)
{
if (!str)
error->all(file,line,
"Expected integer parameter in input script or data file");
int n = strlen(str);
if (n == 0)
error->all(file,line,
"Expected integer parameter in input script or data file");
for (int i = 0; i < n; i++) {
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
error->all(file,line,
"Expected integer parameter in input script or data file");
}
return ATOTAGINT(str);
}
/* ----------------------------------------------------------------------

View File

@ -105,6 +105,7 @@ class Force : protected Pointers {
double numeric(const char *, int, char *);
int inumeric(const char *, int, char *);
bigint bnumeric(const char *, int, char *);
tagint tnumeric(const char *, int, char *);
FILE *open_potential(const char *);
const char *potname(const char *);

View File

@ -198,18 +198,12 @@ void Group::assign(int narg, char **arg)
else error->all(FLERR,"Illegal group command");
tagint bound1,bound2;
if (sizeof(tagint) == sizeof(smallint))
bound1 = force->inumeric(FLERR,arg[3]);
else
bound1 = force->bnumeric(FLERR,arg[3]);
bound1 = force->tnumeric(FLERR,arg[3]);
bound2 = -1;
if (condition == BETWEEN) {
if (narg != 5) error->all(FLERR,"Illegal group command");
if (sizeof(tagint) == sizeof(smallint))
bound2 = force->inumeric(FLERR,arg[4]);
else
bound2 = force->bnumeric(FLERR,arg[4]);
bound2 = force->tnumeric(FLERR,arg[4]);
} else if (narg != 4) error->all(FLERR,"Illegal group command");
int *attribute = NULL;
@ -284,13 +278,15 @@ void Group::assign(int narg, char **arg)
for (int iarg = 2; iarg < narg; iarg++) {
if (strchr(arg[iarg],':')) {
start = ATOTAGINT(strtok(arg[iarg],":"));
stop = ATOTAGINT(strtok(NULL,":"));
ptr = strtok(arg[iarg],":");
start = force->tnumeric(FLERR,ptr);
ptr = strtok(NULL,":");
stop = force->tnumeric(FLERR,ptr);
ptr = strtok(NULL,":");
if (ptr) delta = ATOTAGINT(ptr);
if (ptr) delta = force->tnumeric(FLERR,ptr);
else delta = 1;
} else {
start = stop = ATOTAGINT(arg[iarg]);
start = stop = force->tnumeric(FLERR,arg[iarg]);
delta = 1;
}