apply utils::logical() in more places

This commit is contained in:
Axel Kohlmeyer
2021-09-21 14:15:02 -04:00
parent 41a3eccd1c
commit 1ba77e1629
30 changed files with 172 additions and 376 deletions

View File

@ -312,32 +312,26 @@ FixColvars::FixColvars(LAMMPS *lmp, int narg, char **arg) :
tmp_name = nullptr;
/* parse optional arguments */
int argsdone = 4;
while (argsdone < narg) {
int iarg = 4;
while (iarg < narg) {
// we have keyword/value pairs. check if value is missing
if (argsdone+1 == narg)
if (iarg+1 == narg)
error->all(FLERR,"Missing argument to keyword");
if (0 == strcmp(arg[argsdone], "input")) {
inp_name = strdup(arg[argsdone+1]);
} else if (0 == strcmp(arg[argsdone], "output")) {
out_name = strdup(arg[argsdone+1]);
} else if (0 == strcmp(arg[argsdone], "seed")) {
rng_seed = utils::inumeric(FLERR,arg[argsdone+1],false,lmp);
} else if (0 == strcmp(arg[argsdone], "unwrap")) {
if (0 == strcmp(arg[argsdone+1], "yes")) {
unwrap_flag = 1;
} else if (0 == strcmp(arg[argsdone+1], "no")) {
unwrap_flag = 0;
} else {
error->all(FLERR,"Incorrect fix colvars unwrap flag");
}
} else if (0 == strcmp(arg[argsdone], "tstat")) {
tmp_name = strdup(arg[argsdone+1]);
if (0 == strcmp(arg[iarg], "input")) {
inp_name = strdup(arg[iarg+1]);
} else if (0 == strcmp(arg[iarg], "output")) {
out_name = strdup(arg[iarg+1]);
} else if (0 == strcmp(arg[iarg], "seed")) {
rng_seed = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
} else if (0 == strcmp(arg[iarg], "unwrap")) {
unwrap_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
} else if (0 == strcmp(arg[iarg], "tstat")) {
tmp_name = strdup(arg[iarg+1]);
} else {
error->all(FLERR,"Unknown fix colvars parameter");
}
++argsdone; ++argsdone;
++iarg; ++iarg;
}
if (!out_name) out_name = strdup("out");

View File

@ -188,17 +188,11 @@ int DumpAtomZstd::modify_param(int narg, char **arg)
try {
if (strcmp(arg[0], "checksum") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
if (strcmp(arg[1], "yes") == 0)
writer.setChecksum(true);
else if (strcmp(arg[1], "no") == 0)
writer.setChecksum(false);
else
error->all(FLERR, "Illegal dump_modify command");
writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1);
return 2;
} else if (strcmp(arg[0], "compression_level") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
writer.setCompressionLevel(compression_level);
writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp));
return 2;
}
} catch (FileWriterException &e) {

View File

@ -233,17 +233,11 @@ int DumpCFGZstd::modify_param(int narg, char **arg)
try {
if (strcmp(arg[0], "checksum") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
if (strcmp(arg[1], "yes") == 0)
writer.setChecksum(true);
else if (strcmp(arg[1], "no") == 0)
writer.setChecksum(false);
else
error->all(FLERR, "Illegal dump_modify command");
writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1);
return 2;
} else if (strcmp(arg[0], "compression_level") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
writer.setCompressionLevel(compression_level);
writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp));
return 2;
}
} catch (FileWriterException &e) {

View File

@ -205,14 +205,11 @@ int DumpCustomZstd::modify_param(int narg, char **arg)
try {
if (strcmp(arg[0], "checksum") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true);
else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false);
else error->all(FLERR,"Illegal dump_modify command");
writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1);
return 2;
} else if (strcmp(arg[0], "compression_level") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
writer.setCompressionLevel(compression_level);
writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp));
return 2;
}
} catch (FileWriterException &e) {

View File

@ -190,17 +190,11 @@ int DumpLocalZstd::modify_param(int narg, char **arg)
try {
if (strcmp(arg[0], "checksum") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
if (strcmp(arg[1], "yes") == 0)
writer.setChecksum(true);
else if (strcmp(arg[1], "no") == 0)
writer.setChecksum(false);
else
error->all(FLERR, "Illegal dump_modify command");
writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1);
return 2;
} else if (strcmp(arg[0], "compression_level") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
writer.setCompressionLevel(compression_level);
writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp));
return 2;
}
} catch (FileWriterException &e) {

View File

@ -156,17 +156,11 @@ int DumpXYZZstd::modify_param(int narg, char **arg)
try {
if (strcmp(arg[0], "checksum") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
if (strcmp(arg[1], "yes") == 0)
writer.setChecksum(true);
else if (strcmp(arg[1], "no") == 0)
writer.setChecksum(false);
else
error->all(FLERR, "Illegal dump_modify command");
writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1);
return 2;
} else if (strcmp(arg[0], "compression_level") == 0) {
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
writer.setCompressionLevel(compression_level);
writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp));
return 2;
}
} catch (FileWriterException &e) {

View File

@ -796,12 +796,7 @@ int FixPolarizeBEMGMRES::modify_param(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg], "kspace") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command");
if (strcmp(arg[iarg + 1], "yes") == 0)
kspaceflag = 1;
else if (strcmp(arg[iarg + 1], "no") == 0)
kspaceflag = 0;
else
error->all(FLERR, "Illegal fix_modify command for fix polarize");
kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "dielectrics") == 0) {
if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command");

View File

@ -355,12 +355,7 @@ int FixPolarizeBEMICC::modify_param(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg], "kspace") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command");
if (strcmp(arg[iarg + 1], "yes") == 0)
kspaceflag = 1;
else if (strcmp(arg[iarg + 1], "no") == 0)
kspaceflag = 0;
else
error->all(FLERR, "Illegal fix_modify command for fix polarize");
kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "dielectrics") == 0) {
if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command");

View File

@ -478,12 +478,7 @@ int FixPolarizeFunctional::modify_param(int narg, char **arg)
while (iarg < narg) {
if (strcmp(arg[iarg], "kspace") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command");
if (strcmp(arg[iarg + 1], "yes") == 0)
kspaceflag = 1;
else if (strcmp(arg[iarg + 1], "no") == 0)
kspaceflag = 0;
else
error->all(FLERR, "Illegal fix_modify command for fix polarize/functional");
kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "dielectrics") == 0) {
if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command");

View File

@ -91,9 +91,7 @@ FixLangevinDrude::FixLangevinDrude(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"zero") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin/drude command");
if (strcmp(arg[iarg+1],"no") == 0) zero = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) zero = 1;
else error->all(FLERR,"Illegal fix langevin/drude command");
zero = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else error->all(FLERR,"Illegal fix langevin/drude command");
}

