Merge branch 'master' into pair-style-nnp

This commit is contained in:
Axel Kohlmeyer
2021-05-24 12:08:45 -04:00
30 changed files with 159 additions and 52 deletions

16
.github/CODEOWNERS vendored
View File

@ -13,29 +13,37 @@ lib/kim/* @ellio167
lib/mesont/* @iafoss lib/mesont/* @iafoss
# whole packages # whole packages
src/COMPRESS/* @akohlmey src/COMPRESS/* @rbberger
src/GPU/* @ndtrung81 src/GPU/* @ndtrung81
src/KOKKOS/* @stanmoore1 src/KOKKOS/* @stanmoore1
src/KIM/* @ellio167 src/KIM/* @ellio167
src/LATTE/* @cnegre src/LATTE/* @cnegre
src/MESSAGE/* @sjplimp src/MESSAGE/* @sjplimp
src/MLIAP/* @athomps
src/SNAP/* @athomps
src/SPIN/* @julient31 src/SPIN/* @julient31
src/USER-BROWNIAN/* @samueljmcameron
src/USER-CGDNA/* @ohenrich src/USER-CGDNA/* @ohenrich
src/USER-CGSDK/* @akohlmey src/USER-CGSDK/* @akohlmey
src/USER-COLVARS/* @giacomofiorin src/USER-COLVARS/* @giacomofiorin
src/USER-FEP/* @agiliopadua
src/USER-HDNNP/* @singraber
src/USER-INTEL/* @wmbrownintel src/USER-INTEL/* @wmbrownintel
src/USER-MANIFOLD/* @Pakketeretet2 src/USER-MANIFOLD/* @Pakketeretet2
src/USER-MDI/* @taylor-a-barnes
src/USER-MEAMC/* @martok src/USER-MEAMC/* @martok
src/USER-MESONT/* @iafoss src/USER-MESONT/* @iafoss
src/USER-MOFFF/* @hheenen src/USER-MOFFF/* @hheenen
src/USER-MOLFILE/* @akohlmey src/USER-MOLFILE/* @akohlmey
src/USER-NETCDF/* @pastewka src/USER-NETCDF/* @pastewka
src/USER-PACE/* @yury-lysogorskiy
src/USER-PLUMED/* @gtribello src/USER-PLUMED/* @gtribello
src/USER-PHONON/* @lingtikong src/USER-PHONON/* @lingtikong
src/USER-PTM/* @pmla src/USER-PTM/* @pmla
src/USER-OMP/* @akohlmey src/USER-OMP/* @akohlmey
src/USER-QMMM/* @akohlmey src/USER-QMMM/* @akohlmey
src/USER-REAXC/* @hasanmetin src/USER-REAXC/* @hasanmetin
src/USER-REACTION/* @jrgissing
src/USER-SCAFACOS/* @rhalver src/USER-SCAFACOS/* @rhalver
src/USER-TALLY/* @akohlmey src/USER-TALLY/* @akohlmey
src/USER-UEF/* @danicholson src/USER-UEF/* @danicholson
@ -47,7 +55,6 @@ src/GPU/pair_vashishta_gpu.* @andeplane
src/KOKKOS/pair_vashishta_kokkos.* @andeplane src/KOKKOS/pair_vashishta_kokkos.* @andeplane
src/MANYBODY/pair_vashishta_table.* @andeplane src/MANYBODY/pair_vashishta_table.* @andeplane
src/MANYBODY/pair_atm.* @sergeylishchuk src/MANYBODY/pair_atm.* @sergeylishchuk
src/USER-REACTION/fix_bond_react.* @jrgissing
src/USER-MISC/*_grem.* @dstelter92 src/USER-MISC/*_grem.* @dstelter92
src/USER-MISC/compute_stress_mop*.* @RomainVermorel src/USER-MISC/compute_stress_mop*.* @RomainVermorel
@ -122,6 +129,8 @@ tools/emacs/* @HaoZeke
tools/singularity/* @akohlmey @rbberger tools/singularity/* @akohlmey @rbberger
tools/code_standard/* @rbberger tools/code_standard/* @rbberger
tools/valgrind/* @akohlmey tools/valgrind/* @akohlmey
tools/swig/* @akohlmey
tools/offline/* @rbberger
# tests # tests
unittest/* @akohlmey @rbberger unittest/* @akohlmey @rbberger
@ -130,7 +139,7 @@ unittest/* @akohlmey @rbberger
cmake/* @junghans @rbberger cmake/* @junghans @rbberger
cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin
cmake/Modules/Packages/KIM.cmake @junghans @rbberger @ellio167 cmake/Modules/Packages/KIM.cmake @junghans @rbberger @ellio167
cmake/presets/*.cmake @junghans @rbberger @akohlmey cmake/presets/*.cmake @akohlmey
# python # python
python/* @rbberger python/* @rbberger
@ -142,6 +151,7 @@ fortran/* @akohlmey
doc/utils/*/* @rbberger doc/utils/*/* @rbberger
doc/Makefile @rbberger doc/Makefile @rbberger
doc/README @rbberger doc/README @rbberger
examples/plugin/* @akohlmey
# for releases # for releases
src/version.h @sjplimp src/version.h @sjplimp

View File

@ -7,6 +7,11 @@ cmake_minimum_required(VERSION 3.10)
if(POLICY CMP0074) if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
endif() endif()
# set policy to silence warnings about missing executable permissions in
# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW
if (POLICY CMP0109)
cmake_policy(SET CMP0109 OLD)
endif()
######################################## ########################################
project(lammps CXX) project(lammps CXX)
@ -104,6 +109,12 @@ endif()
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF) option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF)
# allow enabling clang-tidy for C++ files
set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Include clang-tidy processing when compiling")
if(ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*-header-filter=.*" CACHE STRING "")
endif()
include(GNUInstallDirs) include(GNUInstallDirs)
file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp) file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)

View File

@ -6,15 +6,27 @@ set(YAML_MD5 "bb15429d8fb787e7d3f1c83ae129a999" CACHE STRING "MD5 checksum of li
mark_as_advanced(YAML_URL) mark_as_advanced(YAML_URL)
mark_as_advanced(YAML_MD5) mark_as_advanced(YAML_MD5)
# support cross-compilation to windows
if(CMAKE_CROSSCOMPILING AND (CMAKE_SYSTEM_NAME STREQUAL "Windows"))
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
set(YAML_CROSS_HOST --host=i686-mingw64)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(YAML_CROSS_HOST --host=x86_64-mingw64)
else()
message(FATAL_ERROR "Unsupported cross-compilation "
" for ${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}"
" on ${CMAKE_HOST_SYSTEM}/${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
endif()
ExternalProject_Add(libyaml ExternalProject_Add(libyaml
URL ${YAML_URL} URL ${YAML_URL}
URL_MD5 ${YAML_MD5} URL_MD5 ${YAML_MD5}
SOURCE_DIR "${CMAKE_BINARY_DIR}/yaml-src" SOURCE_DIR "${CMAKE_BINARY_DIR}/yaml-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/yaml-build" BINARY_DIR "${CMAKE_BINARY_DIR}/yaml-build"
CONFIGURE_COMMAND <SOURCE_DIR>/configure ${CONFIGURE_REQUEST_PIC} CONFIGURE_COMMAND <SOURCE_DIR>/configure ${CONFIGURE_REQUEST_PIC}
CXX=${CMAKE_CXX_COMPILER} CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER}
CC=${CMAKE_C_COMPILER} --prefix=<INSTALL_DIR> --disable-shared ${YAML_CROSS_HOST}
--prefix=<INSTALL_DIR> --disable-shared
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX} BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX}
TEST_COMMAND "") TEST_COMMAND "")

View File

@ -4,10 +4,18 @@ set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(MPI_CXX "clang++" CACHE STRING "" FORCE) set(MPI_CXX "clang++" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "clang" CACHE STRING "" FORCE) set(OpenMP_C "clang" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)

View File

@ -3,10 +3,20 @@
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "ifort" CACHE STRING "" FORCE) set(CMAKE_Fortran_COMPILER "ifort" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(MPI_CXX "icpc" CACHE STRING "" FORCE) set(MPI_CXX "icpc" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "icc" CACHE STRING "" FORCE) set(OpenMP_C "icc" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE) set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)

View File

@ -1,12 +1,22 @@
# preset that will enable the LLVM based Intel compilers with support for MPI and OpenMP (on Linux boxes) # preset that will enable the LLVM based Intel compilers with support for MPI and OpenMP and Fortran (on Linux boxes)
set(CMAKE_CXX_COMPILER "icpx" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "icpx" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "icx" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "icx" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "ifx" CACHE STRING "" FORCE) set(CMAKE_Fortran_COMPILER "ifx" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE)
set(MPI_CXX "icpx" CACHE STRING "" FORCE) set(MPI_CXX "icpx" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "icx" CACHE STRING "" FORCE) set(OpenMP_C "icx" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE) set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)

View File

@ -28,6 +28,28 @@ variable VERBOSE set to 1:
---------- ----------
.. _clang-tidy
Enable static code analysis with clang-tidy
-------------------------------------------
The `clang-tidy tool <https://clang.llvm.org/extra/clang-tidy/>`_ is a
static code analysis tool to diagnose (and potentially fix) typical
programming errors or coding style violations. It has a modular framework
of tests that can be adjusted to help identifying problems before they
become bugs and also assist in modernizing large code bases (like LAMMPS).
It can be enabled for all C++ code with the following CMake flag
.. code-block:: bash
-D ENABLE_CLANG_TIDY=value # value = no (default) or yes
With this flag enabled all source files will be processed twice, first to
be compiled and then to be analyzed. Please note that the analysis can be
significantly more time consuming than the compilation itself.
----------
.. _iwyu_processing: .. _iwyu_processing:
Report missing and unneeded '#include' statements Report missing and unneeded '#include' statements

View File

@ -448,7 +448,7 @@ time via the "-sf kk" or "-suffix kk" :doc:`command-line switches <Run_options>`
:ref:`USER-INTEL <PKG-USER-INTEL>`, and :ref:`USER-OMP <PKG-USER-OMP>` packages, which :ref:`USER-INTEL <PKG-USER-INTEL>`, and :ref:`USER-OMP <PKG-USER-OMP>` packages, which
have styles optimized for CPUs, KNLs, and GPUs. have styles optimized for CPUs, KNLs, and GPUs.
You must have a C++11 compatible compiler to use this package. You must have a C++14 compatible compiler to use this package.
KOKKOS makes extensive use of advanced C++ features, which can KOKKOS makes extensive use of advanced C++ features, which can
expose compiler bugs, especially when compiling for maximum expose compiler bugs, especially when compiling for maximum
performance at high optimization levels. Please see the file performance at high optimization levels. Please see the file

View File

@ -18,15 +18,31 @@
// Wrap API changes between Python 2 and 3 using macros // Wrap API changes between Python 2 and 3 using macros
#if PY_MAJOR_VERSION == 2 #if PY_MAJOR_VERSION == 2
#if defined(_MSC_VER) || defined(__MINGW32__)
#define PY_INT_FROM_LONG(X) PyLong_FromLongLong(X)
#else
#define PY_INT_FROM_LONG(X) PyInt_FromLong(X) #define PY_INT_FROM_LONG(X) PyInt_FromLong(X)
#endif
#if defined(_MSC_VER) || defined(__MINGW32__)
#define PY_INT_AS_LONG(X) PyLong_AsLongLong(X)
#else
#define PY_INT_AS_LONG(X) PyInt_AsLong(X) #define PY_INT_AS_LONG(X) PyInt_AsLong(X)
#endif
#define PY_STRING_FROM_STRING(X) PyString_FromString(X) #define PY_STRING_FROM_STRING(X) PyString_FromString(X)
#define PY_VOID_POINTER(X) PyCObject_FromVoidPtr((void *) X, nullptr) #define PY_VOID_POINTER(X) PyCObject_FromVoidPtr((void *) X, nullptr)
#define PY_STRING_AS_STRING(X) PyString_AsString(X) #define PY_STRING_AS_STRING(X) PyString_AsString(X)
#elif PY_MAJOR_VERSION == 3 #elif PY_MAJOR_VERSION == 3
#if defined(_MSC_VER) || defined(__MINGW32__)
#define PY_INT_FROM_LONG(X) PyLong_FromLongLong(X)
#else
#define PY_INT_FROM_LONG(X) PyLong_FromLong(X) #define PY_INT_FROM_LONG(X) PyLong_FromLong(X)
#endif
#if defined(_MSC_VER) || defined(__MINGW32__)
#define PY_INT_AS_LONG(X) PyLong_AsLongLong(X)
#else
#define PY_INT_AS_LONG(X) PyLong_AsLong(X) #define PY_INT_AS_LONG(X) PyLong_AsLong(X)
#endif
#define PY_STRING_FROM_STRING(X) PyUnicode_FromString(X) #define PY_STRING_FROM_STRING(X) PyUnicode_FromString(X)
#define PY_VOID_POINTER(X) PyCapsule_New((void *) X, nullptr, nullptr) #define PY_VOID_POINTER(X) PyCapsule_New((void *) X, nullptr, nullptr)
#define PY_STRING_AS_STRING(X) PyUnicode_AsUTF8(X) #define PY_STRING_AS_STRING(X) PyUnicode_AsUTF8(X)

View File

@ -58,7 +58,7 @@ ComputeSpin::ComputeSpin(LAMMPS *lmp, int narg, char **arg) :
long_spin_flag = 0; long_spin_flag = 0;
precession_spin_flag = 0; precession_spin_flag = 0;
init(); ComputeSpin::init();
allocate(); allocate();

View File

@ -44,7 +44,7 @@ ComputeGyrationShape::ComputeGyrationShape(LAMMPS *lmp, int narg, char **arg) :
// ID of compute gyration // ID of compute gyration
id_gyration = utils::strdup(arg[3]); id_gyration = utils::strdup(arg[3]);
init(); ComputeGyrationShape::init();
vector = new double[6]; vector = new double[6];
} }

View File

@ -40,7 +40,7 @@ ComputeGyrationShapeChunk::ComputeGyrationShapeChunk(LAMMPS *lmp, int narg, char
// ID of compute gyration // ID of compute gyration
id_gyration_chunk = utils::strdup(arg[3]); id_gyration_chunk = utils::strdup(arg[3]);
init(); ComputeGyrationShapeChunk::init();
array_flag = 1; array_flag = 1;
size_array_cols = 6; size_array_cols = 6;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories https://lammps.sandia.gov/, Sandia National Laboratories
@ -14,8 +13,8 @@
#include "arg_info.h" #include "arg_info.h"
#include <stdexcept>
#include <cstring> #include <cstring>
#include <stdexcept>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -29,46 +28,51 @@ using namespace LAMMPS_NS;
* \param arg string with possible reference * \param arg string with possible reference
* \param allowed integer with bitmap of allowed types of references */ * \param allowed integer with bitmap of allowed types of references */
ArgInfo::ArgInfo(const std::string &arg, int allowed) ArgInfo::ArgInfo(const std::string &arg, int allowed) : type(NONE), dim(0), index1(-1), index2(-1)
: type(NONE), dim(0), index1(-1), index2(-1)
{ {
if ((arg.size() > 2) && (arg[1] == '_')) { if ((arg.size() > 2) && (arg[1] == '_')) {
if ((arg[0] == 'c') && (allowed & COMPUTE)) type = COMPUTE; if ((arg[0] == 'c') && (allowed & COMPUTE))
else if ((arg[0] == 'f') && (allowed & FIX)) type = FIX; type = COMPUTE;
else if ((arg[0] == 'v') && (allowed & VARIABLE)) type = VARIABLE; else if ((arg[0] == 'f') && (allowed & FIX))
else if ((arg[0] == 'd') && (allowed & DNAME)) type = DNAME; type = FIX;
else if ((arg[0] == 'i') && (allowed & INAME)) type = INAME; else if ((arg[0] == 'v') && (allowed & VARIABLE))
type = VARIABLE;
else if ((arg[0] == 'd') && (allowed & DNAME))
type = DNAME;
else if ((arg[0] == 'i') && (allowed & INAME))
type = INAME;
else { else {
index1 = 0; index1 = 0;
name = arg; name = arg;
return; return;
} }
std::size_t has_idx1 = arg.find('[',2); std::size_t has_idx1 = arg.find('[', 2);
if (has_idx1 != std::string::npos) { if (has_idx1 != std::string::npos) {
name = arg.substr(2,has_idx1-2); name = arg.substr(2, has_idx1 - 2);
dim = 1; dim = 1;
std::size_t has_idx2 = arg.find('[',has_idx1+1); std::size_t has_idx2 = arg.find('[', has_idx1 + 1);
if (has_idx2 != std::string::npos) { if (has_idx2 != std::string::npos) {
dim = 2; dim = 2;
if (arg[arg.size()-1] != ']') { if (arg[arg.size() - 1] != ']') {
type = UNKNOWN; type = UNKNOWN;
} else { } else {
try { try {
index2 = std::stoi(arg.substr(has_idx2+1,arg.size()-(has_idx2+2))); index2 = std::stoi(arg.substr(has_idx2 + 1, arg.size() - (has_idx2 + 2)));
} catch (std::invalid_argument &) { } catch (std::invalid_argument &) {
type = UNKNOWN; type = UNKNOWN;
} }
} }
} else has_idx2 = arg.size(); } else
has_idx2 = arg.size();
if (arg[has_idx2-1] != ']') { if (arg[has_idx2 - 1] != ']') {
type = UNKNOWN; type = UNKNOWN;
} else { } else {
try { try {
index1 = std::stoi(arg.substr(has_idx1+1,arg.size()-(has_idx2+2))); index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx2 + 2)));
} catch (std::invalid_argument &) { } catch (std::invalid_argument &) {
type = UNKNOWN; type = UNKNOWN;
} }
@ -97,8 +101,7 @@ ArgInfo::ArgInfo(const std::string &arg, int allowed)
char *ArgInfo::copy_name() char *ArgInfo::copy_name()
{ {
char *dest = new char[name.size()+1]; char *dest = new char[name.size() + 1];
strcpy(dest,name.c_str()); strcpy(dest, name.c_str()); // NOLINT
return dest; return dest;
} }

View File

@ -44,7 +44,7 @@ ComputeAngmomChunk::ComputeAngmomChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeAngmomChunk::init();
// chunk-based data // chunk-based data

View File

@ -46,7 +46,7 @@ ComputeCOMChunk::ComputeCOMChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeCOMChunk::init();
// chunk-based data // chunk-based data

View File

@ -62,7 +62,7 @@ ComputeDipoleChunk::ComputeDipoleChunk(LAMMPS *lmp, int narg, char **arg) :
else error->all(FLERR,"Illegal compute dipole/chunk command"); else error->all(FLERR,"Illegal compute dipole/chunk command");
} }
init(); ComputeDipoleChunk::init();
// chunk-based data // chunk-based data

View File

@ -39,7 +39,7 @@ ComputeGyrationChunk::ComputeGyrationChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeGyrationChunk::init();
// optional args // optional args

View File

@ -44,7 +44,7 @@ ComputeInertiaChunk::ComputeInertiaChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeInertiaChunk::init();
// chunk-based data // chunk-based data

View File

@ -48,7 +48,7 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
firstflag = 1; firstflag = 1;
init(); ComputeMSDChunk::init();
// create a new fix STORE style for reference positions // create a new fix STORE style for reference positions
// id = compute-ID + COMPUTE_STORE, fix group = compute group // id = compute-ID + COMPUTE_STORE, fix group = compute group

View File

@ -48,7 +48,7 @@ ComputeOmegaChunk::ComputeOmegaChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeOmegaChunk::init();
// chunk-based data // chunk-based data

View File

@ -36,7 +36,7 @@ ComputePropertyChunk::ComputePropertyChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputePropertyChunk::init();
// parse values // parse values

View File

@ -48,7 +48,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
biasflag = 0; biasflag = 0;
init(); ComputeTempChunk::init();
// optional per-chunk values // optional per-chunk values

View File

@ -43,7 +43,7 @@ ComputeTorqueChunk::ComputeTorqueChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeTorqueChunk::init();
// chunk-based data // chunk-based data

View File

@ -44,7 +44,7 @@ ComputeVCMChunk::ComputeVCMChunk(LAMMPS *lmp, int narg, char **arg) :
idchunk = utils::strdup(arg[3]); idchunk = utils::strdup(arg[3]);
init(); ComputeVCMChunk::init();
// chunk-based data // chunk-based data

View File

@ -449,7 +449,7 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
std::string estyle = style + "/" + lmp->suffix; std::string estyle = style + "/" + lmp->suffix2;
if (angle_map->find(estyle) != angle_map->end()) { if (angle_map->find(estyle) != angle_map->end()) {
AngleCreator &angle_creator = (*angle_map)[estyle]; AngleCreator &angle_creator = (*angle_map)[estyle];
return angle_creator(lmp); return angle_creator(lmp);
@ -679,7 +679,7 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
} }
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 1; sflag = 2;
std::string estyle = style + "/" + lmp->suffix2; std::string estyle = style + "/" + lmp->suffix2;
if (kspace_map->find(estyle) != kspace_map->end()) { if (kspace_map->find(estyle) != kspace_map->end()) {
KSpaceCreator &kspace_creator = (*kspace_map)[estyle]; KSpaceCreator &kspace_creator = (*kspace_map)[estyle];

View File

@ -244,7 +244,7 @@ union ubuf {
#if defined(__INTEL_LLVM_COMPILER) || defined(__INTEL_COMPILER) #if defined(__INTEL_LLVM_COMPILER) || defined(__INTEL_COMPILER)
#define _alignvar(expr, val) __declspec(align(val)) expr #define _alignvar(expr, val) __declspec(align(val)) expr
#elif defined(__GNUC__) #elif defined(__GNUC__) || defined(__PGI)
#define _alignvar(expr, val) expr __attribute((aligned(val))) #define _alignvar(expr, val) expr __attribute((aligned(val)))
#else #else
#define _alignvar(expr, val) expr #define _alignvar(expr, val) expr
@ -252,9 +252,9 @@ union ubuf {
// declaration to lift aliasing restrictions // declaration to lift aliasing restrictions
#if defined(__INTEL_LLVM_COMPILER) || defined(__INTEL_COMPILER) #if defined(__INTEL_COMPILER) || defined(__PGI)
#define _noalias restrict #define _noalias restrict
#elif defined(__GNUC__) #elif defined(__GNUC__) || defined(__INTEL_LLVM_COMPILER)
#define _noalias __restrict #define _noalias __restrict
#else #else
#define _noalias #define _noalias

View File

@ -638,7 +638,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
char *utils::strdup(const std::string &text) char *utils::strdup(const std::string &text)
{ {
char *tmp = new char[text.size() + 1]; char *tmp = new char[text.size() + 1];
strcpy(tmp, text.c_str()); strcpy(tmp, text.c_str()); // NOLINT
return tmp; return tmp;
} }

View File

@ -362,7 +362,11 @@ TEST(LAMMPS_init, NoOpenMP)
FILE *fp = fopen("in.lammps_class_noomp", "w"); FILE *fp = fopen("in.lammps_class_noomp", "w");
fputs("\n", fp); fputs("\n", fp);
fclose(fp); fclose(fp);
#if defined(__WIN32)
_putenv("OMP_NUM_THREADS");
#else
unsetenv("OMP_NUM_THREADS"); unsetenv("OMP_NUM_THREADS");
#endif
const char *args[] = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"}; const char *args[] = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"};
char **argv = (char **)args; char **argv = (char **)args;

View File

@ -26,7 +26,7 @@ set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_library(style_tests STATIC yaml_writer.cpp error_stats.cpp test_config_reader.cpp test_main.cpp) add_library(style_tests STATIC yaml_writer.cpp error_stats.cpp test_config_reader.cpp test_main.cpp)
target_compile_definitions(style_tests PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER}) target_compile_definitions(style_tests PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER})
target_include_directories(style_tests PRIVATE ${LAMMPS_SOURCE_DIR}) target_include_directories(style_tests PRIVATE ${LAMMPS_SOURCE_DIR})
target_link_libraries(style_tests PUBLIC GTest::GTest GTest::GMock Yaml::Yaml) target_link_libraries(style_tests PUBLIC GTest::GTest GTest::GMock Yaml::Yaml lammps)
if(BUILD_MPI) if(BUILD_MPI)
target_link_libraries(style_tests PUBLIC MPI::MPI_CXX) target_link_libraries(style_tests PUBLIC MPI::MPI_CXX)
else() else()

View File

@ -7,6 +7,7 @@ endif()
include(CheckLanguage) include(CheckLanguage)
check_language(Fortran) check_language(Fortran)
if(CMAKE_Fortran_COMPILER) if(CMAKE_Fortran_COMPILER)
enable_language(C)
enable_language(Fortran) enable_language(Fortran)
get_filename_component(LAMMPS_FORTRAN_MODULE ${LAMMPS_SOURCE_DIR}/../fortran/lammps.f90 ABSOLUTE) get_filename_component(LAMMPS_FORTRAN_MODULE ${LAMMPS_SOURCE_DIR}/../fortran/lammps.f90 ABSOLUTE)
if(BUILD_MPI) if(BUILD_MPI)