diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index 9ed591f73f..38cc372e22 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -13,21 +13,23 @@ ------------------------------------------------------------------------- */ #include "compute_bond_local.h" -#include -#include + #include "atom.h" #include "atom_vec.h" -#include "molecule.h" -#include "update.h" -#include "domain.h" -#include "force.h" #include "bond.h" #include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" #include "input.h" -#include "variable.h" #include "math_extra.h" #include "memory.h" -#include "error.h" +#include "molecule.h" +#include "update.h" +#include "variable.h" + +#include +#include using namespace LAMMPS_NS; @@ -81,7 +83,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) : vstr[nvar] = utils::strdup(&arg[iarg][2]); nvar++; } else if (arg[iarg][0] == 'b') { - int n = atoi(&arg[iarg][1]); + int n = std::stoi(&arg[iarg][1]); if (n <= 0) error->all(FLERR, "Invalid keyword {} in compute bond/local command", arg[iarg]); bstyle[nvalues] = BN; bindex[nvalues++] = n - 1; diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp index 88991f7481..ac6a3bfb99 100644 --- a/src/compute_pair_local.cpp +++ b/src/compute_pair_local.cpp @@ -67,7 +67,7 @@ ComputePairLocal::ComputePairLocal(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg], "dz") == 0) pstyle[nvalues++] = DZ; else if (arg[iarg][0] == 'p') { - int n = atoi(&arg[iarg][1]); + int n = std::stoi(&arg[iarg][1]); if (n <= 0) error->all(FLERR, "Invalid keyword {} in compute pair/local command", arg[iarg]); pstyle[nvalues] = PN; pindex[nvalues++] = n - 1; diff --git a/src/lammps.cpp b/src/lammps.cpp index b3659fdf50..8e81f785de 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -191,7 +191,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : int me,nprocs; MPI_Comm_rank(communicator,&me); MPI_Comm_size(communicator,&nprocs); - int color = atoi(arg[iarg+1]); + int color = std::stoi(arg[iarg+1]); MPI_Comm subcomm; MPI_Comm_split(communicator,color,me,&subcomm); external_comm = communicator; diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 10d16ac859..f252e01644 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -484,7 +484,7 @@ void ReaderNative::read_atoms(int n, int nfield, double **fields) // convert selected fields to floats for (int m = 0; m < nfield; m++) - fields[i][m] = atof(words[fieldindex[m]].c_str()); + fields[i][m] = std::stod(words[fieldindex[m]]); } } } diff --git a/src/universe.cpp b/src/universe.cpp index edd5b01031..fb07e26759 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -181,10 +181,10 @@ void Universe::add_world(char *str) if ((found == 0) || (found == (part.size() - 1))) { valid = false; } else if (found == std::string::npos) { - nper = atoi(part.c_str()); + nper = std::stoi(part); } else { - n = atoi(part.substr(0,found).c_str()); - nper = atoi(part.substr(found+1).c_str()); + n = std::stoi(part.substr(0,found)); + nper = std::stoi(part.substr(found+1)); } } @@ -193,8 +193,7 @@ void Universe::add_world(char *str) if (n < 1 || nper < 1) valid = false; if (!valid) - error->universe_all(FLERR,fmt::format("Invalid partition string '{}'", - str)); + error->universe_all(FLERR, fmt::format("Invalid partition string '{}'", str)); } else nper = nprocs; memory->grow(procs_per_world,nworlds+n,"universe:procs_per_world"); diff --git a/src/write_coeff.cpp b/src/write_coeff.cpp index 11987d4b37..5a7177f62f 100644 --- a/src/write_coeff.cpp +++ b/src/write_coeff.cpp @@ -152,7 +152,7 @@ void WriteCoeff::command(int narg, char **arg) } // parse type number and skip over it - int type = atoi(str); + int type = std::stoi(str); char *p = str; while ((*p != '\0') && (*p == ' ')) ++p; while ((*p != '\0') && isdigit(*p)) ++p;