Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.10 patches/gromacs2025 #1162

Draft
wants to merge 7 commits into
base: v2.10
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions patches/gromacs-2025.0.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


function plumed_preliminary_test(){
# check if the README contains the word GROMACS and if gromacs has been already configured
grep -q GROMACS README 1>/dev/null 2>/dev/null
}

function plumed_patch_info(){
cat << EOF
A basic PLUMED interface is already present in GROMACS

This patch previes extra features to be implemented in the official PLUMED integration in the next GROMACS version

Patching must be done in the gromacs root directory _before_ the cmake command is invoked.

The GROMACS integration has some improvements with the compatibility wiht the multi-threading implementation
but it is still preferable to configure gromacs as

cmake -DGMX_THREAD_MPI=OFF and add -DGMX_MPI=ON if you want to use MPI.

To enable PLUMED in a gromacs simulation one should use
mdrun with an extra -plumed flag. The flag can be used to
specify the name of the PLUMED input file, e.g.:

gmx mdrun -plumed plumed.dat

For more information on gromacs you should visit http://www.gromacs.org

EOF
}

plumed_before_patch(){
plumed_patch_info
}

PLUMED_PATCH_NO_INCLUDE=true

PLUMED_PATCH_EXTRA_FILES="src/external/plumed/PlumedInclude.h src/external/plumed/PlumedKernel.cpp src/gromacs/applied_forces/plumed/PlumedOutside.cpp src/gromacs/applied_forces/plumed/PlumedOutside.h"
82 changes: 82 additions & 0 deletions patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.







# Builds the interface to plumed and add the linkage to libPlumed

gmx_option_multichoice(GMX_USE_PLUMED
"Build the PLUMED wrapper with GROMACS"
ON
ON)
mark_as_advanced(GMX_USE_PLUMED)

function(gmx_manage_plumed)
# Create a link target, leave it empty if the plumed option is not active
add_library(plumedgmx INTERFACE)
set (GMX_PLUMED_ACTIVE OFF CACHE INTERNAL "Cache entry for PLUMED activation")
if(WIN32)
if(GMX_USE_PLUMED STREQUAL "ON")
message(FATAL_ERROR "PLUMED is not supported on Windows. Reconfigure with -DGMX_USE_PLUMED=OFF.")
endif()
elseif(NOT GMX_USE_PLUMED STREQUAL "OFF")
include(CMakePushCheckState)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
include(CheckFunctionExists)
check_function_exists(dlopen HAVE_DLOPEN)
cmake_pop_check_state()
if(HAVE_DLOPEN)
# Plumed.h compiled in c++ mode creates a fully inlined interface
# So we just need to activate the directory in applied_forces
set(PLUMED_DIR "${CMAKE_SOURCE_DIR}/src/external/plumed")
target_link_libraries( plumedgmx INTERFACE ${CMAKE_DL_LIBS} )
# The plumedgmx already exists, now we set it up:
target_include_directories(plumedgmx SYSTEM INTERFACE $<BUILD_INTERFACE:${PLUMED_DIR}>)
set (GMX_PLUMED_ACTIVE ON CACHE INTERNAL "Cache entry for PLUMED activation")
else()
if(GMX_USE_PLUMED STREQUAL "ON")
message(FATAL_ERROR "PLUMED needs dlopen or anything equivalent. Reconfigure with -DGMX_USE_PLUMED=OFF.")
else() # "AUTO"
message(STATUS "PLUMED needs dlopen or anything equivalent. Disabling support.")
endif()

endif()

endif()

endfunction()
82 changes: 82 additions & 0 deletions patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake.preplumed
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.







# Builds the interface to plumed and add the linkage to libPlumed

gmx_option_multichoice(GMX_USE_PLUMED
"Build the PLUMED wrapper with GROMACS"
AUTO
AUTO ON OFF)
mark_as_advanced(GMX_USE_PLUMED)

function(gmx_manage_plumed)
# Create a link target, leave it empty if the plumed option is not active
add_library(plumedgmx INTERFACE)
set (GMX_PLUMED_ACTIVE OFF CACHE INTERNAL "Cache entry for PLUMED activation")
if(WIN32)
if(GMX_USE_PLUMED STREQUAL "ON")
message(FATAL_ERROR "PLUMED is not supported on Windows. Reconfigure with -DGMX_USE_PLUMED=OFF.")
endif()
elseif(NOT GMX_USE_PLUMED STREQUAL "OFF")
include(CMakePushCheckState)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
include(CheckFunctionExists)
check_function_exists(dlopen HAVE_DLOPEN)
cmake_pop_check_state()
if(HAVE_DLOPEN)
# Plumed.h compiled in c++ mode creates a fully inlined interface
# So we just need to activate the directory in applied_forces
set(PLUMED_DIR "${CMAKE_SOURCE_DIR}/src/external/plumed")
target_link_libraries( plumedgmx INTERFACE ${CMAKE_DL_LIBS} )
# The plumedgmx already exists, now we set it up:
target_include_directories(plumedgmx SYSTEM INTERFACE $<BUILD_INTERFACE:${PLUMED_DIR}>)
set (GMX_PLUMED_ACTIVE ON CACHE INTERNAL "Cache entry for PLUMED activation")
else()
if(GMX_USE_PLUMED STREQUAL "ON")
message(FATAL_ERROR "PLUMED needs dlopen or anything equivalent. Reconfigure with -DGMX_USE_PLUMED=OFF.")
else() # "AUTO"
message(STATUS "PLUMED needs dlopen or anything equivalent. Disabling support.")
endif()

endif()

endif()

endfunction()
14 changes: 14 additions & 0 deletions patches/gromacs-2025.0.diff/src/external/plumed/PlumedInclude.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#define __PLUMED_WRAPPER_FORTRAN 0 // NOLINT(bugprone-reserved-identifier)

#define __PLUMED_WRAPPER_LINK_RUNTIME 1 // NOLINT(bugprone-reserved-identifier)
#define __PLUMED_WRAPPER_EXTERN 1 // NOLINT(bugprone-reserved-identifier)

#define __PLUMED_WRAPPER_CXX 1 // NOLINT(bugprone-reserved-identifier)
#define __PLUMED_WRAPPER_LIBCXX11 1 // NOLINT(bugprone-reserved-identifier)
#define __PLUMED_WRAPPER_LIBCXX17 1 // NOLINT(bugprone-reserved-identifier)
#ifndef __PLUMED_WRAPPER_IMPLEMENTATION // NOLINT(bugprone-reserved-identifier)
# define __PLUMED_WRAPPER_IMPLEMENTATION 0 // NOLINT(bugprone-reserved-identifier)
#endif
#define __PLUMED_HAS_DLOPEN // NOLINT(bugprone-reserved-identifier)

#include "external/plumed/Plumed.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define __PLUMED_WRAPPER_IMPLEMENTATION 1 // NOLINT(bugprone-reserved-identifier)

#include "PlumedInclude.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.

# If Plumed is not activated then compile just the stub implementation plumedMDModule_stub.cpp
# In other case compile regular plumedMDModule.cpp and tests
if(GMX_PLUMED_ACTIVE)
set(PLUMED_SOURCES
../../../external/plumed/PlumedKernel.cpp
PlumedOutside.cpp
plumedforceprovider.cpp
plumedOptions.cpp
plumedMDModule.cpp
)
gmx_add_libgromacs_sources(
${PLUMED_SOURCES}
)

if (BUILD_TESTING)
add_subdirectory(tests)
endif()
else()
gmx_add_libgromacs_sources(
plumedMDModule_stub.cpp
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright 2024- The GROMACS Authors
# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# https://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at https://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out https://www.gromacs.org.

# If Plumed is not activated then compile just the stub implementation plumedMDModule_stub.cpp
# In other case compile regular plumedMDModule.cpp and tests
if(GMX_PLUMED_ACTIVE)
set(PLUMED_SOURCES plumedforceprovider.cpp
plumedOptions.cpp
plumedMDModule.cpp
)
gmx_add_libgromacs_sources(
${PLUMED_SOURCES}
)

if (BUILD_TESTING)
add_subdirectory(tests)
endif()
else()
gmx_add_libgromacs_sources(
plumedMDModule_stub.cpp
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "PlumedOutside.h"

/*PLUMED*/
namespace PLMD
{
PlumedOutside::PlumedOutside() {}
PlumedOutside::~PlumedOutside() {}
void PlumedOutside::setPlumed(Plumed* plumed)
{
plumed_ = plumed;
active_ = true;
}

bool PlumedOutside::plumedHREX()
{
return false;
// not yet integrated
// return plumedHREX_;
}

bool PlumedOutside::active()
{
return active_;
}

PlumedOutside& plumedOutside()
{
static PlumedOutside outside;
return outside;
} /* */
} // namespace PLMD
/*ENDPLUMED*/
Loading