diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 672c0018b0..7180a04873 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -136,13 +136,12 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"neigh") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); - if (strcmp(arg[iarg+1],"yes") == 0) _gpu_mode = GPU_NEIGH; - else if (strcmp(arg[iarg+1],"no") == 0) _gpu_mode = GPU_FORCE; - else if (strcmp(arg[iarg+1],"on") == 0) _gpu_mode = GPU_NEIGH; - else if (strcmp(arg[iarg+1],"off") == 0) _gpu_mode = GPU_FORCE; - else if (strcmp(arg[iarg+1],"true") == 0) _gpu_mode = GPU_NEIGH; - else if (strcmp(arg[iarg+1],"false") == 0) _gpu_mode = GPU_FORCE; - else if (strcmp(arg[iarg+1],"hybrid") == 0) _gpu_mode = GPU_HYB_NEIGH; + const std::string modearg = arg[iarg+1]; + if ((modearg == "yes") || (modearg == "on") || (modearg == "true")) + _gpu_mode = GPU_NEIGH; + else if ((modearg == "no") || (modearg == "off") || (modearg == "false")) + _gpu_mode = GPU_FORCE; + else if (modearg == "hybrid") _gpu_mode = GPU_HYB_NEIGH; else error->all(FLERR,"Illegal package gpu command"); iarg += 2; } else if (strcmp(arg[iarg],"newton") == 0) { diff --git a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp index e8dc972a2a..304d5bbf0f 100644 --- a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp +++ b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp @@ -257,16 +257,9 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : int mlo,mhi; utils::bounds(FLERR,arg[iarg+1],1,nbody,mlo,mhi,error); - double xflag,yflag,zflag; - if (strcmp(arg[iarg+2],"off") == 0) xflag = 0.0; - else if (strcmp(arg[iarg+2],"on") == 0) xflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+3],"off") == 0) yflag = 0.0; - else if (strcmp(arg[iarg+3],"on") == 0) yflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+4],"off") == 0) zflag = 0.0; - else if (strcmp(arg[iarg+4],"on") == 0) zflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); + const double xflag = (double) utils::logical(FLERR,arg[iarg+2],false,lmp); + const double yflag = (double) utils::logical(FLERR,arg[iarg+3],false,lmp); + const double zflag = (double) utils::logical(FLERR,arg[iarg+4],false,lmp); int count = 0; for (int m = mlo; m <= mhi; m++) { diff --git a/src/PHONON/dynamical_matrix.cpp b/src/PHONON/dynamical_matrix.cpp index 443d468a45..f7cb3f7f44 100644 --- a/src/PHONON/dynamical_matrix.cpp +++ b/src/PHONON/dynamical_matrix.cpp @@ -184,17 +184,17 @@ void DynamicalMatrix::options(int narg, char **arg) if (narg < 0) error->all(FLERR,"Illegal dynamical_matrix command"); int iarg = 0; const char* filename = "dynmat.dyn"; + while (iarg < narg) { if (strcmp(arg[iarg],"binary") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); if (strcmp(arg[iarg+1],"gzip") == 0) { compressed = 1; - } else if (strcmp(arg[iarg+1],"yes") == 0) { - binaryflag = 1; + } else { + binaryflag = utils::logical(FLERR,arg[iarg+1],false,lmp); } iarg += 2; - } - else if (strcmp(arg[iarg],"file") == 0) { + } else if (strcmp(arg[iarg],"file") == 0) { if (iarg+2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); filename = arg[iarg + 1]; file_flag = 1; diff --git a/src/PHONON/third_order.cpp b/src/PHONON/third_order.cpp index e9add72267..565e8b50e5 100644 --- a/src/PHONON/third_order.cpp +++ b/src/PHONON/third_order.cpp @@ -185,19 +185,19 @@ void ThirdOrder::options(int narg, char **arg) const char *filename = "third_order.dat"; while (iarg < narg) { - if (strcmp(arg[iarg],"file") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Illegal third_order command"); - filename = arg[iarg + 1]; - file_flag = 1; - iarg += 2; - } else if (strcmp(arg[iarg],"binary") == 0) { + if (strcmp(arg[iarg],"binary") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal third_order command"); if (strcmp(arg[iarg+1],"gzip") == 0) { compressed = 1; - } else if (strcmp(arg[iarg+1],"yes") == 0) { - binaryflag = 1; + } else { + binaryflag = utils::logical(FLERR,arg[iarg+1],false,lmp); } iarg += 2; + } else if (strcmp(arg[iarg],"file") == 0) { + if (iarg+2 > narg) error->all(FLERR, "Illegal third_order command"); + filename = arg[iarg + 1]; + file_flag = 1; + iarg += 2; } else error->all(FLERR,"Illegal third_order command"); } if (file_flag == 1 and me == 0) { diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index b8fc08dc14..06cfe0d0bd 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -56,9 +56,7 @@ FixQEqDynamic::FixQEqDynamic(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/dynamic command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/dynamic command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/dynamic command"); } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index eb206effc6..77a5ae36a1 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -66,9 +66,7 @@ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/fire command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/fire command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/fire command"); } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index e836c0dad8..3ad76b74d9 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -42,9 +42,7 @@ FixQEqPoint::FixQEqPoint(LAMMPS *lmp, int narg, char **arg) : FixQEq(lmp, narg, arg) { if (narg == 10) { if (strcmp(arg[8],"warn") == 0) { - if (strcmp(arg[9],"no") == 0) maxwarn = 0; - else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/point command"); + maxwarn = utils::logical(FLERR,arg[9],false,lmp); } else error->all(FLERR,"Illegal fix qeq/point command"); } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/point command"); } diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 4cc254a361..8c1b95996b 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -43,9 +43,7 @@ FixQEqShielded::FixQEqShielded(LAMMPS *lmp, int narg, char **arg) : FixQEq(lmp, narg, arg) { if (narg == 10) { if (strcmp(arg[8],"warn") == 0) { - if (strcmp(arg[9],"no") == 0) maxwarn = 0; - else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/shielded command"); + maxwarn = utils::logical(FLERR,arg[9],false,lmp); } else error->all(FLERR,"Illegal fix qeq/shielded command"); } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/shielded command"); if (reax_flag) extract_reax(); diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 4b4814d982..d491b301d5 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -55,9 +55,7 @@ FixQEqSlater::FixQEqSlater(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/slater command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/slater command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/slater command"); } diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 7b891d42fe..ac009821cf 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -179,24 +179,20 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : int num_common_keywords = 2; for (int m = 0; m < num_common_keywords; m++) { if (strcmp(arg[iarg],"stabilization") == 0) { - if (strcmp(arg[iarg+1],"no") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " - "'stabilization' keyword has too few arguments"); - iarg += 2; - } - if (strcmp(arg[iarg+1],"yes") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " + "'stabilization' keyword has too few arguments"); + stabilization_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); + if (stabilization_flag) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix bond/react command:" "'stabilization' keyword has too few arguments"); exclude_group = utils::strdup(arg[iarg+2]); - stabilization_flag = 1; nve_limit_xmax = arg[iarg+3]; iarg += 4; - } + } else iarg += 2; } else if (strcmp(arg[iarg],"reset_mol_ids") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " "'reset_mol_ids' keyword has too few arguments"); - if (strcmp(arg[iarg+1],"yes") == 0) reset_mol_ids_flag = 1; // default - if (strcmp(arg[iarg+1],"no") == 0) reset_mol_ids_flag = 0; + reset_mol_ids_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"react") == 0) { break; diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 758ee70ab7..a8cc249e58 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -227,21 +227,18 @@ void PairReaxFF::settings(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"checkqeq") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + qeqflag = utils::logical(FLERR,arg[iarg+1],false,lmp); if (strcmp(arg[iarg+1],"yes") == 0) qeqflag = 1; else if (strcmp(arg[iarg+1],"no") == 0) qeqflag = 0; else error->all(FLERR,"Illegal pair_style reaxff command"); iarg += 2; } else if (strcmp(arg[iarg],"enobonds") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); - if (strcmp(arg[iarg+1],"yes") == 0) api->control->enobondsflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) api->control->enobondsflag = 0; - else error->all(FLERR,"Illegal pair_style reaxff command"); + api->control->enobondsflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"lgvdw") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); - if (strcmp(arg[iarg+1],"yes") == 0) api->control->lgflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) api->control->lgflag = 0; - else error->all(FLERR,"Illegal pair_style reaxff command"); + api->control->lgflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"safezone") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 6f3486945c..db9767d01e 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -535,9 +535,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"reinit") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid command"); - if (strcmp("yes",arg[iarg+1]) == 0) reinitflag = 1; - else if (strcmp("no",arg[iarg+1]) == 0) reinitflag = 0; - else error->all(FLERR,"Illegal fix rigid command"); + reinitflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"gravity") == 0) { diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 40bfc3ce2d..7216c56c83 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -227,17 +227,13 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"reinit") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command"); - if (strcmp("yes",arg[iarg+1]) == 0) reinitflag = 1; - else if (strcmp("no",arg[iarg+1]) == 0) reinitflag = 0; - else error->all(FLERR,"Illegal fix rigid/small command"); + reinitflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mol") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command"); int imol = atom->find_molecule(arg[iarg+1]); - if (imol == -1) - error->all(FLERR,"Molecule template ID for " - "fix rigid/small does not exist"); + if (imol == -1) error->all(FLERR,"Molecule template ID for fix rigid/small does not exist"); onemols = &atom->molecules[imol]; nmol = onemols[0]->nset; restart_file = 1; diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index e8430b6ab1..ae1d0f4cd5 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -129,9 +129,7 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"dftb") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix msst command"); - if (strcmp(arg[iarg+1],"yes") == 0) dftb = 1; - else if (strcmp(arg[iarg+1],"yes") == 0) dftb = 0; - else error->all(FLERR,"Illegal fix msst command"); + dftb = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"beta") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix msst command"); @@ -152,8 +150,7 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) : mesg += fmt::format(" Cell mass-like parameter qmass " "(units of mass^2/length^4) = {:.8g}\n", qmass); mesg += fmt::format(" Shock velocity = {:.8g}\n", velocity); - mesg += fmt::format(" Artificial viscosity " - "(units of mass/length/time) = {:.8g}\n", mu); + mesg += fmt::format(" Artificial viscosity (units of mass/length/time) = {:.8g}\n", mu); if (p0_set) mesg += fmt::format(" Initial pressure specified to be {:.8g}\n", p0); diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index c64609cfe3..970af9c4fb 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -71,7 +71,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : { if (lmp->citeme) lmp->citeme->add(cite_fix_nve_spin); - if (narg < 4) error->all(FLERR,"Illegal fix/NVE/spin command"); + if (narg < 4) error->all(FLERR,"Illegal fix/nve/spin command"); time_integrate = 1; sector_flag = NONE; @@ -86,7 +86,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : // checking if map array or hash is defined if (atom->map_style == Atom::MAP_NONE) - error->all(FLERR,"Fix NVE/spin requires an atom map, see atom_modify"); + error->all(FLERR,"Fix nve/spin requires an atom map, see atom_modify"); // defining sector_flag @@ -95,7 +95,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : sector_flag = 0; } else if (nprocs_tmp >= 1) { sector_flag = 1; - } else error->all(FLERR,"Illegal fix/NVE/spin command"); + } else error->all(FLERR,"Illegal fix/nve/spin command"); // defining lattice_flag @@ -105,25 +105,26 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"lattice") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix/NVE/spin command"); - if (strcmp(arg[iarg+1],"no") == 0) lattice_flag = 0; - else if (strcmp(arg[iarg+1],"frozen") == 0) lattice_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) lattice_flag = 1; - else if (strcmp(arg[iarg+1],"moving") == 0) lattice_flag = 1; - else error->all(FLERR,"Illegal fix/NVE/spin command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix/nve/spin command"); + const std::string latarg = arg[iarg+1]; + if ((latarg == "no") || (latarg == "off") || (latarg == "false") || (latarg == "frozen")) + lattice_flag = 0; + else if ((latarg == "yes") || (latarg == "on") || (latarg == "true") || (latarg == "moving")) + lattice_flag = 1; + else error->all(FLERR,"Illegal fix/nve/spin command"); iarg += 2; - } else error->all(FLERR,"Illegal fix/NVE/spin command"); + } else error->all(FLERR,"Illegal fix/nve/spin command"); } // check if the atom/spin style is defined if (!atom->sp_flag) - error->all(FLERR,"Fix NVE/spin requires atom/spin style"); + error->all(FLERR,"Fix nve/spin requires atom/spin style"); // check if sector_flag is correctly defined if (sector_flag == 0 && nprocs_tmp > 1) - error->all(FLERR,"Illegal fix/NVE/spin command"); + error->all(FLERR,"Illegal fix/nve/spin command"); // initialize the magnetic interaction flags @@ -307,7 +308,7 @@ void FixNVESpin::init() // setting the sector variables/lists nsectors = 0; - memory->create(rsec,3,"NVE/spin:rsec"); + memory->create(rsec,3,"nve/spin:rsec"); // perform the sectoring operation @@ -316,10 +317,10 @@ void FixNVESpin::init() // init. size of stacking lists (sectoring) nlocal_max = atom->nlocal; - memory->grow(stack_head,nsectors,"NVE/spin:stack_head"); - memory->grow(stack_foot,nsectors,"NVE/spin:stack_foot"); - memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); - memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + memory->grow(stack_head,nsectors,"nve/spin:stack_head"); + memory->grow(stack_foot,nsectors,"nve/spin:stack_foot"); + memory->grow(backward_stacks,nlocal_max,"nve/spin:backward_stacks"); + memory->grow(forward_stacks,nlocal_max,"nve/spin:forward_stacks"); } /* ---------------------------------------------------------------------- */ @@ -391,7 +392,7 @@ void FixNVESpin::initial_integrate(int /*vflag*/) AdvanceSingleSpin(i); } } - } else error->all(FLERR,"Illegal fix NVE/spin command"); + } else error->all(FLERR,"Illegal fix nve/spin command"); // update x for all particles @@ -444,7 +445,7 @@ void FixNVESpin::initial_integrate(int /*vflag*/) AdvanceSingleSpin(i); } } - } else error->all(FLERR,"Illegal fix NVE/spin command"); + } else error->all(FLERR,"Illegal fix nve/spin command"); } @@ -468,8 +469,8 @@ void FixNVESpin::pre_neighbor() if (nlocal_max < nlocal) { // grow linked lists if necessary nlocal_max = nlocal; - memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); - memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + memory->grow(backward_stacks,nlocal_max,"nve/spin:backward_stacks"); + memory->grow(forward_stacks,nlocal_max,"nve/spin:forward_stacks"); } for (int j = 0; j < nsectors; j++) { diff --git a/src/SPIN/pair_spin_exchange_biquadratic.cpp b/src/SPIN/pair_spin_exchange_biquadratic.cpp index 8bff5e1b1d..fb727e1939 100644 --- a/src/SPIN/pair_spin_exchange_biquadratic.cpp +++ b/src/SPIN/pair_spin_exchange_biquadratic.cpp @@ -121,12 +121,8 @@ void PairSpinExchangeBiquadratic::coeff(int narg, char **arg) // read energy offset flag if specified while (iarg < narg) { - if (strcmp(arg[10],"offset") == 0) { - if (strcmp(arg[11],"yes") == 0) { - e_offset = 1; - } else if (strcmp(arg[11],"no") == 0) { - e_offset = 0; - } else error->all(FLERR,"Incorrect args for pair coefficients"); + if (strcmp(arg[iarg],"offset") == 0) { + e_offset = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/input.cpp b/src/input.cpp index 296623932a..833dbaa6df 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1822,11 +1822,13 @@ void Input::suffix() { if (narg < 1) error->all(FLERR,"Illegal suffix command"); - if (strcmp(arg[0],"off") == 0) lmp->suffix_enable = 0; - else if (strcmp(arg[0],"on") == 0) { - if (!lmp->suffix) - error->all(FLERR,"May only enable suffixes after defining one"); + const std::string firstarg = arg[0]; + + if ((firstarg == "off") || (firstarg == "no") || (firstarg == "false")) { + lmp->suffix_enable = 0; + } else if ((firstarg == "on") || (firstarg == "yes") || (firstarg == "true")) { lmp->suffix_enable = 1; + if (!lmp->suffix) error->all(FLERR,"May only enable suffixes after defining one"); } else { lmp->suffix_enable = 1; @@ -1834,7 +1836,7 @@ void Input::suffix() delete[] lmp->suffix2; lmp->suffix = lmp->suffix2 = nullptr; - if (strcmp(arg[0],"hybrid") == 0) { + if (firstarg == "hybrid") { if (narg != 3) error->all(FLERR,"Illegal suffix command"); lmp->suffix = utils::strdup(arg[1]); lmp->suffix2 = utils::strdup(arg[2]); diff --git a/src/lammps.cpp b/src/lammps.cpp index d40289729c..d9bb56d882 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -266,12 +266,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : strcmp(arg[iarg],"-k") == 0) { if (iarg+2 > narg) error->universe_all(FLERR,"Invalid command-line argument"); - if (strcmp(arg[iarg+1],"on") == 0) kokkosflag = 1; - else if (strcmp(arg[iarg+1],"off") == 0) kokkosflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) kokkosflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) kokkosflag = 0; - else if (strcmp(arg[iarg+1],"true") == 0) kokkosflag = 1; - else if (strcmp(arg[iarg+1],"false") == 0) kokkosflag = 0; + const std::string kokkosarg = arg[iarg+1]; + if ((kokkosarg == "on") || (kokkosarg == "yes") || (kokkosarg == "true")) + kokkosflag = 1; + else if ((kokkosarg == "off") || (kokkosarg == "no") || (kokkosarg == "false")) + kokkosflag = 0; else error->universe_all(FLERR,"Invalid command-line argument"); iarg += 2; // delimit any extra args for the Kokkos instantiation