View File

@ -256,9 +256,7 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"mtk") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0;
else error->all(FLERR,"Illegal fix nvt/npt/nph command");
mtk_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"tloop") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
@ -277,27 +275,19 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"scalexy") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0;
else error->all(FLERR,"Illegal fix nvt/npt/nph command");
scalexy = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"scalexz") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0;
else error->all(FLERR,"Illegal fix nvt/npt/nph command");
scalexz = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"scaleyz") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0;
else error->all(FLERR,"Illegal fix nvt/npt/nph command");
scaleyz = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"flip") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");
if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0;
else error->all(FLERR,"Illegal fix nvt/npt/nph command");
flipflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"fixedpoint") == 0) {
if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command");

View File

@ -17,21 +17,23 @@
------------------------------------------------------------------------- */
#include "compute_entropy_atom.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "update.h"
#include "modify.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "neigh_request.h"
#include "force.h"
#include "pair.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "math_const.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "modify.h"
#include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h"
#include "pair.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace MathConst;
@ -44,8 +46,7 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) :
pair_entropy(nullptr), pair_entropy_avg(nullptr)
{
if (narg < 5 || narg > 10)
error->all(FLERR,"Illegal compute entropy/atom command; wrong number"
" of arguments");
error->all(FLERR,"Illegal compute entropy/atom command; wrong number of arguments");
// Arguments are: sigma cutoff avg yes/no cutoff2 local yes/no
// sigma is the gaussian width
@ -57,11 +58,9 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) :
// the g(r)
sigma = utils::numeric(FLERR,arg[3],false,lmp);
if (sigma <= 0.0) error->all(FLERR,"Illegal compute entropy/atom"
" command; sigma must be positive");
if (sigma <= 0.0) error->all(FLERR,"Illegal compute entropy/atom command; sigma must be positive");
cutoff = utils::numeric(FLERR,arg[4],false,lmp);
if (cutoff <= 0.0) error->all(FLERR,"Illegal compute entropy/atom"
" command; cutoff must be positive");
if (cutoff <= 0.0) error->all(FLERR,"Illegal compute entropy/atom command; cutoff must be positive");
cutoff2 = 0.;
avg_flag = 0;
@ -71,26 +70,17 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) :
int iarg = 5;
while (iarg < narg) {
if (strcmp(arg[iarg],"avg") == 0) {
if (iarg+2 > narg)
error->all(FLERR,"Illegal compute entropy/atom;"
" missing arguments after avg");
if (strcmp(arg[iarg+1],"yes") == 0) avg_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) avg_flag = 0;
else error->all(FLERR,"Illegal compute entropy/atom;"
" argument after avg should be yes or no");
if (iarg+3 > narg) error->all(FLERR,"Illegal compute entropy/atom command");
avg_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
cutoff2 = utils::numeric(FLERR,arg[iarg+2],false,lmp);
if (cutoff2 < 0.0) error->all(FLERR,"Illegal compute entropy/atom"
" command; negative cutoff2");
if (cutoff2 < 0.0) error->all(FLERR,"Illegal compute entropy/atom command; negative cutoff2");
cutsq2 = cutoff2*cutoff2;
iarg += 3;
} else if (strcmp(arg[iarg],"local") == 0) {
if (strcmp(arg[iarg+1],"yes") == 0) local_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) local_flag = 0;
else error->all(FLERR,"Illegal compute entropy/atom;"
" argument after local should be yes or no");
if (iarg+2 > narg) error->all(FLERR,"Illegal compute entropy/atom command");
local_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,"Illegal compute entropy/atom; argument after"
" sigma and cutoff should be avg or local");
} else error->all(FLERR,"Illegal compute entropy/atom command");
}

