diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 266a79bc3c..ba51ab8697 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -399,7 +399,7 @@ void PairEAMAlloyGPU::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index 2bd5a53324..62a7ad866d 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -30,6 +30,7 @@ #include "gpu_extra.h" #include "domain.h" #include "suffix.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -398,7 +399,7 @@ void PairEAMFSGPU::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index 1963722d86..c822b4c3fa 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -29,6 +29,7 @@ #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -1012,7 +1013,7 @@ void PairEAMAlloyKokkos::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index a33923887b..581de7d163 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -29,6 +29,7 @@ #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -1012,7 +1013,7 @@ void PairEAMFSKokkos::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index a64df08127..8c98e32d5b 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -32,6 +32,7 @@ #include "neigh_request.h" #include "atom_kokkos.h" #include "kokkos.h" +#include "utils.h" #ifdef _OPENMP #include @@ -1752,7 +1753,7 @@ void PairExp6rxKokkos::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -1771,7 +1772,7 @@ void PairExp6rxKokkos::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index e730466fcb..eb88583801 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -571,7 +571,7 @@ void PairADP::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in ADP potential file"); diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 2fc4caec7b..48f2665b1b 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -34,6 +34,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -623,7 +624,7 @@ void PairComb::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -642,7 +643,7 @@ void PairComb::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index bf66ea550a..08de937cf3 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -634,7 +634,7 @@ void PairComb3::read_file(char *file) if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -654,7 +654,7 @@ void PairComb3::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line){ error->all(FLERR,"Incorrect format in COMB3 potential file"); diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index a9622f9e07..6472426038 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -147,7 +147,7 @@ void PairEAMAlloy::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index c91e7b5298..378af8d861 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -147,7 +147,7 @@ void PairEAMFS::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 667311812b..363eb9231b 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -29,6 +29,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" @@ -408,7 +409,7 @@ void PairGW::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -427,7 +428,7 @@ void PairGW::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index d39bf53b99..27ab1a3bde 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -27,6 +27,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" using namespace LAMMPS_NS; @@ -102,7 +103,7 @@ void PairGWZBL::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -121,7 +122,7 @@ void PairGWZBL::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 92456790cc..3a446b2680 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -29,6 +29,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -325,7 +326,7 @@ void PairNb3bHarmonic::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -344,7 +345,7 @@ void PairNb3bHarmonic::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index f1d1a6fa9f..30ceb1b2d0 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -28,6 +28,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -389,7 +390,7 @@ void PairSW::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -408,7 +409,7 @@ void PairSW::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index 5f53760e71..fb26beee1d 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -28,6 +28,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" #include "math_special.h" @@ -433,7 +434,7 @@ void PairTersoff::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -452,7 +453,7 @@ void PairTersoff::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 9d4bdb7fd0..d6d097727b 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -28,6 +28,7 @@ #include "math_special.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -86,7 +87,7 @@ void PairTersoffMOD::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -105,7 +106,7 @@ void PairTersoffMOD::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index 6c2c4f4e7a..f38feccd3f 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -25,6 +25,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -77,7 +78,7 @@ void PairTersoffMODC::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -96,7 +97,7 @@ void PairTersoffMODC::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index d5e3fb1b0f..f09835d575 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -29,6 +29,7 @@ #include "error.h" #include "math_const.h" #include "math_special.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -104,7 +105,7 @@ void PairTersoffZBL::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -123,7 +124,7 @@ void PairTersoffZBL::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 13b44c58a4..bc360c782a 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -29,6 +29,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -395,7 +396,7 @@ void PairVashishta::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -414,7 +415,7 @@ void PairVashishta::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index fb0a550898..a1b4d23b05 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -41,6 +41,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -1066,7 +1067,7 @@ void FixCMAP::read_data_section(char *keyword, int n, char *buf, next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != 7) { diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 84ba33e28a..63fa3caefe 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -27,6 +27,7 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -738,7 +739,7 @@ void FixQEq::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // must have 6 parameters per line. diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index dafc0c0875..5a1f942815 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -33,6 +33,7 @@ #include "error.h" #include "force.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -447,7 +448,7 @@ void NEB::readfile(char *file, int flag) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != ATTRIBUTE_PERLINE) diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index d77bf988a6..28a348e58b 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -35,6 +35,7 @@ #include "memory.h" #include "error.h" #include "rigid_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -2330,7 +2331,7 @@ void FixRigid::readfile(int which, double *vec, buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != ATTRIBUTE_PERBODY) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 9974a7f888..89fa3add4b 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -39,6 +39,7 @@ #include "memory.h" #include "error.h" #include "rigid_const.h" +#include "utils.h" #include @@ -2488,7 +2489,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != ATTRIBUTE_PERBODY) diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 8c252cca1d..7108e62142 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -25,6 +25,7 @@ #include "sna.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -526,7 +527,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != 2) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -567,7 +568,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords != 3) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -609,7 +610,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords != 1) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -666,7 +667,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; if (nwords != 2) diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 075850d1af..5d58a22567 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -441,7 +441,7 @@ void NEBSpin::readfile(char *file, int flag) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != ATTRIBUTE_PERLINE) diff --git a/src/USER-DPD/fix_eos_table_rx.cpp b/src/USER-DPD/fix_eos_table_rx.cpp index 3fe2f479bf..d9641f2aab 100644 --- a/src/USER-DPD/fix_eos_table_rx.cpp +++ b/src/USER-DPD/fix_eos_table_rx.cpp @@ -337,7 +337,7 @@ void FixEOStableRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -356,7 +356,7 @@ void FixEOStableRX::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != min_params_per_line && nwords != max_params_per_line) @@ -475,7 +475,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) for (int i = 0; i < ninputs; i++) { utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - nwords = atom->count_words(line); + nwords = utils::count_words(utils::trim_comment(line)); if(nwords != nspecies+2){ printf("nwords=%d nspecies=%d\n",nwords,nspecies); error->all(FLERR,"Illegal fix eos/table/rx command"); diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 3d870cc902..07e56d9db8 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -31,6 +31,7 @@ #include "neigh_request.h" #include "math_special.h" #include "pair_dpd_fdt_energy.h" +#include "utils.h" #include // std::vector<> #include // std::max @@ -296,7 +297,7 @@ void FixRX::post_constructor() // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line @@ -884,7 +885,7 @@ void FixRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; nreactions++; @@ -938,7 +939,7 @@ void FixRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index 4aee497b64..f13f911326 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -756,7 +756,7 @@ void PairExp6rx::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -775,7 +775,7 @@ void PairExp6rx::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -865,7 +865,7 @@ void PairExp6rx::read_file2(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -884,7 +884,7 @@ void PairExp6rx::read_file2(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-INTEL/pair_eam_alloy_intel.cpp b/src/USER-INTEL/pair_eam_alloy_intel.cpp index da8a180fff..c71d27a40b 100644 --- a/src/USER-INTEL/pair_eam_alloy_intel.cpp +++ b/src/USER-INTEL/pair_eam_alloy_intel.cpp @@ -24,6 +24,7 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -146,7 +147,7 @@ void PairEAMAlloyIntel::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/USER-INTEL/pair_eam_fs_intel.cpp b/src/USER-INTEL/pair_eam_fs_intel.cpp index 043f77db3e..d69c79f168 100644 --- a/src/USER-INTEL/pair_eam_fs_intel.cpp +++ b/src/USER-INTEL/pair_eam_fs_intel.cpp @@ -24,6 +24,7 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -146,7 +147,7 @@ void PairEAMFSIntel::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index c49b5abf0b..6cd8ec6136 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -28,6 +28,7 @@ #include "neigh_request.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -383,7 +384,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -396,7 +397,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) break; } if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -561,7 +562,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if (atom->count_words(line) == 0) continue; + if (utils::count_words(line) == 0) continue; // params = ptrs to all fields in line diff --git a/src/USER-MISC/fix_gle.cpp b/src/USER-MISC/fix_gle.cpp index b8bdc66d08..a1cf1ac2e9 100644 --- a/src/USER-MISC/fix_gle.cpp +++ b/src/USER-MISC/fix_gle.cpp @@ -29,6 +29,7 @@ #include "random_mars.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -251,7 +252,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; ptr = strtok(line," \t\n\r\f"); @@ -323,7 +324,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; ptr = strtok(line," \t\n\r\f"); diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index a03e24ed35..4941f2c7b3 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -31,6 +31,7 @@ #include "citeme.h" #include "math_special.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathSpecial; @@ -387,7 +388,7 @@ void PairAGNI::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; if (nwords > MAXWORD) diff --git a/src/USER-MISC/pair_drip.cpp b/src/USER-MISC/pair_drip.cpp index bb28d056ac..e6b0e5acc6 100644 --- a/src/USER-MISC/pair_drip.cpp +++ b/src/USER-MISC/pair_drip.cpp @@ -254,7 +254,7 @@ void PairDRIP::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -273,7 +273,7 @@ void PairDRIP::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index 8dee4a606b..d873a04c39 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -35,6 +35,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -905,7 +906,7 @@ void PairEDIP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -924,7 +925,7 @@ void PairEDIP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 9f953610de..cfda5c1a7c 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -31,6 +31,7 @@ #include "memory.h" #include "error.h" #include "citeme.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -671,7 +672,7 @@ void PairEDIPMulti::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -690,7 +691,7 @@ void PairEDIPMulti::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 62ef24da85..2036df7add 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -30,6 +30,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" @@ -619,7 +620,7 @@ void PairExTeP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -638,7 +639,7 @@ void PairExTeP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -744,7 +745,7 @@ void PairExTeP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index cf77f7e1ee..32689307c0 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -34,6 +34,7 @@ #include "my_page.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -286,7 +287,7 @@ void PairILPGrapheneHBN::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -305,7 +306,7 @@ void PairILPGrapheneHBN::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index 3f624fc785..f5f2a6ca01 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -34,6 +34,7 @@ #include "my_page.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -287,7 +288,7 @@ void PairKolmogorovCrespiFull::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -306,7 +307,7 @@ void PairKolmogorovCrespiFull::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index 61c326ac87..07f0a766e4 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -32,6 +32,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -345,7 +346,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -364,7 +365,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 8930042cef..f6464153e5 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -33,6 +33,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -341,7 +342,7 @@ void PairLebedevaZ::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -360,7 +361,7 @@ void PairLebedevaZ::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 5c4f60f354..57c897bdfc 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -32,6 +32,7 @@ #include "force.h" #include "comm.h" #include "memory.h" +#include "utils.h" #include "error.h" @@ -873,7 +874,7 @@ void PairTersoffTable::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -892,7 +893,7 @@ void PairTersoffTable::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-OMP/pair_eam_alloy_omp.cpp b/src/USER-OMP/pair_eam_alloy_omp.cpp index d36574713f..83851b7f3c 100644 --- a/src/USER-OMP/pair_eam_alloy_omp.cpp +++ b/src/USER-OMP/pair_eam_alloy_omp.cpp @@ -147,7 +147,7 @@ void PairEAMAlloyOMP::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/USER-OMP/pair_eam_fs_omp.cpp b/src/USER-OMP/pair_eam_fs_omp.cpp index d1014c5a14..5baab303e2 100644 --- a/src/USER-OMP/pair_eam_fs_omp.cpp +++ b/src/USER-OMP/pair_eam_fs_omp.cpp @@ -147,7 +147,7 @@ void PairEAMFSOMP::read_file(char *filename) MPI_Bcast(line,n,MPI_CHAR,0,world); sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords != file->nelements + 1) error->all(FLERR,"Incorrect element names in EAM potential file"); diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index 096a42b1a8..b11e750505 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -30,6 +30,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" #include "math_special.h" @@ -125,7 +126,7 @@ void PairTersoffZBLOMP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -144,7 +145,7 @@ void PairTersoffZBLOMP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/atom.cpp b/src/atom.cpp index 1ed28507ad..134def74a3 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1031,56 +1031,6 @@ void Atom::bonus_check() "atoms with enabled body flags"); } -/* ---------------------------------------------------------------------- - count and return words in a single line - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line) -{ - int n = strlen(line) + 1; - char *copy; - memory->create(copy,n,"atom:copy"); - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - memory->destroy(copy); - return n; -} - -/* ---------------------------------------------------------------------- - count and return words in a single line using provided copy buf - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line, char *copy) -{ - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - int n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - return n; -} - /* ---------------------------------------------------------------------- deallocate molecular topology arrays done before realloc with (possibly) new 2nd dimension set to @@ -1139,7 +1089,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3) @@ -1289,7 +1239,7 @@ void Atom::data_vels(int n, char *buf, tagint id_offset) next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec->size_data_vel) @@ -1641,7 +1591,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset) next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec_bonus->size_data_bonus) diff --git a/src/atom.h b/src/atom.h index c55821eea2..b94189e6e1 100644 --- a/src/atom.h +++ b/src/atom.h @@ -277,8 +277,6 @@ class Atom : protected Pointers { void bonus_check(); int parse_data(const char *); - int count_words(const char *); - int count_words(const char *, char *); void deallocate_topology(); diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 555114e4f9..5fb17ca636 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -18,6 +18,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -217,7 +218,7 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != nvalue+1) { diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp index 604660e7c4..182da8ecaa 100644 --- a/src/fix_tmd.cpp +++ b/src/fix_tmd.cpp @@ -447,12 +447,12 @@ void FixTMD::readfile(char *file) zprd = hi - lo; bufptr = next + 1; continue; - } else if (atom->count_words(bufptr) == 4) { + } else if (utils::count_words(bufptr) == 4) { if (xprd >= 0.0 || yprd >= 0.0 || zprd >= 0.0) error->all(FLERR,"Incorrect format in TMD target file"); imageflag = 0; firstline = 0; - } else if (atom->count_words(bufptr) == 7) { + } else if (utils::count_words(bufptr) == 7) { if (xprd < 0.0 || yprd < 0.0 || zprd < 0.0) error->all(FLERR,"Incorrect format in TMD target file"); imageflag = 1; diff --git a/src/molecule.cpp b/src/molecule.cpp index 15b2385436..1f0a9e1601 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -25,6 +25,7 @@ #include "math_extra.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -1400,7 +1401,7 @@ void Molecule::body(int flag, int pflag, char *line) while (nword < nparam) { readline(line); - ncount = atom->count_words(line); + ncount = utils::count_words(line); if (ncount == 0) error->one(FLERR,"Too few values in body section of molecule file"); if (nword+ncount > nparam) diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 628f6a6b36..4511b34c24 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -30,6 +30,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -278,7 +279,7 @@ void PairCoulStreitz::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -297,7 +298,7 @@ void PairCoulStreitz::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/read_data.cpp b/src/read_data.cpp index c9bf86fb2b..edeb6398b8 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -70,7 +70,6 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) { MPI_Comm_rank(world,&me); line = new char[MAXLINE]; - copy = new char[MAXLINE]; keyword = new char[MAXLINE]; style = new char[MAXLINE]; buffer = new char[CHUNK*MAXLINE]; @@ -96,7 +95,6 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) ReadData::~ReadData() { delete [] line; - delete [] copy; delete [] keyword; delete [] style; delete [] buffer; @@ -1736,7 +1734,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr) while (nword < ninteger) { eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); + ncount = utils::count_words(&buffer[m]); if (ncount == 0) error->one(FLERR,"Too few values in body lines in data file"); nword += ncount; @@ -1750,7 +1748,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr) while (nword < ndouble) { eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); + ncount = utils::count_words(&buffer[m]); if (ncount == 0) error->one(FLERR,"Too few values in body lines in data file"); nword += ncount; diff --git a/src/read_data.h b/src/read_data.h index aee54ef3ed..84c098635a 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -32,7 +32,7 @@ class ReadData : protected Pointers { private: int me,compressed; - char *line,*copy,*keyword,*buffer,*style; + char *line,*keyword,*buffer,*style; FILE *fp; char **arg; int narg,maxarg; diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 26cb45a686..6cb8096d9c 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -162,7 +162,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, char *labelline = &line[strlen("ITEM: ATOMS ")]; - nwords = atom->count_words(labelline); + nwords = utils::count_words(labelline); char **labels = new char*[nwords]; labels[0] = strtok(labelline," \t\n\r\f"); if (labels[0] == NULL) { diff --git a/src/thermo.cpp b/src/thermo.cpp index 3748ee77fe..73c915da4a 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -44,6 +44,7 @@ #include "memory.h" #include "error.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -159,7 +160,7 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) // allocate per-field memory // process line of keywords - nfield_initial = atom->count_words(line); + nfield_initial = utils::count_words(line); allocate(); parse_fields(line);