Skip to content

Commit

Permalink
Merge pull request lammps#4250 from akohlmey/collected-small-fixes
Browse files Browse the repository at this point in the history
Collected small changes and fixes
  • Loading branch information
akohlmey authored Jul 31, 2024
2 parents ff2639a + 8bc3870 commit 18b3f6b
Show file tree
Hide file tree
Showing 28 changed files with 223 additions and 169 deletions.
2 changes: 1 addition & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ endif()
include(Testing)
include(CodeCoverage)
include(CodingStandard)
find_package(ClangFormat 8.0)
find_package(ClangFormat 11.0)

if(ClangFormat_FOUND)
add_custom_target(format-src
Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/FindClangFormat.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Find clang-format
find_program(ClangFormat_EXECUTABLE NAMES clang-format
clang-format-20.0
clang-format-19.0
clang-format-18.0
clang-format-17.0
clang-format-16.0
clang-format-15.0
Expand Down
2 changes: 1 addition & 1 deletion doc/utils/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx >= 5.3.0, <8.0
Sphinx >= 5.3.0, <7.5
sphinxcontrib-spelling
sphinxcontrib-jquery
sphinx-design
Expand Down
14 changes: 7 additions & 7 deletions src/AMOEBA/amoeba_convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#ifndef LMP_AMOEBA_CONVOLUTION_H
#define LMP_AMOEBA_CONVOLUTION_H

#include "pointers.h"
#include "lmpfftsettings.h"
#include "pointers.h"

namespace LAMMPS_NS {

Expand All @@ -27,7 +27,7 @@ class AmoebaConvolution : protected Pointers {
int nxlo_in, nxhi_in, nylo_in, nyhi_in, nzlo_in, nzhi_in;
int nxlo_out, nxhi_out, nylo_out, nyhi_out, nzlo_out, nzhi_out;
int nxlo_fft, nxhi_fft, nylo_fft, nyhi_fft, nzlo_fft, nzhi_fft;
bigint nfft_global; // nx * ny * nz
bigint nfft_global; // nx * ny * nz
FFT_SCALAR *grid_brick_start; // lower left corner of (c)grid_brick data

AmoebaConvolution(class LAMMPS *, class Pair *, int, int, int, int, int);
Expand All @@ -40,11 +40,11 @@ class AmoebaConvolution : protected Pointers {
double time_fft;

protected:
int which; // caller name for convolution being performed
int flag3d; // 1 if using 3d grid_brick, 0 for 4d cgrid_brick
int nbrick_owned; // owned grid points in brick decomp
int nbrick_ghosts; // owned + ghost brick grid points
int ngrid_either; // max of nbrick_owned or nfft_owned
int which; // caller name for convolution being performed
int flag3d; // 1 if using 3d grid_brick, 0 for 4d cgrid_brick
int nbrick_owned; // owned grid points in brick decomp
int nbrick_ghosts; // owned + ghost brick grid points
int ngrid_either; // max of nbrick_owned or nfft_owned

class Pair *amoeba;
class FFT3d *fft1, *fft2;
Expand Down
4 changes: 2 additions & 2 deletions src/DPD-REACT/fix_eos_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ void FixEOStable::param_extract(Table *tb, Table *tb2, char *line)
while (word) {
if (strcmp(word,"N") == 0) {
word = strtok(nullptr," \t\n\r\f");
tb->ninput = atoi(word);
tb2->ninput = atoi(word);
tb->ninput = std::stoi(word);
tb2->ninput = std::stoi(word);
} else {
error->one(FLERR,"Invalid keyword in fix eos/table parameters");
}
Expand Down
20 changes: 10 additions & 10 deletions src/DPD-REACT/fix_eos_table_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) :
}

if (rx_flag) read_file(arg[7]);
else dHf[0] = atof(arg[7]);
else dHf[0] = std::stod(arg[7]);

if (narg==10) {
energyCorr[0] = atof(arg[8]);
tempCorrCoeff[0] = atof(arg[9]);
energyCorr[0] = std::stod(arg[8]);
tempCorrCoeff[0] = std::stod(arg[9]);
}

comm_forward = 3;
Expand Down Expand Up @@ -373,11 +373,11 @@ void FixEOStableRX::read_file(char *file)
if (strcmp(words[0],&atom->dvname[ispecies][0]) == 0) break;

if (ispecies < nspecies) {
dHf[ispecies] = atof(words[1]);
dHf[ispecies] = std::stod(words[1]);
if (nwords > min_params_per_line+1) {
energyCorr[ispecies] = atof(words[2]);
tempCorrCoeff[ispecies] = atof(words[3]);
moleculeCorrCoeff[ispecies] = atof(words[4]);
energyCorr[ispecies] = std::stod(words[2]);
tempCorrCoeff[ispecies] = std::stod(words[3]);
moleculeCorrCoeff[ispecies] = std::stod(words[4]);
}
}
}
Expand Down Expand Up @@ -482,7 +482,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword)

word = strtok(line," \t\n\r\f");
word = strtok(nullptr," \t\n\r\f");
rtmp = atof(word);
rtmp = std::stod(word);

for (int icolumn=0; icolumn < ncolumn; icolumn++) {
ispecies = eosSpecies[icolumn];
Expand All @@ -491,7 +491,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword)
Table *tbl2 = &tables2[ispecies];

word = strtok(nullptr," \t\n\r\f");
tmpE = atof(word);
tmpE = std::stod(word);

tbl->rfile[i] = rtmp;
tbl->efile[i] = tmpE;
Expand Down Expand Up @@ -574,7 +574,7 @@ void FixEOStableRX::param_extract(Table *tb, char *line)
char *word = strtok(line," \t\n\r\f");
if (strcmp(word,"N") == 0) {
word = strtok(nullptr," \t\n\r\f");
tb->ninput = atoi(word);
tb->ninput = std::stoi(word);
} else
error->one(FLERR,"Invalid keyword in fix eos/table/rx parameters");
word = strtok(nullptr," \t\n\r\f");
Expand Down
8 changes: 4 additions & 4 deletions src/DPD-REACT/fix_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ void FixRX::read_file(char *file)

word = strtok(line," \t\n\r\f");
while (word != nullptr) {
tmpStoich = atof(word);
tmpStoich = std::stod(word);
word = strtok(nullptr, " \t\n\r\f");
for (ispecies = 0; ispecies < nspecies; ispecies++) {
if (strcmp(word,&atom->dvname[ispecies][0]) == 0) {
Expand All @@ -886,13 +886,13 @@ void FixRX::read_file(char *file)
if (strcmp(word,"=") == 0) sign = 1.0;
if (strcmp(word,"+") != 0 && strcmp(word,"=") != 0) {
if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation");
Arr[nreactions] = atof(word);
Arr[nreactions] = std::stod(word);
word = strtok(nullptr, " \t\n\r\f");
if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation");
nArr[nreactions] = atof(word);
nArr[nreactions] = std::stod(word);
word = strtok(nullptr, " \t\n\r\f");
if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation");
Ea[nreactions] = atof(word);
Ea[nreactions] = std::stod(word);
sign = -1.0;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/DPD-REACT/pair_exp6_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,15 @@ void PairExp6rx::read_file2(char *file)

if (strcmp(words[0],"alpha") == 0) {
for (int ii=1; ii<params_per_line; ii++)
coeffAlpha[ii-1] = atof(words[ii]);
coeffAlpha[ii-1] = std::stod(words[ii]);
}
if (strcmp(words[0],"epsilon") == 0) {
for (int ii=1; ii<params_per_line; ii++)
coeffEps[ii-1] = atof(words[ii]);
coeffEps[ii-1] = std::stod(words[ii]);
}
if (strcmp(words[0],"rm") == 0) {
for (int ii=1; ii<params_per_line; ii++)
coeffRm[ii-1] = atof(words[ii]);
coeffRm[ii-1] = std::stod(words[ii]);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/DPD-REACT/pair_multi_lucy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,20 +481,20 @@ void PairMultiLucy::param_extract(Table *tb, char *line)
while (word) {
if (strcmp(word,"N") == 0) {
word = strtok(nullptr," \t\n\r\f");
tb->ninput = atoi(word);
tb->ninput = std::stoi(word);
} else if (strcmp(word,"R") == 0 || strcmp(word,"RSQ") == 0) {
if (strcmp(word,"R") == 0) tb->rflag = RLINEAR;
else if (strcmp(word,"RSQ") == 0) tb->rflag = RSQ;
word = strtok(nullptr," \t\n\r\f");
tb->rlo = atof(word);
tb->rlo = std::stod(word);
word = strtok(nullptr," \t\n\r\f");
tb->rhi = atof(word);
tb->rhi = std::stod(word);
} else if (strcmp(word,"FP") == 0) {
tb->fpflag = 1;
word = strtok(nullptr," \t\n\r\f");
tb->fplo = atof(word);
tb->fplo = std::stod(word);
word = strtok(nullptr," \t\n\r\f");
tb->fphi = atof(word);
tb->fphi = std::stod(word);
} else {
printf("WORD: %s\n",word);
error->one(FLERR,"Invalid keyword in pair table parameters");
Expand Down
10 changes: 5 additions & 5 deletions src/DPD-REACT/pair_multi_lucy_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,20 +612,20 @@ void PairMultiLucyRX::param_extract(Table *tb, char *line)
while (word) {
if (strcmp(word,"N") == 0) {
word = strtok(nullptr," \t\n\r\f");
tb->ninput = atoi(word);
tb->ninput = std::stoi(word);
} else if (strcmp(word,"R") == 0 || strcmp(word,"RSQ") == 0) {
if (strcmp(word,"R") == 0) tb->rflag = RLINEAR;
else if (strcmp(word,"RSQ") == 0) tb->rflag = RSQ;
word = strtok(nullptr," \t\n\r\f");
tb->rlo = atof(word);
tb->rlo = std::stod(word);
word = strtok(nullptr," \t\n\r\f");
tb->rhi = atof(word);
tb->rhi = std::stod(word);
} else if (strcmp(word,"FP") == 0) {
tb->fpflag = 1;
word = strtok(nullptr," \t\n\r\f");
tb->fplo = atof(word);
tb->fplo = std::stod(word);
word = strtok(nullptr," \t\n\r\f");
tb->fphi = atof(word);
tb->fphi = std::stod(word);
} else {
printf("WORD: %s\n",word);
error->one(FLERR,"Invalid keyword in pair table parameters");
Expand Down
3 changes: 1 addition & 2 deletions src/ELECTRODE/electrode_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ using namespace LAMMPS_NS;
using namespace MathConst;

ElectrodeVector::ElectrodeVector(LAMMPS *lmp, int sensor_group, int source_group, double eta,
bool invert_source) :
Pointers(lmp)
bool invert_source) : Pointers(lmp)
{
igroup = sensor_group; // group of all atoms at which we calculate potential
this->source_group = source_group; // group of all atoms influencing potential
Expand Down
3 changes: 2 additions & 1 deletion src/ELECTRODE/fix_electrode_conp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ void FixElectrodeConp::update_charges()
dot_old = dot_new;
}
recompute_potential(std::move(b), q_local);
if ((delta > cg_threshold) && (comm->me == 0)) error->warning(FLERR, "CG threshold not reached");
if ((delta > cg_threshold) && (comm->me == 0))
error->warning(FLERR, "CG threshold not reached");
} else {
error->all(FLERR, "This algorithm is not implemented, yet");
}
Expand Down
2 changes: 1 addition & 1 deletion src/H5MD/dump_h5md.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int element_args(int narg, char **arg, int *every)
while (iarg<narg) {
if (strcmp(arg[iarg], "every")==0) {
if (narg<2) return -1;
*every = atoi(arg[iarg+1]);
*every = std::stoi(arg[iarg+1]);
iarg+=2;
} else {
break;
Expand Down
14 changes: 7 additions & 7 deletions src/INTEL/fix_intel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ FixIntel::FixIntel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
iarg += 2;
} else if (strcmp(arg[iarg], "tpc") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command");
_offload_tpc = atoi(arg[iarg+1]);
_offload_tpc = std::stoi(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"tptask") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command");
_offload_threads = atoi(arg[iarg+1]);
_offload_threads = std::stoi(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"no_affinity") == 0) {
no_affinity = 1;
Expand All @@ -150,7 +150,7 @@ FixIntel::FixIntel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
iarg++;
} else if (strcmp(arg[iarg],"buffers") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command");
_allow_separate_buffers = atoi(arg[iarg+1]);
_allow_separate_buffers = std::stoi(arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal package intel command");
}
Expand Down Expand Up @@ -1198,7 +1198,7 @@ int FixIntel::set_host_affinity(const int nomp)
if (p == nullptr) return -1;
ncores = 0;
while (fgets(readbuf, 512, p)) {
proc_list[ncores] = atoi(readbuf);
proc_list[ncores] = std::stoi(readbuf);
ncores++;
}
pclose(p);
Expand All @@ -1218,7 +1218,7 @@ int FixIntel::set_host_affinity(const int nomp)
if (nthreads == 0) {
estring = getenv("OMP_NUM_THREADS");
if (estring != nullptr) {
nthreads = atoi(estring);
nthreads = std::stoi(estring);
if (nthreads < 2) nthreads = 1;
} else
nthreads = 1;
Expand Down Expand Up @@ -1251,7 +1251,7 @@ int FixIntel::set_host_affinity(const int nomp)
if (p == nullptr) return -1;

while (fgets(readbuf, 512, p)) {
lwp = atoi(readbuf);
lwp = std::stoi(readbuf);
int first = coi_cores + node_rank * mpi_cores;
CPU_ZERO(&cpuset);
for (int i = first; i < first + mpi_cores; i++)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ int FixIntel::set_host_affinity(const int nomp)
if (p == nullptr) return -1;

while (fgets(readbuf, 512, p)) {
lwp = atoi(readbuf);
lwp = std::stoi(readbuf);
nlwp++;
if (nlwp <= plwp) continue;

Expand Down
6 changes: 3 additions & 3 deletions src/KIM/kim_param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ void KimParam::command(int narg, char **arg)
if (npos != std::string::npos) {
argtostr[npos] = ' ';
auto words = utils::split_words(argtostr);
nlbound = atoi(words[0].c_str());
nubound = atoi(words[1].c_str());
nlbound = std::stoi(words[0]);
nubound = std::stoi(words[1]);

if ((nubound < 1) || (nubound > extent) || (nlbound < 1) || (nlbound > nubound))
error->all(FLERR, "Illegal index_range '{}-{}' for '{}' parameter with the "
"extent of '{}'",nlbound, nubound, paramname, extent);
} else {
nlbound = atoi(argtostr.c_str());
nlbound = std::stoi(argtostr);

if (nlbound < 1 || nlbound > extent)
error->all(FLERR, "Illegal index '{}' for '{}' parameter with the extent of '{}'",
Expand Down
6 changes: 3 additions & 3 deletions src/KIM/pair_kim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,14 @@ void PairKIM::coeff(int narg, char **arg)
if (npos != std::string::npos) {
argtostr[npos] = ' ';
auto words = utils::split_words(argtostr);
nlbound = atoi(words[0].c_str());
nubound = atoi(words[1].c_str());
nlbound = std::stoi(words[0]);
nubound = std::stoi(words[1]);

if ((nubound < 1) || (nubound > extent) || (nlbound < 1) || (nlbound > nubound))
error->all(FLERR,"Illegal index_range '{}-{}' for '{}' parameter with the extent "
"of '{}'", nlbound, nubound, paramname, extent);
} else {
nlbound = atoi(argtostr.c_str());
nlbound = std::stoi(argtostr);

if ((nlbound < 1) || (nlbound > extent))
error->all(FLERR,"Illegal index '{}' for '{}' parameter with the extent of '{}'",
Expand Down
Loading

0 comments on commit 18b3f6b

Please sign in to comment.