View File

@ -258,9 +258,7 @@ int DumpDCD::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"unwrap") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1;
else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0;
else error->all(FLERR,"Illegal dump_modify command");
unwrap_flag = utils::logical(FLERR,arg[1],false,lmp);
return 2;
}
return 0;

View File

@ -24,19 +24,20 @@
------------------------------------------------------------------------- */
#include "dump_xtc.h"
#include <cmath>
#include <cstring>
#include <climits>
#include "domain.h"
#include "atom.h"
#include "update.h"
#include "group.h"
#include "output.h"
#include "force.h"
#include "comm.h"
#include "memory.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "output.h"
#include "update.h"
#include <climits>
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
@ -278,9 +279,7 @@ int DumpXTC::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"unwrap") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1;
else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0;
else error->all(FLERR,"Illegal dump_modify command");
unwrap_flag = utils::logical(FLERR,arg[1],false,lmp);
return 2;
} else if (strcmp(arg[0],"precision") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");

View File

@ -91,9 +91,7 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"energy") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword");
if (strcmp(arg[iarg+1],"yes") == 0) workflag = true;
else if (strcmp(arg[iarg+1],"no") != 0)
error->all(FLERR,"Illegal energy keyword");
workflag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1;
iarg += 2;
} else error->all(FLERR,"Illegal fix flow/gauss command");
}

View File

@ -19,17 +19,18 @@
#include "fix_gld.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "random_mars.h"
#include "respa.h"
#include "update.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "force.h"
#include "update.h"
#include "respa.h"
#include "comm.h"
#include "random_mars.h"
#include "memory.h"
#include "error.h"
#include "group.h"
#define GLD_UNIFORM_DISTRO
@ -128,26 +129,14 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"zero") == 0) {
if (iarg+2 > narg) {
error->all(FLERR, "Illegal fix gld command");
}
if (strcmp(arg[iarg+1],"no") == 0) {
zeroflag = 0;
} else if (strcmp(arg[iarg+1],"yes") == 0) {
zeroflag = 1;
} else {
error->all(FLERR,"Illegal fix gld command");
}
if (iarg+2 > narg) error->all(FLERR, "Illegal fix gld command");
zeroflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
}
else if (strcmp(arg[iarg],"frozen") == 0) {
if (iarg+2 > narg) {
error->all(FLERR, "Illegal fix gld command");
}
if (strcmp(arg[iarg+1],"no") == 0) {
freezeflag = 0;
} else if (strcmp(arg[iarg+1],"yes") == 0) {
freezeflag = 1;
if (iarg+2 > narg) error->all(FLERR, "Illegal fix gld command");
freezeflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
if (freezeflag) {
for (int i = 0; i < atom->nlocal; i++) {
if (atom->mask[i] & groupbit) {
for (int k = 0; k < 3*prony_terms; k=k+3)
@ -158,8 +147,6 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) :
}
}
}
} else {
error->all(FLERR, "Illegal fix gld command");
}
iarg += 2;
}

