diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index fada17d168..fff791e6d4 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -314,10 +314,15 @@ pkg_depends(USER-LB MPI) pkg_depends(USER-PHONON KSPACE) pkg_depends(USER-SCAFACOS MPI) +include(CheckIncludeFileCXX) find_package(OpenMP QUIET) option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND}) 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() @@ -436,7 +441,13 @@ else() endif() if(PKG_VORONOI) - option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" OFF) + 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) message(STATUS "Voro++ download requested - we will build our own") include(ExternalProject) @@ -469,7 +480,13 @@ if(PKG_VORONOI) endif() if(PKG_LATTE) - option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" OFF) + 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") @@ -480,7 +497,7 @@ if(PKG_LATTE) 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} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES} ) ExternalProject_get_property(latte_build INSTALL_DIR) set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a) @@ -496,7 +513,15 @@ endif() if(PKG_USER-SCAFACOS) find_package(GSL REQUIRED) - option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" OFF) + 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) message(STATUS "ScaFaCoS download requested - we will build our own") include(ExternalProject) @@ -536,8 +561,8 @@ if(PKG_USER-SCAFACOS) 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) + find_package(PkgConfig REQUIRED) + pkg_check_modules(SCAFACOS REQUIRED scafacos) list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS}) endif() include_directories(${SCAFACOS_INCLUDE_DIRS}) @@ -551,7 +576,16 @@ if(PKG_USER-PLUMED) 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) + 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(BUILD_MPI) set(PLUMED_CONFIG_MPI "--enable-mpi") @@ -596,7 +630,7 @@ if(PKG_USER-PLUMED) set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include") else() find_package(PkgConfig REQUIRED) - pkg_check_modules(PLUMED plumed 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) @@ -630,7 +664,13 @@ if(PKG_USER-NETCDF) endif() if(PKG_USER-SMD) - option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" OFF) + 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) @@ -678,7 +718,13 @@ if(PKG_KIM) list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES}) add_definitions(-DLMP_KIM_CURL) endif() - option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" OFF) + 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) message(STATUS "KIM-API download requested - we will build our own") enable_language(C) @@ -699,10 +745,7 @@ if(PKG_KIM) 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) - if(NOT KIM-API_FOUND) - message(FATAL_ERROR "KIM-API not found, help CMake to find it by setting PKG_CONFIG_PATH, or set DOWNLOAD_KIM=ON to download it") - endif() + find_package(KIM-API REQUIRED) endif() list(APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}") include_directories(${KIM-API_INCLUDE_DIRS}) @@ -740,7 +783,13 @@ endif() if(PKG_MSCG) find_package(GSL REQUIRED) - option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" OFF) + 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") @@ -789,7 +838,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}) @@ -1444,6 +1492,15 @@ if(BUILD_EXE) if(ENABLE_TESTING) add_test(ShowHelp ${LAMMPS_BINARY} -help) endif() + + enable_language(C) + get_filename_component(MSI2LMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../tools/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() ############################################################################### @@ -1507,11 +1564,14 @@ if(BUILD_DOC) endif() ############################################################################### -# 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_FRC_FILES_DIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps/frc_files) +install(DIRECTORY ${LAMMPS_SOURCE_DIR}/../tools/msi2lmp/frc_files/ DESTINATION ${LAMMPS_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) install( diff --git a/cmake/Modules/FindKIM-API.cmake b/cmake/Modules/FindKIM-API.cmake index d9397b9aba..5108b0f98c 100644 --- a/cmake/Modules/FindKIM-API.cmake +++ b/cmake/Modules/FindKIM-API.cmake @@ -36,14 +36,23 @@ # KIM-API-CMAKE_CXX_COMPILER # KIM-API-CMAKE_Fortran_COMPILER # -find_package(PkgConfig REQUIRED) + +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 REQUIRED libkim-api>=2.0) +pkg_check_modules(KIM-API ${REQ_OR_QUI} libkim-api>=2.0) -pkg_get_variable(KIM-API-V2-CMAKE_C_COMPILER libkim-api CMAKE_C_COMPILER) -pkg_get_variable(KIM-API-V2-CMAKE_CXX_COMPILER libkim-api CMAKE_CXX_COMPILER) -pkg_get_variable(KIM-API-V2_CMAKE_Fortran_COMPILER libkim-api CMAKE_Fortran_COMPILER) +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 diff --git a/cmake/etc/profile.d/lammps.csh.in b/cmake/etc/profile.d/lammps.csh.in index def49bf75c..42f222d67c 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 acd75fa0cf..c1967cb5b2 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/clang.cmake b/cmake/presets/clang.cmake new file mode 100644 index 0000000000..828f359f54 --- /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/doc/lammps.1 b/doc/lammps.1 index d49650bfaa..4686198fef 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,40 +1,259 @@ -.TH LAMMPS "2018-08-22" +.TH LAMMPS "11 April 2019" "2019-04-11" .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