diff --git a/.github/ISSUE_TEMPLATE/generic.md b/.github/ISSUE_TEMPLATE/generic.md new file mode 100644 index 0000000000000000000000000000000000000000..15d2763919fdc531040b3110eec19832720c09dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/generic.md @@ -0,0 +1,21 @@ +--- +name: Generic Issue +about: For issues that do not fit any of the other categories +title: "_Replace With a Descriptive Title_" +labels: +assignees: '' + +--- + +**Summary** + +_Please provide a clear and concise description of what this issue report is about._ + +**LAMMPS Version and Platform** + +_Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version_ + +**Details** + +_Please explain the issue in detail here_ + diff --git a/.github/ISSUE_TEMPLATE/help_request.md b/.github/ISSUE_TEMPLATE/help_request.md new file mode 100644 index 0000000000000000000000000000000000000000..5e5b3ebffd2d146042ca35b28eb3a9d0bbffad86 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/help_request.md @@ -0,0 +1,15 @@ +--- +name: Request for Help +about: "Don't post help requests here, email the lammps-users mailing list" +title: "" +labels: invalid +assignees: '' + +--- + +Please **do not** post requests for help (e.g. with installing or using LAMMPS) here. +Instead send an e-mail to the lammps-users mailing list. + +This issue tracker is for tracking LAMMPS development related issues only. + +Thanks for your cooperation. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 32b76a079c8aa86f1ec26850b7d2fb29bc10a4e2..9e43aa024440acc0557054f75e991aaf724c7171 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,22 +4,19 @@ _Briefly describe the new feature(s), enhancement(s), or bugfix(es) included in **Related Issues** -__If this addresses an open GitHub Issue, mention the issue number here. Use the phrases `fixes #221` or `closes #135`, when you want those issues to be automatically closed when the pull request is merged_ +_If this addresses an open GitHub issue for this project, please mention the issue number here, and describe the relation. Use the phrases `fixes #221` or `closes #135`, when you want an issue to be automatically closed when the pull request is merged_ **Author(s)** -_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request. If this pull request adds new files to the distribution, please also provide a suitable "long-lived" e-mail address (e.g. from gmail, yahoo, outlook, etc.) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this code. now and in the future_ +_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request. If this pull request adds new files to the distribution, please also provide a suitable "long-lived" e-mail address (ideally something that can outlive your institution's e-mail, in case you change jobs) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this contributed code._ **Licensing** -By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under the GNU General Public License version 2. - -_Please complete the following statement by adding "yes" or "no":_ -My contribution may be re-licensed as LGPL (for use of LAMMPS as a library linked to proprietary software): +By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1). **Backward Compatibility** -_Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why_ +_Please state whether any changes in the pull request will break backward compatibility for inputs, and - if yes - explain what has been changed and why_ **Implementation Notes** @@ -27,7 +24,7 @@ _Provide any relevant details about how the changes are implemented, how correct **Post Submission Checklist** -_Please check the fields below as they are completed **after** the pull request has been submitted_ +_Please check the fields below as they are completed **after** the pull request has been submitted. Delete lines that don't apply_ - [ ] The feature or features in this pull request is complete - [ ] Licensing information is complete diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9ad64a59edeb91fd1362deb29daa569a9511e552..bde36aa8962d8801315306ae2dd400c4cf2ae00d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -10,6 +10,11 @@ get_filename_component(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src ABSO get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib ABSOLUTE) get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE) get_filename_component(LAMMPS_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../doc ABSOLUTE) +get_filename_component(LAMMPS_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../tools ABSOLUTE) +get_filename_component(LAMMPS_PYTHON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../python ABSOLUTE) +get_filename_component(LAMMPS_POTENTIALS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../potentials ABSOLUTE) + +find_package(Git) # by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -21,58 +26,13 @@ file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) file(GLOB LMP_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp) list(REMOVE_ITEM LIB_SOURCES ${LMP_SOURCES}) -# Utility functions -function(list_to_bulletpoints result) - list(REMOVE_AT ARGV 0) - set(temp "") - foreach(item ${ARGV}) - set(temp "${temp}* ${item}\n") - endforeach() - set(${result} "${temp}" PARENT_SCOPE) -endfunction(list_to_bulletpoints) - -function(validate_option name values) - string(TOLOWER ${${name}} needle_lower) - string(TOUPPER ${${name}} needle_upper) - list(FIND ${values} ${needle_lower} IDX_LOWER) - list(FIND ${values} ${needle_upper} IDX_UPPER) - if(${IDX_LOWER} LESS 0 AND ${IDX_UPPER} LESS 0) - list_to_bulletpoints(POSSIBLE_VALUE_LIST ${${values}}) - message(FATAL_ERROR "\n########################################################################\n" - "Invalid value '${${name}}' for option ${name}\n" - "\n" - "Possible values are:\n" - "${POSSIBLE_VALUE_LIST}" - "########################################################################") - endif() -endfunction(validate_option) - -function(get_lammps_version version_header variable) - file(READ ${version_header} line) - set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) - string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1" day "${line}") - string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\2" month "${line}") - string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\3" year "${line}") - string(STRIP ${day} day) - string(STRIP ${month} month) - string(STRIP ${year} year) - list(FIND MONTHS "${month}" month) - string(LENGTH ${day} day_length) - string(LENGTH ${month} month_length) - if(day_length EQUAL 1) - set(day "0${day}") - endif() - if(month_length EQUAL 1) - set(month "0${month}") - endif() - set(${variable} "${year}${month}${day}" PARENT_SCOPE) -endfunction() - -get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION) - # Cmake modules/macros are in a subdirectory to keep this file cleaner set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) +include(LAMMPSUtils) + +get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION) + include(PreventInSourceBuilds) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) @@ -83,27 +43,14 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) # check for files auto-generated by make-based buildsystem # this is fast, so check for it all the time -message(STATUS "Running check for auto-generated files from make-based build system") -file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/style_*.h) -list(APPEND SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h) -foreach(_SRC ${SRC_AUTOGEN_FILES}) - get_filename_component(FILENAME "${_SRC}" NAME) - if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME}) - message(FATAL_ERROR "\n########################################################################\n" - "Found header file(s) generated by the make-based build system\n" - "\n" - "Please run\n" - "make -C ${LAMMPS_SOURCE_DIR} purge\n" - "to remove\n" - "########################################################################") - endif() -endforeach() +check_for_autogen_files(${LAMMPS_SOURCE_DIR}) ###################################################################### # compiler tests # these need ot be done early (before further tests). ##################################################################### include(CheckCCompilerFlag) +include(CheckIncludeFileCXX) if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") @@ -159,6 +106,8 @@ if(BUILD_LIB) endif() endif() +option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) + if(NOT BUILD_EXE AND NOT BUILD_LIB) message(FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE") endif() @@ -170,37 +119,34 @@ set(LAMMPS_LINK_LIBS) set(LAMMPS_DEPS) set(LAMMPS_API_DEFINES) -set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR - KSPACE MANYBODY MC MESSAGE MISC MOLECULE PERI REPLICA RIGID SHOCK - SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI POEMS LATTE USER-ATC USER-AWPMD - USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-DIFFRACTION - USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD - USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF - USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC USER-SCAFACOS - USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK - USER-QUIP USER-QMMM USER-YAFF) +set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE + GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ + REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI + USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS + USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB + USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE + USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC + USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF + USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU) -set(OTHER_PACKAGES CORESHELL QEQ) -foreach(PKG ${DEFAULT_PACKAGES}) - option(PKG_${PKG} "Build ${PKG} Package" OFF) -endforeach() -foreach(PKG ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) endforeach() ###################################################### # packages with special compiler needs or external libs ###################################################### -if(PKG_USER-QUIP OR PKG_USER-QMMM OR PKG_LATTE OR PKG_USER-SCAFACOS) - enable_language(Fortran) -endif() +include_directories(${LAMMPS_SOURCE_DIR}) -if(PKG_USER-H5MD OR PKG_USER-QMMM OR PKG_USER-SCAFACOS) +if(PKG_USER-ADIOS) + # The search for ADIOS2 must come before MPI because + # it includes its own MPI search with the latest FindMPI.cmake + # script that defines the MPI::MPI_C target enable_language(C) + find_package(ADIOS2 REQUIRED) + list(APPEND LAMMPS_LINK_LIBS adios2::adios2) endif() -include_directories(${LAMMPS_SOURCE_DIR}) - # do MPI detection after language activation, if MPI for these language is required find_package(MPI QUIET) option(BUILD_MPI "Build MPI version" ${MPI_FOUND}) @@ -220,7 +166,6 @@ else() list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() - set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall) set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES}) @@ -243,62 +188,6 @@ if(LAMMPS_EXCEPTIONS) set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS") endif() -option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) - -option(ENABLE_TESTING "Enable testing" OFF) -if(ENABLE_TESTING AND BUILD_EXE) - enable_testing() - option(LAMMPS_TESTING_SOURCE_DIR "Location of lammps-testing source directory" "") - option(LAMMPS_TESTING_GIT_TAG "Git tag of lammps-testing" "master") - mark_as_advanced(LAMMPS_TESTING_SOURCE_DIR LAMMPS_TESTING_GIT_TAG) - - if (CMAKE_VERSION VERSION_GREATER "3.10.3" AND NOT LAMMPS_TESTING_SOURCE_DIR) - include(FetchContent) - - FetchContent_Declare(lammps-testing - GIT_REPOSITORY https://github.com/lammps/lammps-testing.git - GIT_TAG ${LAMMPS_TESTING_GIT_TAG} - ) - - FetchContent_GetProperties(lammps-testing) - if(NOT lammps-testing_POPULATED) - message(STATUS "Downloading tests...") - FetchContent_Populate(lammps-testing) - endif() - - set(LAMMPS_TESTING_SOURCE_DIR ${lammps-testing_SOURCE_DIR}) - elseif(NOT LAMMPS_TESTING_SOURCE_DIR) - message(WARNING "Full test-suite requires CMake >= 3.11 or copy of\n" - "https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR") - endif() - - if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR}) - message(STATUS "Running test discovery...") - - file(GLOB_RECURSE TEST_SCRIPTS ${LAMMPS_TESTING_SOURCE_DIR}/tests/core/*/in.*) - foreach(script_path ${TEST_SCRIPTS}) - get_filename_component(TEST_NAME ${script_path} EXT) - get_filename_component(SCRIPT_NAME ${script_path} NAME) - get_filename_component(PARENT_DIR ${script_path} DIRECTORY) - string(SUBSTRING ${TEST_NAME} 1 -1 TEST_NAME) - string(REPLACE "-" "_" TEST_NAME ${TEST_NAME}) - string(REPLACE "+" "_" TEST_NAME ${TEST_NAME}) - set(TEST_NAME "test_core_${TEST_NAME}_serial") - add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -in ${SCRIPT_NAME}) - set_tests_properties(${TEST_NAME} PROPERTIES WORKING_DIRECTORY ${PARENT_DIR}) - endforeach() - list(LENGTH TEST_SCRIPTS NUM_TESTS) - - message(STATUS "Found ${NUM_TESTS} tests.") - endif() -endif() - -macro(pkg_depends PKG1 PKG2) - if(PKG_${PKG1} AND NOT (PKG_${PKG2} OR BUILD_${PKG2})) - message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}") - endif() -endmacro() - # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(MPIIO MPI) @@ -308,56 +197,36 @@ pkg_depends(USER-PHONON KSPACE) pkg_depends(USER-SCAFACOS MPI) find_package(OpenMP QUIET) -option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND}) -if(BUILD_OMP OR PKG_KOKKOS OR PKG_USER-INTEL) + +# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30 +# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas +# where we assume older GCC semantics. For the time being, we disable OpenMP by default +# for GCC 9.x and beyond. People may manually turn it on, but need to run the script +# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9. +if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9)) + option(BUILD_OMP "Build with OpenMP support" OFF) +else() + option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND}) +endif() + +if(BUILD_OMP) find_package(OpenMP REQUIRED) + check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE) + if(NOT HAVE_OMP_H_INCLUDE) + message(FATAL_ERROR "Cannot find required 'omp.h' header file") + endif() set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() -if(PKG_KSPACE) - option(FFT_SINGLE "Use single precision FFT instead of double" OFF) - set(FFTW "FFTW3") - if(FFT_SINGLE) - set(FFTW "FFTW3F") - add_definitions(-DFFT_SINGLE) - endif() - find_package(${FFTW} QUIET) - if(${FFTW}_FOUND) - set(FFT "${FFTW}" CACHE STRING "FFT library for KSPACE package") - else() - set(FFT "KISS" CACHE STRING "FFT library for KSPACE package") - endif() - set(FFT_VALUES KISS ${FFTW} MKL) - set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES}) - validate_option(FFT FFT_VALUES) - string(TOUPPER ${FFT} FFT) - if(NOT FFT STREQUAL "KISS") - find_package(${FFT} REQUIRED) - if(NOT FFT STREQUAL "FFTW3F") - add_definitions(-DFFT_FFTW) - else() - add_definitions(-DFFT_${FFT}) - endif() - include_directories(${${FFT}_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${${FFT}_LIBRARIES}) - else() - add_definitions(-DFFT_KISS) - endif() - set(FFT_PACK "array" CACHE STRING "Optimization for FFT") - set(FFT_PACK_VALUES array pointer memcpy) - set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES}) - validate_option(FFT_PACK FFT_PACK_VALUES) - if(NOT FFT_PACK STREQUAL "array") - string(TOUPPER ${FFT_PACK} FFT_PACK) - add_definitions(-DFFT_PACK_${FFT_PACK}) - endif() -endif() -if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) +if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-PLUMED OR PKG_USER-QUIP OR PKG_LATTE) find_package(LAPACK) find_package(BLAS) if(NOT LAPACK_FOUND OR NOT BLAS_FOUND) + if(CMAKE_GENERATOR STREQUAL "Ninja") + status(FATAL_ERROR "Cannot build internal linear algebra library with Ninja build tool due to lack for Fortran support") + endif() enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF]) add_library(linalg STATIC ${LAPACK_SOURCES}) @@ -367,21 +236,6 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) endif() endif() -if(PKG_PYTHON) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - add_definitions(-DLMP_PYTHON) - include_directories(${PYTHON_INCLUDE_DIR}) - list(APPEND LAMMPS_LINK_LIBS ${PYTHON_LIBRARY}) - if(BUILD_LIB AND BUILD_SHARED_LIBS) - if(NOT PYTHON_INSTDIR) - execute_process(COMMAND ${PYTHON_EXECUTABLE} - -c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE PYTHON_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - endif() - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../python/lammps.py DESTINATION ${PYTHON_INSTDIR}) - endif() -endif() find_package(JPEG QUIET) option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) @@ -437,320 +291,22 @@ else() set(CUDA_REQUEST_PIC) endif() - -if(PKG_VORONOI) - option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" OFF) - if(DOWNLOAD_VORO) - message(STATUS "Voro++ download requested - we will build our own") - include(ExternalProject) - - if(BUILD_SHARED_LIBS) - set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") - else() - set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") - endif() - string(APPEND VORO_BUILD_CFLAGS ${CMAKE_CXX_FLAGS}) - set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS}) - - ExternalProject_Add(voro_build - URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz - URL_MD5 2338b824c3b7b25590e18e8df5d68af9 - CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND "" - ) - ExternalProject_get_property(voro_build SOURCE_DIR) - set(VORO_LIBRARIES ${SOURCE_DIR}/src/libvoro++.a) - set(VORO_INCLUDE_DIRS ${SOURCE_DIR}/src) - list(APPEND LAMMPS_DEPS voro_build) - else() - find_package(VORO) - if(NOT VORO_FOUND) - message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it") - endif() - endif() - include_directories(${VORO_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${VORO_LIBRARIES}) -endif() - -if(PKG_LATTE) - option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" OFF) - if(DOWNLOAD_LATTE) - if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR - message(FATAL_ERROR "For downlading LATTE you need at least cmake-3.7") - endif() - message(STATUS "LATTE download requested - we will build our own") - include(ExternalProject) - ExternalProject_Add(latte_build - URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz - URL_MD5 85ac414fdada2d04619c8f936344df14 - SOURCE_SUBDIR cmake - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} - ) - ExternalProject_get_property(latte_build INSTALL_DIR) - set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a) - list(APPEND LAMMPS_DEPS latte_build) - else() - find_package(LATTE) - if(NOT LATTE_FOUND) - message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it") - endif() - endif() - list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES}) -endif() - -if(PKG_USER-SCAFACOS) - find_package(GSL REQUIRED) - option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" OFF) - if(DOWNLOAD_SCAFACOS) - message(STATUS "ScaFaCoS download requested - we will build our own") - include(ExternalProject) - ExternalProject_Add(scafacos_build - URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz - URL_MD5 bd46d74e3296bd8a444d731bb10c1738 - CONFIGURE_COMMAND /configure --prefix= --disable-doc - --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m - --with-internal-fftw --with-internal-pfft - --with-internal-pnfft ${CONFIGURE_REQUEST_PIC} - FC=${CMAKE_MPI_Fortran_COMPILER} - CXX=${CMAKE_MPI_CXX_COMPILER} - CC=${CMAKE_MPI_C_COMPILER} - F77= - ) - ExternalProject_get_property(scafacos_build INSTALL_DIR) - set(SCAFACOS_BUILD_DIR ${INSTALL_DIR}) - set(SCAFACOS_INCLUDE_DIRS ${SCAFACOS_BUILD_DIR}/include) - list(APPEND LAMMPS_DEPS scafacos_build) - # list and order from pkg_config file of ScaFaCoS build - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_direct.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_ewald.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fmm.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p2nfft.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p3m.a) - list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES}) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_near.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_gridsort.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_resort.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_redist.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_common.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pnfft.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pfft.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3_mpi.a) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3.a) - list(APPEND LAMMPS_LINK_LIBS ${MPI_Fortran_LIBRARIES}) - list(APPEND LAMMPS_LINK_LIBS ${MPI_C_LIBRARIES}) - else() - FIND_PACKAGE(PkgConfig REQUIRED) - PKG_CHECK_MODULES(SCAFACOS scafacos REQUIRED) - list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS}) - endif() - include_directories(${SCAFACOS_INCLUDE_DIRS}) -endif() - -if(PKG_USER-PLUMED) - find_package(GSL REQUIRED) - set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library") - set(PLUMED_MODE_VALUES static shared runtime) - set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES}) - validate_option(PLUMED_MODE PLUMED_MODE_VALUES) - string(TOUPPER ${PLUMED_MODE} PLUMED_MODE) - - option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" OFF) - if(DOWNLOAD_PLUMED) - message(STATUS "PLUMED download requested - we will build our own") - include(ExternalProject) - ExternalProject_Add(plumed_build - URL https://github.com/plumed/plumed2/releases/download/v2.4.4/plumed-src-2.4.4.tgz - URL_MD5 71ed465bdc7c2059e282dbda8d564e71 - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix= - ${CONFIGURE_REQUEST_PIC} - --enable-modules=all - CXX=${CMAKE_MPI_CXX_COMPILER} - CC=${CMAKE_MPI_C_COMPILER} - ) - ExternalProject_get_property(plumed_build INSTALL_DIR) - set(PLUMED_INSTALL_DIR ${INSTALL_DIR}) - list(APPEND LAMMPS_DEPS plumed_build) - if(PLUMED_MODE STREQUAL "STATIC") - add_definitions(-D__PLUMED_WRAPPER_CXX=1) - list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/plumed/obj/kernel.o - "${PLUMED_INSTALL_DIR}/lib/plumed/obj/PlumedStatic.o" ${GSL_LIBRARIES} ${CMAKE_DL_LIBS}) - elseif(PLUMED_MODE STREQUAL "SHARED") - list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.so ${CMAKE_DL_LIBS}) - elseif(PLUMED_MODE STREQUAL "RUNTIME") - add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel.so) - list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS}) - endif() - set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include") - else() - find_package(PkgConfig REQUIRED) - pkg_check_modules(PLUMED plumed REQUIRED) - if(PLUMED_MODE STREQUAL "STATIC") - add_definitions(-D__PLUMED_WRAPPER_CXX=1) - include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static) - elseif(PLUMED_MODE STREQUAL "SHARED") - include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared) - elseif(PLUMED_MODE STREQUAL "RUNTIME") - add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel.so) - include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime) - endif() - list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD}) - endif() - include_directories(${PLUMED_INCLUDE_DIRS}) -endif() - -if(PKG_USER-MOLFILE) - add_library(molfile INTERFACE) - target_include_directories(molfile INTERFACE ${LAMMPS_LIB_SOURCE_DIR}/molfile) - target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) - list(APPEND LAMMPS_LINK_LIBS molfile) -endif() - -if(PKG_USER-NETCDF) - find_package(NetCDF REQUIRED) - include_directories(${NETCDF_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${NETCDF_LIBRARIES}) - add_definitions(-DLMP_HAS_NETCDF -DNC_64BIT_DATA=0x0020) -endif() - -if(PKG_USER-SMD) - option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" OFF) - if(DOWNLOAD_EIGEN3) - message(STATUS "Eigen3 download requested - we will build our own") - include(ExternalProject) - ExternalProject_Add(Eigen3_build - URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz - URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07 - CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" - ) - ExternalProject_get_property(Eigen3_build SOURCE_DIR) - set(EIGEN3_INCLUDE_DIR ${SOURCE_DIR}) - list(APPEND LAMMPS_DEPS Eigen3_build) - else() - find_package(Eigen3 NO_MODULE) - mark_as_advanced(Eigen3_DIR) - if(NOT EIGEN3_FOUND) - message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it") - endif() - endif() - include_directories(${EIGEN3_INCLUDE_DIR}) -endif() - -if(PKG_USER-QUIP) - find_package(QUIP REQUIRED) - list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES}) -endif() - -if(PKG_USER-QMMM) - message(WARNING "Building QMMM with CMake is still experimental") - find_package(QE REQUIRED) - include_directories(${QE_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES}) -endif() - -if(PKG_USER-VTK) - find_package(VTK REQUIRED NO_MODULE) - include(${VTK_USE_FILE}) - add_definitions(-DLAMMPS_VTK) - list(APPEND LAMMPS_LINK_LIBS ${VTK_LIBRARIES}) -endif() - -if(PKG_KIM) - option(DOWNLOAD_KIM "Download KIM-API v1 from OpenKIM instead of using an already installed one)" OFF) - if(DOWNLOAD_KIM) - message(STATUS "KIM-API v1 download requested - we will build our own") - include(ExternalProject) - ExternalProject_Add(kim_build - URL https://github.com/openkim/kim-api/archive/v1.9.5.tar.gz - URL_MD5 9f66efc128da33039e30659f36fc6d00 - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix= - ) - ExternalProject_get_property(kim_build INSTALL_DIR) - set(KIM_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api-v1) - set(KIM_LIBRARIES ${INSTALL_DIR}/lib/libkim-api-v1.so) - list(APPEND LAMMPS_DEPS kim_build) - else() - find_package(KIM) - if(NOT KIM_FOUND) - message(FATAL_ERROR "KIM-API v1 not found, help CMake to find it by setting KIM_LIBRARY and KIM_INCLUDE_DIR, or set DOWNLOAD_KIM=ON to download it") - endif() - endif() - list(APPEND LAMMPS_LINK_LIBS ${KIM_LIBRARIES}) - include_directories(${KIM_INCLUDE_DIRS}) -endif() - -if(PKG_MESSAGE) - option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF) - file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) - - add_library(cslib STATIC ${cslib_SOURCES}) - if(BUILD_MPI) - target_compile_definitions(cslib PRIVATE -DMPI_YES) - set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi") - else() - target_compile_definitions(cslib PRIVATE -DMPI_NO) - set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi") - endif() - - if(MESSAGE_ZMQ) - target_compile_definitions(cslib PRIVATE -DZMQ_YES) - find_package(ZMQ REQUIRED) - target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS}) - target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES}) - else() - target_compile_definitions(cslib PRIVATE -DZMQ_NO) - target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ) - endif() - - list(APPEND LAMMPS_LINK_LIBS cslib) - include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src) -endif() - -if(PKG_MSCG) - find_package(GSL REQUIRED) - option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" OFF) - if(DOWNLOAD_MSCG) - if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR - message(FATAL_ERROR "For downlading MSCG you need at least cmake-3.7") - endif() - include(ExternalProject) - if(NOT LAPACK_FOUND) - set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a") - endif() - ExternalProject_Add(mscg_build - URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz - URL_MD5 8c45e269ee13f60b303edd7823866a91 - SOURCE_SUBDIR src/CMake - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS} - BUILD_COMMAND make mscg INSTALL_COMMAND "" - ) - ExternalProject_get_property(mscg_build BINARY_DIR) - set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a) - ExternalProject_get_property(mscg_build SOURCE_DIR) - set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src) - list(APPEND LAMMPS_DEPS mscg_build) - if(NOT LAPACK_FOUND) - file(MAKE_DIRECTORY ${MSCG_INCLUDE_DIRS}) - add_dependencies(mscg_build linalg) - endif() - else() - find_package(MSCG) - if(NOT MSCG_FOUND) - message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it") - endif() - endif() - list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES}) - include_directories(${MSCG_INCLUDE_DIRS}) -endif() - -if(PKG_COMPRESS) - find_package(ZLIB REQUIRED) - include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${ZLIB_LIBRARIES}) -endif() +include(Packages/KSPACE) +include(Packages/PYTHON) +include(Packages/VORONOI) +include(Packages/USER-SCAFACOS) +include(Packages/USER-PLUMED) +include(Packages/USER-MOLFILE) +include(Packages/USER-NETCDF) +include(Packages/USER-SMD) +include(Packages/USER-QUIP) +include(Packages/USER-QMMM) +include(Packages/USER-VTK) +include(Packages/KIM) +include(Packages/LATTE) +include(Packages/MESSAGE) +include(Packages/MSCG) +include(Packages/COMPRESS) # the windows version of LAMMPS requires a couple extra libraries if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") @@ -760,7 +316,6 @@ endif() ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # ######################################################################## -include(CheckIncludeFileCXX) foreach(HEADER cmath) check_include_file_cxx(${HEADER} FOUND_${HEADER}) if(NOT FOUND_${HEADER}) @@ -808,6 +363,8 @@ foreach(PKG ${DEFAULT_PACKAGES}) list(APPEND LIB_SOURCES ${${PKG}_SOURCES}) include_directories(${${PKG}_SOURCES_DIR}) endif() + + RegisterPackages(${${PKG}_SOURCES_DIR}) endforeach() # packages that need defines set @@ -826,6 +383,8 @@ foreach(PKG ${ACCEL_PACKAGES}) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) + + RegisterPackages(${${PKG}_SOURCES_DIR}) endforeach() ############################################## @@ -867,427 +426,30 @@ if(PKG_USER-ATC) target_link_libraries(atc ${LAPACK_LIBRARIES}) endif() -if(PKG_USER-H5MD) - find_package(HDF5 REQUIRED) - target_link_libraries(h5md ${HDF5_LIBRARIES}) - target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) - include_directories(${HDF5_INCLUDE_DIRS}) -endif() - +include(Packages/USER-H5MD) ###################################################################### # packages which selectively include variants based on enabled styles # e.g. accelerator packages ###################################################################### -if(PKG_CORESHELL) - set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL) - set(CORESHELL_SOURCES) - set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}") - - # detects styles which have a CORESHELL version - RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES) - - get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES) - - list(APPEND LIB_SOURCES ${CORESHELL_SOURCES}) - include_directories(${CORESHELL_SOURCES_DIR}) -endif() - -# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed -if(PKG_QEQ) - set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ) - file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h) - file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp) - - if(NOT PKG_MANYBODY) - list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h) - list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp) - endif() - set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}") - - foreach(MY_HEADER ${QEQ_HEADERS}) - AddStyleHeader(${MY_HEADER} FIX) - endforeach() - - get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES) - list(APPEND LIB_SOURCES ${QEQ_SOURCES}) - include_directories(${QEQ_SOURCES_DIR}) -endif() - -if(PKG_USER-OMP) - set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP) - set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp - ${USER-OMP_SOURCES_DIR}/thr_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp - ${USER-OMP_SOURCES_DIR}/domain_omp.cpp) - add_definitions(-DLMP_USER_OMP) - set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}") - - # detects styles which have USER-OMP version - RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES) - RegisterFixStyle("${USER-OMP_SOURCES_DIR}/fix_omp.h") - - get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES) - - # manually add package dependent source files from USER-OMP that do not provide styles - - if(PKG_ASPHERE) - list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp) - endif() - - if(PKG_RIGID) - list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp) - endif() - - if(PKG_USER-REAXC) - list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp) - endif() - - list(APPEND LIB_SOURCES ${USER-OMP_SOURCES}) - include_directories(${USER-OMP_SOURCES_DIR}) -endif() - -# Fix rigid/meso requires RIGID to be installed -if(PKG_USER-SDPD) - set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD) - - get_property(hlist GLOBAL PROPERTY FIX) - if(NOT PKG_RIGID) - list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h) - list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp) - endif() - set_property(GLOBAL PROPERTY FIX "${hlist}") - - include_directories(${USER-SDPD_SOURCES_DIR}) -endif() - -if(PKG_KOKKOS) - set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) - set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos) - add_definitions(-DLMP_KOKKOS) - add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR}) - - set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src - ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src - ${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src - ${LAMMPS_LIB_KOKKOS_BIN_DIR}) - include_directories(${Kokkos_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS kokkos) - - set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS) - set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp - ${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp) - - if(PKG_KSPACE) - list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp) - endif() - - set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}") - - # detects styles which have KOKKOS version - RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES) - - # register kokkos-only styles - RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h) - RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h) - - if(PKG_USER-DPD) - get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES) - list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp) - RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h) - set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}") - endif() - - get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES) - - list(APPEND LIB_SOURCES ${KOKKOS_PKG_SOURCES}) - include_directories(${KOKKOS_PKG_SOURCES_DIR}) -endif() - -if(PKG_OPT) - set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT) - set(OPT_SOURCES) - set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}") - - # detects styles which have OPT version - RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES) - - get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES) - - list(APPEND LIB_SOURCES ${OPT_SOURCES}) - include_directories(${OPT_SOURCES_DIR}) -endif() - -if(PKG_USER-INTEL) - find_package(TBB REQUIRED) - find_package(MKL REQUIRED) - - if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message(FATAL_ERROR "USER-INTEL is only useful together with intel compiler") - endif() - - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - message(FATAL_ERROR "USER-INTEL needs at least a 2016 intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}") - endif() - - if(NOT BUILD_OMP) - message(FATAL_ERROR "USER-INTEL requires OpenMP") - endif() - - if(NOT ${LAMMPS_MEMALIGN} STREQUAL "64") - message(FATAL_ERROR "USER-INTEL is only useful with LAMMPS_MEMALIGN=64") - endif() - - set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)") - set(INTEL_ARCH_VALUES cpu knl) - set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES}) - validate_option(INTEL_ARCH INTEL_ARCH_VALUES) - string(TOUPPER ${INTEL_ARCH} INTEL_ARCH) - - if(INTEL_ARCH STREQUAL "KNL") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload") - set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"") - add_compile_options(-xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS}) - add_definitions(-DLMP_INTEL_OFFLOAD) - else() - if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") - endif() - include(CheckCXXCompilerFlag) - foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict) - check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG}) - if(COMPILER_SUPPORTS${_FLAG}) - add_compile_options(${_FLAG}) - endif() - endforeach() - endif() - - add_definitions(-DLMP_INTEL_USELRT -DLMP_USE_MKL_RNG) - - list(APPEND LAMMPS_LINK_LIBS ${TBB_MALLOC_LIBRARIES} ${MKL_LIBRARIES}) - - set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL) - set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/intel_preprocess.h - ${USER-INTEL_SOURCES_DIR}/intel_buffers.h - ${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp - ${USER-INTEL_SOURCES_DIR}/math_extra_intel.h - ${USER-INTEL_SOURCES_DIR}/nbin_intel.h - ${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp - ${USER-INTEL_SOURCES_DIR}/npair_intel.h - ${USER-INTEL_SOURCES_DIR}/npair_intel.cpp - ${USER-INTEL_SOURCES_DIR}/intel_simd.h - ${USER-INTEL_SOURCES_DIR}/intel_intrinsics.h) - - set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}") - - # detects styles which have USER-INTEL version - RegisterStylesExt(${USER-INTEL_SOURCES_DIR} opt USER-INTEL_SOURCES) - - get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES) - - list(APPEND LIB_SOURCES ${USER-INTEL_SOURCES}) - include_directories(${USER-INTEL_SOURCES_DIR}) -endif() - -if(PKG_GPU) - if (CMAKE_VERSION VERSION_LESS "3.1") - message(FATAL_ERROR "For the GPU package you need at least cmake-3.1") - endif() - set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) - set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h - ${GPU_SOURCES_DIR}/fix_gpu.h - ${GPU_SOURCES_DIR}/fix_gpu.cpp) - - set(GPU_API "opencl" CACHE STRING "API used by GPU package") - set(GPU_API_VALUES opencl cuda) - set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES}) - validate_option(GPU_API GPU_API_VALUES) - string(TOUPPER ${GPU_API} GPU_API) - - set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision") - set(GPU_PREC_VALUES double mixed single) - set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES}) - validate_option(GPU_PREC GPU_PREC_VALUES) - string(TOUPPER ${GPU_PREC} GPU_PREC) - - if(GPU_PREC STREQUAL "DOUBLE") - set(GPU_PREC_SETTING "DOUBLE_DOUBLE") - elseif(GPU_PREC STREQUAL "MIXED") - set(GPU_PREC_SETTING "SINGLE_DOUBLE") - elseif(GPU_PREC STREQUAL "SINGLE") - set(GPU_PREC_SETTING "SINGLE_SINGLE") - endif() - - file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) - file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) - - if(GPU_API STREQUAL "CUDA") - find_package(CUDA REQUIRED) - find_program(BIN2C bin2c) - if(NOT BIN2C) - message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.") - endif() - option(CUDPP_OPT "Enable CUDPP_OPT" ON) - - set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") - - file(GLOB GPU_LIB_CU ${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 ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) - file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) - endif() - - # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice - # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture - set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ") - # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0 - if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0")) - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ") - endif() - # Kepler (GPU Arch 3.x) is supported by CUDA 5 and later - if(CUDA_VERSION VERSION_GREATER "4.9") - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ") - endif() - # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later - if(CUDA_VERSION VERSION_GREATER "5.9") - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ") - endif() - # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later - if(CUDA_VERSION VERSION_GREATER "7.9") - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ") - endif() - # Volta (GPU Arch 7.0) is supported by CUDA 9 and later - if(CUDA_VERSION VERSION_GREATER "8.9") - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ") - endif() - # Turing (GPU Arch 7.5) is supported by CUDA 10 and later - if(CUDA_VERSION VERSION_GREATER "9.9") - string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ") - endif() - - cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) - - cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) - - foreach(CU_OBJ ${GPU_GEN_OBJS}) - get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) - string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}") - add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h - COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h - DEPENDS ${CU_OBJ} - COMMENT "Generating ${CU_NAME}_cubin.h") - list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) - endforeach() - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") - - - add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) - target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) - target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT) - if(CUDPP_OPT) - target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) - target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) - endif() - - list(APPEND LAMMPS_LINK_LIBS gpu) - - add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) - target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR) - target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) - target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) - - - elseif(GPU_API STREQUAL "OPENCL") - find_package(OpenCL REQUIRED) - set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning") - set(OCL_TUNE_VALUES intel fermi kepler cypress generic) - set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES}) - validate_option(OCL_TUNE OCL_TUNE_VALUES) - string(TOUPPER ${OCL_TUNE} OCL_TUNE) - - 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 ${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) - - foreach(GPU_KERNEL ${GPU_LIB_CU}) - get_filename_component(basename ${GPU_KERNEL} NAME_WE) - string(SUBSTRING ${basename} 4 -1 KERNEL_NAME) - GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL}) - list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h) - endforeach() - - GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu) - GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) - list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h) - - add_library(gpu STATIC ${GPU_LIB_SOURCES}) - target_link_libraries(gpu ${OpenCL_LIBRARIES}) - target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS}) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT) - target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) - - list(APPEND LAMMPS_LINK_LIBS gpu) - - add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) - target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL) - target_link_libraries(ocl_get_devices PRIVATE ${OpenCL_LIBRARIES}) - target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS}) - endif() - - # GPU package - FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) - - set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") - - # detects styles which have GPU version - RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES) - - get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) - - list(APPEND LIB_SOURCES ${GPU_SOURCES}) - include_directories(${GPU_SOURCES_DIR}) -endif() +include(Packages/CORESHELL) +include(Packages/QEQ) +include(Packages/USER-OMP) +include(Packages/USER-SDPD) +include(Packages/KOKKOS) +include(Packages/OPT) +include(Packages/USER-INTEL) +include(Packages/GPU) ###################################################### # Generate style headers based on global list of # styles registered during package selection +# Generate packages headers from all packages ###################################################### set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles) GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR}) +GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR}) include_directories(${LAMMPS_STYLE_HEADERS_DIR}) @@ -1296,7 +458,7 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ###################################### set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n") set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n") -set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) list(SORT temp_PKG_LIST) foreach(PKG ${temp_PKG_LIST}) if(PKG_${PKG}) @@ -1308,6 +470,18 @@ message(STATUS "Generating lmpinstalledpkgs.h...") file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${temp}" ) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h") +###################################### +# Generate lmpgitversion.h +###################################### +add_custom_target(gitversion COMMAND ${CMAKE_COMMAND} + -DCMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + -DGIT_EXECUTABLE="${GIT_EXECUTABLE}" + -DGIT_FOUND="${GIT_FOUND}" + -DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h) +list(APPEND LAMMPS_DEPS gitversion) + ########################################### # Actually add executable and lib to build ############################################ @@ -1349,76 +523,39 @@ if(BUILD_EXE) set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1) - if(ENABLE_TESTING) - add_test(ShowHelp ${LAMMPS_BINARY} -help) - endif() endif() -############################################################################### -# Build documentation -############################################################################### -option(BUILD_DOC "Build LAMMPS documentation" OFF) -if(BUILD_DOC) - include(ProcessorCount) - ProcessorCount(NPROCS) - find_package(PythonInterp 3 REQUIRED) - - set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv) - - file(GLOB DOC_SOURCES ${LAMMPS_DOC_DIR}/src/[^.]*.txt) - file(GLOB PDF_EXTRA_SOURCES ${LAMMPS_DOC_DIR}/src/lammps_commands*.txt ${LAMMPS_DOC_DIR}/src/lammps_support.txt ${LAMMPS_DOC_DIR}/src/lammps_tutorials.txt) - list(REMOVE_ITEM DOC_SOURCES ${PDF_EXTRA_SOURCES}) - - add_custom_command( - OUTPUT docenv - COMMAND ${VIRTUALENV} docenv - ) - - set(DOCENV_BINARY_DIR ${CMAKE_BINARY_DIR}/docenv/bin) - - add_custom_command( - OUTPUT requirements.txt - DEPENDS docenv - COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_DOC_DIR}/utils/requirements.txt requirements.txt - COMMAND ${DOCENV_BINARY_DIR}/pip install -r requirements.txt --upgrade - COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters - ) - - set(RST_FILES "") - set(RST_DIR ${CMAKE_BINARY_DIR}/rst) - file(MAKE_DIRECTORY ${RST_DIR}) - foreach(TXT_FILE ${DOC_SOURCES}) - get_filename_component(FILENAME ${TXT_FILE} NAME_WE) - set(RST_FILE ${RST_DIR}/${FILENAME}.rst) - list(APPEND RST_FILES ${RST_FILE}) - add_custom_command( - OUTPUT ${RST_FILE} - DEPENDS requirements.txt docenv ${TXT_FILE} - COMMAND ${DOCENV_BINARY_DIR}/txt2rst -o ${RST_DIR} ${TXT_FILE} - ) - endforeach() - - add_custom_command( - OUTPUT html - DEPENDS ${RST_FILES} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DOC_DIR}/src ${RST_DIR} - COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -j ${NPROCS} -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${RST_DIR} html - ) +if(BUILD_TOOLS) + add_executable(binary2txt ${LAMMPS_TOOLS_DIR}/binary2txt.cpp) + install(TARGETS binary2txt DESTINATION ${CMAKE_INSTALL_BINDIR}) - add_custom_target( - doc ALL - DEPENDS html - SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES} - ) + # ninja-build currently does not support fortran. thus we skip building this tool + if(NOT CMAKE_GENERATOR STREQUAL "Ninja") + message(STATUS "Skipping building 'chain.x' with Ninja build tool due to lack of Fortran support") + enable_language(Fortran) + add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f) + target_link_libraries(chain.x ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) + endif() - install(DIRECTORY ${CMAKE_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}) + enable_language(C) + get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) + file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c) + add_executable(msi2lmp ${MSI2LMP_SOURCES}) + target_link_libraries(msi2lmp m) + install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endif() +include(Documentation) + ############################################################################### -# Install potential files in data directory +# Install potential and force field files in data directory ############################################################################### -set(LAMMPS_POTENTIALS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps/potentials) -install(DIRECTORY ${LAMMPS_SOURCE_DIR}/../potentials/ DESTINATION ${LAMMPS_POTENTIALS_DIR}) +set(LAMMPS_INSTALL_POTENTIALS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps/potentials) +install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_POTENTIALS_DIR}) + +set(LAMMPS_INSTALL_FRC_FILES_DIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps/frc_files) +install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files/ DESTINATION ${LAMMPS_INSTALL_FRC_FILES_DIR}) configure_file(etc/profile.d/lammps.sh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh @ONLY) configure_file(etc/profile.d/lammps.csh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh @ONLY) @@ -1429,38 +566,55 @@ install( ) ############################################################################### -# Testing -# -# Requires latest gcovr (for GCC 8.1 support):# -# pip install git+https://github.com/gcovr/gcovr.git +# Install LAMMPS lib and python module into site-packages folder with +# "install-python" target. Behaves exactly like "make install-python" for +# conventional build. Only available, if a shared library is built. +# This is primarily for people that only want to use the Python wrapper. ############################################################################### -if(ENABLE_COVERAGE) - find_program(GCOVR_BINARY gcovr) - find_package_handle_standard_args(GCOVR DEFAULT_MSG GCOVR_BINARY) - - if(GCOVR_FOUND) - get_filename_component(ABSOLUTE_LAMMPS_SOURCE_DIR ${LAMMPS_SOURCE_DIR} ABSOLUTE) - - add_custom_target( - gen_coverage_xml - COMMAND ${GCOVR_BINARY} -s -x -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating XML Coverage Report..." - ) - - add_custom_target( - gen_coverage_html - COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.html - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating HTML Coverage Report..." - ) - endif() +if(BUILD_LIB AND BUILD_SHARED_LIBS) + find_package(PythonInterp) + if (PYTHONINTERP_FOUND) + add_custom_target( + install-python + ${PYTHON_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h + -m ${LAMMPS_PYTHON_DIR}/lammps.py + -l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX} + WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} + COMMENT "Installing LAMMPS Python module") + else() + add_custom_target( + install-python + ${CMAKE_COMMAND} -E echo "Must have Python installed to install the LAMMPS Python module") + endif() +else() + add_custom_target( + install-python + ${CMAKE_COMMAND} -E echo "Must build LAMMPS as a shared library to use the Python module") endif() +############################################################################### +# Add LAMMPS python module to "install" target. This is taylored for building +# LAMMPS for package managers and with different prefix settings. +# This requires either a shared library or that the PYTHON package is included. +############################################################################### +if((BUILD_LIB AND BUILD_SHARED_LIBS) OR (PKG_PYTHON)) + find_package(PythonInterp) + if (PYTHONINTERP_FOUND) + execute_process(COMMAND ${PYTHON_EXECUTABLE} + -c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) + set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module") + install(FILES ${LAMMPS_PYTHON_DIR}/lammps.py DESTINATION ${PYTHON_INSTDIR}) + endif() +endif() + +include(Testing) +include(CodeCoverage) + ############################################################################### # Print package summary ############################################################################### -foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) if(PKG_${PKG}) message(STATUS "Building package: ${PKG}") endif() diff --git a/cmake/Modules/CodeCoverage.cmake b/cmake/Modules/CodeCoverage.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d018db43d98aebcd934e0e77c0ed092a554b603d --- /dev/null +++ b/cmake/Modules/CodeCoverage.cmake @@ -0,0 +1,28 @@ +############################################################################### +# Coverage +# +# Requires latest gcovr (for GCC 8.1 support):# +# pip install git+https://github.com/gcovr/gcovr.git +############################################################################### +if(ENABLE_COVERAGE) + find_program(GCOVR_BINARY gcovr) + find_package_handle_standard_args(GCOVR DEFAULT_MSG GCOVR_BINARY) + + if(GCOVR_FOUND) + get_filename_component(ABSOLUTE_LAMMPS_SOURCE_DIR ${LAMMPS_SOURCE_DIR} ABSOLUTE) + + add_custom_target( + gen_coverage_xml + COMMAND ${GCOVR_BINARY} -s -x -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating XML Coverage Report..." + ) + + add_custom_target( + gen_coverage_html + COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.html + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating HTML Coverage Report..." + ) + endif() +endif() diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake new file mode 100644 index 0000000000000000000000000000000000000000..99f570820ad439eb71448c24241efca83cc50624 --- /dev/null +++ b/cmake/Modules/Documentation.cmake @@ -0,0 +1,59 @@ +############################################################################### +# Build documentation +############################################################################### +option(BUILD_DOC "Build LAMMPS documentation" OFF) +if(BUILD_DOC) + include(ProcessorCount) + ProcessorCount(NPROCS) + find_package(PythonInterp 3 REQUIRED) + + set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv) + + file(GLOB DOC_SOURCES ${LAMMPS_DOC_DIR}/src/[^.]*.txt) + file(GLOB PDF_EXTRA_SOURCES ${LAMMPS_DOC_DIR}/src/lammps_commands*.txt ${LAMMPS_DOC_DIR}/src/lammps_support.txt ${LAMMPS_DOC_DIR}/src/lammps_tutorials.txt) + list(REMOVE_ITEM DOC_SOURCES ${PDF_EXTRA_SOURCES}) + + add_custom_command( + OUTPUT docenv + COMMAND ${VIRTUALENV} docenv + ) + + set(DOCENV_BINARY_DIR ${CMAKE_BINARY_DIR}/docenv/bin) + + add_custom_command( + OUTPUT requirements.txt + DEPENDS docenv + COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_DOC_DIR}/utils/requirements.txt requirements.txt + COMMAND ${DOCENV_BINARY_DIR}/pip install -r requirements.txt --upgrade + COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters + ) + + set(RST_FILES "") + set(RST_DIR ${CMAKE_BINARY_DIR}/rst) + file(MAKE_DIRECTORY ${RST_DIR}) + foreach(TXT_FILE ${DOC_SOURCES}) + get_filename_component(FILENAME ${TXT_FILE} NAME_WE) + set(RST_FILE ${RST_DIR}/${FILENAME}.rst) + list(APPEND RST_FILES ${RST_FILE}) + add_custom_command( + OUTPUT ${RST_FILE} + DEPENDS requirements.txt docenv ${TXT_FILE} + COMMAND ${DOCENV_BINARY_DIR}/txt2rst -o ${RST_DIR} ${TXT_FILE} + ) + endforeach() + + add_custom_command( + OUTPUT html + DEPENDS ${RST_FILES} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DOC_DIR}/src ${RST_DIR} + COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -j ${NPROCS} -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${RST_DIR} html + ) + + add_custom_target( + doc ALL + DEPENDS html + SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES} + ) + + install(DIRECTORY ${CMAKE_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}) +endif() diff --git a/cmake/Modules/FindKIM-API.cmake b/cmake/Modules/FindKIM-API.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5108b0f98c42acfc2a3fcec2a4fc7e557470148c --- /dev/null +++ b/cmake/Modules/FindKIM-API.cmake @@ -0,0 +1,59 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the Common Development +# and Distribution License Version 1.0 (the "License"). +# +# You can obtain a copy of the license at +# http://www.opensource.org/licenses/CDDL-1.0. See the License for the +# specific language governing permissions and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each file and +# include the License file in a prominent location with the name LICENSE.CDDL. +# If applicable, add the following below this CDDL HEADER, with the fields +# enclosed by brackets "[]" replaced with your own identifying information: +# +# Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved. +# +# CDDL HEADER END +# + +# +# Copyright (c) 2013--2019, Regents of the University of Minnesota. +# All rights reserved. +# +# Contributors: +# Richard Berger +# Christoph Junghans +# Ryan S. Elliott +# + +# - Find KIM-API +# +# sets standard pkg_check_modules variables plus: +# +# KIM-API-CMAKE_C_COMPILER +# KIM-API-CMAKE_CXX_COMPILER +# KIM-API-CMAKE_Fortran_COMPILER +# + +if(KIM-API_FIND_QUIETLY) + set(REQ_OR_QUI "QUIET") +else() + set(REQ_OR_QUI "REQUIRED") +endif() + +find_package(PkgConfig ${REQ_OR_QUI}) +include(FindPackageHandleStandardArgs) + +pkg_check_modules(KIM-API ${REQ_OR_QUI} libkim-api>=2.0) + +if(KIM-API_FOUND) + pkg_get_variable(KIM-API-CMAKE_C_COMPILER libkim-api CMAKE_C_COMPILER) + pkg_get_variable(KIM-API-CMAKE_CXX_COMPILER libkim-api CMAKE_CXX_COMPILER) + pkg_get_variable(KIM-API_CMAKE_Fortran_COMPILER libkim-api CMAKE_Fortran_COMPILER) +endif() + +# handle the QUIETLY and REQUIRED arguments and set KIM-API_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(KIM-API REQUIRED_VARS KIM-API_LIBRARIES) diff --git a/cmake/Modules/FindKIM.cmake b/cmake/Modules/FindKIM.cmake deleted file mode 100644 index a01f817cf67a1314d5e49e96718298f78842cda4..0000000000000000000000000000000000000000 --- a/cmake/Modules/FindKIM.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# - Find kim -# Find the native KIM headers and libraries. -# -# KIM_INCLUDE_DIRS - where to find kim.h, etc. -# KIM_LIBRARIES - List of libraries when using kim. -# KIM_FOUND - True if kim found. -# - -find_path(KIM_INCLUDE_DIR KIM_API.h PATH_SUFFIXES kim-api-v1) - -find_library(KIM_LIBRARY NAMES kim-api-v1) - -set(KIM_LIBRARIES ${KIM_LIBRARY}) -set(KIM_INCLUDE_DIRS ${KIM_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set KIM_FOUND to TRUE -# if all listed variables are TRUE - -find_package_handle_standard_args(KIM DEFAULT_MSG KIM_LIBRARY KIM_INCLUDE_DIR) - -mark_as_advanced(KIM_INCLUDE_DIR KIM_LIBRARY ) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3ea2b3cb7ec977175d026672c1a03f386fc86e61 --- /dev/null +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -0,0 +1,71 @@ +# Utility functions +function(list_to_bulletpoints result) + list(REMOVE_AT ARGV 0) + set(temp "") + foreach(item ${ARGV}) + set(temp "${temp}* ${item}\n") + endforeach() + set(${result} "${temp}" PARENT_SCOPE) +endfunction(list_to_bulletpoints) + +function(validate_option name values) + string(TOLOWER ${${name}} needle_lower) + string(TOUPPER ${${name}} needle_upper) + list(FIND ${values} ${needle_lower} IDX_LOWER) + list(FIND ${values} ${needle_upper} IDX_UPPER) + if(${IDX_LOWER} LESS 0 AND ${IDX_UPPER} LESS 0) + list_to_bulletpoints(POSSIBLE_VALUE_LIST ${${values}}) + message(FATAL_ERROR "\n########################################################################\n" + "Invalid value '${${name}}' for option ${name}\n" + "\n" + "Possible values are:\n" + "${POSSIBLE_VALUE_LIST}" + "########################################################################") + endif() +endfunction(validate_option) + +function(get_lammps_version version_header variable) + file(READ ${version_header} line) + set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) + string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1" day "${line}") + string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\2" month "${line}") + string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\3" year "${line}") + string(STRIP ${day} day) + string(STRIP ${month} month) + string(STRIP ${year} year) + list(FIND MONTHS "${month}" month) + string(LENGTH ${day} day_length) + string(LENGTH ${month} month_length) + if(day_length EQUAL 1) + set(day "0${day}") + endif() + if(month_length EQUAL 1) + set(month "0${month}") + endif() + set(${variable} "${year}${month}${day}" PARENT_SCOPE) +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 ${source_dir}/style_*.h) + file(GLOB SRC_AUTOGEN_PACKAGES ${source_dir}/packages_*.h) + list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) + foreach(_SRC ${SRC_AUTOGEN_FILES}) + get_filename_component(FILENAME "${_SRC}" NAME) + if(EXISTS ${source_dir}/${FILENAME}) + message(FATAL_ERROR "\n########################################################################\n" + "Found header file(s) generated by the make-based build system\n" + "\n" + "Please run\n" + "make -C ${source_dir} purge\n" + "to remove\n" + "########################################################################") + endif() + endforeach() +endfunction() + +macro(pkg_depends PKG1 PKG2) + if(PKG_${PKG1} AND NOT (PKG_${PKG2} OR BUILD_${PKG2})) + message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}") + endif() +endmacro() diff --git a/cmake/Modules/OpenCLUtils.cmake b/cmake/Modules/OpenCLUtils.cmake index 5c147a685cfee925796d48a22d0be2cbe1a99020..a9441ce518497e4ba34383ad7a77f1ebd5bc903b 100644 --- a/cmake/Modules/OpenCLUtils.cmake +++ b/cmake/Modules/OpenCLUtils.cmake @@ -6,7 +6,7 @@ function(GenerateOpenCLHeader varname outfile files) foreach(IDX RANGE 2 ${ARG_END}) list(GET ARGV ${IDX} filename) file(READ ${filename} content) - string(REGEX REPLACE "\\s*//[^\n]*\n" "" content "${content}") + string(REGEX REPLACE "\\s*//[^\n]*\n" "\n" content "${content}") string(REGEX REPLACE "\\\\" "\\\\\\\\" content "${content}") string(REGEX REPLACE "\"" "\\\\\"" content "${content}") string(REGEX REPLACE "([^\n]+)\n" "\"\\1\\\\n\"\n" content "${content}") diff --git a/cmake/Modules/Packages/COMPRESS.cmake b/cmake/Modules/Packages/COMPRESS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..864b868865f531ebcce5374bceed2612fb37d391 --- /dev/null +++ b/cmake/Modules/Packages/COMPRESS.cmake @@ -0,0 +1,5 @@ +if(PKG_COMPRESS) + find_package(ZLIB REQUIRED) + include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${ZLIB_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/CORESHELL.cmake b/cmake/Modules/Packages/CORESHELL.cmake new file mode 100644 index 0000000000000000000000000000000000000000..591477c89948c3d34f975e8cdf65181b96af9171 --- /dev/null +++ b/cmake/Modules/Packages/CORESHELL.cmake @@ -0,0 +1,13 @@ +if(PKG_CORESHELL) + set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL) + set(CORESHELL_SOURCES) + set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}") + + # detects styles which have a CORESHELL version + RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES) + + get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES) + + list(APPEND LIB_SOURCES ${CORESHELL_SOURCES}) + include_directories(${CORESHELL_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake new file mode 100644 index 0000000000000000000000000000000000000000..dab9d51a3f9eb823f09c05ac438546c64f05e9f1 --- /dev/null +++ b/cmake/Modules/Packages/GPU.cmake @@ -0,0 +1,194 @@ +if(PKG_GPU) + if (CMAKE_VERSION VERSION_LESS "3.1") + message(FATAL_ERROR "For the GPU package you need at least cmake-3.1") + endif() + set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) + set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h + ${GPU_SOURCES_DIR}/fix_gpu.h + ${GPU_SOURCES_DIR}/fix_gpu.cpp) + + set(GPU_API "opencl" CACHE STRING "API used by GPU package") + set(GPU_API_VALUES opencl cuda) + set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES}) + validate_option(GPU_API GPU_API_VALUES) + string(TOUPPER ${GPU_API} GPU_API) + + set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision") + set(GPU_PREC_VALUES double mixed single) + set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES}) + validate_option(GPU_PREC GPU_PREC_VALUES) + string(TOUPPER ${GPU_PREC} GPU_PREC) + + if(GPU_PREC STREQUAL "DOUBLE") + set(GPU_PREC_SETTING "DOUBLE_DOUBLE") + elseif(GPU_PREC STREQUAL "MIXED") + set(GPU_PREC_SETTING "SINGLE_DOUBLE") + elseif(GPU_PREC STREQUAL "SINGLE") + set(GPU_PREC_SETTING "SINGLE_SINGLE") + endif() + + file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) + file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) + + if(GPU_API STREQUAL "CUDA") + find_package(CUDA REQUIRED) + find_program(BIN2C bin2c) + if(NOT BIN2C) + message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.") + endif() + option(CUDPP_OPT "Enable CUDPP_OPT" ON) + option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF) + if(CUDA_MPS_SUPPORT) + set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY") + endif() + + set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") + + file(GLOB GPU_LIB_CU ${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 ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) + file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) + endif() + + # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice + # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture + set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ") + # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0 + if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0")) + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ") + endif() + # Kepler (GPU Arch 3.x) is supported by CUDA 5 and later + if(CUDA_VERSION VERSION_GREATER "4.9") + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ") + endif() + # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later + if(CUDA_VERSION VERSION_GREATER "5.9") + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ") + endif() + # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later + if(CUDA_VERSION VERSION_GREATER "7.9") + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ") + endif() + # Volta (GPU Arch 7.0) is supported by CUDA 9 and later + if(CUDA_VERSION VERSION_GREATER "8.9") + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ") + endif() + # Turing (GPU Arch 7.5) is supported by CUDA 10 and later + if(CUDA_VERSION VERSION_GREATER "9.9") + string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ") + endif() + + cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) + + cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC} + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) + + foreach(CU_OBJ ${GPU_GEN_OBJS}) + get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) + string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}") + add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h + COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h + DEPENDS ${CU_OBJ} + COMMENT "Generating ${CU_NAME}_cubin.h") + list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) + endforeach() + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") + + + add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) + target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS}) + if(CUDPP_OPT) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) + target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) + endif() + + list(APPEND LAMMPS_LINK_LIBS gpu) + + add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) + target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR) + target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) + + + elseif(GPU_API STREQUAL "OPENCL") + find_package(OpenCL REQUIRED) + set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning") + set(OCL_TUNE_VALUES intel fermi kepler cypress generic) + set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES}) + validate_option(OCL_TUNE OCL_TUNE_VALUES) + string(TOUPPER ${OCL_TUNE} OCL_TUNE) + + 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 ${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 + ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu + ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu + ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu + ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu + ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu + ) + + foreach(GPU_KERNEL ${GPU_LIB_CU}) + get_filename_component(basename ${GPU_KERNEL} NAME_WE) + string(SUBSTRING ${basename} 4 -1 KERNEL_NAME) + GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL}) + list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h) + endforeach() + + GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu) + GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) + GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu) + GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu) + GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu) + GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu) + GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu) + + list(APPEND GPU_LIB_SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h + ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h + ) + + add_library(gpu STATIC ${GPU_LIB_SOURCES}) + target_link_libraries(gpu ${OpenCL_LIBRARIES}) + target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT) + target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) + + list(APPEND LAMMPS_LINK_LIBS gpu) + + add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) + target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL) + target_link_libraries(ocl_get_devices PRIVATE ${OpenCL_LIBRARIES}) + target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS}) + endif() + + # GPU package + FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) + + set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") + + # detects styles which have GPU version + RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES) + + get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) + + list(APPEND LIB_SOURCES ${GPU_SOURCES}) + include_directories(${GPU_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8815f73881b71e1c98780e62043eaf1e4b4983f2 --- /dev/null +++ b/cmake/Modules/Packages/KIM.cmake @@ -0,0 +1,42 @@ +if(PKG_KIM) + find_package(CURL) + if(CURL_FOUND) + include_directories(${CURL_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES}) + add_definitions(-DLMP_KIM_CURL) + endif() + find_package(KIM-API QUIET) + if(KIM-API_FOUND) + set(DOWNLOAD_KIM_DEFAULT OFF) + else() + set(DOWNLOAD_KIM_DEFAULT ON) + endif() + option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT}) + if(DOWNLOAD_KIM) + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded KIM-API library with Ninja build tool") + endif() + message(STATUS "KIM-API download requested - we will build our own") + enable_language(C) + enable_language(Fortran) + include(ExternalProject) + ExternalProject_Add(kim_build + URL https://s3.openkim.org/kim-api/kim-api-2.0.2.txz + URL_MD5 537d9c0abd30f85b875ebb584f9143fa + BINARY_DIR build + CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ) + ExternalProject_get_property(kim_build INSTALL_DIR) + set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api) + set(KIM-API_LDFLAGS ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}) + list(APPEND LAMMPS_DEPS kim_build) + else() + find_package(KIM-API REQUIRED) + endif() + list(APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}") + include_directories(${KIM-API_INCLUDE_DIRS}) +endif() diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2f7d40180201b37f0fab715b5e396324044766ec --- /dev/null +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -0,0 +1,53 @@ +if(PKG_KOKKOS) + set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) + set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos) + add_definitions(-DLMP_KOKKOS) + add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR}) + + set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src + ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src + ${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src + ${LAMMPS_LIB_KOKKOS_BIN_DIR}) + include_directories(${Kokkos_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS kokkos) + + set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS) + set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp + ${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp) + + if(PKG_KSPACE) + list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp) + endif() + + set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}") + + # detects styles which have KOKKOS version + RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES) + + # register kokkos-only styles + RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h) + RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h) + + if(PKG_USER-DPD) + get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES) + list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp) + RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h) + set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}") + endif() + + get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES) + + list(APPEND LIB_SOURCES ${KOKKOS_PKG_SOURCES}) + include_directories(${KOKKOS_PKG_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6938a93a3667dcbc337105172060c32d9c5b4cbb --- /dev/null +++ b/cmake/Modules/Packages/KSPACE.cmake @@ -0,0 +1,38 @@ +if(PKG_KSPACE) + option(FFT_SINGLE "Use single precision FFT instead of double" OFF) + set(FFTW "FFTW3") + if(FFT_SINGLE) + set(FFTW "FFTW3F") + add_definitions(-DFFT_SINGLE) + endif() + find_package(${FFTW} QUIET) + if(${FFTW}_FOUND) + set(FFT "${FFTW}" CACHE STRING "FFT library for KSPACE package") + else() + set(FFT "KISS" CACHE STRING "FFT library for KSPACE package") + endif() + set(FFT_VALUES KISS ${FFTW} MKL) + set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES}) + validate_option(FFT FFT_VALUES) + string(TOUPPER ${FFT} FFT) + if(NOT FFT STREQUAL "KISS") + find_package(${FFT} REQUIRED) + if(NOT FFT STREQUAL "FFTW3F") + add_definitions(-DFFT_FFTW) + else() + add_definitions(-DFFT_${FFT}) + endif() + include_directories(${${FFT}_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${${FFT}_LIBRARIES}) + else() + add_definitions(-DFFT_KISS) + endif() + set(FFT_PACK "array" CACHE STRING "Optimization for FFT") + set(FFT_PACK_VALUES array pointer memcpy) + set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES}) + validate_option(FFT_PACK FFT_PACK_VALUES) + if(NOT FFT_PACK STREQUAL "array") + string(TOUPPER ${FFT_PACK} FFT_PACK) + add_definitions(-DFFT_PACK_${FFT_PACK}) + endif() +endif() diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake new file mode 100644 index 0000000000000000000000000000000000000000..de7116780bfe262faeebecfebea3a465c9a7f4de --- /dev/null +++ b/cmake/Modules/Packages/LATTE.cmake @@ -0,0 +1,38 @@ +if(PKG_LATTE) + enable_language(Fortran) + find_package(LATTE) + if(LATTE_FOUND) + set(DOWNLOAD_LATTE_DEFAULT OFF) + else() + set(DOWNLOAD_LATTE_DEFAULT ON) + endif() + option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT}) + if(DOWNLOAD_LATTE) + if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR + message(FATAL_ERROR "For downlading LATTE you need at least cmake-3.7") + endif() + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool") + endif() + message(STATUS "LATTE download requested - we will build our own") + include(ExternalProject) + ExternalProject_Add(latte_build + URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz + URL_MD5 85ac414fdada2d04619c8f936344df14 + SOURCE_SUBDIR cmake + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} + -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES} + -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS} + -DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ) + ExternalProject_get_property(latte_build INSTALL_DIR) + set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a) + list(APPEND LAMMPS_DEPS latte_build) + else() + find_package(LATTE) + if(NOT LATTE_FOUND) + message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it") + endif() + endif() + list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3c1bdde855c366fbf74374c08d8bcb6f88eb1d24 --- /dev/null +++ b/cmake/Modules/Packages/MESSAGE.cmake @@ -0,0 +1,29 @@ +if(PKG_MESSAGE) + option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF) + file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F + ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c + ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) + + add_library(cslib STATIC ${cslib_SOURCES}) + if(BUILD_MPI) + target_compile_definitions(cslib PRIVATE -DMPI_YES) + set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi") + else() + target_compile_definitions(cslib PRIVATE -DMPI_NO) + target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI) + set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi") + endif() + + if(MESSAGE_ZMQ) + target_compile_definitions(cslib PRIVATE -DZMQ_YES) + find_package(ZMQ REQUIRED) + target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS}) + target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES}) + else() + target_compile_definitions(cslib PRIVATE -DZMQ_NO) + target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ) + endif() + + list(APPEND LAMMPS_LINK_LIBS cslib) + include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src) +endif() diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b442580583a650ebf58241a82b226374483e3cc3 --- /dev/null +++ b/cmake/Modules/Packages/MSCG.cmake @@ -0,0 +1,45 @@ +if(PKG_MSCG) + find_package(GSL REQUIRED) + find_package(MSCG QUIET) + if(MSGC_FOUND) + set(DOWNLOAD_MSCG_DEFAULT OFF) + else() + set(DOWNLOAD_MSCG_DEFAULT ON) + endif() + option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT}) + if(DOWNLOAD_MSCG) + if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR + message(FATAL_ERROR "For downlading MSCG you need at least cmake-3.7") + endif() + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool") + endif() + include(ExternalProject) + if(NOT LAPACK_FOUND) + set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a") + endif() + ExternalProject_Add(mscg_build + URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz + URL_MD5 8c45e269ee13f60b303edd7823866a91 + SOURCE_SUBDIR src/CMake + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS} + BUILD_COMMAND make mscg INSTALL_COMMAND "" + ) + ExternalProject_get_property(mscg_build BINARY_DIR) + set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a) + ExternalProject_get_property(mscg_build SOURCE_DIR) + set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src) + list(APPEND LAMMPS_DEPS mscg_build) + if(NOT LAPACK_FOUND) + file(MAKE_DIRECTORY ${MSCG_INCLUDE_DIRS}) + add_dependencies(mscg_build linalg) + endif() + else() + find_package(MSCG) + if(NOT MSCG_FOUND) + message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it") + endif() + endif() + list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES}) + include_directories(${MSCG_INCLUDE_DIRS}) +endif() diff --git a/cmake/Modules/Packages/OPT.cmake b/cmake/Modules/Packages/OPT.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f2802c757bdb1d3472395270c9ba1f7a4b652c19 --- /dev/null +++ b/cmake/Modules/Packages/OPT.cmake @@ -0,0 +1,13 @@ +if(PKG_OPT) + set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT) + set(OPT_SOURCES) + set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}") + + # detects styles which have OPT version + RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES) + + get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES) + + list(APPEND LIB_SOURCES ${OPT_SOURCES}) + include_directories(${OPT_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4f8959ae389ca97ef8774641f08949cf1bff600c --- /dev/null +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -0,0 +1,6 @@ +if(PKG_PYTHON) + find_package(PythonLibs REQUIRED) + add_definitions(-DLMP_PYTHON) + include_directories(${PYTHON_INCLUDE_DIR}) + list(APPEND LAMMPS_LINK_LIBS ${PYTHON_LIBRARY}) +endif() diff --git a/cmake/Modules/Packages/QEQ.cmake b/cmake/Modules/Packages/QEQ.cmake new file mode 100644 index 0000000000000000000000000000000000000000..94cca30540dab41dd831254881ed86f788d00653 --- /dev/null +++ b/cmake/Modules/Packages/QEQ.cmake @@ -0,0 +1,20 @@ +# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed +if(PKG_QEQ) + set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ) + file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h) + file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp) + + if(NOT PKG_MANYBODY) + list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h) + list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp) + endif() + set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}") + + foreach(MY_HEADER ${QEQ_HEADERS}) + AddStyleHeader(${MY_HEADER} FIX) + endforeach() + + get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES) + list(APPEND LIB_SOURCES ${QEQ_SOURCES}) + include_directories(${QEQ_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/USER-H5MD.cmake b/cmake/Modules/Packages/USER-H5MD.cmake new file mode 100644 index 0000000000000000000000000000000000000000..40ea7b7444cd024c762e9708ebc8dd965a95c153 --- /dev/null +++ b/cmake/Modules/Packages/USER-H5MD.cmake @@ -0,0 +1,8 @@ +if(PKG_USER-H5MD) + enable_language(C) + + find_package(HDF5 REQUIRED) + target_link_libraries(h5md ${HDF5_LIBRARIES}) + target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) + include_directories(${HDF5_INCLUDE_DIRS}) +endif() diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/USER-INTEL.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3c0cc7ba2498df01d0a3450faf7049808d6379a8 --- /dev/null +++ b/cmake/Modules/Packages/USER-INTEL.cmake @@ -0,0 +1,118 @@ +if(PKG_USER-INTEL) + check_include_file_cxx(immintrin.h FOUND_IMMINTRIN) + if(NOT FOUND_IMMINTRIN) + message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it") + endif() + + add_definitions(-DLMP_USER_INTEL) + + set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)") + set(INTEL_ARCH_VALUES cpu knl) + set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES}) + validate_option(INTEL_ARCH INTEL_ARCH_VALUES) + string(TOUPPER ${INTEL_ARCH} INTEL_ARCH) + + find_package(Threads QUIET) + if(Threads_FOUND) + set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)") + else() + set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)") + endif() + set(INTEL_LRT_VALUES none threads c++11) + set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES}) + validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES) + string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE) + if(INTEL_LRT_MODE STREQUAL "THREADS") + if(Threads_FOUND) + add_definitions(-DLMP_INTEL_USELRT) + list(APPEND LAMMPS_LINK_LIBS ${CMAKE_THREAD_LIBS_INIT}) + else() + message(FATAL_ERROR "Must have working threads library for Long-range thread support") + endif() + endif() + if(INTEL_LRT_MODE STREQUAL "C++11") + add_definitions(-DLMP_INTEL_USERLRT -DLMP_INTEL_LRT11) + endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) + message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}") + endif() + else() + message(WARNING "USER-INTEL gives best performance with Intel compilers") + endif() + + find_package(TBB QUIET) + if(TBB_FOUND) + list(APPEND LAMMPS_LINK_LIBS ${TBB_MALLOC_LIBRARIES}) + else() + add_definitions(-DLMP_INTEL_NO_TBB) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries") + endif() + endif() + + find_package(MKL QUIET) + if(MKL_FOUND) + add_definitions(-DLMP_USE_MKL_RNG) + list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES}) + else() + message(STATUS "Pair style dpd/intel will be faster with MKL libraries") + endif() + + if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256")) + message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform") + endif() + + if(INTEL_ARCH STREQUAL "KNL") + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture") + endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload") + set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"") + add_compile_options(-xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS}) + add_definitions(-DLMP_INTEL_OFFLOAD) + else() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") + endif() + include(CheckCXXCompilerFlag) + foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict) + check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG}) + if(COMPILER_SUPPORTS${_FLAG}) + add_compile_options(${_FLAG}) + endif() + endforeach() + else() + add_compile_options(-O3 -ffast-math) + endif() + endif() + + # collect sources + set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL) + set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp + ${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp + ${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp + ${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp + ${USER-INTEL_SOURCES_DIR}/npair_intel.cpp) + + set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}") + + # detect styles which have a USER-INTEL version + RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES) + RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h) + RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h) + RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h) + + get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES) + if(PKG_KSPACE) + list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp) + RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h) + endif() + + list(APPEND LIB_SOURCES ${USER-INTEL_SOURCES}) + include_directories(${USER-INTEL_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/USER-MOLFILE.cmake new file mode 100644 index 0000000000000000000000000000000000000000..16ffc349940eb3b5a58b1eab4f73b4154523a075 --- /dev/null +++ b/cmake/Modules/Packages/USER-MOLFILE.cmake @@ -0,0 +1,10 @@ +if(PKG_USER-MOLFILE) + set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers") + add_library(molfile INTERFACE) + target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) + # no need to link with -ldl on windows + if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) + endif() + list(APPEND LAMMPS_LINK_LIBS molfile) +endif() diff --git a/cmake/Modules/Packages/USER-NETCDF.cmake b/cmake/Modules/Packages/USER-NETCDF.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a90725bbbc65114fbc546006848a7a0c68b49304 --- /dev/null +++ b/cmake/Modules/Packages/USER-NETCDF.cmake @@ -0,0 +1,6 @@ +if(PKG_USER-NETCDF) + find_package(NetCDF REQUIRED) + include_directories(${NETCDF_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${NETCDF_LIBRARIES}) + add_definitions(-DLMP_HAS_NETCDF -DNC_64BIT_DATA=0x0020) +endif() diff --git a/cmake/Modules/Packages/USER-OMP.cmake b/cmake/Modules/Packages/USER-OMP.cmake new file mode 100644 index 0000000000000000000000000000000000000000..668f42f10a56f382d5a1146193a6b7c69da0a00a --- /dev/null +++ b/cmake/Modules/Packages/USER-OMP.cmake @@ -0,0 +1,42 @@ +if(PKG_USER-OMP) + set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP) + set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp + ${USER-OMP_SOURCES_DIR}/thr_omp.cpp + ${USER-OMP_SOURCES_DIR}/fix_omp.cpp + ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp + ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp + ${USER-OMP_SOURCES_DIR}/domain_omp.cpp) + add_definitions(-DLMP_USER_OMP) + set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}") + + # detects styles which have USER-OMP version + RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES) + RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h) + + get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES) + + # manually add package dependent source files from USER-OMP that do not provide styles + + if(PKG_ASPHERE) + list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp) + endif() + + if(PKG_RIGID) + list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp) + endif() + + if(PKG_USER-REAXC) + list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp + ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp) + endif() + + list(APPEND LIB_SOURCES ${USER-OMP_SOURCES}) + include_directories(${USER-OMP_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake new file mode 100644 index 0000000000000000000000000000000000000000..500558fc72c4942903cd8e0bca9aa49f13c6a3c9 --- /dev/null +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -0,0 +1,79 @@ +if(PKG_USER-PLUMED) + find_package(GSL REQUIRED) + set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library") + set(PLUMED_MODE_VALUES static shared runtime) + set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES}) + validate_option(PLUMED_MODE PLUMED_MODE_VALUES) + string(TOUPPER ${PLUMED_MODE} PLUMED_MODE) + + find_package(PkgConfig QUIET) + set(DOWNLOAD_PLUMED_DEFAULT ON) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PLUMED QUIET plumed) + if(PLUMED_FOUND) + set(DOWNLOAD_PLUMED_DEFAULT OFF) + endif() + endif() + + option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT}) + if(DOWNLOAD_PLUMED) + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded Plumed library with Ninja build tool") + endif() + if(BUILD_MPI) + set(PLUMED_CONFIG_MPI "--enable-mpi") + set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER}) + set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER}) + else() + set(PLUMED_CONFIG_MPI "--disable-mpi") + set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER}) + set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER}) + endif() + if(BUILD_OMP) + set(PLUMED_CONFIG_OMP "--enable-openmp") + else() + set(PLUMED_CONFIG_OMP "--disable-openmp") + endif() + message(STATUS "PLUMED download requested - we will build our own") + include(ExternalProject) + ExternalProject_Add(plumed_build + URL https://github.com/plumed/plumed2/releases/download/v2.5.1/plumed-src-2.5.1.tgz + URL_MD5 c2a7b519e32197a120cdf47e0f194f81 + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND /configure --prefix= + ${CONFIGURE_REQUEST_PIC} + --enable-modules=all + ${PLUMED_CONFIG_MPI} + ${PLUMED_CONFIG_OMP} + CXX=${PLUMED_CONFIG_CXX} + CC=${PLUMED_CONFIG_CC} + ) + ExternalProject_get_property(plumed_build INSTALL_DIR) + set(PLUMED_INSTALL_DIR ${INSTALL_DIR}) + list(APPEND LAMMPS_DEPS plumed_build) + if(PLUMED_MODE STREQUAL "STATIC") + add_definitions(-D__PLUMED_WRAPPER_CXX=1) + list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.a ${GSL_LIBRARIES} ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS}) + elseif(PLUMED_MODE STREQUAL "SHARED") + list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.so ${PLUMED_INSTALL_DIR}/lib/libplumedKernel.so ${CMAKE_DL_LIBS}) + elseif(PLUMED_MODE STREQUAL "RUNTIME") + add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel.so) + list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS}) + endif() + set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include") + else() + find_package(PkgConfig REQUIRED) + pkg_check_modules(PLUMED REQUIRED plumed) + if(PLUMED_MODE STREQUAL "STATIC") + add_definitions(-D__PLUMED_WRAPPER_CXX=1) + include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static) + elseif(PLUMED_MODE STREQUAL "SHARED") + include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared) + elseif(PLUMED_MODE STREQUAL "RUNTIME") + add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel.so) + include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime) + endif() + list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD}) + endif() + include_directories(${PLUMED_INCLUDE_DIRS}) +endif() diff --git a/cmake/Modules/Packages/USER-QMMM.cmake b/cmake/Modules/Packages/USER-QMMM.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e0ae1a46dc19128f03c6004e232b284ea3692dbd --- /dev/null +++ b/cmake/Modules/Packages/USER-QMMM.cmake @@ -0,0 +1,9 @@ +if(PKG_USER-QMMM) + enable_language(Fortran) + enable_language(C) + + message(WARNING "Building QMMM with CMake is still experimental") + find_package(QE REQUIRED) + include_directories(${QE_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/USER-QUIP.cmake b/cmake/Modules/Packages/USER-QUIP.cmake new file mode 100644 index 0000000000000000000000000000000000000000..93096a2f54bec679eda388df567f5b35662641cf --- /dev/null +++ b/cmake/Modules/Packages/USER-QUIP.cmake @@ -0,0 +1,5 @@ +if(PKG_USER-QUIP) + enable_language(Fortran) + find_package(QUIP REQUIRED) + list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..475f2585c80fcfb19c4f8d6cf731791d122a9f90 --- /dev/null +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -0,0 +1,62 @@ +if(PKG_USER-SCAFACOS) + enable_language(Fortran) + enable_language(C) + + find_package(GSL REQUIRED) + find_package(PkgConfig QUIET) + set(DOWNLOAD_SCAFACOS_DEFAULT ON) + if(PKG_CONFIG_FOUND) + pkg_check_modules(SCAFACOS QUIET scafacos) + if(SCAFACOS_FOUND) + set(DOWNLOAD_SCAFACOS_DEFAULT OFF) + endif() + endif() + option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT}) + if(DOWNLOAD_SCAFACOS) + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded ScaFaCoS library with Ninja build tool") + endif() + message(STATUS "ScaFaCoS download requested - we will build our own") + include(ExternalProject) + ExternalProject_Add(scafacos_build + URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz + URL_MD5 bd46d74e3296bd8a444d731bb10c1738 + CONFIGURE_COMMAND /configure --prefix= --disable-doc + --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m + --with-internal-fftw --with-internal-pfft + --with-internal-pnfft ${CONFIGURE_REQUEST_PIC} + FC=${CMAKE_MPI_Fortran_COMPILER} + CXX=${CMAKE_MPI_CXX_COMPILER} + CC=${CMAKE_MPI_C_COMPILER} + F77= + ) + ExternalProject_get_property(scafacos_build INSTALL_DIR) + set(SCAFACOS_BUILD_DIR ${INSTALL_DIR}) + set(SCAFACOS_INCLUDE_DIRS ${SCAFACOS_BUILD_DIR}/include) + list(APPEND LAMMPS_DEPS scafacos_build) + # list and order from pkg_config file of ScaFaCoS build + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_direct.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_ewald.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fmm.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p2nfft.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p3m.a) + list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES}) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_near.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_gridsort.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_resort.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_redist.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_common.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pnfft.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pfft.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3_mpi.a) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3.a) + list(APPEND LAMMPS_LINK_LIBS ${MPI_Fortran_LIBRARIES}) + list(APPEND LAMMPS_LINK_LIBS ${MPI_C_LIBRARIES}) + else() + find_package(PkgConfig REQUIRED) + pkg_check_modules(SCAFACOS REQUIRED scafacos) + list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS}) + endif() + include_directories(${SCAFACOS_INCLUDE_DIRS}) +endif() diff --git a/cmake/Modules/Packages/USER-SDPD.cmake b/cmake/Modules/Packages/USER-SDPD.cmake new file mode 100644 index 0000000000000000000000000000000000000000..530dcf2bd915446b24e5521e97f59b24504df340 --- /dev/null +++ b/cmake/Modules/Packages/USER-SDPD.cmake @@ -0,0 +1,13 @@ +# Fix rigid/meso requires RIGID to be installed +if(PKG_USER-SDPD) + set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD) + + get_property(hlist GLOBAL PROPERTY FIX) + if(NOT PKG_RIGID) + list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h) + list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp) + endif() + set_property(GLOBAL PROPERTY FIX "${hlist}") + + include_directories(${USER-SDPD_SOURCES_DIR}) +endif() diff --git a/cmake/Modules/Packages/USER-SMD.cmake b/cmake/Modules/Packages/USER-SMD.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a868918e378649a501b4a616ba1bf0aafd49b2db --- /dev/null +++ b/cmake/Modules/Packages/USER-SMD.cmake @@ -0,0 +1,28 @@ +if(PKG_USER-SMD) + find_package(Eigen3 NO_MODULE) + if(EIGEN3_FOUND) + set(DOWNLOAD_EIGEN3_DEFAULT OFF) + else() + set(DOWNLOAD_EIGEN3_DEFAULT ON) + endif() + option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) + if(DOWNLOAD_EIGEN3) + message(STATUS "Eigen3 download requested - we will build our own") + include(ExternalProject) + ExternalProject_Add(Eigen3_build + URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz + URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07 + CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" + ) + ExternalProject_get_property(Eigen3_build SOURCE_DIR) + set(EIGEN3_INCLUDE_DIR ${SOURCE_DIR}) + list(APPEND LAMMPS_DEPS Eigen3_build) + else() + find_package(Eigen3 NO_MODULE) + mark_as_advanced(Eigen3_DIR) + if(NOT EIGEN3_FOUND) + message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it") + endif() + endif() + include_directories(${EIGEN3_INCLUDE_DIR}) +endif() diff --git a/cmake/Modules/Packages/USER-VTK.cmake b/cmake/Modules/Packages/USER-VTK.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d264577ca2f77f5af3b2cbac590f4d9fc07500d9 --- /dev/null +++ b/cmake/Modules/Packages/USER-VTK.cmake @@ -0,0 +1,6 @@ +if(PKG_USER-VTK) + find_package(VTK REQUIRED NO_MODULE) + include(${VTK_USE_FILE}) + add_definitions(-DLAMMPS_VTK) + list(APPEND LAMMPS_LINK_LIBS ${VTK_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/VORONOI.cmake b/cmake/Modules/Packages/VORONOI.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5ce974a7ae701baea0e3aa2def430a18c351c5e9 --- /dev/null +++ b/cmake/Modules/Packages/VORONOI.cmake @@ -0,0 +1,41 @@ +if(PKG_VORONOI) + find_package(VORO) + if(VORO_FOUND) + set(DOWNLOAD_VORO_DEFAULT OFF) + else() + set(DOWNLOAD_VORO_DEFAULT ON) + endif() + option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT}) + if(DOWNLOAD_VORO) + if(CMAKE_GENERATOR STREQUAL "Ninja") + message(FATAL_ERROR "Cannot build downloaded Voro++ library with Ninja build tool") + endif() + message(STATUS "Voro++ download requested - we will build our own") + include(ExternalProject) + + if(BUILD_SHARED_LIBS) + set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") + else() + set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") + endif() + string(APPEND VORO_BUILD_CFLAGS ${CMAKE_CXX_FLAGS}) + set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS}) + + ExternalProject_Add(voro_build + URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz + URL_MD5 2338b824c3b7b25590e18e8df5d68af9 + CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND "" + ) + ExternalProject_get_property(voro_build SOURCE_DIR) + set(VORO_LIBRARIES ${SOURCE_DIR}/src/libvoro++.a) + set(VORO_INCLUDE_DIRS ${SOURCE_DIR}/src) + list(APPEND LAMMPS_DEPS voro_build) + else() + find_package(VORO) + if(NOT VORO_FOUND) + message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it") + endif() + endif() + include_directories(${VORO_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${VORO_LIBRARIES}) +endif() diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index a7b23b4cf1c968591b611768edc13d7e9d95e6de..04883d02925f6a9862ef7cd3c89ecdcdab148f47 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -91,6 +91,10 @@ function(RegisterFixStyle path) AddStyleHeader(${path} FIX) endfunction(RegisterFixStyle) +function(RegisterIntegrateStyle path) + AddStyleHeader(${path} INTEGRATE) +endfunction(RegisterIntegrateStyle) + function(RegisterStyles search_path) FindStyleHeaders(${search_path} ANGLE_CLASS angle_ ANGLE ) # angle ) # force FindStyleHeaders(${search_path} ATOM_CLASS atom_vec_ ATOM_VEC ) # atom ) # atom atom_vec_hybrid @@ -177,3 +181,88 @@ function(DetectBuildSystemConflict lammps_src_dir) endforeach() endif() endfunction(DetectBuildSystemConflict) + + +function(FindPackagesHeaders path style_class file_pattern headers) + file(GLOB files "${path}/${file_pattern}*.h") + get_property(plist GLOBAL PROPERTY ${headers}) + + foreach(file_name ${files}) + file(STRINGS ${file_name} is_style LIMIT_COUNT 1 REGEX ${style_class}) + if(is_style) + list(APPEND plist ${file_name}) + endif() + endforeach() + set_property(GLOBAL PROPERTY ${headers} "${plist}") +endfunction(FindPackagesHeaders) + +function(RegisterPackages search_path) + FindPackagesHeaders(${search_path} ANGLE_CLASS angle_ PKGANGLE ) # angle ) # force + FindPackagesHeaders(${search_path} ATOM_CLASS atom_vec_ PKGATOM_VEC ) # atom ) # atom atom_vec_hybrid + FindPackagesHeaders(${search_path} BODY_CLASS body_ PKGBODY ) # body ) # atom_vec_body + FindPackagesHeaders(${search_path} BOND_CLASS bond_ PKGBOND ) # bond ) # force + FindPackagesHeaders(${search_path} COMMAND_CLASS "[^.]" PKGCOMMAND ) # command ) # input + FindPackagesHeaders(${search_path} COMPUTE_CLASS compute_ PKGCOMPUTE ) # compute ) # modify + FindPackagesHeaders(${search_path} DIHEDRAL_CLASS dihedral_ PKGDIHEDRAL ) # dihedral ) # force + FindPackagesHeaders(${search_path} DUMP_CLASS dump_ PKGDUMP ) # dump ) # output write_dump + FindPackagesHeaders(${search_path} FIX_CLASS fix_ PKGFIX ) # fix ) # modify + FindPackagesHeaders(${search_path} IMPROPER_CLASS improper_ PKGIMPROPER ) # improper ) # force + FindPackagesHeaders(${search_path} INTEGRATE_CLASS "[^.]" PKGINTEGRATE ) # integrate ) # update + FindPackagesHeaders(${search_path} KSPACE_CLASS "[^.]" PKGKSPACE ) # kspace ) # force + FindPackagesHeaders(${search_path} MINIMIZE_CLASS min_ PKGMINIMIZE ) # minimize ) # update + FindPackagesHeaders(${search_path} NBIN_CLASS nbin_ PKGNBIN ) # nbin ) # neighbor + FindPackagesHeaders(${search_path} NPAIR_CLASS npair_ PKGNPAIR ) # npair ) # neighbor + FindPackagesHeaders(${search_path} NSTENCIL_CLASS nstencil_ PKGNSTENCIL ) # nstencil ) # neighbor + FindPackagesHeaders(${search_path} NTOPO_CLASS ntopo_ PKGNTOPO ) # ntopo ) # neighbor + FindPackagesHeaders(${search_path} PAIR_CLASS pair_ PKGPAIR ) # pair ) # force + FindPackagesHeaders(${search_path} READER_CLASS reader_ PKGREADER ) # reader ) # read_dump + FindPackagesHeaders(${search_path} REGION_CLASS region_ PKGREGION ) # region ) # domain +endfunction(RegisterPackages) + +function(CreatePackagesHeader path filename) + set(temp "") + if(ARGC GREATER 2) + list(REMOVE_AT ARGV 0 1) + foreach(FNAME ${ARGV}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${FNAME}") + get_filename_component(DNAME ${FNAME} DIRECTORY) + get_filename_component(DNAME ${DNAME} NAME) + get_filename_component(FNAME ${FNAME} NAME) + set(temp "${temp}#undef PACKAGE\n#define PACKAGE \"${DNAME}\"\n") + set(temp "${temp}#include \"${DNAME}/${FNAME}\"\n") + endforeach() + endif() + message(STATUS "Generating ${filename}...") + file(WRITE "${path}/${filename}.tmp" "${temp}" ) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}/${filename}.tmp" "${path}/${filename}") + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${path}/${filename}") +endfunction(CreatePackagesHeader) + +function(GeneratePackagesHeader path property style) + get_property(files GLOBAL PROPERTY ${property}) + CreatePackagesHeader("${path}" "packages_${style}.h" ${files}) +endfunction(GeneratePackagesHeader) + +function(GeneratePackagesHeaders output_path) + GeneratePackagesHeader(${output_path} PKGANGLE angle ) # force + GeneratePackagesHeader(${output_path} PKGATOM_VEC atom ) # atom atom_vec_hybrid + GeneratePackagesHeader(${output_path} PKGBODY body ) # atom_vec_body + GeneratePackagesHeader(${output_path} PKGBOND bond ) # force + GeneratePackagesHeader(${output_path} PKGCOMMAND command ) # input + GeneratePackagesHeader(${output_path} PKGCOMPUTE compute ) # modify + GeneratePackagesHeader(${output_path} PKGDIHEDRAL dihedral ) # force + GeneratePackagesHeader(${output_path} PKGDUMP dump ) # output write_dump + GeneratePackagesHeader(${output_path} PKGFIX fix ) # modify + GeneratePackagesHeader(${output_path} PKGIMPROPER improper ) # force + GeneratePackagesHeader(${output_path} PKGINTEGRATE integrate ) # update + GeneratePackagesHeader(${output_path} PKGKSPACE kspace ) # force + GeneratePackagesHeader(${output_path} PKGMINIMIZE minimize ) # update + GeneratePackagesHeader(${output_path} PKGNBIN nbin ) # neighbor + GeneratePackagesHeader(${output_path} PKGNPAIR npair ) # neighbor + GeneratePackagesHeader(${output_path} PKGNSTENCIL nstencil ) # neighbor + GeneratePackagesHeader(${output_path} PKGNTOPO ntopo ) # neighbor + GeneratePackagesHeader(${output_path} PKGPAIR pair ) # force + GeneratePackagesHeader(${output_path} PKGREADER reader ) # read_dump + GeneratePackagesHeader(${output_path} PKGREGION region ) # domain +endfunction(GeneratePackagesHeaders) + diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0eeef00fe9ab4b603fe319825662a6b827f46ac7 --- /dev/null +++ b/cmake/Modules/Testing.cmake @@ -0,0 +1,52 @@ +############################################################################### +# Testing +############################################################################### +option(ENABLE_TESTING "Enable testing" OFF) +if(ENABLE_TESTING AND BUILD_EXE) + enable_testing() + option(LAMMPS_TESTING_SOURCE_DIR "Location of lammps-testing source directory" "") + option(LAMMPS_TESTING_GIT_TAG "Git tag of lammps-testing" "master") + mark_as_advanced(LAMMPS_TESTING_SOURCE_DIR LAMMPS_TESTING_GIT_TAG) + + if (CMAKE_VERSION VERSION_GREATER "3.10.3" AND NOT LAMMPS_TESTING_SOURCE_DIR) + include(FetchContent) + + FetchContent_Declare(lammps-testing + GIT_REPOSITORY https://github.com/lammps/lammps-testing.git + GIT_TAG ${LAMMPS_TESTING_GIT_TAG} + ) + + FetchContent_GetProperties(lammps-testing) + if(NOT lammps-testing_POPULATED) + message(STATUS "Downloading tests...") + FetchContent_Populate(lammps-testing) + endif() + + set(LAMMPS_TESTING_SOURCE_DIR ${lammps-testing_SOURCE_DIR}) + elseif(NOT LAMMPS_TESTING_SOURCE_DIR) + message(WARNING "Full test-suite requires CMake >= 3.11 or copy of\n" + "https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR") + endif() + + add_test(ShowHelp ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -help) + + if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR}) + message(STATUS "Running test discovery...") + + file(GLOB_RECURSE TEST_SCRIPTS ${LAMMPS_TESTING_SOURCE_DIR}/tests/core/*/in.*) + foreach(script_path ${TEST_SCRIPTS}) + get_filename_component(TEST_NAME ${script_path} EXT) + get_filename_component(SCRIPT_NAME ${script_path} NAME) + get_filename_component(PARENT_DIR ${script_path} DIRECTORY) + string(SUBSTRING ${TEST_NAME} 1 -1 TEST_NAME) + string(REPLACE "-" "_" TEST_NAME ${TEST_NAME}) + string(REPLACE "+" "_" TEST_NAME ${TEST_NAME}) + set(TEST_NAME "test_core_${TEST_NAME}_serial") + add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -in ${SCRIPT_NAME}) + set_tests_properties(${TEST_NAME} PROPERTIES WORKING_DIRECTORY ${PARENT_DIR}) + endforeach() + list(LENGTH TEST_SCRIPTS NUM_TESTS) + + message(STATUS "Found ${NUM_TESTS} tests.") + endif() +endif() diff --git a/cmake/Modules/generate_lmpgitversion.cmake b/cmake/Modules/generate_lmpgitversion.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a4aa59b26272c5d88934f373881d19804aa528e8 --- /dev/null +++ b/cmake/Modules/generate_lmpgitversion.cmake @@ -0,0 +1,30 @@ +set(temp "#ifndef LMP_GIT_VERSION_H\n#define LMP_GIT_VERSION_H\n") +set(temp_git_commit "(unknown)") +set(temp_git_branch "(unknown)") +set(temp_git_describe "(unknown)") +set(temp_git_info "false") +if(GIT_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git) + set(temp_git_info "true") + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/.. rev-parse HEAD + OUTPUT_VARIABLE temp_git_commit + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/.. rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE temp_git_branch + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/.. describe --dirty=-modified + OUTPUT_VARIABLE temp_git_describe + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +set(temp "${temp}const bool LAMMPS_NS::LAMMPS::has_git_info = ${temp_git_info};\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_commit[] = \"${temp_git_commit}\";\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_branch[] = \"${temp_git_branch}\";\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"${temp_git_describe}\";\n") +set(temp "${temp}#endif\n\n") + +message(STATUS "Generating lmpgitversion.h...") +file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" ) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h") diff --git a/cmake/README.md b/cmake/README.md index ce3b4502afb4f6572c555ac1e01a2c9496b02214..c11326f9d5d37bda7806cdb0cdf90bd24f0074d2 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -155,11 +155,13 @@ make The CMake build exposes a lot of different options. In the old build system some of the package selections were possible by using special make target like -`make yes-std` or `make no-lib`. Achieving the same result with cmake requires +`make yes-std` or `make no-lib`. Achieving a similar result with cmake requires specifying all options manually. This can quickly become a very long command line that is hard to handle. While these could be stored in a simple script file, there is another way of defining "presets" to compile LAMMPS in a certain -way. +way. Since the cmake build process - contrary to the conventional build system - +includes the compilation of the bundled libraries into the standard build process, +the grouping of those presets is somewhat different. A preset is a regular CMake script file that can use constructs such as variables, lists and for-loops to manipulate configuration options and create @@ -171,10 +173,10 @@ Such a file can then be passed to cmake via the `-C` flag. Several examples of presets can be found in the `cmake/presets` folder. ```bash -# build LAMMPS with all "standard" packages which don't use libraries and enable GPU package +# build LAMMPS with all packages enabled which don't use external libraries and enable GPU package mkdir build cd build -cmake -C ../cmake/presets/std_nolib.cmake -D PKG_GPU=on ../cmake +cmake -C ../cmake/presets/all_on.cmake -C ../cmake/presets/nolib.cmake -D PKG_GPU=on ../cmake ``` # Reference @@ -209,7 +211,7 @@ cmake -C ../cmake/presets/std_nolib.cmake -D PKG_GPU=on ../cmake - + CMAKE_VERBOSE_MAKEFILE Enable verbose output from Makefile builds (useful for debugging), the same can be achived by adding `VERBOSE=1` to the `make` call.
@@ -1429,6 +1431,17 @@ TODO
+ + INTEL_LRT_MODE + How to support Long-range thread mode in Verlet integration + +
+
threads (default, if pthreads available)
+
none (default, if pthreads not available)
+
c++11
+
+ + @@ -1503,6 +1516,16 @@ target API. + + CUDA_MPS_SUPPORT (CUDA only) + Enable tweaks for running with Nvidia CUDA Multi-process services daemon + +
+
on
+
off (default)
+
+ + BIN2C (CUDA only) Path to bin2c executable, will automatically pick up the first one in your $PATH. diff --git a/cmake/etc/profile.d/lammps.csh.in b/cmake/etc/profile.d/lammps.csh.in index def49bf75c0112503f7286dbb68843a258e993f3..42f222d67c859d688d824a2cfaefb639fb0a025d 100644 --- a/cmake/etc/profile.d/lammps.csh.in +++ b/cmake/etc/profile.d/lammps.csh.in @@ -1,2 +1,4 @@ -# set environment for LAMMPS executables to find potential files +# set environment for LAMMPS and msi2lmp executables +# to find potential and force field files if ( "$?LAMMPS_POTENTIALS" == 0 ) setenv LAMMPS_POTENTIALS @LAMMPS_POTENTIALS_DIR@ +if ( "$?MSI2LMP_LIBRARY" == 0 ) setenv MSI2LMP_LIBRARY @LAMMPS_FRC_FILES_DIR@ diff --git a/cmake/etc/profile.d/lammps.sh.in b/cmake/etc/profile.d/lammps.sh.in index acd75fa0cff7bae7013d8c32d8453e2083dc217d..c1967cb5b2ec30cb53984275712bd14268e0c655 100644 --- a/cmake/etc/profile.d/lammps.sh.in +++ b/cmake/etc/profile.d/lammps.sh.in @@ -1,2 +1,5 @@ -# set environment for LAMMPS executables to find potential files -export LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS-@LAMMPS_POTENTIALS_DIR@} +# set environment for LAMMPS and msi2lmp executables +# to find potential and force field files +LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS-@LAMMPS_POTENTIALS_DIR@} +MSI2LMP_LIBRARY=${MSI2LMP_LIBRARY-@LAMMPS_FRC_FILES_DIR@} +export LAMMPS_POTENTIALS MSI2LMP_LIBRARY diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index b434796d7cb248da7cd29f9369dd549e8e2667a4..9d03be99ecb41d059a1e8e072b776513df84122a 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -1,21 +1,17 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) +# preset that turns on all existing packages off. can be used to reset +# an existing package selection without losing any other settings -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) +set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU + GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MISC MESSAGE MOLECULE + MPIIO MSCG OPT PERI POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN + SRD VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK + USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP + USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO + USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP + USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP + USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 3a1100f3370b370edde256998dfeb695db721575..2ff107975a6d3e92906186093e37df3e49ad48b8 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -1,21 +1,19 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) +# preset that turns on all existing packages. using the combination +# this preset followed by the nolib.cmake preset should configure a +# LAMMPS binary, with as many packages included, that can be compiled +# with just a working C++ compiler and an MPI library. -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) +set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU + GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MISC MESSAGE MOLECULE + MPIIO MSCG OPT PERI POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN + SRD VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK + USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP + USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO + USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP + USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP + USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/clang.cmake b/cmake/presets/clang.cmake new file mode 100644 index 0000000000000000000000000000000000000000..828f359f540baa99e8ef6064b7dda24f1e1dbc0b --- /dev/null +++ b/cmake/presets/clang.cmake @@ -0,0 +1,17 @@ +# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) + +set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBG" CACHE STRING "" FORCE) +set(MPI_CXX "clang++" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +unset(HAVE_OMP_H_INCLUDE CACHE) + +set(OpenMP_C "clang" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_CXX "clang++" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "/usr/lib64/libomp.so" CACHE PATH "" FORCE) + diff --git a/cmake/presets/manual_selection.cmake b/cmake/presets/manual_selection.cmake deleted file mode 100644 index 6db41b708c04aa773a72a1cb82af34d4b0ff2897..0000000000000000000000000000000000000000 --- a/cmake/presets/manual_selection.cmake +++ /dev/null @@ -1,71 +0,0 @@ -set(PKG_ASPHERE OFF CACHE BOOL "" FORCE) -set(PKG_BODY OFF CACHE BOOL "" FORCE) -set(PKG_CLASS2 OFF CACHE BOOL "" FORCE) -set(PKG_COLLOID OFF CACHE BOOL "" FORCE) -set(PKG_COMPRESS OFF CACHE BOOL "" FORCE) -set(PKG_CORESHELL OFF CACHE BOOL "" FORCE) -set(PKG_DIPOLE OFF CACHE BOOL "" FORCE) -set(PKG_GPU OFF CACHE BOOL "" FORCE) -set(PKG_GRANULAR OFF CACHE BOOL "" FORCE) -set(PKG_KIM OFF CACHE BOOL "" FORCE) -set(PKG_KOKKOS OFF CACHE BOOL "" FORCE) -set(PKG_KSPACE OFF CACHE BOOL "" FORCE) -set(PKG_LATTE OFF CACHE BOOL "" FORCE) -set(PKG_LIB OFF CACHE BOOL "" FORCE) -set(PKG_MANYBODY OFF CACHE BOOL "" FORCE) -set(PKG_MC OFF CACHE BOOL "" FORCE) -set(PKG_MEAM OFF CACHE BOOL "" FORCE) -set(PKG_MISC OFF CACHE BOOL "" FORCE) -set(PKG_MOLECULE OFF CACHE BOOL "" FORCE) -set(PKG_MPIIO OFF CACHE BOOL "" FORCE) -set(PKG_MSCG OFF CACHE BOOL "" FORCE) -set(PKG_OPT OFF CACHE BOOL "" FORCE) -set(PKG_PERI OFF CACHE BOOL "" FORCE) -set(PKG_POEMS OFF CACHE BOOL "" FORCE) -set(PKG_PYTHOFF OFF CACHE BOOL "" FORCE) -set(PKG_QEQ OFF CACHE BOOL "" FORCE) -set(PKG_REAX OFF CACHE BOOL "" FORCE) -set(PKG_REPLICA OFF CACHE BOOL "" FORCE) -set(PKG_RIGID OFF CACHE BOOL "" FORCE) -set(PKG_SHOCK OFF CACHE BOOL "" FORCE) -set(PKG_SNAP OFF CACHE BOOL "" FORCE) -set(PKG_SRD OFF CACHE BOOL "" FORCE) -set(PKG_VOROFFOI OFF CACHE BOOL "" FORCE) - -set(PKG_USER OFF CACHE BOOL "" FORCE) -set(PKG_USER-ATC OFF CACHE BOOL "" FORCE) -set(PKG_USER-AWPMD OFF CACHE BOOL "" FORCE) -set(PKG_USER-BOCS OFF CACHE BOOL "" FORCE) -set(PKG_USER-CGDNA OFF CACHE BOOL "" FORCE) -set(PKG_USER-CGSDK OFF CACHE BOOL "" FORCE) -set(PKG_USER-COLVARS OFF CACHE BOOL "" FORCE) -set(PKG_USER-DIFFRACTIOFF OFF CACHE BOOL "" FORCE) -set(PKG_USER-DPD OFF CACHE BOOL "" FORCE) -set(PKG_USER-DRUDE OFF CACHE BOOL "" FORCE) -set(PKG_USER-EFF OFF CACHE BOOL "" FORCE) -set(PKG_USER-FEP OFF CACHE BOOL "" FORCE) -set(PKG_USER-H5MD OFF CACHE BOOL "" FORCE) -set(PKG_USER-INTEL OFF CACHE BOOL "" FORCE) -set(PKG_USER-LB OFF CACHE BOOL "" FORCE) -set(PKG_USER-MANIFOLD OFF CACHE BOOL "" FORCE) -set(PKG_USER-MEAMC OFF CACHE BOOL "" FORCE) -set(PKG_USER-MESO OFF CACHE BOOL "" FORCE) -set(PKG_USER-MGPT OFF CACHE BOOL "" FORCE) -set(PKG_USER-MISC OFF CACHE BOOL "" FORCE) -set(PKG_USER-MOFFF OFF CACHE BOOL "" FORCE) -set(PKG_USER-MOLFILE OFF CACHE BOOL "" FORCE) -set(PKG_USER-NETCDF OFF CACHE BOOL "" FORCE) -set(PKG_USER-OMP OFF CACHE BOOL "" FORCE) -set(PKG_USER-PHONON OFF CACHE BOOL "" FORCE) -set(PKG_USER-PLUMED OFF CACHE BOOL "" FORCE) -set(PKG_USER-QMMM OFF CACHE BOOL "" FORCE) -set(PKG_USER-QTB OFF CACHE BOOL "" FORCE) -set(PKG_USER-QUIP OFF CACHE BOOL "" FORCE) -set(PKG_USER-REAXC OFF CACHE BOOL "" FORCE) -set(PKG_USER-SDPD OFF CACHE BOOL "" FORCE) -set(PKG_USER-SMD OFF CACHE BOOL "" FORCE) -set(PKG_USER-SMTBQ OFF CACHE BOOL "" FORCE) -set(PKG_USER-SPH OFF CACHE BOOL "" FORCE) -set(PKG_USER-TALLY OFF CACHE BOOL "" FORCE) -set(PKG_USER-UEF OFF CACHE BOOL "" FORCE) -set(PKG_USER-VTK OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/mingw-cross.cmake b/cmake/presets/mingw-cross.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b53e5a7b93f8df22b3041fa83ad9314a99de6945 --- /dev/null +++ b/cmake/presets/mingw-cross.cmake @@ -0,0 +1,17 @@ +set(WIN_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU + GRANULAR KSPACE MANYBODY MC MISC MOLECULE OPT PERI POEMS QEQ + REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI USER-ATC USER-AWPMD + USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION + USER-DPD USER-DRUDE USER-EFF USER-FEP USER-INTEL USER-MANIFOLD + USER-MEAMC USER-MESO USER-MISC USER-MOFFF USER-MOLFILE USER-OMP + USER-PHONON USER-PTM USER-QTB USER-REAXC USER-SDPD USER-SMD + USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-YAFF) + +foreach(PKG ${WIN_PACKAGES}) + set(PKG_${PKG} ON CACHE BOOL "" FORCE) +endforeach() + +set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE) +set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE) +set(LAMMPS_MEMALIGN "0" CACHE STRING "" FORCE) +set(INTEL_LRT_MODE "none" CACHE STRING "" FORCE) diff --git a/cmake/presets/minimal.cmake b/cmake/presets/minimal.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e9ce6d6103fb6d128373cacb0e65f8dcdce8e407 --- /dev/null +++ b/cmake/presets/minimal.cmake @@ -0,0 +1,8 @@ +# preset that turns on just a few, frequently used packages +# this will be compiled quickly and handle a lot of common inputs. + +set(ALL_PACKAGES KSPACE MANYBODY MOLECULE RIGID) + +foreach(PKG ${ALL_PACKAGES}) + set(PKG_${PKG} ON CACHE BOOL "" FORCE) +endforeach() diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake new file mode 100644 index 0000000000000000000000000000000000000000..35ad7ba55c688d4bdc371e8ff5a715f8c94a0f78 --- /dev/null +++ b/cmake/presets/most.cmake @@ -0,0 +1,15 @@ +# preset that turns on a wide range of packages, some of which require +# external libraries. Compared to all_on.cmake some more unusual packages +# are removed. The resulting binary should be able to run most inputs. + +set(ALL_PACKAGES ASPHERE CLASS2 COLLOID CORESHELL DIPOLE + GRANULAR KSPACE MANYBODY MC MISC MOLECULE OPT PERI + PYTHON QEQ REPLICA RIGID SHOCK SRD VORONOI + USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD + USER-DRUDE USER-FEP USER-MEAMC USER-MESO + USER-MISC USER-MOFFF USER-OMP USER-PLUMED USER-PHONON USER-REAXC + USER-SPH USER-SMD USER-UEF USER-YAFF) + +foreach(PKG ${ALL_PACKAGES}) + set(PKG_${PKG} ON CACHE BOOL "" FORCE) +endforeach() diff --git a/cmake/presets/nolib.cmake b/cmake/presets/nolib.cmake index 4c02fb621030becdcc7a6734ebc976bf974f2a89..c0968a8d8255fbb142f8d1eb8e21e7cf9c13be6b 100644 --- a/cmake/presets/nolib.cmake +++ b/cmake/presets/nolib.cmake @@ -1,21 +1,10 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) +# preset that turns off all packages that require some form of external +# library or special compiler (fortran or cuda) or equivalent. -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) +set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MPIIO MSCG PYTHON + VORONOI USER-ADIOS USER-ATC USER-AWPMD USER-H5MD USER-LB + USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP + USER-SCAFACOS USER-SMD USER-VTK) foreach(PKG ${PACKAGES_WITH_LIB}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/std.cmake b/cmake/presets/std.cmake deleted file mode 100644 index 4176aba44e7cd947d56a0b01732a5aeca7a35259..0000000000000000000000000000000000000000 --- a/cmake/presets/std.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) - -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) - -foreach(PKG ${STANDARD_PACKAGES}) - set(PKG_${PKG} ON CACHE BOOL "" FORCE) -endforeach() diff --git a/cmake/presets/std_nolib.cmake b/cmake/presets/std_nolib.cmake deleted file mode 100644 index aa067f2ba0e9f5ab8cba281a6ac9597d944f7dfc..0000000000000000000000000000000000000000 --- a/cmake/presets/std_nolib.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) - -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) - -foreach(PKG ${STANDARD_PACKAGES}) - set(PKG_${PKG} ON CACHE BOOL "" FORCE) -endforeach() - -foreach(PKG ${PACKAGES_WITH_LIB}) - set(PKG_${PKG} OFF CACHE BOOL "" FORCE) -endforeach() diff --git a/cmake/presets/user.cmake b/cmake/presets/user.cmake deleted file mode 100644 index af606203e993c173340af918a0ae6e8956cb582b..0000000000000000000000000000000000000000 --- a/cmake/presets/user.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MEAM MISC - MOLECULE MPIIO MSCG OPT PERI POEMS - PYTHON QEQ REAX REPLICA RIGID SHOCK SNAP SRD VORONOI) - -set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD - USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO - USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB - USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK) - -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI - USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-LB USER-MOLFILE - USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SMD USER-VTK) - -set(ALL_PACKAGES ${STANDARD_PACKAGES} ${USER_PACKAGES}) - -foreach(PKG ${USER_PACKAGES}) - set(PKG_${PKG} ON CACHE BOOL "" FORCE) -endforeach() diff --git a/doc/.gitignore b/doc/.gitignore index b20157057c1656b6dec13dfa8b106fe4173eaaae..88679898a89e26d53d8a43f4d7a04a60260ecc93 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -1,3 +1,4 @@ +/old /html /latex /spelling diff --git a/doc/Makefile b/doc/Makefile index d117c2d98c0baed8f503f5dbbce13e92af2d994a..5c679440b82543c515e1ce9f258497c7b8df2d12 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -39,7 +39,7 @@ help: @echo "Please use \`make ' where is one of" @echo " html create HTML doc pages in html dir" @echo " pdf create Developer.pdf and Manual.pdf in this dir" - @echo " old create old-style HTML doc pages in old dir" + @echo " old create old-style HTML doc pages and Manual.pdf in old dir" @echo " fetch fetch HTML and PDF files from LAMMPS web site" @echo " epub create ePUB format manual for e-book readers" @echo " mobi convert ePUB to MOBI format manual for e-book readers (e.g. Kindle)" @@ -56,7 +56,7 @@ clean-all: clean rm -rf $(BUILDDIR)/* utils/txt2html/txt2html.exe clean: - rm -rf $(RSTDIR) html old epub + rm -rf $(RSTDIR) html old epub latex rm -rf spelling clean-spelling: @@ -115,21 +115,44 @@ mobi: epub @ebook-convert LAMMPS.epub LAMMPS.mobi @echo "Conversion finished. The MOBI manual file is created." -pdf: utils/txt2html/txt2html.exe +pdf: $(OBJECTS) $(ANCHORCHECK) @(\ - set -e; \ cd src/Developer; \ pdflatex developer; \ pdflatex developer; \ mv developer.pdf ../../Developer.pdf; \ - cd ..; \ - ../utils/txt2html/txt2html.exe -b *.txt; \ - htmldoc --batch lammps.book; \ - for s in `echo *.txt | sed -e 's/ \(pairs\|bonds\|angles\|dihedrals\|impropers\|commands_list\|fixes\|computes\).txt/ /g' | sed -e 's,\.txt,\.html,g'` ; \ - do grep -q ^$$s lammps.book || \ - echo WARNING: doc file $$s missing in src/lammps.book; done; \ - rm *.html; \ + cd ../../; \ + ) + @(\ + . $(VENV)/bin/activate ;\ + cp -r src/* $(RSTDIR)/ ;\ + sphinx-build $(SPHINXEXTRA) -b latex -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) latex ;\ + echo "############################################" ;\ + doc_anchor_check src/*.txt ;\ + echo "############################################" ;\ + deactivate ;\ ) + @cd latex && \ + sed 's/latexmk -pdf -dvi- -ps-/pdflatex/g' Makefile > temp && \ + mv temp Makefile && \ + sed 's/\\begin{equation}//g' LAMMPS.tex > tmp.tex && \ + mv tmp.tex LAMMPS.tex && \ + sed 's/\\end{equation}//g' LAMMPS.tex > tmp.tex && \ + mv tmp.tex LAMMPS.tex && \ + make && \ + make && \ + mv LAMMPS.pdf ../Manual.pdf && \ + cd ../; + @rm -rf latex/_sources + @rm -rf latex/PDF + @rm -rf latex/USER + @cp -r src/PDF latex/PDF + @cp -r src/USER latex/USER + @rm -rf latex/PDF/.[sg]* + @rm -rf latex/USER/.[sg]* + @rm -rf latex/USER/*/.[sg]* + @rm -rf latex/USER/*/*.[sg]* + @echo "Build finished. Manual.pdf and Developer.pdf are in this directory." old: utils/txt2html/txt2html.exe @rm -rf old @@ -139,6 +162,18 @@ old: utils/txt2html/txt2html.exe cp Eqs/*.jpg ../old/Eqs; \ cp JPG/* ../old/JPG; \ cp PDF/* ../old/PDF; + @( set -e;\ + cd src/Developer; \ + pdflatex developer; \ + pdflatex developer; \ + mv developer.pdf ../../old/Developer.pdf; \ + cd ../../old; \ + for s in `echo ../src/*.txt | sed -e 's,\.\./src/,,g' -e 's/ \(pairs\|bonds\|angles\|dihedrals\|impropers\|commands_list\|fixes\|computes\).txt/ /g' | sed -e 's,\.txt,\.html,g'` ; \ + do grep -q ^$$s ../src/lammps.book || \ + echo WARNING: doc file $$s missing in src/lammps.book; done; \ + htmldoc --batch ../src/lammps.book; \ + ) + fetch: @rm -rf html_www Manual_www.pdf Developer_www.pdf diff --git a/doc/lammps.1 b/doc/lammps.1 index d49650bfaad03678902a67c1937db7264f758004..7ba31bfd0637b32d2d51c65d30216edbf5d4ddd1 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,40 +1,259 @@ -.TH LAMMPS "2018-08-22" +.TH LAMMPS "18 June 2019" "2019-06-18" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. .SH SYNOPSIS -.B lmp --in in.file +.B lmp +\-in [OPTIONS] ... or -mpirun \-np 2 -.B lmp --in in.file +mpirun \-np 2 +.B lmp + [OPTIONS] ... + +or + +.B lmp +\-r2data file.restart file.data .SH DESCRIPTION -.B LAMMPS -LAMMPS is a classical molecular dynamics code, and an acronym for Large-scale -Atomic/Molecular Massively Parallel Simulator. LAMMPS has potentials for soft -materials (biomolecules, polymers) and solid-state materials (metals, -semiconductors) and coarse-grained or mesoscopic systems. It can be used to -model atoms or, more generically, as a parallel particle simulator at the +.B LAMMPS +is a classical molecular dynamics code, and an acronym for \fBL\fRarge-scale +\fBA\fRtomic/\fBM\fRolecular \fBM\fRassively \fBP\fRarallel \fBS\fRimulator. +.B LAMMPS +has potentials for soft +materials (bio-molecules, polymers) and solid-state materials (metals, +semiconductors) and coarse-grained or mesoscopic systems. It can be used to +model atoms or, more generically, as a parallel particle simulator at the atomic, meso, or continuum scale. -See http://lammps.sandia.gov/ for documentation. +See https://lammps.sandia.gov/ for more information and documentation. + +.SH EXECUTABLE NAME +The +.B LAMMPS +executable can have different names depending on how it was configured, +compiled and installed. It will be either +.B lmp +or +.B lmp_. +The suffix corresponds to the (machine specific) makefile +used to compile +.B LAMMPS +when using the conventional build process. When building +.B LAMMPS +using +.B CMake +this parameter can be chosen arbitrarily at configuration +time, but more common is to just use +.B lmp +without a suffix. In this manpage we will use +.B lmp +to represent any of those names. .SH OPTIONS -See https://lammps.sandia.gov/doc/Run_options.html for details on -command-line options. -.SH COPYRIGHT -© 2003--2018 Sandia Corporation +.TP +\fB\-h\fR or \fB\-help\fR +Print a brief help summary and a list of settings and options compiled +into this executable. It also explicitly lists all LAMMPS styles +(atom_style, fix, compute, pair_style, bond_style, etc) available in +the specific executable. This can tell you if the command you want to +use was included via the appropriate package at compile time. +LAMMPS will print the info and immediately exit if this switch is used. +.TP +\fB\-e\fR or \fB\-echo\fR +Set the style of command echoing. The style can be +.B none +or +.B screen +or +.B log +or +.B both. +Depending on the style, each command read from the input script will +be echoed to the screen and/or logfile. This can be useful to figure +out which line of your script is causing an input error. +The default value is +.B log. +.TP +\fB\-i \fR or \fB\-in \fR +Specify a file to use as an input script. If it is not specified, +LAMMPS reads its script from standard input. This is a required +switch when running LAMMPS in multi-partition mode. +.TP +\fB\-k on/off [keyword value]\fR or \fB\-kokkos on/off [keyword value]\fR +Enable or disable general KOKKOS support, as provided by the KOKKOS +package. Even if LAMMPS is built with this package, this switch must +be set to \fBon\fR to enable running with KOKKOS-enabled styles. More +details on this switch and its optional keyword value pairs are discussed +at: https://lammps.sandia.gov/doc/Run_options.html +.TP +\fB\-l \fR or \fB\-log \fR +Specify a log file for LAMMPS to write status information to. +The default value is "log.lammps". If the file name "none" is used, +\fBLAMMPS\fR will not write a log file. In multi-partition mode only +some high-level all-partition information is written to the "" +file, the remainder is written in a per-partition file ".N" +with "N" being the respective partition number, unless overridden +by the \-plog flag (see below). +.TP +\fB\-m \fR or \fB\-mpicolor \fR +If used, this must be the first command-line argument after the +.B LAMMPS +executable name. It is only used when +.B LAMMPS +is launched by an mpirun command which also launches one or more +other executable(s) at the same time. +.B LAMMPS +and the other executable(s) perform an MPI_Comm_split(), each with +their own different colors, to split the MPI_COMM_WORLD communicator +for each executable to the subset of processors they are supposed to +be actually running on. Currently, this is only used in +.B LAMMPS +to perform client/server messaging with another application. +.B LAMMPS +can act as either a client or server (or both). +.TP +\fB\-nc\fR or \fB\-nocite\fR +Disable writing the "log.cite" file which is normally written to +list references for specific cite-able features used during a +.B LAMMPS +run. +.TP +\fB\-pk