View File

@ -297,9 +297,7 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"mtk") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0;
else error->all(FLERR,"Illegal fix npt/cauchy command");
mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"tloop") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
@ -318,27 +316,19 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"scalexy") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0;
else error->all(FLERR,"Illegal fix npt/cauchy command");
scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"scalexz") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0;
else error->all(FLERR,"Illegal fix npt/cauchy command");
scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"scaleyz") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0;
else error->all(FLERR,"Illegal fix npt/cauchy command");
scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"flip") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0;
else error->all(FLERR,"Illegal fix npt/cauchy command");
flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"update") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
@ -352,10 +342,8 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
alpha = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"continue") == 0) {
if (strcmp(arg[iarg+1],"yes") != 0 && strcmp(arg[iarg+1],"no") != 0)
error->all(FLERR,"Illegal cauchystat continue value. "
"Must be 'yes' or 'no'");
restartPK = !strcmp(arg[iarg+1],"yes");
if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");
restartPK = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"fixedpoint") == 0) {
if (iarg+4 > narg) error->all(FLERR,"Illegal fix npt/cauchy command");

View File

@ -103,16 +103,12 @@ FixPAFI::FixPAFI(LAMMPS *lmp, int narg, char **arg) :
int iarg = 7;
while (iarg < narg) {
if (strcmp(arg[iarg],"overdamped") == 0) {
if (strcmp(arg[iarg+1],"no") == 0) od_flag = 0;
else if (strcmp(arg[iarg+1],"0") == 0) od_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) od_flag = 1;
else if (strcmp(arg[iarg+1],"1") == 0) od_flag = 1;
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pafi command");
od_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"com") == 0) {
if (strcmp(arg[iarg+1],"no") == 0) com_flag = 0;
else if (strcmp(arg[iarg+1],"0") == 0) com_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) com_flag = 1;
else if (strcmp(arg[iarg+1],"1") == 0) com_flag = 1;
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pafi command");
com_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,"Illegal fix pafi command");
}

View File

@ -124,18 +124,12 @@ ComputeFEP::ComputeFEP(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"tail") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword "
"in compute fep");
if (strcmp(arg[iarg+1],"no") == 0) tailflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) tailflag = 1;
else error->all(FLERR,"Illegal optional keyword in compute fep");
if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword in compute fep");
tailflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"volume") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword "
"in compute fep");
if (strcmp(arg[iarg+1],"no") == 0) volumeflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) volumeflag = 1;
else error->all(FLERR,"Illegal optional keyword in compute fep");
if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword in compute fep");
volumeflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else
error->all(FLERR,"Illegal optional keyword in compute fep");

View File

@ -138,21 +138,15 @@ FixAdaptFEP::FixAdaptFEP(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"reset") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command");
if (strcmp(arg[iarg+1],"no") == 0) resetflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) resetflag = 1;
else error->all(FLERR,"Illegal fix adapt/fep command");
resetflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"scale") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command");
if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1;
else error->all(FLERR,"Illegal fix adapt/fep command");
scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"after") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command");
if (strcmp(arg[iarg+1],"no") == 0) afterflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) afterflag = 1;
else error->all(FLERR,"Illegal fix adapt/fep command");
afterflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,"Illegal fix adapt/fep command");
}

View File

