diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 18ad8255ef..ec28fdb06b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,8 +1,9 @@ +# -*- CMake -*- master configuration file for building LAMMPS ######################################## # CMake build system # This file is part of LAMMPS # Created by Christoph Junghans and Richard Berger -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) ######################################## # set policy to silence warnings about ignoring _ROOT but use it if(POLICY CMP0074) @@ -12,22 +13,11 @@ endif() if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() -# set policy to silence warnings about missing executable permissions in -# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW -if(POLICY CMP0109) - cmake_policy(SET CMP0109 OLD) -endif() # set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) endif() -######################################## -# Use CONFIGURE_DEPENDS as option for file(GLOB...) when available -if(CMAKE_VERSION VERSION_LESS 3.12) - unset(CONFIGURE_DEPENDS) -else() - set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) -endif() + ######################################## project(lammps CXX) @@ -203,8 +193,8 @@ else() endif() include(GNUInstallDirs) -file(GLOB ALL_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) -file(GLOB MAIN_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/main.cpp) +file(GLOB ALL_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB MAIN_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/main.cpp) list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES}) add_library(lammps ${ALL_SOURCES}) @@ -442,7 +432,7 @@ if(PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTRODE OR BUILD_T find_package(BLAS) endif() if(NOT LAPACK_FOUND OR NOT BLAS_FOUND OR USE_INTERNAL_LINALG) - file(GLOB LINALG_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) + file(GLOB LINALG_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) add_library(linalg STATIC ${LINALG_SOURCES}) set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE}) set(BLAS_LIBRARIES "$") @@ -460,12 +450,7 @@ option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) if(WITH_JPEG) find_package(JPEG REQUIRED) target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE JPEG::JPEG) - endif() + target_link_libraries(lammps PRIVATE JPEG::JPEG) endif() find_package(PNG QUIET) @@ -577,8 +562,8 @@ endforeach() foreach(PKG ${STANDARD_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -605,8 +590,8 @@ endforeach() foreach(PKG ${SUFFIX_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -620,7 +605,7 @@ endforeach() foreach(PKG_LIB POEMS ATC AWPMD H5MD) if(PKG_${PKG_LIB}) string(TOLOWER "${PKG_LIB}" PKG_LIB) - file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${CONFIGURE_DEPENDS} + file(GLOB_RECURSE ${PKG_LIB}_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE}) @@ -815,20 +800,11 @@ install( # This is primarily for people that only want to use the Python wrapper. ############################################################################### if(BUILD_SHARED_LIBS) - if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - else() - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() + find_package(Python COMPONENTS Interpreter) if(BUILD_IS_MULTI_CONFIG) set(MY_BUILD_DIR ${CMAKE_BINARY_DIR}/$) else() @@ -887,13 +863,23 @@ else() endif() include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) +if(GIT_FOUND AND EXISTS ${LAMMPS_DIR}/.git) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=-modified --always + OUTPUT_VARIABLE GIT_DESCRIBE + ERROR_QUIET + WORKING_DIRECTORY ${LAMMPS_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() message(STATUS "<<< Build configuration >>> - LAMMPS Version: ${PROJECT_VERSION} + LAMMPS Version: ${PROJECT_VERSION} ${GIT_DESCRIBE} Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} CMake Version: ${CMAKE_VERSION} Build type: ${LAMMPS_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") +if(CMAKE_CROSSCOMPILING) + message(STATUS "Cross compiling on ${CMAKE_HOST_SYSTEM}") +endif() ############################################################################### # Print package summary ############################################################################### @@ -937,11 +923,9 @@ if(_index GREATER -1) endif() message(STATUS "<<< Linker flags: >>>") message(STATUS "Executable name: ${LAMMPS_BINARY}") -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - get_target_property(OPTIONS lammps LINK_OPTIONS) - if(OPTIONS) - message(STATUS "Linker options: ${OPTIONS}") - endif() +get_target_property(OPTIONS lammps LINK_OPTIONS) +if(OPTIONS) + message(STATUS "Linker options: ${OPTIONS}") endif() if(CMAKE_EXE_LINKER_FLAGS) message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}") diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 4efd373d22..94639c7771 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -1,19 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python3_VERSION ${PYTHON_VERSION_STRING}) - endif() -else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.5) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 COMPONENTS Interpreter QUIET) +# use default (or custom) Python executable, if version is sufficient +if(Python_VERSION VERSION_GREATER_EQUAL 3.6) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() +find_package(Python3 COMPONENTS Interpreter) if(Python3_EXECUTABLE) - if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) + if(Python3_VERSION VERSION_GREATER_EQUAL 3.6) add_custom_target( check-whitespace ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py . diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 0b01407cd9..400109067f 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -5,24 +5,18 @@ option(BUILD_DOC "Build LAMMPS HTML documentation" OFF) if(BUILD_DOC) # Current Sphinx versions require at least Python 3.8 - if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.8 REQUIRED) - set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv) - else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.8) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 REQUIRED COMPONENTS Interpreter) - if(Python3_VERSION VERSION_LESS 3.8) - message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") - endif() - set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.8) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) + if(Python3_VERSION VERSION_LESS 3.8) + message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") + endif() + set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + find_package(Doxygen 1.8.10 REQUIRED) - - file(GLOB DOC_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_DOC_DIR}/src/[^.]*.rst) - + file(GLOB DOC_SOURCES CONFIGURE_DEPENDS ${LAMMPS_DOC_DIR}/src/[^.]*.rst) add_custom_command( OUTPUT docenv @@ -80,7 +74,7 @@ if(BUILD_DOC) message(STATUS "Using already downloaded archive ${CMAKE_BINARY_DIR}/libpace.tar.gz") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - file(GLOB MATHJAX_VERSION_DIR ${CONFIGURE_DEPENDS} ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) + file(GLOB MATHJAX_VERSION_DIR CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${DOC_BUILD_STATIC_DIR}/mathjax) endif() diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake index 97f0304279..fe436aef28 100644 --- a/cmake/Modules/FindCythonize.cmake +++ b/cmake/Modules/FindCythonize.cmake @@ -7,15 +7,7 @@ # adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake #============================================================================= -if(CMAKE_VERSION VERSION_LESS 3.12) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.6 COMPONENTS Interpreter QUIET) -endif() +find_package(Python 3.6 COMPONENTS Interpreter QUIET) # Use the Cython executable that lives next to the Python executable # if it is a local installation. diff --git a/cmake/Modules/LAMMPSInterfacePlugin.cmake b/cmake/Modules/LAMMPSInterfacePlugin.cmake index 024dc571b3..7d4c06184e 100644 --- a/cmake/Modules/LAMMPSInterfacePlugin.cmake +++ b/cmake/Modules/LAMMPSInterfacePlugin.cmake @@ -63,7 +63,7 @@ endfunction(validate_option) # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 1ceec7e06e..bb5ea07609 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -41,7 +41,7 @@ endfunction() # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) @@ -80,8 +80,8 @@ endfunction() function(check_for_autogen_files source_dir) message(STATUS "Running check for auto-generated files from make-based build system") - file(GLOB SRC_AUTOGEN_FILES ${CONFIGURE_DEPENDS} ${source_dir}/style_*.h) - file(GLOB SRC_AUTOGEN_PACKAGES ${CONFIGURE_DEPENDS} ${source_dir}/packages_*.h) + file(GLOB SRC_AUTOGEN_FILES CONFIGURE_DEPENDS ${source_dir}/style_*.h) + file(GLOB SRC_AUTOGEN_PACKAGES CONFIGURE_DEPENDS ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) diff --git a/cmake/Modules/Packages/COLVARS.cmake b/cmake/Modules/Packages/COLVARS.cmake index 325e0e205e..745c1de026 100644 --- a/cmake/Modules/Packages/COLVARS.cmake +++ b/cmake/Modules/Packages/COLVARS.cmake @@ -1,6 +1,6 @@ set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars) -file(GLOB COLVARS_SOURCES ${CONFIGURE_DEPENDS} ${COLVARS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB COLVARS_SOURCES CONFIGURE_DEPENDS ${COLVARS_SOURCE_DIR}/[^.]*.cpp) option(COLVARS_DEBUG "Enable debugging messages for Colvars (quite verbose)" OFF) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 99321fce9f..47be8b8538 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -39,7 +39,7 @@ if (PKG_AMOEBA) ${GPU_SOURCES_DIR}/amoeba_convolution_gpu.cpp) endif() -file(GLOB GPU_LIB_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) +file(GLOB GPU_LIB_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) if(GPU_API STREQUAL "CUDA") @@ -70,7 +70,7 @@ if(GPU_API STREQUAL "CUDA") set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") # ensure that no *cubin.h files exist from a compile in the lib/gpu folder - file(GLOB GPU_LIB_OLD_CUBIN_HEADERS ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) + file(GLOB GPU_LIB_OLD_CUBIN_HEADERS CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) if(GPU_LIB_OLD_CUBIN_HEADERS) message(FATAL_ERROR "########################################################################\n" "Found file(s) generated by the make-based build system in lib/gpu\n" @@ -80,15 +80,15 @@ if(GPU_API STREQUAL "CUDA") "########################################################################") endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) if(CUDPP_OPT) cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) - file(GLOB GPU_LIB_CUDPP_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) - file(GLOB GPU_LIB_CUDPP_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) + file(GLOB GPU_LIB_CUDPP_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) + file(GLOB GPU_LIB_CUDPP_CU CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) endif() # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice @@ -205,7 +205,7 @@ elseif(GPU_API STREQUAL "OPENCL") include(OpenCLUtils) set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h) - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu) list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu @@ -335,7 +335,7 @@ elseif(GPU_API STREQUAL "HIP") endif() endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) set(GPU_LIB_CU_HIP "") diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 995d2d9490..d724ec18fc 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -1,12 +1,7 @@ set(KIM-API_MIN_VERSION 2.1.3) find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE CURL::libcurl) - endif() + target_link_libraries(lammps PRIVATE CURL::libcurl) target_compile_definitions(lammps PRIVATE -DLMP_KIM_CURL) set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.") mark_as_advanced(LMP_DEBUG_CURL) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 931bc0fa53..6359d9e615 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -156,7 +156,7 @@ if(PKG_ML-IAP) # Add KOKKOS version of ML-IAP Python coupling if non-KOKKOS version is included if(MLIAP_ENABLE_PYTHON AND Cythonize_EXECUTABLE) - file(GLOB MLIAP_KOKKOS_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) + file(GLOB MLIAP_KOKKOS_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) foreach(MLIAP_CYTHON_FILE ${MLIAP_KOKKOS_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h diff --git a/cmake/Modules/Packages/LEPTON.cmake b/cmake/Modules/Packages/LEPTON.cmake index 33e14d092c..b1944c2400 100644 --- a/cmake/Modules/Packages/LEPTON.cmake +++ b/cmake/Modules/Packages/LEPTON.cmake @@ -4,7 +4,7 @@ if(LEPTON_SOURCE_DIR) endif() set(LEPTON_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/lepton) -file(GLOB LEPTON_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) +file(GLOB LEPTON_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64") OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64") OR @@ -15,7 +15,7 @@ else() endif() if(LEPTON_ENABLE_JIT) - file(GLOB ASMJIT_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) + file(GLOB ASMJIT_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) endif() add_library(lepton STATIC ${LEPTON_SOURCES} ${ASMJIT_SOURCES}) diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index dc3af94a0a..447b941d99 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -26,29 +26,9 @@ if(DOWNLOAD_MDI) # detect if we have python development support and thus can enable python plugins set(MDI_USE_PYTHON_PLUGINS OFF) - if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs QUIET) # Deprecated since version 3.12 - if(PYTHONLIBS_FOUND) - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - set(MDI_USE_PYTHON_PLUGINS ON) - endif() - else() - find_package(Python QUIET COMPONENTS Development) - if(Python_Development_FOUND) - set(MDI_USE_PYTHON_PLUGINS ON) - endif() + find_package(Python QUIET COMPONENTS Development) + if(Python_Development_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) endif() # python plugins are not supported and thus must be always off on Windows if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -102,13 +82,9 @@ if(DOWNLOAD_MDI) # if compiling with python plugins we need # to add python libraries as dependency. if(MDI_USE_PYTHON_PLUGINS) - if(CMAKE_VERSION VERSION_LESS 3.12) - list(APPEND MDI_DEP_LIBS ${PYTHON_LIBRARIES}) - else() - list(APPEND MDI_DEP_LIBS Python::Python) - endif() - + list(APPEND MDI_DEP_LIBS Python::Python) endif() + # need to add support for dlopen/dlsym, except when compiling for Windows. if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}") diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index f8439be538..d6059c44b8 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -2,12 +2,7 @@ set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize QUIET) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy QUIET) - else() - # assume we have NumPy - set(Python_NumPy_FOUND ON) - endif() + find_package(Python COMPONENTS NumPy QUIET) if(Cythonize_FOUND AND Python_NumPy_FOUND) set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() @@ -17,24 +12,16 @@ option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_EN if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy REQUIRED) - endif() + find_package(Python COMPONENTS NumPy REQUIRED) if(NOT PKG_PYTHON) message(FATAL_ERROR "Must enable PYTHON package for including Python support in ML-IAP") endif() - if(CMAKE_VERSION VERSION_LESS 3.12) - if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() - else() - if(Python_VERSION VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() + if(Python_VERSION VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) - file(GLOB MLIAP_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) + file(GLOB MLIAP_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) foreach(MLIAP_CYTHON_FILE ${MLIAP_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index 4a2925fe31..59260e39d5 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -1,29 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() + +if(NOT Python_INTERPRETER) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) -else() - if(NOT Python_INTERPRETER) - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) - endif() - find_package(Python REQUIRED COMPONENTS Interpreter Development) - target_link_libraries(lammps PRIVATE Python::Python) + find_package(Python COMPONENTS Interpreter) endif() +find_package(Python REQUIRED COMPONENTS Interpreter Development) +target_link_libraries(lammps PRIVATE Python::Python) target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index 2a0a91e843..d4644bd042 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -1,5 +1,5 @@ function(FindStyleHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(hlist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) @@ -187,7 +187,7 @@ endfunction(DetectBuildSystemConflict) function(FindPackagesHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(plist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 5345211178..ff595d3c8f 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -6,7 +6,7 @@ if(ENABLE_TESTING) find_program(VALGRIND_BINARY NAMES valgrind) # generate custom suppression file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "\n") - file(GLOB VALGRIND_SUPPRESSION_FILES ${CONFIGURE_DEPENDS} ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) + file(GLOB VALGRIND_SUPPRESSION_FILES CONFIGURE_DEPENDS ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) foreach(SUPP ${VALGRIND_SUPPRESSION_FILES}) file(READ ${SUPP} SUPPRESSIONS) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "${SUPPRESSIONS}") @@ -19,7 +19,7 @@ if(ENABLE_TESTING) # we need to build and link a LOT of tester executables, so it is worth checking if # a faster linker is available. requires GNU or Clang compiler, newer CMake. # also only verified with Fedora Linux > 30 and Ubuntu 18.04 or 22.04+(Ubuntu 20.04 fails) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND ((CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04) OR (CMAKE_DISTRO_VERSION VERSION_GREATER_EQUAL 22.04))) @@ -66,16 +66,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() - else() - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) - endif() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) endif() endif() @@ -118,16 +110,8 @@ validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) if(NOT ENABLE_SANITIZER STREQUAL "none") if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - endif() - else() - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) else() message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") set(ENABLE_SANITIZER "none") diff --git a/cmake/Modules/Tools.cmake b/cmake/Modules/Tools.cmake index b9ead04e45..133301c3d4 100644 --- a/cmake/Modules/Tools.cmake +++ b/cmake/Modules/Tools.cmake @@ -26,7 +26,7 @@ if(BUILD_TOOLS) enable_language(C) get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) - file(GLOB MSI2LMP_SOURCES ${CONFIGURE_DEPENDS} ${MSI2LMP_SOURCE_DIR}/[^.]*.c) + file(GLOB MSI2LMP_SOURCES CONFIGURE_DEPENDS ${MSI2LMP_SOURCE_DIR}/[^.]*.c) add_executable(msi2lmp ${MSI2LMP_SOURCES}) if(STANDARD_MATH_LIB) target_link_libraries(msi2lmp PRIVATE ${STANDARD_MATH_LIB}) diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index 9be2c33165..6c46f6d672 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -16,8 +16,7 @@ environments is on a :doc:`separate page `. .. note:: - LAMMPS currently requires that CMake version 3.10 or later is available; - version 3.12 or later is preferred. + LAMMPS currently requires that CMake version 3.16 or later is available. .. warning:: @@ -34,19 +33,18 @@ Advantages of using CMake ^^^^^^^^^^^^^^^^^^^^^^^^^ CMake is an alternative to compiling LAMMPS in the traditional way -through :doc:`(manually customized) makefiles ` and a recent -addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL) -and Richard Berger (Temple U). Using CMake has multiple advantages that -are specifically helpful for people with limited experience in compiling -software or for people that want to modify or extend LAMMPS. +through :doc:`(manually customized) makefiles `. Using +CMake has multiple advantages that are specifically helpful for +people with limited experience in compiling software or for people +that want to modify or extend LAMMPS. - CMake can detect available hardware, tools, features, and libraries and adapt the LAMMPS default build configuration accordingly. - CMake can generate files for different build tools and integrated development environments (IDE). - CMake supports customization of settings with a command line, text - mode, or graphical user interface. No knowledge of file formats or - complex command line syntax is required. + mode, or graphical user interface. No manual editing of files, + knowledge of file formats or complex command line syntax is required. - All enabled components are compiled in a single build operation. - Automated dependency tracking for all files and configuration options. - Support for true out-of-source compilation. Multiple configurations diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 9066531459..19e56fcc83 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -91,6 +91,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`ke/atom/eff ` * :doc:`ke/eff ` * :doc:`ke/rigid ` + * :doc:`local/comp/atom (k) ` * :doc:`mliap ` * :doc:`momentum ` * :doc:`msd ` diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index 627f9e458c..8f9bcc0a38 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -3,9 +3,9 @@ Using CMake with LAMMPS tutorial The support for building LAMMPS with CMake is a recent addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL) and Richard -Berger (Temple U). One of the key strengths of CMake is that it is not -tied to a specific platform or build system and thus generate the files -necessary to build and develop for different build systems and on +Berger (LANL). One of the key strengths of CMake is that it is not +tied to a specific platform or build system and thus it generates the +files necessary to build and develop for different build systems and on different platforms. Note, that this applies to the build system itself not the LAMMPS code. In other words, without additional porting effort, it is not possible - for example - to compile LAMMPS with Visual C++ on @@ -14,7 +14,7 @@ necessary to program LAMMPS as a project in integrated development environments (IDE) like Eclipse, Visual Studio, QtCreator, Xcode, CodeBlocks, Kate and others. -A second important feature of CMake is, that it can detect and validate +A second important feature of CMake is that it can detect and validate available libraries, optimal settings, available support tools and so on, so that by default LAMMPS will take advantage of available tools without requiring to provide the details about how to enable/integrate @@ -32,8 +32,7 @@ program ``cmake`` (or ``cmake3``), a text mode interactive user interface (TUI) program ``ccmake`` (or ``ccmake3``), or a graphical user interface (GUI) program ``cmake-gui``. All of them are portable software available on all supported platforms and can be used -interchangeably. The minimum supported CMake version is 3.10 (3.12 or -later is recommended). +interchangeably. The minimum required CMake version is 3.16. All details about features and settings for CMake are in the `CMake online documentation `_. We focus @@ -43,11 +42,20 @@ Prerequisites ------------- This tutorial assumes that you are operating in a command-line environment -using a shell like Bash. +using a shell like Bash or Zsh. -- Linux: any Terminal window will work -- macOS: launch the Terminal application. -- Windows 10: install and run the :doc:`Windows Subsystem for Linux ` +- Linux: any Terminal window will work or text console +- macOS: launch the Terminal application +- Windows 10 or 11: install and run the :doc:`Windows Subsystem for Linux ` +- other Unix-like operating systems like FreeBSD + +.. note:: + + It is also possible to use CMake on Windows 10 or 11 through either the Microsoft + Visual Studio IDE with the bundled CMake or from the Windows command prompt using + a separately installed CMake package, both using the native Microsoft Visual C++ + compilers and (optionally) the Microsoft MPI SDK. This tutorial, however, only + covers unix-like command line interfaces. We also assume that you have downloaded and unpacked a recent LAMMPS source code package or used Git to create a clone of the LAMMPS sources on your compilation machine. diff --git a/doc/src/Intro_portability.rst b/doc/src/Intro_portability.rst index 66b62a234e..472a2bee88 100644 --- a/doc/src/Intro_portability.rst +++ b/doc/src/Intro_portability.rst @@ -25,7 +25,7 @@ LAMMPS can be compiled from source code using a (traditional) build system based on shell scripts, a few shell utilities (grep, sed, cat, tr) and the GNU make program. This requires running within a Bourne shell (``/bin/sh``). Alternatively, a build system with different back ends -can be created using CMake. CMake must be at least version 3.10. +can be created using CMake. CMake must be at least version 3.16. Operating systems ^^^^^^^^^^^^^^^^^ @@ -62,9 +62,9 @@ regularly tested. Portability compliance ^^^^^^^^^^^^^^^^^^^^^^ -Only a subset of the LAMMPS source code is fully compliant to all of the -above mentioned standards. This is rather typical for projects like -LAMMPS that largely depend on contributions from the user community. +Only a subset of the LAMMPS source code is *fully* compliant to *all* +of the above mentioned standards. This is rather typical for projects +like LAMMPS that largely depend on contributions from the user community. Not all contributors are trained as programmers and not all of them have access to multiple platforms for testing. As part of the continuous integration process, however, all contributions are automatically tested diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 4e5d8e6cb4..317efa4f41 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -245,6 +245,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`ke/atom/eff ` - per-atom translational and radial kinetic energy in the electron force field model * :doc:`ke/eff ` - kinetic energy of a group of nuclei and electrons in the electron force field model * :doc:`ke/rigid ` - translational kinetic energy of rigid bodies +* :doc:`local/comp/atom ` - local composition for each atom * :doc:`mliap ` - gradients of energy and forces with respect to model parameters and related quantities for training machine learning interatomic potentials * :doc:`momentum ` - translational momentum * :doc:`msd ` - mean-squared displacement of group of atoms diff --git a/doc/src/compute_local_comp_atom.rst b/doc/src/compute_local_comp_atom.rst new file mode 100644 index 0000000000..2d0dd8c6f2 --- /dev/null +++ b/doc/src/compute_local_comp_atom.rst @@ -0,0 +1,118 @@ +.. index:: compute local/comp/atom +.. index:: compute local/comp/atom/kk + +compute local/comp/atom command +=============================== + +Accelerator Variants: *local/comp/atom/kk* + +Syntax +"""""" + +.. code-block:: LAMMPS + + compute ID group-ID local/comp/atom keyword values ... + +* ID, group-ID are documented in :doc:`compute ` command +* local/comp/atom = style name of this compute command +* one or more keyword/value pairs may be appended + + .. parsed-literal:: + + keyword = *cutoff* + *cutoff* value = distance cutoff + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all local/comp/atom + + compute 1 all local/comp/atom cutoff 9.0 + comm_modify cutoff 9.0 + + +Description +""""""""""" + +.. versionadded:: TBD + +Define a computation that calculates a local composition vector for each +atom. For a central atom with :math:`M` neighbors within the neighbor cutoff sphere, +composition is defined as the number of atoms of a given type +(including the central atom) divided by (:math:`M+1`). For a given central atom, +the sum of all compositions equals one. + +.. note:: + + This compute uses the number of atom types, not chemical species, assigned in + :doc:`pair_coeff ` command. If an interatomic potential has two + species (i.e., Cu and Ni) assigned to four different atom types in + :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the compute will + output four fractional values. In those cases, the user may desire an extra + calculation step to consolidate per-type fractions into per-species fractions. + This calculation can be conducted within LAMMPS using another compute such as + :doc:`compute reduce `, an atom-style :doc:`variable`, or as a + post-processing step. + +---------- + +The optional keyword *cutoff* defines the distance cutoff used when +searching for neighbors. The default value is the cutoff specified by +the pair style. If no pair style is defined, then a cutoff must be +defined using this keyword. If the specified cutoff is larger than +that of the pair_style plus neighbor skin (or no pair style is +defined), the *comm_modify cutoff* option must also be set to match +that of the *cutoff* keyword. + +The neighbor list needed to compute this quantity is constructed each +time the calculation is performed (i.e. each time a snapshot of atoms +is dumped). Thus it can be inefficient to compute/dump this quantity +too frequently. + +.. note:: + + If you have a bonded system, then the settings of + :doc:`special_bonds ` command can remove pairwise + interactions between atoms in the same bond, angle, or dihedral. + This is the default setting for the :doc:`special_bonds + ` command, and means those pairwise interactions do + not appear in the neighbor list. Because this compute uses the + neighbor list, it also means those pairs will not be included in + the order parameter. This difficulty can be circumvented by + writing a dump file, and using the :doc:`rerun ` command to + compute the order parameter for snapshots in the dump file. The + rerun script can use a :doc:`special_bonds ` command + that includes all pairs in the neighbor list. + +---------- + +Output info +""""""""""" + +This compute calculates a per-atom array with :math:`1 + N` columns, where :math:`N` +is the number of atom types. The first column is a count of the number of atoms +used to calculate composition (including the central atom), and each subsequent +column indicates the fraction of that atom type within the cutoff sphere. + +These values can be accessed by any command that uses per-atom values +from a compute as input. See the :doc:`Howto output ` +doc page for an overview of LAMMPS output options. + +Restrictions +"""""""""""" + +This compute is part of the EXTRA-COMPUTE package. It is only enabled +if LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +Related commands +"""""""""""""""" + +:doc:`comm_modify ` + +Default +""""""" + +The option defaults are *cutoff* = pair style cutoff. diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index b7edd05ea7..1643b51fec 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -3621,6 +3621,7 @@ Tk Tkin tloop tlsph +tm tmax Tmax tmd @@ -4093,6 +4094,7 @@ zmq zN zs zsc +Zsh zst Zstandard zstd diff --git a/examples/COUPLE/plugin/CMakeLists.txt b/examples/COUPLE/plugin/CMakeLists.txt index 14bef44ffa..00f86058fb 100644 --- a/examples/COUPLE/plugin/CMakeLists.txt +++ b/examples/COUPLE/plugin/CMakeLists.txt @@ -1,9 +1,8 @@ -########################################## -# CMake build system for coupling to the LAMMPS library +# -*- CMake -*- file for example programs that use the LAMMPS library # where the library is loaded dynamically at runtime. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/examples/COUPLE/simple/CMakeLists.txt b/examples/COUPLE/simple/CMakeLists.txt index eed9a147bd..c09b372183 100644 --- a/examples/COUPLE/simple/CMakeLists.txt +++ b/examples/COUPLE/simple/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- file for simple examples using the LAMMPS library interface + +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/examples/PACKAGES/pace/plugin/CMakeLists.txt b/examples/PACKAGES/pace/plugin/CMakeLists.txt index 25fa877ffc..0701a754c4 100644 --- a/examples/PACKAGES/pace/plugin/CMakeLists.txt +++ b/examples/PACKAGES/pace/plugin/CMakeLists.txt @@ -1,10 +1,9 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- build system for plugin examples. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(paceplugin VERSION 1.0 LANGUAGES CXX) diff --git a/examples/kim/plugin/CMakeLists.txt b/examples/kim/plugin/CMakeLists.txt index 78d117469d..999214f9b8 100644 --- a/examples/kim/plugin/CMakeLists.txt +++ b/examples/kim/plugin/CMakeLists.txt @@ -1,10 +1,9 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- file for building plugins. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(kimplugin VERSION 1.0 LANGUAGES CXX) @@ -31,12 +30,7 @@ target_link_libraries(kimplugin PRIVATE KIM-API::kim-api) # need libcurl find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(kimplugin PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(kimplugin PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(kimplugin PRIVATE CURL::libcurl) - endif() + target_link_libraries(kimplugin PRIVATE CURL::libcurl) target_compile_definitions(kimplugin PRIVATE -DLMP_KIM_CURL) set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.") mark_as_advanced(LMP_DEBUG_CURL) diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index ef494fe941..750b5601da 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -1,10 +1,9 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- file for plugin examples. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/src/.gitignore b/src/.gitignore index 6e2a8b92c9..115291c39a 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -580,6 +580,8 @@ /compute_ke_eff.h /compute_ke_rigid.cpp /compute_ke_rigid.h +/compute_local_comp_atom.cpp +/compute_local_comp_atom.h /compute_meso_e_atom.cpp /compute_meso_e_atom.h /compute_meso_rho_atom.cpp diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp new file mode 100644 index 0000000000..77c4993996 --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -0,0 +1,214 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Megan McCarthy (SNL) +------------------------------------------------------------------------- */ + +#include "compute_local_comp_atom.h" + +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "math_const.h" +#include "memory.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include + +using namespace LAMMPS_NS; +using namespace MathConst; + +/* ---------------------------------------------------------------------- */ + +ComputeLocalCompAtom::ComputeLocalCompAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), result(nullptr) +{ + if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute local/comp/atom command"); + + cutoff = 0.0; + + int iarg = 3; + while (iarg < narg) { + if (strcmp(arg[iarg], "cutoff") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal compute local/comp/atom command"); + cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + if (cutoff <= 0.0) error->all(FLERR, "Illegal compute local/comp/atom command"); + iarg += 2; + } else + error->all(FLERR, "Illegal compute local/comp/atom command"); + } + + peratom_flag = 1; + + ntypes = atom->ntypes; + size_peratom_cols = 1 + ntypes; + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputeLocalCompAtom::~ComputeLocalCompAtom() +{ + if (copymode) return; + + memory->destroy(result); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompAtom::init() +{ + if (!force->pair && cutoff == 0.0) + error->all(FLERR, + "Compute local/comp/atom requires a cutoff be specified " + "or a pair style be defined"); + + double skin = neighbor->skin; + if (cutoff != 0.0) { + double cutghost; // as computed by Neighbor and Comm + if (force->pair) + cutghost = MAX(force->pair->cutforce + skin, comm->cutghostuser); + else + cutghost = comm->cutghostuser; + + if (cutoff > cutghost) + error->all(FLERR, + "Compute local/comp/atom cutoff exceeds ghost atom range - " + "use comm_modify cutoff command"); + } + + int cutflag = 1; + if (force->pair) { + if (cutoff == 0.0) { cutoff = force->pair->cutforce; } + if (cutoff <= force->pair->cutforce + skin) cutflag = 0; + } + + cutsq = cutoff * cutoff; + + // need an occasional full neighbor list + + auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); + if (cutflag) req->set_cutoff(cutoff); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompAtom::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompAtom::compute_peratom() +{ + int i, j, ii, jj, inum, jnum; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + int *ilist, *jlist, *numneigh, **firstneigh; + int count, itype, jtype; + + invoked_peratom = update->ntimestep; + + // grow result array if necessary + + if (atom->nmax > nmax) { + memory->destroy(result); + nmax = atom->nmax; + memory->create(result, nmax, size_peratom_cols, "local/comp/atom:result"); + array_atom = result; + } + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // compute properties for each atom in group + // use full neighbor list to count atoms less than cutoff + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + + // get per-atom local compositions + + for (ii = 0; ii < inum; ii++) { + + i = ilist[ii]; + + if (mask[i] & groupbit) { + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + // i atom contribution + + count = 1; + + itype = type[i]; + result[i][itype]++; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + jtype = type[j]; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq < cutsq) { + count++; + result[i][jtype]++; + } + } + + // total count of atoms found in sampled radius range + + result[i][0] = count; + + // local comp fractions per element + + double lfac = 1.0 / count; + for (int n = 1; n < size_peratom_cols; n++) + result[i][n+1] *= lfac; + + } + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeLocalCompAtom::memory_usage() +{ + double bytes = (double) 2 * nmax * sizeof(double); + return bytes; +} diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.h b/src/EXTRA-COMPUTE/compute_local_comp_atom.h new file mode 100644 index 0000000000..76d92de08d --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(local/comp/atom,ComputeLocalCompAtom); +// clang-format on +#else + +#ifndef LMP_COMPUTE_LOCAL_COMP_ATOM_H +#define LMP_COMPUTE_LOCAL_COMP_ATOM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeLocalCompAtom : public Compute { + public: + ComputeLocalCompAtom(class LAMMPS *, int, char **); + ~ComputeLocalCompAtom() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + double memory_usage() override; + + protected: + int nmax, ntypes; + double cutoff; // global cutoff distance + double cutsq; // cutoff**2 + class NeighList *list; // neighbor list + double **result; // peratom array of local compositions +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index ede766cbf8..a842a169c0 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -96,6 +96,8 @@ action compute_coord_atom_kokkos.cpp action compute_coord_atom_kokkos.h action compute_erotate_sphere_kokkos.cpp action compute_erotate_sphere_kokkos.h +action compute_local_comp_atom_kokkos.cpp compute_local_comp_atom.cpp +action compute_local_comp_atom_kokkos.h compute_local_comp_atom.h action compute_orientorder_atom_kokkos.cpp action compute_orientorder_atom_kokkos.h action compute_temp_deform_kokkos.cpp diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp new file mode 100644 index 0000000000..356efea2f1 --- /dev/null +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -0,0 +1,180 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU Gdirectoryeneral Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Megan McCarthy (SNL) +------------------------------------------------------------------------- */ + +#include "compute_local_comp_atom_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "memory_kokkos.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor_kokkos.h" +#include "pair.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +ComputeLocalCompAtomKokkos::ComputeLocalCompAtomKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeLocalCompAtom(lmp, narg, arg) +{ + kokkosable = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = EMPTY_MASK; + datamask_modify = EMPTY_MASK; +} + +/* ---------------------------------------------------------------------- */ + +template +ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() +{ + if (copymode) return; + + memoryKK->destroy_kokkos(k_result,result); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeLocalCompAtomKokkos::init() +{ + ComputeLocalCompAtom::init(); + + // adjust neighbor list request for KOKKOS + + auto request = neighbor->find_request(this); + request->set_kokkos_host(std::is_same::value && + !std::is_same::value); + request->set_kokkos_device(std::is_same::value); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeLocalCompAtomKokkos::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + // grow result array if necessary + + int size_peratom_cols = 1 + atom->ntypes; + if (atom->nmax > nmax) { + memoryKK->destroy_kokkos(k_result,result); + nmax = atom->nmax; + memoryKK->create_kokkos(k_result,result,nmax,size_peratom_cols,"local/comp/atom:result"); + d_result = k_result.view(); + array_atom = result; + } + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + int inum = list->inum; + + NeighListKokkos* k_list = static_cast*>(list); + d_numneigh = k_list->d_numneigh; + d_neighbors = k_list->d_neighbors; + d_ilist = k_list->d_ilist; + + // compute properties for each atom in group + // use full neighbor list to count atoms less than cutoff + + atomKK->sync(execution_space,X_MASK|TYPE_MASK|MASK_MASK); + x = atomKK->k_x.view(); + type = atomKK->k_type.view(); + mask = atomKK->k_mask.view(); + ntypes = atom->ntypes; + + Kokkos::deep_copy(d_result,0.0); + + copymode = 1; + typename Kokkos::RangePolicy policy(0,inum); + Kokkos::parallel_for("ComputeLocalComp",policy,*this); + copymode = 0; + + k_result.modify(); + k_result.sync_host(); +} + +template +KOKKOS_INLINE_FUNCTION +void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int &ii) const +{ + const int i = d_ilist[ii]; + + if (mask[i] & groupbit) { + + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int jnum = d_numneigh[i]; + + // i atom contribution + + int count = 1.0; + int itype = type[i]; + d_result(i,itype)++; + + for (int jj = 0; jj < jnum; jj++) { + + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + + int jtype = type[j]; + + const F_FLOAT delx = x(j,0) - xtmp; + const F_FLOAT dely = x(j,1) - ytmp; + const F_FLOAT delz = x(j,2) - ztmp; + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + d_result(i,jtype) += 1.0; + } + } + + // total count of atoms found in sampled radius range + + d_result(i,0) = count; + + // local comp fractions per atom type + + double lfac = 1.0 / count; + + for (int n = 1; n < size_peratom_cols; n++) { + d_result(i,n) *= lfac; + } + } +} + +namespace LAMMPS_NS { +template class ComputeLocalCompAtomKokkos; +#ifdef LMP_KOKKOS_GPU +template class ComputeLocalCompAtomKokkos; +#endif +} diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h new file mode 100644 index 0000000000..5fb52474b2 --- /dev/null +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -0,0 +1,64 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(local/comp/atom/kk,ComputeLocalCompAtomKokkos); +ComputeStyle(local/comp/atom/kk/device,ComputeLocalCompAtomKokkos); +ComputeStyle(local/comp/atom/kk/host,ComputeLocalCompAtomKokkos); +// clang-format on + +#else + +#ifndef LMP_COMPUTE_LOCAL_COMP_ATOM_KOKKOS_H +#define LMP_COMPUTE_LOCAL_COMP_ATOM_KOKKOS_H + +#include "compute_local_comp_atom.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +// clang-format off +struct TagComputeLocalCompAtom {}; +// clang-format on + +template class ComputeLocalCompAtomKokkos : public ComputeLocalCompAtom { + public: + typedef DeviceType device_type; + typedef ArrayTypes AT; + + ComputeLocalCompAtomKokkos(class LAMMPS *, int, char **); + ~ComputeLocalCompAtomKokkos() override; + void init() override; + void compute_peratom() override; + + KOKKOS_INLINE_FUNCTION + void operator()(TagComputeLocalCompAtom, const int &) const; + + private: + + typename AT::t_x_array x; + typename ArrayTypes::t_int_1d type; + typename ArrayTypes::t_int_1d mask; + + typename AT::t_neighbors_2d d_neighbors; + typename AT::t_int_1d d_ilist; + typename AT::t_int_1d d_numneigh; + DAT::tdual_float_2d k_result; + typename AT::t_float_2d d_result; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/tools/phonon/CMakeLists.spglib b/tools/phonon/CMakeLists.spglib index 566e58a2b6..65299a18e2 100644 --- a/tools/phonon/CMakeLists.spglib +++ b/tools/phonon/CMakeLists.spglib @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- file for building spglib for phana +cmake_minimum_required(VERSION 3.16) project(spglib C) set(CMAKE_MACOSX_RPATH 1) set(CMAKE_C_FLAGS_RELEASE "-Wall -O2") @@ -10,7 +11,6 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # Version numbers file(READ ${PROJECT_SOURCE_DIR}/src/version.h version_file) string(REGEX MATCH "SPGLIB_MAJOR_VERSION ([0-9]+)" spglib_major_version ${version_file}) diff --git a/tools/phonon/CMakeLists.txt b/tools/phonon/CMakeLists.txt index 00f3ee55d1..f2f090cdbb 100644 --- a/tools/phonon/CMakeLists.txt +++ b/tools/phonon/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- configuration for building the PHONON package analysis tool: phana # Support Linux from Ubuntu 20.04LTS onward, CentOS 7.x (with EPEL), # macOS, MSVC 2019 (=Version 16) diff --git a/tools/phonon/tricubic/CMakeLists.txt b/tools/phonon/tricubic/CMakeLists.txt index 190c6ceb80..f3a229c410 100644 --- a/tools/phonon/tricubic/CMakeLists.txt +++ b/tools/phonon/tricubic/CMakeLists.txt @@ -1,7 +1,8 @@ +# -*- CMake -*- configuration for building the tricubic library # Support Linux from Ubuntu 20.04LTS onward, CentOS 7.x (with EPEL), # macOS, MSVC 2019 (=Version 16) -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # set up project project(tricubic VERSION 1.1 DESCRIPTION "Tricubic library" LANGUAGES CXX) diff --git a/tools/swig/CMakeLists.txt b/tools/swig/CMakeLists.txt index 966837dc2f..162d2702c4 100644 --- a/tools/swig/CMakeLists.txt +++ b/tools/swig/CMakeLists.txt @@ -1,7 +1,7 @@ -# CMake configuration for generating script language interfaces with SWIG +# -*- CMake -*- configuration for generating LAMMPS script language wrappers with SWIG # set minimum CMake version required and switch to new policies for SWIG -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) if(POLICY CMP0078) cmake_policy(SET CMP0078 NEW) endif() diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index f7be54f9ae..ba80e654bb 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,10 +1,9 @@ -######################################## -# CMake build for automated testing +# -*- CMake -*- build file for automated testing # This file is part of LAMMPS # Created by Axel Kohlmeyer and Richard Berger ######################################## -# download and build googletest framework +# download and build googletest framework # cannot compile googletest anymore with the default GCC on RHEL 7.x if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)) message(FATAL_ERROR "Need GNU C++ compiler version 6.x or later for unit testing") @@ -36,11 +35,7 @@ endforeach() # must repeat handling coverage for older CMake if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") endif() ######################################## diff --git a/unittest/c-library/CMakeLists.txt b/unittest/c-library/CMakeLists.txt index e55e94f709..0ab216caf5 100644 --- a/unittest/c-library/CMakeLists.txt +++ b/unittest/c-library/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing the c-library interface add_executable(test_library_open test_library_open.cpp test_main.cpp) target_link_libraries(test_library_open PRIVATE lammps GTest::GMock) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index aa1bd22fa4..f6a73b56b3 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing LAMMPS commands add_executable(test_simple_commands test_simple_commands.cpp) diff --git a/unittest/cplusplus/CMakeLists.txt b/unittest/cplusplus/CMakeLists.txt index 9199e20792..445e0fffeb 100644 --- a/unittest/cplusplus/CMakeLists.txt +++ b/unittest/cplusplus/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing the direct calls to individual C++ classes add_executable(test_lammps_class test_lammps_class.cpp) target_link_libraries(test_lammps_class PRIVATE lammps GTest::GMockMain) diff --git a/unittest/force-styles/CMakeLists.libyaml b/unittest/force-styles/CMakeLists.libyaml index 51e8589f7b..8d4760f18c 100644 --- a/unittest/force-styles/CMakeLists.libyaml +++ b/unittest/force-styles/CMakeLists.libyaml @@ -1,6 +1,6 @@ # Custom minimal -*- CMake -*- file for libyaml -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(libyaml VERSION 0.2.5 DESCRIPTION "LibYAML a YAML parser and emitter library" LANGUAGES C diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index ac5cd7dfd7..7d29395e39 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of classes computing or modifying forces find_package(YAML) if(NOT YAML_FOUND) @@ -19,16 +20,7 @@ function(extract_tags out yaml_file) set(${out} "${TAGS}" PARENT_SCOPE) endfunction() -if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter) -endif() +find_package(Python COMPONENTS Interpreter) if(Python_EXECUTABLE) add_custom_target(check-tests ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check_tests.py @@ -53,10 +45,8 @@ target_link_libraries(style_tests PUBLIC GTest::GMock Yaml::Yaml lammps) # propagate sanitizer options to test tools if(ENABLE_SANITIZER AND (NOT (ENABLE_SANITIZER STREQUAL "none"))) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) endif() # unit test for error stats class @@ -97,7 +87,7 @@ else() endif() # tests for molecular systems and related pair styles -file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/mol-pair-*.yaml) +file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/mol-pair-*.yaml) # cannot test MSM with single precision data if(FFT_SINGLE) list(FILTER MOL_PAIR_TESTS EXCLUDE REGEX "msm") @@ -115,7 +105,7 @@ foreach(TEST ${MOL_PAIR_TESTS}) endforeach() # tests for metal-like atomic systems and related pair styles -file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml) +file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml) foreach(TEST ${ATOMIC_PAIR_TESTS}) string(REGEX REPLACE "^.*atomic-pair-(.*)\.yaml" "AtomicPairStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -129,7 +119,7 @@ foreach(TEST ${ATOMIC_PAIR_TESTS}) endforeach() # tests for Si-like manybody systems and related pair styles -file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml) +file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml) foreach(TEST ${MANYBODY_PAIR_TESTS}) string(REGEX REPLACE "^.*manybody-pair-(.*)\.yaml" "ManybodyPairStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -146,7 +136,7 @@ endforeach() add_executable(test_bond_style test_bond_style.cpp) target_link_libraries(test_bond_style PRIVATE lammps style_tests) -file(GLOB BOND_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/bond-*.yaml) +file(GLOB BOND_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/bond-*.yaml) foreach(TEST ${BOND_TESTS}) string(REGEX REPLACE "^.*bond-(.*)\.yaml" "BondStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -163,7 +153,7 @@ endforeach() add_executable(test_angle_style test_angle_style.cpp) target_link_libraries(test_angle_style PRIVATE lammps style_tests) -file(GLOB ANGLE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/angle-*.yaml) +file(GLOB ANGLE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/angle-*.yaml) foreach(TEST ${ANGLE_TESTS}) string(REGEX REPLACE "^.*angle-(.*)\.yaml" "AngleStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -177,7 +167,7 @@ foreach(TEST ${ANGLE_TESTS}) endforeach() # kspace style tester, currently uses the pair style tool -file(GLOB KSPACE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/kspace-*.yaml) +file(GLOB KSPACE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/kspace-*.yaml) # cannot test MSM with single precision data if(FFT_SINGLE) list(FILTER KSPACE_TESTS EXCLUDE REGEX "msm") @@ -205,7 +195,7 @@ endif() target_link_libraries(test_fix_timestep PRIVATE lammps style_tests) # tests for timestep related fixes (time integration, thermostat, force manipulation, constraints/restraints) -file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml) +file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml) foreach(TEST ${FIX_TIMESTEP_TESTS}) string(REGEX REPLACE "^.*fix-timestep-(.*)\.yaml" "FixTimestep:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -226,7 +216,7 @@ endforeach() add_executable(test_dihedral_style test_dihedral_style.cpp) target_link_libraries(test_dihedral_style PRIVATE lammps style_tests) -file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/dihedral-*.yaml) +file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/dihedral-*.yaml) foreach(TEST ${DIHEDRAL_TESTS}) string(REGEX REPLACE "^.*dihedral-(.*)\.yaml" "DihedralStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -243,7 +233,7 @@ endforeach() add_executable(test_improper_style test_improper_style.cpp) target_link_libraries(test_improper_style PRIVATE lammps style_tests) -file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/improper-*.yaml) +file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/improper-*.yaml) foreach(TEST ${IMPROPER_TESTS}) string(REGEX REPLACE "^.*improper-(.*)\.yaml" "ImproperStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 9934c87ab1..58c797b6e6 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of file reading or writing classes and functions in LAMMPS add_executable(test_atom_styles test_atom_styles.cpp) target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock) diff --git a/unittest/formats/test_file_operations.cpp b/unittest/formats/test_file_operations.cpp index c2d2652b53..c05a71a494 100644 --- a/unittest/formats/test_file_operations.cpp +++ b/unittest/formats/test_file_operations.cpp @@ -612,6 +612,10 @@ TEST_F(FileOperationsTest, read_data_fix) EXPECT_EQ(lmp->atom->tag[GETIDX(8)], 8); EXPECT_EQ(lmp->atom->tag[GETIDX(9)], 9); EXPECT_EQ(lmp->atom->tag[GETIDX(10)], 10); + + // clean up + delete_file("test_mol_id_merge.data"); + delete_file("test_mol_id.data"); } int main(int argc, char **argv) diff --git a/unittest/fortran/CMakeLists.txt b/unittest/fortran/CMakeLists.txt index 6d6fe4cd54..de6b6cf7a8 100644 --- a/unittest/fortran/CMakeLists.txt +++ b/unittest/fortran/CMakeLists.txt @@ -1,3 +1,5 @@ +# -*- CMake -*- file for testing the Fortran interface to LAMMPS + include(CheckGeneratorSupport) if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN) message(STATUS "Skipping Tests for the LAMMPS Fortran Module: no Fortran support in build tool") diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index 750716eb1a..b4ba281d93 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -1,7 +1,8 @@ -# Test calling Python from LAMMPS (and importing the LAMMPS module -# inside those functions). This can do an "anonymous" import of symbols -# from the executable, so the shared library is not needed. The -# availability of the PYTHON package is tested for inside the tester. +# -*- CMake -*- file for tests calling Python from LAMMPS (and importing +# the LAMMPS module inside those functions). This can do an "anonymous" +# import of symbols from the executable, so the shared library is not +# needed. The availability of the PYTHON package is tested for inside +# the tester. set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) @@ -11,20 +12,12 @@ if(NOT BUILD_SHARED_LIBS) return() endif() -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.6) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter Development) -endif() +find_package(Python 3.6 COMPONENTS Interpreter Development) if(PKG_PYTHON) add_executable(test_python_package test_python_package.cpp) target_link_libraries(test_python_package PRIVATE lammps GTest::GMock) target_compile_definitions(test_python_package PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER}) - # this requires CMake 3.12. don't care to add backward compatibility for this. if(Python_Development_FOUND) target_compile_definitions(test_python_package PRIVATE -DTEST_HAVE_PYTHON_DEVELOPMENT=1) target_link_libraries(test_python_package PRIVATE Python::Python) diff --git a/unittest/tools/CMakeLists.txt b/unittest/tools/CMakeLists.txt index 4e0180311e..7a496722d2 100644 --- a/unittest/tools/CMakeLists.txt +++ b/unittest/tools/CMakeLists.txt @@ -1,13 +1,8 @@ +# -*- CMake -*- file for tests of utily functions and classes in LAMMPS # we use python 3's subprocess module to run the tools and check the output -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.5 COMPONENTS Interpreter) -endif() +find_package(Python 3.6 COMPONENTS Interpreter) + get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(BUILD_IS_MULTI_CONFIG) set(LAMMPS_SHELL_EXE_DIR ${CMAKE_BINARY_DIR}/$) diff --git a/unittest/utils/CMakeLists.txt b/unittest/utils/CMakeLists.txt index 8c1a5a3f6a..c277a0353b 100644 --- a/unittest/utils/CMakeLists.txt +++ b/unittest/utils/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of utily functions and classes in LAMMPS add_executable(test_tokenizer test_tokenizer.cpp) target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain)