# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-cmake_minimum_required(VERSION 2.8.8)
-# When we require cmake >= 2.8.12, it will provide
-# CMAKE_MINIMUM_REQUIRED_VERSION automatically, but in the meantime we
-# need to set a variable, and it must have a different name.
-set(GMX_CMAKE_MINIMUM_REQUIRED_VERSION "2.8.8")
+cmake_minimum_required(VERSION 3.4.3)
# CMake modules/macros are in a subdirectory to keep this file cleaner
# This needs to be set before project() in order to pick up toolchain files
include(gmxBuildTypeReleaseWithAssert)
if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert Profile." FORCE)
- # There's no need to offer a user the choice of ThreadSanitizer
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert Profile TSAN ASAN MSAN." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
- "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert" "Profile")
+ "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert" "Profile" "TSAN" "ASAN" "MSAN")
endif()
if(CMAKE_CONFIGURATION_TYPES)
# Add appropriate GROMACS-specific build types for the Visual
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
-# Set a default valgrind suppression file.
-# This unfortunately needs to duplicate information from CTest to work as
-# expected...
-set(MEMORYCHECK_SUPPRESSIONS_FILE
- "${CMAKE_SOURCE_DIR}/cmake/legacy_and_external.supp"
- CACHE FILEPATH
- "File that contains suppressions for the memory checker")
-include(CTest)
+include(gmxCTestUtilities)
+gmx_ctest_init()
include(gmxCPackUtilities)
gmx_cpack_init()
option(GMX_USE_OPENCL "Enable OpenCL acceleration" OFF)
-# Decide on GPU settings based on user-settings and GPU/CUDA detection.
-# GCC 4.6 requires CUDA 5.0 and VS2015 requires CUDA 8.0
+# Decide on GPU settings based on user-settings and GPU/CUDA
+# detection. GCC 4.8 requires CUDA 6.0 (but we choose 6.5 for the
+# preliminary C++11 support), icc 15 requires CUDA 7.0, and VS2015
+# requires CUDA 8.0
if(MSVC)
set(REQUIRED_CUDA_VERSION 8.0)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ set(REQUIRED_CUDA_VERSION 7.0)
else()
- set(REQUIRED_CUDA_VERSION 5.0)
+ set(REQUIRED_CUDA_VERSION 6.5)
endif()
set(REQUIRED_CUDA_COMPUTE_CAPABILITY 2.0)
include(gmxCFlags)
gmx_c_flags()
+# These collect libraries that Gromacs requires for linking:
+# - Libraries that are required for libgromacs (only)
+set(GMX_EXTRA_LIBRARIES "")
+# - Libraries that are required for all code in the repository
+set(GMX_COMMON_LIBRARIES "")
+# - Libraries that all code linked against libgromacs needs
+# (i.e., something that is exposed in installed headers).
+set(GMX_PUBLIC_LIBRARIES "")
+
# This variable should be used for additional compiler flags which are not
# generated in gmxCFlags nor are SIMD or MPI related.
set(EXTRA_C_FLAGS "")
# Run through a number of tests for buggy compilers and other issues
include(gmxTestCompilerProblems)
gmx_test_compiler_problems()
-# GMX_SIMD will not be set automatically until the second
-# pass (which is not strictly guaranteed to occur), so putting this
-# check here among logically-related tests is inefficient, but the
-# potential loss is likely zero.
-if(GMX_SIMD STREQUAL "AVX_256"
- AND CMAKE_COMPILER_IS_GNUCC
- AND (C_COMPILER_VERSION VERSION_EQUAL "4.6.1"
- OR CXX_COMPILER_VERSION VERSION_EQUAL "4.6.1"))
- message(FATAL_ERROR "gcc 4.6.1 has buggy support for AVX, and GROMACS mdrun will not work. If you want simulation performance, use a more recent compiler. Otherwise, use GMX_SIMD=SSE4.1")
- # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49002
-endif()
# Implement double-precision option. This is complicated because we
# need installed headers to use the precision mode of the build that
# Find external packages #
########################################################################
-# TNG wants zlib if it is available. And static libxml2 might have a dependency
-find_package(ZLIB QUIET)
-include(gmxTestZLib)
-gmx_test_zlib(HAVE_ZLIB)
-
# Unconditionally find the package, as it is also required for unit
# tests. This exports LIBXML2_FOUND, which we should not use because
# it does not tell us that linking will succeed. Instead, we test that
gmx_check_if_changed(HWLOC_FOUND_CHANGED HWLOC_FOUND)
if (_STATIC_HWLOC AND HWLOC_FOUND_CHANGED)
- message(STATUS "Static hwloc library found, will not attempt using it as it could lead to link-time errors. To use the detected library, manually set GMX_HWLOC=ON and you will likely have to pass appropriate linker flags too to satisfy the link-time dependencies of your hwloc library. Try "pkg-config --libs --static hwloc" for suggestions on what you will need.")
+ message(STATUS "Static hwloc library found, will not attempt using it as it could lead to link-time errors. To use the detected library, manually set GMX_HWLOC=ON and you will likely have to pass appropriate linker flags too to satisfy the link-time dependencies of your hwloc library. Try \"pkg-config --libs --static hwloc\" for suggestions on what you will need.")
set(GMX_HWLOC_DEFAULT OFF)
else()
set(GMX_HWLOC_DEFAULT ON)
option(GMX_HWLOC "Add support for hwloc Portable Hardware locality library" ${GMX_HWLOC_DEFAULT})
if(GMX_HWLOC)
if(HWLOC_FOUND)
- include_directories(${HWLOC_INCLUDE_DIRS})
+ include_directories(SYSTEM ${HWLOC_INCLUDE_DIRS})
list(APPEND GMX_EXTRA_LIBRARIES ${HWLOC_LIBRARIES})
else()
message(FATAL_ERROR "Hwloc package support requested, but not found.")
add_definitions(-DTMPI_ATOMICS_DISABLED)
endif()
-# Note this relies on zlib detection having already run
include(gmxManageTNG)
include(gmxManageLmfit)
if(GMX_GPU)
# now that we have detected the dependencies, do the second configure pass
gmx_gpu_setup()
-else()
- mark_as_advanced(CUDA_HOST_COMPILER)
endif()
if(CYGWIN)
add_definitions( -DHAVE_CONFIG_H )
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src)
-include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/include)
+# TODO required at high level because both libgromacs and progs/mdrun
+# require it, both for thread-MPI and its atomics and mutexes.
+include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/include)
# Required for config.h, maybe should only be set in src/CMakeLists.txt
include_directories(BEFORE ${CMAKE_BINARY_DIR}/src)
endif()
# Math and thread libraries must often come after all others when linking...
-if(HAVE_LIBM)
- list(APPEND GMX_EXTRA_LIBRARIES m)
+if (HAVE_LIBM)
+ list(APPEND GMX_PUBLIC_LIBRARIES m)
endif()
option(GMX_NACL "Configure for Native Client builds" OFF)
message("CMAKE_CXX_FLAGS_RELEASE: ${GMXC_CXXFLAGS_RELEASE}")
message("CMAKE_CXX_FLAGS_DEBUG: ${GMXC_CXXFLAGS_DEBUG}")
message("CMAKE_EXE_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS}")
- message("CMAKE_SHARED_LINKER_FLAGS: ${MPI_LINKER_FLAGS}")
+ message("CMAKE_SHARED_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS}")
endif()
if(NOT GMX_OPENMP)
################################################################
# Shared library load path settings
################################################################
-# CMake supports RPATH on OS X only from 2.8.12 upwards.
-# CMAKE_SYSTEM_VERSION > 8.0 matches OS X 10.5 and above, where RPATH support
-# was added.
-
if(NOT GMX_BUILD_SHARED_EXE)
# No rpath
set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
-elseif((NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR
- ((CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0) AND (NOT CMAKE_VERSION VERSION_LESS 2.8.12)))
+else()
# The build folder always has bin/ and lib/; if we are also going to
# install to lib/, then the installation RPATH works also in the build
# tree. This makes installation slightly faster (no need to rewrite the
endif()
# Set the RPATH as relative to the executable location to make the
# binaries relocatable.
- if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") #Assume OS X >=10.5
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${GMX_LIB_INSTALL_DIR}")
else()
set(CMAKE_INSTALL_RPATH "@executable_path/../${GMX_LIB_INSTALL_DIR}")
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH 1)
-else()
- # We are on Darwin/OSX, and CMake cannot handle RPATHs automatically.
- if(CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0)
- # Set the RPATH options manually.
- set(CMAKE_INSTALL_NAME_DIR "@rpath")
- set(GMX_EXE_LINKER_FLAGS ${GMX_EXE_LINKER_FLAGS} "-Wl,-rpath,@executable_path/../${GMX_LIB_INSTALL_DIR}")
- else()
- # Use the old INSTALL_NAME_DIR mechanism if RPATH is not supported.
- set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
- endif()
endif()
#COPYING file: Only necessary for binary distributions.
endif()
if (BUILD_TESTING)
- # "tests" target builds all the separate test binaries.
- add_custom_target(tests)
- # "run-ctest" is an internal target that actually runs the tests.
- # This is necessary to be able to add separate targets that execute as part
- # of 'make check', but are ensured to be executed after the actual tests.
- add_custom_target(run-ctest
- COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
- COMMENT "Running all tests"
- VERBATIM)
- add_dependencies(run-ctest tests)
- # "check" target builds and runs all tests.
- add_custom_target(check DEPENDS run-ctest)
+ include(tests/CheckTarget.cmake)
endif()
if (NOT GMX_BUILD_MDRUN_ONLY)
'time.h']
_std_c_cpp_headers = ['c' + x[:-2] for x in _std_c_headers]
_std_cpp_headers = ['algorithm', 'array', 'chrono', 'deque', 'exception', 'fstream',
- 'functional', 'iomanip', 'ios', 'iosfwd', 'iostream', 'istream', 'iterator',
+ 'functional', 'initializer_list', 'iomanip', 'ios', 'iosfwd',
+ 'iostream', 'istream', 'iterator',
'limits', 'list', 'map', 'memory', 'new', 'numeric', 'ostream', 'random',
'regex', 'set', 'sstream', 'stdexcept', 'streambuf', 'string', 'strstream',
'thread', 'tuple', 'type_traits', 'typeindex', 'typeinfo', 'vector', 'utility']
if not options.quiet:
sys.stderr.write('Scanning source tree...\n')
+ if not options.source_root:
+ sys.stderr.write('Source root required not specified.\n')
+ sys.exit(2)
+ if not options.build_root:
+ sys.stderr.write('Build root required not specified.\n')
+ sys.exit(2)
tree = GromacsTree(options.source_root, options.build_root, reporter)
tree.load_installed_file_list()
files = []
#include "config.h"
+#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include "gromacs/math/functions.h"
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
+#include "gromacs/mdrunutility/mdmodules.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/pull-params.h"
//! Read pull groups from a tpr file (including position, force const, geometry, number of groups)
void read_tpr_header(const char *fn, t_UmbrellaHeader* header, t_UmbrellaOptions *opt, t_coordselection *coordsel)
{
- t_inputrec ir;
- int i;
- t_state state;
- static int first = 1;
+ gmx::MDModules mdModules;
+ t_inputrec *ir = mdModules.inputrec();
+ t_state state;
+ static int first = 1;
/* printf("Reading %s \n",fn); */
- read_tpx_state(fn, &ir, &state, NULL);
+ read_tpx_state(fn, ir, &state, NULL);
- if (!ir.bPull)
+ if (!ir->bPull)
{
gmx_fatal(FARGS, "This is not a tpr with COM pulling");
}
- if (ir.pull->ncoord == 0)
+ if (ir->pull->ncoord == 0)
{
gmx_fatal(FARGS, "No pull coordinates found in %s", fn);
}
/* Read overall pull info */
- header->npullcrds = ir.pull->ncoord;
- header->bPrintCOM = ir.pull->bPrintCOM;
- header->bPrintRefValue = ir.pull->bPrintRefValue;
- header->bPrintComp = ir.pull->bPrintComp;
+ header->npullcrds = ir->pull->ncoord;
+ header->bPrintCOM = ir->pull->bPrintCOM;
+ header->bPrintRefValue = ir->pull->bPrintRefValue;
+ header->bPrintComp = ir->pull->bPrintComp;
/* Read pull coordinates */
snew(header->pcrd, header->npullcrds);
- for (i = 0; i < ir.pull->ncoord; i++)
+ for (int i = 0; i < ir->pull->ncoord; i++)
{
- header->pcrd[i].pull_type = ir.pull->coord[i].eType;
- header->pcrd[i].geometry = ir.pull->coord[i].eGeom;
- header->pcrd[i].ngroup = ir.pull->coord[i].ngroup;
- header->pcrd[i].k = ir.pull->coord[i].k;
- header->pcrd[i].init_dist = ir.pull->coord[i].init;
+ header->pcrd[i].pull_type = ir->pull->coord[i].eType;
+ header->pcrd[i].geometry = ir->pull->coord[i].eGeom;
+ header->pcrd[i].ngroup = ir->pull->coord[i].ngroup;
+ header->pcrd[i].k = ir->pull->coord[i].k;
+ header->pcrd[i].init_dist = ir->pull->coord[i].init;
- copy_ivec(ir.pull->coord[i].dim, header->pcrd[i].dim);
+ copy_ivec(ir->pull->coord[i].dim, header->pcrd[i].dim);
header->pcrd[i].ndim = header->pcrd[i].dim[XX] + header->pcrd[i].dim[YY] + header->pcrd[i].dim[ZZ];
std::strcpy(header->pcrd[i].coord_unit,
- pull_coordinate_units(&ir.pull->coord[i]));
+ pull_coordinate_units(&ir->pull->coord[i]));
- if (ir.efep != efepNO && ir.pull->coord[i].k != ir.pull->coord[i].kB)
+ if (ir->efep != efepNO && ir->pull->coord[i].k != ir->pull->coord[i].kB)
{
gmx_fatal(FARGS, "Seems like you did free-energy perturbation, and you perturbed the force constant."
" This is not supported.\n");
}
- if (coordsel && (coordsel->n != ir.pull->ncoord))
+ if (coordsel && (coordsel->n != ir->pull->ncoord))
{
gmx_fatal(FARGS, "Found %d pull coordinates in %s, but %d columns in the respective line\n"
- "coordinate selection file (option -is)\n", ir.pull->ncoord, fn, coordsel->n);
+ "coordinate selection file (option -is)\n", ir->pull->ncoord, fn, coordsel->n);
}
}
int geom = -1;
ivec thedim = { 0, 0, 0 };
bool geometryIsSet = false;
- for (i = 0; i < ir.pull->ncoord; i++)
+ for (int i = 0; i < ir->pull->ncoord; i++)
{
if (coordsel == NULL || coordsel->bUse[i])
{
{
printf("\nFile %s, %d coordinates, with these options:\n", fn, header->npullcrds);
int maxlen = 0;
- for (i = 0; i < ir.pull->ncoord; i++)
+ for (int i = 0; i < ir->pull->ncoord; i++)
{
int lentmp = strlen(epullg_names[header->pcrd[i].geometry]);
maxlen = (lentmp > maxlen) ? lentmp : maxlen;
char fmt[STRLEN];
sprintf(fmt, "\tGeometry %%-%ds k = %%-8g position = %%-8g dimensions [%%s %%s %%s] (%%d dimensions). Used: %%s\n",
maxlen+1);
- for (i = 0; i < ir.pull->ncoord; i++)
+ for (int i = 0; i < ir->pull->ncoord; i++)
{
bool use = (coordsel == NULL || coordsel->bUse[i]);
printf(fmt,
epullg_names[header->pcrd[i].geometry], header->pcrd[i].k, header->pcrd[i].init_dist,
int2YN(header->pcrd[i].dim[XX]), int2YN(header->pcrd[i].dim[YY]), int2YN(header->pcrd[i].dim[ZZ]),
header->pcrd[i].ndim, use ? "Yes" : "No");
- printf("\tPull group coordinates of %d groups expected in pullx files.\n", ir.pull->bPrintCOM ? header->pcrd[i].ngroup : 0);
+ printf("\tPull group coordinates of %d groups expected in pullx files.\n", ir->pull->bPrintCOM ? header->pcrd[i].ngroup : 0);
}
printf("\tReference value of the coordinate%s expected in pullx files.\n",
header->bPrintRefValue ? "" : " not");
if (!bGetMinMax)
{
+ assert(window);
bins = opt->bins;
min = opt->min;
max = opt->max;
"Parallelization",
"^^^^^^^^^^^^^^^",
"",
- "If available, the number of OpenMP threads used by gmx wham is controlled with [TT]-nt[tt].",
+ "If available, the number of OpenMP threads used by gmx wham can be controlled by setting",
+ "the [TT]OMP_NUM_THREADS[tt] environment variable.",
"",
"Autocorrelations",
"^^^^^^^^^^^^^^^^",
#include "gromacs/mdtypes/state.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/index.h"
+#include "gromacs/topology/mtop_lookup.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
int mol_id = 0;
int i;
int atnr_mol;
- gmx_mtop_atomlookup_t alook;
- alook = gmx_mtop_atomlookup_settle_init(mtop);
- gmx_mtop_atomnr_to_molblock_ind(alook, at, block, &mol_id, &atnr_mol);
+ *block = 0;
+ mtopGetMolblockIndex(mtop, at, block, &mol_id, &atnr_mol);
for (i = 0; i < *block; i++)
{
mol_id += mtop->molblock[i].nmol;
}
*type = mtop->molblock[*block].type;
- gmx_mtop_atomlookup_destroy(alook);
-
return mol_id;
}
ITYPE ("maxwarn", *maxwarn, 0);
ITYPE ("pieces", *pieces, 1);
EETYPE("asymmetry", *bALLOW_ASYMMETRY, yesno_names);
-
+ check_warning_error(wi, FARGS);
write_inpfile(membed_input, ninp, inp, FALSE, wi);
+ done_warning(wi, FARGS);
}
/* Obtain the maximum and minimum coordinates of the group to be embedded */
mtop->mols.index = new_mols;
mtop->natoms -= n;
state->natoms -= n;
- state->nalloc = state->natoms;
- snew(x_tmp, state->nalloc);
- snew(v_tmp, state->nalloc);
+ snew(x_tmp, state->natoms);
+ snew(v_tmp, state->natoms);
for (i = 0; i < egcNR; i++)
{
}
}
}
- sfree(state->x);
- state->x = x_tmp;
- sfree(state->v);
- state->v = v_tmp;
+ for (int i = 0; i < state->natoms; i++)
+ {
+ copy_rvec(x_tmp[i], state->x[i]);
+ }
+ sfree(x_tmp);
+ for (int i = 0; i < state->natoms; i++)
+ {
+ copy_rvec(v_tmp[i], state->v[i]);
+ }
+ sfree(v_tmp);
for (i = 0; i < egcNR; i++)
{
/* Check that moleculetypes in insertion group are not part of the rest of the system */
check_types(ins_at, rest_at, mtop);
- init_mem_at(mem_p, mtop, state->x, state->box, pos_ins);
+ init_mem_at(mem_p, mtop, as_rvec_array(state->x.data()), state->box, pos_ins);
- prot_area = est_prot_area(pos_ins, state->x, ins_at, mem_p);
+ prot_area = est_prot_area(pos_ins, as_rvec_array(state->x.data()), ins_at, mem_p);
if ( (prot_area > prot_vs_box) && ( (state->box[XX][XX]*state->box[YY][YY]-state->box[XX][YY]*state->box[YY][XX]) < box_vs_prot) )
{
warn++;
/* resize the protein by xy and by z if necessary*/
snew(r_ins, ins_at->nr);
- init_resize(ins_at, r_ins, pos_ins, mem_p, state->x, bALLOW_ASYMMETRY);
+ init_resize(ins_at, r_ins, pos_ins, mem_p, as_rvec_array(state->x.data()), bALLOW_ASYMMETRY);
membed->fac[0] = membed->fac[1] = xy_fac;
membed->fac[2] = z_fac;
membed->xy_step = (xy_max-xy_fac)/(double)(it_xy);
membed->z_step = (z_max-z_fac)/(double)(it_z-1);
- resize(r_ins, state->x, pos_ins, membed->fac);
+ resize(r_ins, as_rvec_array(state->x.data()), pos_ins, membed->fac);
/* remove overlapping lipids and water from the membrane box*/
/*mark molecules to be removed*/
set_pbc(pbc, inputrec->ePBC, state->box);
snew(rm_p, 1);
- lip_rm = gen_rm_list(rm_p, ins_at, rest_at, pbc, mtop, state->x, mem_p, pos_ins,
+ lip_rm = gen_rm_list(rm_p, ins_at, rest_at, pbc, mtop, as_rvec_array(state->x.data()), mem_p, pos_ins,
probe_rad, low_up_rm, bALLOW_ASYMMETRY);
lip_rm -= low_up_rm;