@ -16,23 +16,24 @@
Contributing author: Pierre de Buyl (KU Leuven)
------------------------------------------------------------------------- */
#include <cmath>
#include <cstdio>
#include <cstring>
#include <climits>
#include "ch5md.h"
#include "dump_h5md.h"
#include "domain.h"
#include "atom.h"
#include "update.h"
#include "group.h"
#include "output.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "output.h"
#include "update.h"
#include "version.h"
#include <climits>
#include <cmath>
#include <cstring>
#include "ch5md.h"
using namespace LAMMPS_NS;
#define MYMIN(a,b) ((a) < (b) ? (a) : (b))
@ -152,25 +153,14 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
error->all(FLERR, "Invalid number of arguments in dump h5md");
}
box_is_set = true;
if (strcmp(arg[iarg+1], "yes")==0)
do_box=true;
else if (strcmp(arg[iarg+1], "no")==0)
do_box=false;
else
error->all(FLERR, "Illegal dump h5md command");
do_box = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1;
iarg+=2;
} else if (strcmp(arg[iarg], "create_group")==0) {
if (iarg+1>=narg) {
error->all(FLERR, "Invalid number of arguments in dump h5md");
}
create_group_is_set = true;
if (strcmp(arg[iarg+1], "yes")==0)
create_group=true;
else if (strcmp(arg[iarg+1], "no")==0) {
create_group=false;
}
else
error->all(FLERR, "Illegal dump h5md command");
create_group = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1;
iarg+=2;
} else if (strcmp(arg[iarg], "author")==0) {
if (iarg+1>=narg) {

View File

@ -381,9 +381,7 @@ void KokkosLMP::accelerator(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"newton") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0;
else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1;
else error->all(FLERR,"Illegal package kokkos command");
newtonflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"comm") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
@ -459,21 +457,15 @@ void KokkosLMP::accelerator(int narg, char **arg)
} else if ((strcmp(arg[iarg],"gpu/aware") == 0)
|| (strcmp(arg[iarg],"cuda/aware") == 0)) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0;
else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1;
else error->all(FLERR,"Illegal package kokkos command");
gpu_aware_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"pair/only") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0;
else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1;
else error->all(FLERR,"Illegal package kokkos command");
pair_only_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"neigh/thread") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0;
else if (strcmp(arg[iarg+1],"on") == 0) neigh_thread = 1;
else error->all(FLERR,"Illegal package kokkos command");
neigh_thread = utils::logical(FLERR,arg[iarg+1],false,lmp);
neigh_thread_set = 1;
iarg += 2;
} else error->all(FLERR,"Illegal package kokkos command");

View File

@ -160,15 +160,11 @@ void FixAtomSwap::options(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"ke") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
if (strcmp(arg[iarg+1],"no") == 0) conserve_ke_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) conserve_ke_flag = 1;
else error->all(FLERR,"Illegal fix atom/swap command");
conserve_ke_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"semi-grand") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
if (strcmp(arg[iarg+1],"no") == 0) semi_grand_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) semi_grand_flag = 1;
else error->all(FLERR,"Illegal fix atom/swap command");
semi_grand_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"types") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal fix atom/swap command");

View File

