move Force::bounds() and Force::boundsbig() to utils.

This commit is contained in:
Axel Kohlmeyer
2020-08-29 18:23:03 -04:00
parent 3be064748d
commit fcd0b9f78f
233 changed files with 751 additions and 498 deletions

View File

@ -836,74 +836,6 @@ void Force::set_special(int narg, char **arg)
error->all(FLERR,"Illegal special_bonds command");
}
/* ----------------------------------------------------------------------
compute bounds implied by numeric str with a possible wildcard asterik
1 = lower bound, nmax = upper bound
5 possibilities:
(1) i = i to i, (2) * = nmin to nmax,
(3) i* = i to nmax, (4) *j = nmin to j, (5) i*j = i to j
return nlo,nhi
------------------------------------------------------------------------- */
void Force::bounds(const char *file, int line, char *str,
int nmax, int &nlo, int &nhi, int nmin)
{
char *ptr = strchr(str,'*');
if (ptr == NULL) {
nlo = nhi = atoi(str);
} else if (strlen(str) == 1) {
nlo = nmin;
nhi = nmax;
} else if (ptr == str) {
nlo = nmin;
nhi = atoi(ptr+1);
} else if (strlen(ptr+1) == 0) {
nlo = atoi(str);
nhi = nmax;
} else {
nlo = atoi(str);
nhi = atoi(ptr+1);
}
if (nlo < nmin || nhi > nmax || nlo > nhi)
error->all(file,line,"Numeric index is out of bounds");
}
/* ----------------------------------------------------------------------
compute bounds implied by numeric str with a possible wildcard asterik
1 = lower bound, nmax = upper bound
5 possibilities:
(1) i = i to i, (2) * = nmin to nmax,
(3) i* = i to nmax, (4) *j = nmin to j, (5) i*j = i to j
return nlo,nhi
------------------------------------------------------------------------- */
void Force::boundsbig(const char *file, int line, char *str,
bigint nmax, bigint &nlo, bigint &nhi, bigint nmin)
{
char *ptr = strchr(str,'*');
if (ptr == NULL) {
nlo = nhi = ATOBIGINT(str);
} else if (strlen(str) == 1) {
nlo = nmin;
nhi = nmax;
} else if (ptr == str) {
nlo = nmin;
nhi = ATOBIGINT(ptr+1);
} else if (strlen(ptr+1) == 0) {
nlo = ATOBIGINT(str);
nhi = nmax;
} else {
nlo = ATOBIGINT(str);
nhi = ATOBIGINT(ptr+1);
}
if (nlo < nmin || nhi > nmax || nlo > nhi)
error->all(file,line,"Numeric index is out of bounds");
}
/* ----------------------------------------------------------------------
read a floating point value from a string
generate an error if not a legitimate floating point value