From fd67f83bb7595db7ecff20fc9fc1fef4fe69c364 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Feb 2021 10:27:31 -0500 Subject: [PATCH 1/7] replace atoi() with utils::inumeric() --- src/fix_addforce.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index a06544e268..07031a40a4 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -83,7 +83,7 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"every") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix addforce command"); - nevery = atoi(arg[iarg+1]); + nevery = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nevery <= 0) error->all(FLERR,"Illegal fix addforce command"); iarg += 2; } else if (strcmp(arg[iarg],"region") == 0) { From 99ff0bb4d25f17a6a18c038b8489e485272e71d8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Feb 2021 16:57:49 -0500 Subject: [PATCH 2/7] fix cut-n-paste bug --- src/citeme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citeme.cpp b/src/citeme.cpp index fdd1ee867d..41ac87f5bb 100644 --- a/src/citeme.cpp +++ b/src/citeme.cpp @@ -118,7 +118,7 @@ void CiteMe::flush() if (!citefile.empty()) logbuffer += fmt::format(cite_file,"file",citefile); if (screen_flag == VERBOSE) - scrbuffer += fmt::format(cite_file,"screen","output"); + logbuffer += fmt::format(cite_file,"screen","output"); logbuffer += cite_separator; if (logfile) fputs(logbuffer.c_str(),logfile); logbuffer.clear(); From d5917652d49cd248c3aa9edab463ea2240045ec3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 20 Feb 2021 23:50:55 -0500 Subject: [PATCH 3/7] remove output that is no longer necessary. settings are adapted automatically --- cmake/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index aefa9cd597..f67699c54d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -777,9 +777,7 @@ if(PKG_GPU) message(STATUS "<<< GPU package settings >>> -- GPU API: ${GPU_API}") if(GPU_API STREQUAL "CUDA") - message(STATUS "GPU architecture: ${GPU_ARCH}") - elseif(GPU_API STREQUAL "OPENCL") - message(STATUS "OpenCL tuning: ${OCL_TUNE}") + message(STATUS "GPU default architecture: ${GPU_ARCH}") elseif(GPU_API STREQUAL "HIP") message(STATUS "HIP platform: ${HIP_PLATFORM}") message(STATUS "HIP architecture: ${HIP_ARCH}") From 826c618aa9e3a69eee32abded0686b0191d5211a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 21 Feb 2021 15:09:50 -0500 Subject: [PATCH 4/7] replace a few more cases of atoi()/atof() with utils::*numeric() functions --- src/atom.cpp | 2 +- src/compute_reduce.cpp | 4 ++-- src/fix_property_atom.cpp | 20 +++++++++++++------- src/kspace.cpp | 12 ++++++------ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 75b1b07fbf..fe260309e2 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1752,7 +1752,7 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg) if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set"); for (int itype = lo; itype <= hi; itype++) { - mass[itype] = atof(arg[1]); + mass[itype] = utils::numeric(FLERR,arg[1],false,lmp); mass_setflag[itype] = 1; if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value"); diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 82d3dff458..bc9aeefe7b 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -148,8 +148,8 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal compute reduce command"); if (mode != MINN && mode != MAXX) error->all(FLERR,"Compute reduce replace requires min or max mode"); - int col1 = atoi(arg[iarg+1]) - 1; - int col2 = atoi(arg[iarg+2]) - 1; + int col1 = utils::inumeric(FLERR,arg[iarg+1],false,lmp) - 1; + int col2 = utils::inumeric(FLERR,arg[iarg+2],false,lmp) - 1; if (col1 < 0 || col1 >= nvalues || col2 < 0 || col2 >= nvalues) error->all(FLERR,"Illegal compute reduce command"); if (col1 == col2) error->all(FLERR,"Illegal compute reduce command"); diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index c1c52a3f8c..f18888bbfc 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -254,13 +254,19 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, if ((m = atom->map(itag)) >= 0) { for (j = 0; j < nvalue; j++) { - if (style[j] == MOLECULE) atom->molecule[m] = ATOTAGINT(values[j+1]); - else if (style[j] == CHARGE) atom->q[m] = atof(values[j+1]); - else if (style[j] == RMASS) atom->rmass[m] = atof(values[j+1]); - else if (style[j] == INTEGER) - atom->ivector[index[j]][m] = atoi(values[j+1]); - else if (style[j] == DOUBLE) - atom->dvector[index[j]][m] = atof(values[j+1]); + if (style[j] == MOLECULE) { + atom->molecule[m] = utils::tnumeric(FLERR,values[j+1],false,lmp); + } else if (style[j] == CHARGE) { + atom->q[m] = utils::numeric(FLERR,values[j+1],false,lmp); + } else if (style[j] == RMASS) { + atom->rmass[m] = utils::numeric(FLERR,values[j+1],false,lmp); + } else if (style[j] == INTEGER) { + atom->ivector[index[j]][m] = utils::inumeric(FLERR,values[j+1], + false,lmp); + } else if (style[j] == DOUBLE) { + atom->dvector[index[j]][m] = utils::numeric(FLERR,values[j+1], + true,lmp); + } } } diff --git a/src/kspace.cpp b/src/kspace.cpp index 5556a5e8d0..f44cc42aaf 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -564,9 +564,9 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"kmax/ewald") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal kspace_modify command"); - kx_ewald = atoi(arg[iarg+1]); - ky_ewald = atoi(arg[iarg+2]); - kz_ewald = atoi(arg[iarg+3]); + kx_ewald = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + ky_ewald = utils::inumeric(FLERR,arg[iarg+2],false,lmp); + kz_ewald = utils::inumeric(FLERR,arg[iarg+3],false,lmp); if (kx_ewald < 0 || ky_ewald < 0 || kz_ewald < 0) error->all(FLERR,"Bad kspace_modify kmax/ewald parameter"); if (kx_ewald > 0 && ky_ewald > 0 && kz_ewald > 0) @@ -583,15 +583,15 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"force/disp/real") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - accuracy_real_6 = atof(arg[iarg+1]); + accuracy_real_6 = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"force/disp/kspace") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - accuracy_kspace_6 = atof(arg[iarg+1]); + accuracy_kspace_6 = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"eigtol") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - splittol = atof(arg[iarg+1]); + splittol = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (splittol >= 1.0) error->all(FLERR,"Kspace_modify eigtol must be smaller than one"); iarg += 2; From 06f6766ed6dab0ac18607ea9ee9d237a09569716 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 21 Feb 2021 16:20:36 -0500 Subject: [PATCH 5/7] CMAKE_FIND_LIBRARY_PREFIXES is a path. must use plain "lib" instead, but there is a variable for the suffix --- cmake/Modules/GTest.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake/Modules/GTest.cmake b/cmake/Modules/GTest.cmake index 060a7e42f9..0c62291d5e 100644 --- a/cmake/Modules/GTest.cmake +++ b/cmake/Modules/GTest.cmake @@ -20,10 +20,10 @@ ExternalProject_Add(googletest -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - BUILD_BYPRODUCTS /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${GTEST_LIB_POSTFIX}.a + BUILD_BYPRODUCTS /lib/libgtest${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgmock${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgtest_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgmock_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} LOG_DOWNLOAD ON LOG_CONFIGURE ON LOG_BUILD ON @@ -39,10 +39,10 @@ file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIR}) file(MAKE_DIRECTORY ${GMOCK_INCLUDE_DIR}) ExternalProject_Get_Property(googletest BINARY_DIR) -set(GTEST_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${GTEST_LIB_POSTFIX}.a) -set(GMOCK_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${GTEST_LIB_POSTFIX}.a) -set(GTEST_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${GTEST_LIB_POSTFIX}.a) -set(GMOCK_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${GTEST_LIB_POSTFIX}.a) +set(GTEST_LIBRARY_PATH ${BINARY_DIR}/lib/libgtest${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GMOCK_LIBRARY_PATH ${BINARY_DIR}/lib/libgmock${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GTEST_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/libgtest_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GMOCK_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/libgmock_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) # Prevent GoogleTest from overriding our compiler/linker options # when building with Visual Studio From e0e89c588ba0c907f60824806dcf5ea84e8090d5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 21 Feb 2021 17:11:38 -0500 Subject: [PATCH 6/7] correct library prefix name use also for building libyaml --- cmake/Modules/YAML.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/YAML.cmake b/cmake/Modules/YAML.cmake index a080b566be..f2ba34e1b6 100644 --- a/cmake/Modules/YAML.cmake +++ b/cmake/Modules/YAML.cmake @@ -12,7 +12,7 @@ ExternalProject_Add(libyaml CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} --prefix= --disable-shared - BUILD_BYPRODUCTS /lib/${CMAKE_FIND_LIBRARY_PREFIXES}yaml.a + BUILD_BYPRODUCTS /lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX} TEST_COMMAND "") ExternalProject_Get_Property(libyaml INSTALL_DIR) @@ -23,7 +23,7 @@ set(YAML_LIBRARY_DIR ${INSTALL_DIR}/lib) file(MAKE_DIRECTORY ${YAML_INCLUDE_DIR}) file(MAKE_DIRECTORY ${YAML_LIBRARY_DIR}) -set(YAML_LIBRARY_PATH ${INSTALL_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}yaml.a) +set(YAML_LIBRARY_PATH ${INSTALL_DIR}/lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX}) add_library(Yaml::Yaml UNKNOWN IMPORTED) set_target_properties(Yaml::Yaml PROPERTIES From f3ee948450bbc63eef80c3bad1a2de382dda7b75 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 22 Feb 2021 07:05:20 -0500 Subject: [PATCH 7/7] need to use column 1 in fix ave/time example --- doc/src/compute_temp_chunk.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/compute_temp_chunk.rst b/doc/src/compute_temp_chunk.rst index 77e2568fce..f1c34b42fa 100644 --- a/doc/src/compute_temp_chunk.rst +++ b/doc/src/compute_temp_chunk.rst @@ -153,7 +153,7 @@ temp/chunk calculation to a file is to use the :doc:`fix ave/time compute cc1 all chunk/atom molecule compute myChunk all temp/chunk cc1 temp - fix 1 all ave/time 100 1 100 c_myChunk file tmp.out mode vector + fix 1 all ave/time 100 1 100 c_myChunk[1] file tmp.out mode vector ----------