@ -1180,8 +1180,8 @@ void FixChargeRegulation::setThermoTemperaturePointer() {
int ifix = -1;
ifix = modify->find_fix(idftemp);
if (ifix == -1) {
error->all(FLERR,
"fix charge/regulation regulation could not find a temperature fix id provided by tempfixid\n");
error->all(FLERR, "fix charge/regulation regulation could not find "
"a temperature fix id provided by tempfixid\n");
}
Fix *temperature_fix = modify->fix[ifix];
int dim;
@ -1198,8 +1198,7 @@ void FixChargeRegulation::assign_tags() {
for (int i = 0; i < atom->nlocal; i++) maxtag = MAX(maxtag, tag[i]);
maxtag_all = maxtag;
MPI_Allreduce(&maxtag, &maxtag_all, 1, MPI_LMP_TAGINT, MPI_MAX, world);
if (maxtag_all >= MAXTAGINT)
error->all(FLERR, "New atom IDs exceed maximum allowed ID");
if (maxtag_all >= MAXTAGINT) error->all(FLERR, "New atom IDs exceed maximum allowed ID");
tagint notag = 0;
tagint notag_all;
@ -1267,23 +1266,19 @@ void FixChargeRegulation::options(int narg, char **arg) {
while (iarg < narg) {
if (strcmp(arg[iarg], "lunit_nm") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
llength_unit_in_nm = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "acid_type") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
acid_type = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "base_type") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
base_type = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pH") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
if (strstr(arg[iarg + 1],"v_") == arg[iarg + 1]) {
pHstr = utils::strdup(&arg[iarg + 1][2]);
} else {
@ -1292,45 +1287,37 @@ void FixChargeRegulation::options(int narg, char **arg) {
}
iarg += 2;
} else if (strcmp(arg[iarg], "pIp") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pI_plus = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pIm") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pI_minus = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pKa") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pKa = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pKb") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pKb = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "temp") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
reservoir_temperature = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pKs") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pKs = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "tempfixid") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
idftemp = utils::strdup(arg[iarg+1]);
setThermoTemperaturePointer();
iarg += 2;
} else if (strcmp(arg[iarg], "rxd") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
reaction_distance = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
if ((reaction_distance > domain->prd_half[0]) ||
(reaction_distance > domain->prd_half[1]) ||
@ -1342,61 +1329,44 @@ void FixChargeRegulation::options(int narg, char **arg) {
}
iarg += 2;
} else if (strcmp(arg[iarg], "nevery") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
nevery = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "nmc") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
nmc = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "pmcmoves") == 0) {
if (iarg + 4 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 4 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
pmcmoves[0] = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
pmcmoves[1] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
pmcmoves[2] = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
iarg += 4;
} else if (strcmp(arg[iarg], "seed") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
seed = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "tag") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (strcmp(arg[iarg + 1], "yes") == 0) {
add_tags_flag = true;
} else if (strcmp(arg[iarg + 1], "no") == 0) {
add_tags_flag = false;
} else error->all(FLERR, "Illegal fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
add_tags_flag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1;
iarg += 2;
} else if (strcmp(arg[iarg], "onlysalt") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
if (strcmp(arg[iarg + 1], "yes") == 0) {
only_salt_flag = true;
// need to specify salt charge
if (iarg + 4 > narg)
error->all(FLERR, "Illegal fix charge/regulation command");
salt_charge[0] = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
salt_charge[1] = utils::inumeric(FLERR, arg[iarg + 3], false, lmp);
iarg += 4;
} else if (strcmp(arg[iarg + 1], "no") == 0) {
only_salt_flag = false;
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
only_salt_flag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1;
iarg += 2;
} else error->all(FLERR, "Illegal fix charge/regulation command");
if (only_salt_flag) {
// need to specify salt charge
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command");
salt_charge[0] = utils::inumeric(FLERR, arg[iarg], false, lmp);
salt_charge[1] = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
}
} else if (strcmp(arg[iarg], "group") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix fix charge/regulation command");
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix fix charge/regulation command");
if (ngroups >= ngroupsmax) {
ngroupsmax = ngroups + 1;
groupstrings = (char **)
memory->srealloc(groupstrings,
ngroupsmax * sizeof(char *),
"fix_charge_regulation:groupstrings");
memory->srealloc(groupstrings, ngroupsmax * sizeof(char *), "fix_charge_regulation:groupstrings");
}
groupstrings[ngroups] = utils::strdup(arg[iarg+1]);
ngroups++;

View File

@ -421,9 +421,7 @@ int DumpMolfile::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"unwrap") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1;
else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0;
else error->all(FLERR,"Illegal dump_modify command");
unwrap_flag = utils::logical(FLERR,arg[1],false,lmp);
return 2;
} else if (strcmp(arg[0],"element") == 0) {

View File

@ -871,19 +871,13 @@ int DumpNetCDF::modify_param(int narg, char **arg)
int iarg = 0;
if (strcmp(arg[iarg],"double") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
if (strcmp(arg[iarg],"yes") == 0) {
double_precision = true;
} else if (strcmp(arg[iarg],"no") == 0) {
double_precision = false;
} else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
double_precision = utils::logical(FLERR,arg[iarg],false,lmp) == 1;
iarg++;
return 2;
} else if (strcmp(arg[iarg],"at") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected additional arg after 'at' keyword.");
if (iarg >= narg) error->all(FLERR,"expected additional arg after 'at' keyword.");
framei = utils::inumeric(FLERR,arg[iarg],false,lmp);
if (framei == 0) error->all(FLERR,"frame 0 not allowed for 'at' keyword.");
else if (framei < 0) framei--;
@ -891,13 +885,8 @@ int DumpNetCDF::modify_param(int narg, char **arg)
return 2;
} else if (strcmp(arg[iarg],"thermo") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
if (strcmp(arg[iarg],"yes") == 0) {
thermo = true;
} else if (strcmp(arg[iarg],"no") == 0) {
thermo = false;
} else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
thermo = utils::logical(FLERR,arg[iarg],false,lmp) == 1;
iarg++;
return 2;
} else return 0;

View File

@ -866,19 +866,13 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg)
int iarg = 0;
if (strcmp(arg[iarg],"double") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
if (strcmp(arg[iarg],"yes") == 0) {
double_precision = true;
} else if (strcmp(arg[iarg],"no") == 0) {
double_precision = false;
} else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
double_precision = utils::logical(FLERR,arg[iarg],false,lmp) == 1;
iarg++;
return 2;
} else if (strcmp(arg[iarg],"at") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected additional arg after 'at' keyword.");
if (iarg >= narg) error->all(FLERR,"expected additional arg after 'at' keyword.");
framei = utils::inumeric(FLERR,arg[iarg],false,lmp);
if (framei == 0) error->all(FLERR,"frame 0 not allowed for 'at' keyword.");
else if (framei < 0) framei--;
@ -886,13 +880,8 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg)
return 2;
} else if (strcmp(arg[iarg],"thermo") == 0) {
iarg++;
if (iarg >= narg)
error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
if (strcmp(arg[iarg],"yes") == 0) {
thermo = true;
} else if (strcmp(arg[iarg],"no") == 0) {
thermo = false;
} else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
thermo = utils::logical(FLERR,arg[iarg],false,lmp) == 1;
iarg++;
return 2;
} else return 0;

View File

@ -109,15 +109,11 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg], "neighbors") == 0) {
if (iarg + 2 > narg) error->all(FLERR,"Illegal compute voronoi/atom command");
if (strcmp(arg[iarg+1],"yes") == 0) faces_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) faces_flag = 0;
else error->all(FLERR,"Illegal compute voronoi/atom command");
faces_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "peratom") == 0) {
if (iarg + 2 > narg) error->all(FLERR,"Illegal compute voronoi/atom command");
if (strcmp(arg[iarg+1],"yes") == 0) peratom_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) peratom_flag = 0;
else error->all(FLERR,"Illegal compute voronoi/atom command");
peratom_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
}
else error->all(FLERR,"Illegal compute voronoi/atom command");

View File

@ -2070,9 +2070,7 @@ int DumpVTK::modify_param(int narg, char **arg)
if (strcmp(arg[0],"binary") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command [binary]");
if (strcmp(arg[1],"yes") == 0) binary = 1;
else if (strcmp(arg[1],"no") == 0) binary = 0;
else error->all(FLERR,"Illegal dump_modify command [binary]");
binary = utils::logical(FLERR,arg[1],false,lmp);
return 2;
}

View File

@ -1622,16 +1622,10 @@ void Input::newton()
int newton_pair=1,newton_bond=1;
if (narg == 1) {
if (strcmp(arg[0],"off") == 0) newton_pair = newton_bond = 0;
else if (strcmp(arg[0],"on") == 0) newton_pair = newton_bond = 1;
else error->all(FLERR,"Illegal newton command");
newton_pair = newton_bond = utils::logical(FLERR,arg[0],false,lmp);
} else if (narg == 2) {
if (strcmp(arg[0],"off") == 0) newton_pair = 0;
else if (strcmp(arg[0],"on") == 0) newton_pair= 1;
else error->all(FLERR,"Illegal newton command");
if (strcmp(arg[1],"off") == 0) newton_bond = 0;
else if (strcmp(arg[1],"on") == 0) newton_bond = 1;
else error->all(FLERR,"Illegal newton command");
newton_pair = utils::logical(FLERR,arg[0],false,lmp);
newton_bond = utils::logical(FLERR,arg[1],false,lmp);
} else error->all(FLERR,"Illegal newton command");
force->newton_pair = newton_pair;