diff --git a/CMakeLists.txt b/CMakeLists.txt index bcc9fb9b3c..f1460e525b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,15 +32,13 @@ set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Object code libraries") #set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/${program_name}) set(DIRS_INCLUDE_INSTALL ${CMAKE_INSTALL_INCLUDEDIR}/plumed CACHE PATH "Location of header files" ) -#set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib set(DIRS_LIB_INSTALL ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files" ) set(DIRS_BIN_INSTALL ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of executables" ) -set(DIRS_EXTRA_INSTALL ${CMAKE_INSTALL_LIBDIR}/plumed +set(DIRS_EXTRA_INSTALL ${DIRS_LIB_INSTALL}/plumed CACHE PATH "Location of executables" ) -set(DIRS_CMAKE_INSTALL ${CMAKE_INSTALL_LIBDIR}/cmake/plumed - +set(DIRS_CMAKE_INSTALL ${DIRS_LIB_INSTALL}/cmake/Plumed2 CACHE PATH "Location of executables" ) option(CMAKE_EXPORT_COMPILE_COMMANDS "Enable/Disable output of compile commands during generation." ON) @@ -58,9 +56,13 @@ add_subdirectory(fortran) add_subdirectory(vim) install(DIRECTORY patches - DESTINATION ${DIRS_EXTRA_INSTALL}) + DESTINATION ${DIRS_EXTRA_INSTALL} + USE_SOURCE_PERMISSIONS) #This copy makes plumed work in the builddir -file(COPY patches DESTINATION ${DIRS_EXTRA_INSTALL}) +file(COPY patches + DESTINATION ${DIRS_EXTRA_INSTALL} + USE_SOURCE_PERMISSIONS +) enable_testing() add_subdirectory(regtest) \ No newline at end of file diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index fb7b4c0dc1..08b19a586e 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -11,7 +11,7 @@ install( FILES plumed_f08.f90 plumed.f90 #copy file for build-only plumed file(COPY plumed_f08.f90 plumed.f90 -DESTINATION ${CMAKE_BINARY_DIR}/lib/plumed/fortran +DESTINATION ${CMAKE_BINARY_DIR}/${DIRS_EXTRA_INSTALL}/fortran USE_SOURCE_PERMISSIONS ) include(CheckLanguage) diff --git a/patches/gromacs-2021.7.diff/src/gromacs/CMakeLists.txt b/patches/gromacs-2021.7.diff/src/gromacs/CMakeLists.txt index 47bf3c4792..b54c922b2d 100644 --- a/patches/gromacs-2021.7.diff/src/gromacs/CMakeLists.txt +++ b/patches/gromacs-2021.7.diff/src/gromacs/CMakeLists.txt @@ -33,7 +33,7 @@ # To help us fund GROMACS development, we humbly ask that you cite # the research papers on the package. Check out http://www.gromacs.org. -include(${CMAKE_SOURCE_DIR}/Plumed.cmake) +find_package(Plumed2 REQUIRED) set(LIBGROMACS_SOURCES) @@ -322,7 +322,7 @@ target_link_libraries(libgromacs $<$:socket> PUBLIC ${GMX_PUBLIC_LIBRARIES} - ${PLUMED_LOAD} + Plumed2::sharedplumedMain ) if (GMX_OPENMP) target_link_libraries(libgromacs PUBLIC OpenMP::OpenMP_CXX) diff --git a/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt b/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt index d1256e15b5..c6a59c534b 100644 --- a/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt +++ b/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt @@ -31,7 +31,7 @@ # To help us fund GROMACS development, we humbly ask that you cite # the research papers on the package. Check out https://www.gromacs.org. -include(${CMAKE_SOURCE_DIR}/Plumed.cmake) +find_package(Plumed2 REQUIRED) set(LIBGROMACS_SOURCES) @@ -332,7 +332,7 @@ target_link_libraries(libgromacs $<$:socket> PUBLIC ${GMX_PUBLIC_LIBRARIES} - ${PLUMED_LOAD} + Plumed2::sharedplumedMain ) target_link_libraries(libgromacs PUBLIC legacy_api) # Dependencies from libgromacs to the modules are set up here, but diff --git a/patches/gromacs-2023.config b/patches/gromacs-2023.2.config similarity index 100% rename from patches/gromacs-2023.config rename to patches/gromacs-2023.2.config diff --git a/patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt b/patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt rename to patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt index d4676e0312..2405f2db83 100644 --- a/patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt +++ b/patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt @@ -35,7 +35,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") message(FATAL_ERROR "CMake called with the wrong directory; please use the top GROMACS directory (${CMAKE_CURRENT_SOURCE_DIR}/../../)") endif() -include(${CMAKE_SOURCE_DIR}/Plumed.cmake) +find_package(Plumed2 REQUIRED) set(LIBGROMACS_SOURCES) @@ -202,7 +202,7 @@ if(GMX_GPU_FFT_VKFFT) target_link_libraries(libgromacs PRIVATE VkFFT) endif() if(GMX_GPU_FFT_ROCFFT) - target_link_libraries(libgromacs PUBLIC roc::rocfft) + target_link_libraries(libgromacs PRIVATE roc::rocfft) endif() target_link_libraries(libgromacs PRIVATE $) @@ -345,7 +345,7 @@ target_link_libraries(libgromacs $<$:socket> PUBLIC ${GMX_PUBLIC_LIBRARIES} - ${PLUMED_LOAD} + Plumed2::sharedplumedMain ) target_link_libraries(libgromacs PRIVATE legacy_api) # Dependencies from libgromacs to the modules are set up here, but diff --git a/patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt.preplumed similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt.preplumed index 03120eec2b..114bfd9834 100644 --- a/patches/gromacs-2023.diff/src/gromacs/CMakeLists.txt.preplumed +++ b/patches/gromacs-2023.2.diff/src/gromacs/CMakeLists.txt.preplumed @@ -200,7 +200,7 @@ if(GMX_GPU_FFT_VKFFT) target_link_libraries(libgromacs PRIVATE VkFFT) endif() if(GMX_GPU_FFT_ROCFFT) - target_link_libraries(libgromacs PUBLIC roc::rocfft) + target_link_libraries(libgromacs PRIVATE roc::rocfft) endif() target_link_libraries(libgromacs PRIVATE $) diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.h b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.h similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.h rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.h diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.h.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.h.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/expanded.h.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/expanded.h.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp index 8d523a64d5..a841336961 100644 --- a/patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp +++ b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp @@ -734,6 +734,7 @@ static void computeSpecialForces(FILE* fplog, * \param[in] stepWork Step schedule flags * \param[in] xReadyOnDevice Event synchronizer indicating that the coordinates are ready in the device memory. * \param[in] lambdaQ The Coulomb lambda of the current state. + * \param[in] useMdGpuGraph Whether MD GPU Graph is in use. * \param[in] wcycle The wallcycle structure */ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, @@ -741,6 +742,7 @@ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, const StepWorkload& stepWork, GpuEventSynchronizer* xReadyOnDevice, const real lambdaQ, + bool useMdGpuGraph, gmx_wallcycle* wcycle) { wallcycle_start(wcycle, WallCycleCounter::PmeGpuMesh); @@ -748,7 +750,7 @@ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, bool useGpuDirectComm = false; gmx::PmeCoordinateReceiverGpu* pmeCoordinateReceiverGpu = nullptr; pme_gpu_launch_spread( - pmedata, xReadyOnDevice, wcycle, lambdaQ, useGpuDirectComm, pmeCoordinateReceiverGpu); + pmedata, xReadyOnDevice, wcycle, lambdaQ, useGpuDirectComm, pmeCoordinateReceiverGpu, useMdGpuGraph); wallcycle_stop(wcycle, WallCycleCounter::PmeGpuMesh); } @@ -1574,6 +1576,7 @@ void do_force(FILE* fplog, stepWork, localXReadyOnDevice, lambda[static_cast(FreeEnergyPerturbationCouplingType::Coul)], + simulationWork.useMdGpuGraph, wcycle); } diff --git a/patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp.preplumed similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp.preplumed index 454145524b..a839ab7b83 100644 --- a/patches/gromacs-2023.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +++ b/patches/gromacs-2023.2.diff/src/gromacs/mdlib/sim_util.cpp.preplumed @@ -728,6 +728,7 @@ static void computeSpecialForces(FILE* fplog, * \param[in] stepWork Step schedule flags * \param[in] xReadyOnDevice Event synchronizer indicating that the coordinates are ready in the device memory. * \param[in] lambdaQ The Coulomb lambda of the current state. + * \param[in] useMdGpuGraph Whether MD GPU Graph is in use. * \param[in] wcycle The wallcycle structure */ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, @@ -735,6 +736,7 @@ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, const StepWorkload& stepWork, GpuEventSynchronizer* xReadyOnDevice, const real lambdaQ, + bool useMdGpuGraph, gmx_wallcycle* wcycle) { wallcycle_start(wcycle, WallCycleCounter::PmeGpuMesh); @@ -742,7 +744,7 @@ static inline void launchPmeGpuSpread(gmx_pme_t* pmedata, bool useGpuDirectComm = false; gmx::PmeCoordinateReceiverGpu* pmeCoordinateReceiverGpu = nullptr; pme_gpu_launch_spread( - pmedata, xReadyOnDevice, wcycle, lambdaQ, useGpuDirectComm, pmeCoordinateReceiverGpu); + pmedata, xReadyOnDevice, wcycle, lambdaQ, useGpuDirectComm, pmeCoordinateReceiverGpu, useMdGpuGraph); wallcycle_stop(wcycle, WallCycleCounter::PmeGpuMesh); } @@ -1568,6 +1570,7 @@ void do_force(FILE* fplog, stepWork, localXReadyOnDevice, lambda[static_cast(FreeEnergyPerturbationCouplingType::Coul)], + simulationWork.useMdGpuGraph, wcycle); } diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.h b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.h similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.h rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.h diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/md.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/md.cpp similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/md.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/md.cpp index be971728c8..5dc696885a 100644 --- a/patches/gromacs-2023.diff/src/gromacs/mdrun/md.cpp +++ b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/md.cpp @@ -1140,7 +1140,7 @@ void gmx::LegacySimulator::do_md() if (plumedswitch && bHREX) { // gmx_enerdata_t *hrex_enerd; int nlambda = enerd->foreignLambdaTerms.numLambdas(); - gmx_enerdata_t hrex_enerd(enerd->grpp.nener, nlambda == 0 ? 0 : nlambda - 1); + gmx_enerdata_t hrex_enerd(enerd->grpp.nener, nlambda == 0 ? nullptr: &inputrec->fepvals->all_lambda); int repl = -1; int nrepl = -1; if (MAIN(cr)){ diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/md.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/md.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/md.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/md.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/minimize.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/minimize.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/minimize.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/minimize.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/minimize.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/minimize.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/minimize.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/minimize.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.h b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.h similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.h rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.h diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.h.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.h.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/replicaexchange.h.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/replicaexchange.h.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/rerun.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/rerun.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/rerun.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/rerun.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/rerun.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/rerun.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/rerun.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/rerun.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp index 627c317939..1afe072748 100644 --- a/patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp +++ b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp @@ -72,6 +72,7 @@ #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/oenv.h" #include "gromacs/fileio/tpxio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/gmxlib/network.h" #include "gromacs/gmxlib/nrnb.h" #include "gromacs/gpu_utils/device_stream_manager.h" @@ -937,6 +938,19 @@ int Mdrunner::mdrunner() */ applyGlobalSimulationState( *inputHolder_.get(), partialDeserializedTpr.get(), globalState.get(), inputrec.get(), &mtop); + + static_assert(sc_trrMaxAtomCount == sc_checkpointMaxAtomCount); + if (mtop.natoms > sc_checkpointMaxAtomCount) + { + gmx_fatal(FARGS, + "System has %d atoms, which is more than can be stored in checkpoint and trr " + "files (max %" PRId64 ")", + mtop.natoms, + sc_checkpointMaxAtomCount); + } + + // The XTC format has been updated to support up to 2^31-1 atoms, which is anyway the + // largest supported by GROMACS, so no need for any particular check here. } /* Check and update the hardware options for internal consistency */ @@ -1078,11 +1092,12 @@ int Mdrunner::mdrunner() // the task-deciding functions and will agree on the result // without needing to communicate. // The LBFGS minimizer, test-particle insertion, normal modes and shell dynamics don't support DD + const bool hasCustomParallelization = + (EI_TPI(inputrec->eI) || inputrec->eI == IntegrationAlgorithm::NM); const bool canUseDomainDecomposition = - !(inputrec->eI == IntegrationAlgorithm::LBFGS || EI_TPI(inputrec->eI) - || inputrec->eI == IntegrationAlgorithm::NM - || gmx_mtop_particletype_count(mtop)[ParticleType::Shell] > 0); - GMX_RELEASE_ASSERT(!PAR(cr) || canUseDomainDecomposition, + (inputrec->eI != IntegrationAlgorithm::LBFGS && !hasCustomParallelization + && gmx_mtop_particletype_count(mtop)[ParticleType::Shell] == 0); + GMX_RELEASE_ASSERT(!PAR(cr) || hasCustomParallelization || canUseDomainDecomposition, "A parallel run should not arrive here without DD support"); int useDDWithSingleRank = -1; @@ -1455,6 +1470,9 @@ int Mdrunner::mdrunner() else { /* PME, if used, is done on all nodes with 1D decomposition */ + cr->mpi_comm_mygroup = cr->mpiDefaultCommunicator; + cr->mpi_comm_mysim = cr->mpiDefaultCommunicator; + cr->nnodes = cr->sizeOfDefaultCommunicator; cr->sim_nodeid = cr->rankInDefaultCommunicator; cr->nodeid = cr->rankInDefaultCommunicator; @@ -2109,7 +2127,7 @@ int Mdrunner::mdrunner() /* Energy terms and groups */ gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), - inputrec->fepvals->n_lambda); + &inputrec->fepvals->all_lambda); // cos acceleration is only supported by md, but older tpr // files might still combine it with other integrators diff --git a/patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp.preplumed similarity index 99% rename from patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp.preplumed index b0667d1315..acadeab307 100644 --- a/patches/gromacs-2023.diff/src/gromacs/mdrun/runner.cpp.preplumed +++ b/patches/gromacs-2023.2.diff/src/gromacs/mdrun/runner.cpp.preplumed @@ -72,6 +72,7 @@ #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/oenv.h" #include "gromacs/fileio/tpxio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/gmxlib/network.h" #include "gromacs/gmxlib/nrnb.h" #include "gromacs/gpu_utils/device_stream_manager.h" @@ -927,6 +928,19 @@ int Mdrunner::mdrunner() */ applyGlobalSimulationState( *inputHolder_.get(), partialDeserializedTpr.get(), globalState.get(), inputrec.get(), &mtop); + + static_assert(sc_trrMaxAtomCount == sc_checkpointMaxAtomCount); + if (mtop.natoms > sc_checkpointMaxAtomCount) + { + gmx_fatal(FARGS, + "System has %d atoms, which is more than can be stored in checkpoint and trr " + "files (max %" PRId64 ")", + mtop.natoms, + sc_checkpointMaxAtomCount); + } + + // The XTC format has been updated to support up to 2^31-1 atoms, which is anyway the + // largest supported by GROMACS, so no need for any particular check here. } /* Check and update the hardware options for internal consistency */ @@ -1068,11 +1082,12 @@ int Mdrunner::mdrunner() // the task-deciding functions and will agree on the result // without needing to communicate. // The LBFGS minimizer, test-particle insertion, normal modes and shell dynamics don't support DD + const bool hasCustomParallelization = + (EI_TPI(inputrec->eI) || inputrec->eI == IntegrationAlgorithm::NM); const bool canUseDomainDecomposition = - !(inputrec->eI == IntegrationAlgorithm::LBFGS || EI_TPI(inputrec->eI) - || inputrec->eI == IntegrationAlgorithm::NM - || gmx_mtop_particletype_count(mtop)[ParticleType::Shell] > 0); - GMX_RELEASE_ASSERT(!PAR(cr) || canUseDomainDecomposition, + (inputrec->eI != IntegrationAlgorithm::LBFGS && !hasCustomParallelization + && gmx_mtop_particletype_count(mtop)[ParticleType::Shell] == 0); + GMX_RELEASE_ASSERT(!PAR(cr) || hasCustomParallelization || canUseDomainDecomposition, "A parallel run should not arrive here without DD support"); int useDDWithSingleRank = -1; @@ -1441,6 +1456,9 @@ int Mdrunner::mdrunner() else { /* PME, if used, is done on all nodes with 1D decomposition */ + cr->mpi_comm_mygroup = cr->mpiDefaultCommunicator; + cr->mpi_comm_mysim = cr->mpiDefaultCommunicator; + cr->nnodes = cr->sizeOfDefaultCommunicator; cr->sim_nodeid = cr->rankInDefaultCommunicator; cr->nodeid = cr->rankInDefaultCommunicator; @@ -2095,7 +2113,7 @@ int Mdrunner::mdrunner() /* Energy terms and groups */ gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), - inputrec->fepvals->n_lambda); + &inputrec->fepvals->all_lambda); // cos acceleration is only supported by md, but older tpr // files might still combine it with other integrators diff --git a/patches/gromacs-2023.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp b/patches/gromacs-2023.2.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp diff --git a/patches/gromacs-2023.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed diff --git a/patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp similarity index 98% rename from patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp rename to patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp index 680efa03c9..a83489910c 100644 --- a/patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp +++ b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp @@ -625,6 +625,8 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, const bool pmeSpreadGatherUsesCpu = (pmeRunMode == PmeRunMode::CPU); std::string errorMessage; + // Flag to set if we do not want to log the error with `-update auto` (e.g., for non-GPU build) + bool silenceWarningMessageWithUpdateAuto = forceCpuUpdateDefault; if (isDomainDecomposition) { @@ -664,14 +666,19 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, { errorMessage += "Either PME or short-ranged non-bonded interaction tasks must run on the GPU.\n"; + silenceWarningMessageWithUpdateAuto = true; } if (!gpusWereDetected) { errorMessage += "Compatible GPUs must have been found.\n"; + silenceWarningMessageWithUpdateAuto = true; } if (!(GMX_GPU_CUDA || GMX_GPU_SYCL)) { errorMessage += "Only CUDA and SYCL builds are supported.\n"; + // Silence clang-analyzer deadcode.DeadStores warning about ignoring the previous assignments + GMX_UNUSED_VALUE(silenceWarningMessageWithUpdateAuto); + silenceWarningMessageWithUpdateAuto = true; } if (inputrec.eI != IntegrationAlgorithm::MD) { @@ -768,7 +775,7 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, if (!errorMessage.empty()) { - if (updateTarget == TaskTarget::Auto && !forceCpuUpdateDefault) + if (updateTarget == TaskTarget::Auto && !silenceWarningMessageWithUpdateAuto) { GMX_LOG(mdlog.info) .asParagraph() diff --git a/patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed similarity index 98% rename from patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed index 04eef745da..67386bdc5a 100644 --- a/patches/gromacs-2023.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +++ b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed @@ -624,6 +624,8 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, const bool pmeSpreadGatherUsesCpu = (pmeRunMode == PmeRunMode::CPU); std::string errorMessage; + // Flag to set if we do not want to log the error with `-update auto` (e.g., for non-GPU build) + bool silenceWarningMessageWithUpdateAuto = forceCpuUpdateDefault; if (isDomainDecomposition) { @@ -663,14 +665,19 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, { errorMessage += "Either PME or short-ranged non-bonded interaction tasks must run on the GPU.\n"; + silenceWarningMessageWithUpdateAuto = true; } if (!gpusWereDetected) { errorMessage += "Compatible GPUs must have been found.\n"; + silenceWarningMessageWithUpdateAuto = true; } if (!(GMX_GPU_CUDA || GMX_GPU_SYCL)) { errorMessage += "Only CUDA and SYCL builds are supported.\n"; + // Silence clang-analyzer deadcode.DeadStores warning about ignoring the previous assignments + GMX_UNUSED_VALUE(silenceWarningMessageWithUpdateAuto); + silenceWarningMessageWithUpdateAuto = true; } if (inputrec.eI != IntegrationAlgorithm::MD) { @@ -762,7 +769,7 @@ bool decideWhetherToUseGpuForUpdate(const bool isDomainDecomposition, if (!errorMessage.empty()) { - if (updateTarget == TaskTarget::Auto && !forceCpuUpdateDefault) + if (updateTarget == TaskTarget::Auto && !silenceWarningMessageWithUpdateAuto) { GMX_LOG(mdlog.info) .asParagraph() diff --git a/patches/gromacs-2023.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h rename to patches/gromacs-2023.2.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h diff --git a/patches/gromacs-2023.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed b/patches/gromacs-2023.2.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed similarity index 100% rename from patches/gromacs-2023.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed rename to patches/gromacs-2023.2.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed diff --git a/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake b/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake deleted file mode 100644 index 32d7239cec..0000000000 --- a/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake +++ /dev/null @@ -1,471 +0,0 @@ -# -# This file is part of the GROMACS molecular simulation package. -# -# Copyright 2014- 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. - -# Sets version information variables and provides CMake functions for -# generating files based on them -# -# The following variables are derived from variables initialized by -# https://cmake.org/cmake/help/latest/command/project.html#command:project -# GMX_VERSION_MAJOR Major version number. -# GMX_VERSION_PATCH Patch version number. -# Should always be defined: zero for, e.g., 2016. -# -# This script provides the following basic version variables that need to be -# maintained manually: -# GMX_VERSION_SUFFIX String suffix to add to numeric version string. -# "-dev" is automatically added when not building from a source package, -# and does not need to be kept here. This mechanism is not quite enough -# for building a tarball, but setting the CMake cache variable -# GMX_BUILD_TARBALL=on will suppress the addition of "-dev" to the -# version string. -# LIBRARY_SOVERSION_MAJOR so major version for the built libraries. -# Should be increased for each binary incompatible release. In GROMACS, -# the typical policy is to increase it at the start of the development -# cycle for each major/minor version change, but not for patch releases, -# even if the latter may not always be fully binary compatible. -# Table of historical values -# GROMACS 5.0 0 -# GROMACS 5.1 1 -# GROMACS 2016 2 -# GROMACS 2018 3 -# GROMACS 2019 4 -# GROMACS 2020 5 -# GROMACS 2021 6 -# GROMACS 2022 7 -# GROMACS 2023 8 -# LIBRARY_SOVERSION_MINOR so minor version for the built libraries. -# Should be increased for each release that changes only the implementation. -# In GROMACS, the typical policy is to increase it for each patch version -# change, even if they may not always be fully binary compatible. -# If it is somehow clear that the ABI implementation has not changed -# in a patch release, this variable should not increase. Release candidate -# and beta versions will not increase this number, since nobody should -# write code against such versions. -# LIBRARY_VERSION Full library version. -# REGRESSIONTEST_BRANCH For builds not from source packages, name of the -# regressiontests branch at gerrit.gromacs.org whose HEAD can test this -# code, *if* this code is recent enough (i.e., contains all changes from -# the corresponding code branch that affects the regression test -# results). Even after a release branch is forked for the source -# repository, the correct regressiontests branch can still be main, -# because we do not fork it until behaviour needs to change. -# REGRESSIONTEST_MD5SUM -# The MD5 checksum of the regressiontest tarball. Only used when building -# from a source package. -# GMX_SOURCE_DOI_ID -# ID collected from Zenodo connected to the doi for a released version -# used to identify the source when building an official released version. -# This ID is used for the source code tarball. -# GMX_MANUAL_DOI_ID -# Same as above, but for the reference manual. -# They are collected into a single section below. -# The following variables are set based on these: -# GMX_VERSION String composed from GMX_VERSION_* numeric variables -# above. Example: 4.6.1, 5.0, 2016 -# GMX_VERSION_STRING String with GMX_VERSION suffixed with the given -# suffix and possibly "-dev" for builds not from a source package. -# GMX_VERSION_NUMERIC Numeric version number (e.g., 40601 for 4.6.1, 20160001 for 2016.1). -# GMX_API_VERSION Numeric API version. -# This is currently set automatically to GMX_VERSION_NUMERIC, but may -# become manually maintained in the future if there will be releases -# where the API does not change, but programs/libraries do. -# In such a case, this should be the first version where the current API -# appeared. -# REGRESSIONTEST_VERSION For source packages, version number of the -# matching regressiontests tarball. Not used for builds not from source -# packages. -# The latter two are used to generate gromacs/version.h to allow software -# written against the GROMACS API to provide some #ifdef'ed code to support -# multiple GROMACS versions. -# -# This script also declares machinery to generate and obtain version -# information from a git repository. This is enabled by default if the source -# tree is a git, but can be disabled with -# GMX_GIT_VERSION_INFO Advanced CMake variable to disable git -# version info generation. -# If the version generation is disabled, then the source and manual doi -# will be based on the stored values for the ID. -# The main interface to this machinery is the gmx_configure_version_file() -# CMake function. The signature is -# gmx_configure_version_file( -# [REMOTE_HASH] -# [TARGET ] -# [COMMENT ]) -# Specify the input and output files as for configure_file(). -# The configuration is done with configure_file(... @ONLY) with -# the following variables defined (as well as all the -# GMX_VERSION* variables from above): -# GMX_VERSION_STRING_FULL -# GMX_VERSION_FULL_HASH -# GMX_VERSION_CENTRAL_BASE_HASH -# The output file is created during build time, so any dependent -# targets should specify it as a dependency. -# REMOTE_HASH Currently, this has no effect, but it signifies that the -# file is using the CENTRAL_BASE_HASH variable. -# This variable is much more expensive to initialize than the -# others, so this allows local changes in this file to only -# compute that value when required if that becomes necessary. -# TARGET By default, this function uses add_custom_command() to -# generate the output file. If TARGET is specified, then -# add_custom_target() is used to create a target with the given -# name that runs this custom command. Use this if -# the same file will be used for multiple downstream targets, -# or if the explicit target for the file is otherwise -# necessary. -# COMMENT Set a custom comment to be shown when building the rule -# (see add_custom_command(... COMMENT )). -# As an alternative to using this script, also the following variables are -# provided (can be useful when generating more complex CMake scripts that do -# build-time tasks): -# VERSION_INFO_CMAKE_SCRIPT -# Absolute path to a CMake script that can be included using include() -# to declare the GMX_VERSION_* variables documented for -# gmx_configure_version_file(). -# VERSION_INFO_DEPS -# If a custom command depends on VERSION_INFO_CMAKE_SCRIPT, then it -# should add ${VERSION_INFO_DEPS} to its DEPENDS list to get the -# appropriate dependencies. -# TODO: If someone wants to add a custom target that depends on -# VERSION_INFO_CMAKE_SCRIPT, a separate variable may be needed for those -# dependencies. -# -# The version string printed by 'gmx -version' (and also printed in the startup -# header) can provide useful information for, e.g., diagnosing bug reports and -# identifying what exact version the user was using. The following formats are -# possible (with examples given for a particular version): -# 2018.1 Plain version number without any suffix signifies a build from -# a released source tarball. -# 2018.1-dev '-dev' suffix signifies all other builds. If there is no other -# information, either the user built the code outside any git -# repository, or disabled the version info generation. -# 2018.1-dev-YYYYMMDD-1234abc -# The YYYYMMDD part shows the commit date (not author date) of -# the HEAD commit from which the code was built. The abbreviated -# hash is the hash of that commit (the full hash is available in -# 'gmx -version' output). -# If the HEAD hash is not identified as coming from branches in -# "authoritative" GROMACS repositories, 'gmx -version' will show -# the nearest ancestor commit that is identified as such (but see -# the '-local' and '-unknown' suffixes below). -# 2018.1-dev-YYYYMMDD-1234abc-dirty -# As above, but there were local modifications in the source tree -# when the code was built. -# 2018.1-dev-YYYYMMDD-1234abc-unknown -# As above, but there were no remotes in the repository that -# could be identified as "authoritative" GROMACS repositories. -# This happens if the code is not cloned from git.gromacs.org -# or gerrit.gromacs.org. -# 2018.1-dev-YYYYMMDD-1234abc-local -# As above, but there were no commits in the recent history of -# the branch that could be identified as coming from -# "authoritative" GROMACS repositories. This should be -# relatively rare. -# -# Other variables set here are not intended for use outside this file. -# The scripts gmxGenerateVersionInfo.cmake and gmxConfigureVersionInfo.cmake -# are used internally by this machinery, as well as VersionInfo.cmake.cmakein. - -##################################################################### -# Derived version info. -# Ref https://cmake.org/cmake/help/latest/command/project.html#command:project -set(GMX_VERSION_MAJOR ${Gromacs_VERSION_MAJOR}) -set(GMX_VERSION_PATCH ${Gromacs_VERSION_MINOR}) - -##################################################################### -# Manually maintained version info - -# The suffix is used mainly for betas and release -# candidates, where it signifies the most recent such release from -# this branch; it will be empty before the first such release, as well -# as after the final release is out. -set(GMX_VERSION_SUFFIX "") - -# Conventionally with libtool, any ABI change must change the major -# version number, the minor version number should change if it's just -# the implementation that has been altered, and the third number -# counts the number of old major versions that will still run if -# linked to this library (i.e. it is not a patch number). See the -# above descriptions of LIBRARY_SOVERSION_* for policy for changes -# here. The important thing is to minimize the chance of third-party -# code being able to dynamically link with a version of libgromacs -# that might not work. -set(LIBRARY_SOVERSION_MAJOR 8) -set(LIBRARY_SOVERSION_MINOR 0) -set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0) - -##################################################################### -# General version management based on manually set numbers - -if (GMX_VERSION_PATCH) - set(GMX_VERSION "${GMX_VERSION_MAJOR}.${GMX_VERSION_PATCH}") -else() - set(GMX_VERSION "${GMX_VERSION_MAJOR}") -endif() -# Set REGRESSIONTEST_VERSION before further modification to version info. -set(REGRESSIONTEST_VERSION "${GMX_VERSION}${GMX_VERSION_SUFFIX}") - -# Initialize version string. -# Note: Forks that use the suffixing feature later change GMX_VERSION_STRING -# Ref: https://gitlab.com/gromacs/gromacs/-/merge_requests/2587 -set(GMX_VERSION_STRING "${REGRESSIONTEST_VERSION}") -set(REGRESSIONTEST_BRANCH "release-2023") -# Follow the relevant part of the release checklist at -# https://gitlab.com/gromacs/gromacs/-/wikis/Release-checklist#how-to-build-a-regressiontests-tarball -# in order to have it build the regressiontests tarball with all the -# right version naming. The version number and suffix goes into the -# directory name within the regressiontests tarball, which affects the -# md5sum of the tarball. The matching md5sum has to go here, and if it -# isn't right the real release workflow will report a failure. -set(REGRESSIONTEST_MD5SUM "f697cb2624e332aa6a4ea990990a4682" CACHE INTERNAL "MD5 sum of the regressiontests tarball for this GROMACS version") - -# If you are making a custom fork of GROMACS, please describe your -# fork, perhaps with its version number, in the value of -# GMX_VERSION_STRING_OF_FORK here. This string will appear in the -# header of log files that mdrun writes. This will help you, your -# users, your system administrators, your maintainers and the -# maintainers of GROMACS core understand how to troubleshoot and -# reproduce potential problems. -# -# If you are distributing a patch to GROMACS, then this change would -# be great as part of your patch. Otherwise for personal use, you can -# also just set a CMake cache variable. -set(GMX_VERSION_STRING_OF_FORK plumed-2.9.0-dev CACHE INTERNAL - "Version string for forks of GROMACS to set to describe themselves") -mark_as_advanced(GMX_VERSION_STRING_OF_FORK) -if (GMX_VERSION_STRING_OF_FORK) - # Remove dashes from GMX_VERSION_STRING_OF_FORK to avoid confusing pkg-config. Issue #4363 - string(REPLACE "-" "_" _VERSION_STRING_OF_FORK_CLEAN "${GMX_VERSION_STRING_OF_FORK}") - set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-${_VERSION_STRING_OF_FORK_CLEAN}") -endif() - -option(GMX_BUILD_TARBALL "Build tarball without -dev version suffix" OFF) -mark_as_advanced(GMX_BUILD_TARBALL) -if (NOT SOURCE_IS_SOURCE_DISTRIBUTION AND - NOT GMX_BUILD_TARBALL) - set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-dev") -endif() - -math(EXPR GMX_VERSION_NUMERIC - "${GMX_VERSION_MAJOR}*10000 + ${GMX_VERSION_PATCH}") -set(GMX_API_VERSION ${GMX_VERSION_NUMERIC}) - -# Set those values only in release versions, after getting the identifiers -# from Zenodo for the manual and source code -# Has to be done by hand before every final release -# Use force to override anything given as a cmake command line input -# Actual input depends on the GMX_VERSION_STRING_OF_FORK variable being set or not. -# If it is set, we always default to an empty string, otherwise to the value set for the release build. -if (GMX_VERSION_STRING_OF_FORK) - set(GMX_MANUAL_DOI_INTERNAL "") - set(GMX_SOURCE_DOI_INTERNAL "") -else() - set(GMX_MANUAL_DOI_INTERNAL "10.5281/zenodo.7588711") # Set correct doi string here - set(GMX_SOURCE_DOI_INTERNAL "10.5281/zenodo.7588619") # Set correct doi string here -endif() -set(GMX_MANUAL_DOI ${GMX_MANUAL_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS manual" FORCE) -set(GMX_SOURCE_DOI ${GMX_SOURCE_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS source code" FORCE) - -##################################################################### -# git version info management - -# There can be clusters where git and CMake can run on nodes where the other is -# not available, accessing the same source tree. -# Should be unlikely, but doesn't hurt to check. -set(_git_info_default OFF) -if (SOURCE_IS_GIT_REPOSITORY) - find_package(Git) - if (GIT_FOUND) - set(_git_info_default ON) - endif() -endif() -option(GMX_GIT_VERSION_INFO "Generate git version information" ${_git_info_default}) -mark_as_advanced(GMX_GIT_VERSION_INFO) -# Detect preconditions for version info generation if it is requested. -if (GMX_GIT_VERSION_INFO) - if (NOT SOURCE_IS_GIT_REPOSITORY) - message(FATAL_ERROR - "Cannot generate git version information from source tree not under git. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() - # We need at least git v1.5.3 be able to parse git's date output. - if (NOT GIT_FOUND OR GIT_VERSION_STRING VERSION_LESS "1.5.3") - message(FATAL_ERROR - "No compatible git version found (>= 1.5.3 required). " - "Won't be able to generate development version information. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() -endif() - -include(gmxCustomCommandUtilities) -include(FindPythonModule) -# The first two are also for use outside this file, encapsulating the details -# of how to use the generated VersionInfo.cmake. -set(VERSION_INFO_CMAKE_FILE ${PROJECT_BINARY_DIR}/VersionInfo.cmake) -set(VERSION_INFO_DEPS ${VERSION_INFO_CMAKE_FILE}) -# Capture the location of the necessary files in internal variables for use in -# the function below. -set(VERSION_INFO_CMAKEIN_FILE ${CMAKE_CURRENT_LIST_DIR}/VersionInfo.cmake.cmakein) -set(VERSION_INFO_CONFIGURE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/gmxConfigureVersionInfo.cmake) - -# Rules to create the VersionInfo.cmake file. -# For git info, the sequence is: -# 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo-partial.cmake.cmakein -# - Set all variables that are known at configure time. -# 2. (build time) VersionInfo-partial.cmake.cmakein -> VersionInfo.cmake -# - Set variables that may change as result of repository state changes -# (i.e., everything that requires running git). -# - Runs every time as a git-version-info target, but the output file -# timestamp only changes if its contents actually change. -# - Depending on the native build system, this may run once per build -# or once per each time it is required for step 3. -# 3. (build time) VersionInfo.cmake -> other files -# - Set variables in files specified with gmx_configure_version_file() -# using the values generated in step 2. -# - Each file runs as a custom command that depends on the previous -# steps, and runs only if the VersionInfo.cmake file is newer than the -# output file. -# Without git info, the sequence is: -# 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo.cmake -# - Everything is known at configure time, so the output is generated -# immediately with all variables set (git info will be empty). -# 2. (build time) VersionInfo.cmake -> other files -# - As with git info, processes files from gmx_configure_version_file(). -# - These are again custom commands that depend on the output from -# step 1, so they get regenerated only when the static version info -# changes. -# -# Note that VersionInfo-partial.cmake is also used to transfer version -# information between GitLab CI jobs for release and documentation builds. - -# Configure information known at this time into a partially filled -# version info file. -set(VERSION_INFO_CMAKEIN_FILE_PARTIAL - ${PROJECT_BINARY_DIR}/VersionInfo-partial.cmake.cmakein) -# Leave these to be substituted by the targets below. -set(GMX_VERSION_STRING_FULL "\@GMX_VERSION_STRING_FULL\@") - -if (GMX_GIT_VERSION_INFO) - # Leave these to be substituted by the custom target below. - # Specific for building from git. - set(GMX_VERSION_FULL_HASH "\@GMX_VERSION_FULL_HASH\@") - set(GMX_VERSION_CENTRAL_BASE_HASH "\@GMX_VERSION_CENTRAL_BASE_HASH\@") - # If generating the version info, create a target that runs on every build - # and does the actual git calls, storing the results into a CMake script. - # This needs to be run at build time to update the version information - # properly when the git hash changes, but the build system does not. - # All targets added by gmx_configure_version_file() use the information - # from this script to get their variables from, removing the need to run - # git multiple times and simplifying reuse for other purposes. - gmx_add_custom_output_target(git-version-info RUN_ALWAYS - OUTPUT ${VERSION_INFO_CMAKE_FILE} - COMMAND ${CMAKE_COMMAND} - -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -D PROJECT_VERSION=${GMX_VERSION_STRING} - -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} - -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE} - -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating git version information") - list(APPEND VERSION_INFO_DEPS git-version-info) -else() - # Leave these to be substituted by the custom target below. - # Specific for building from source tarball. - gmx_add_custom_output_target(release-version-info RUN_ALWAYS - OUTPUT ${VERSION_INFO_CMAKE_FILE} - COMMAND ${CMAKE_COMMAND} - -D PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} - -D PROJECT_VERSION=${GMX_VERSION_STRING} - -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} - -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE} - -D VERSION_STRING_OF_FORK=${GMX_VERSION_STRING_OF_FORK} - -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfoWithoutGit.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating release version information") - list(APPEND VERSION_INFO_DEPS release-version-info) -endif() -configure_file(${VERSION_INFO_CMAKEIN_FILE} - ${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - @ONLY) -unset(GMX_VERSION_STRING_FULL) -unset(GMX_VERSION_FULL_HASH) -unset(GMX_VERSION_CENTRAL_BASE_HASH) - -# The main user-visible interface to the machinery. -# See documentation at the top of the script. -function (gmx_configure_version_file INFILE OUTFILE) - include(CMakeParseArguments) - set(_options REMOTE_HASH) - set(_one_value_args COMMENT TARGET) - set(_multi_value_args EXTRA_VARS) - cmake_parse_arguments( - ARG "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) - if (ARG_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}") - endif() - # Some callers may pass partial paths that do not really make sense, - # so create a default comment that only contains the actual file name. - get_filename_component(_basename ${OUTFILE} NAME) - set(_comment "Generating ${_basename}") - if (ARG_COMMENT) - set(_comment ${ARG_COMMENT}) - endif() - # Mimic configure_file() - if (NOT IS_ABSOLUTE ${INFILE}) - set(INFILE ${CMAKE_CURRENT_SOURCE_DIR}/${INFILE}) - endif() - # Create command-line definitions for the requested variables - set(_extra_var_defines) - foreach(_var ${ARG_EXTRA_VARS}) - list(APPEND _extra_var_defines -D "${_var}=${${_var}}") - endforeach() - # The touch command is necessary to ensure that after the target is run, - # the timestamp is newer than in the input files. - add_custom_command(OUTPUT ${OUTFILE} - COMMAND ${CMAKE_COMMAND} - -D VERSION_VARIABLES=${VERSION_INFO_CMAKE_FILE} - -D VERSION_CMAKEIN=${INFILE} - -D VERSION_OUT=${OUTFILE} - ${_extra_var_defines} - -P ${VERSION_INFO_CONFIGURE_SCRIPT} - COMMAND ${CMAKE_COMMAND} -E touch ${OUTFILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${INFILE} ${VERSION_INFO_DEPS} ${VERSION_INFO_CONFIGURE_SCRIPT} - COMMENT "${_comment}" - VERBATIM) - if (ARG_TARGET) - add_custom_target(${ARG_TARGET} DEPENDS ${OUTFILE} VERBATIM) - gmx_set_custom_target_output(${ARG_TARGET} ${OUTFILE}) - endif() -endfunction() diff --git a/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake.preplumed b/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake.preplumed deleted file mode 100644 index 22da2adc01..0000000000 --- a/patches/gromacs-2023.diff/cmake/gmxVersionInfo.cmake.preplumed +++ /dev/null @@ -1,471 +0,0 @@ -# -# This file is part of the GROMACS molecular simulation package. -# -# Copyright 2014- 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. - -# Sets version information variables and provides CMake functions for -# generating files based on them -# -# The following variables are derived from variables initialized by -# https://cmake.org/cmake/help/latest/command/project.html#command:project -# GMX_VERSION_MAJOR Major version number. -# GMX_VERSION_PATCH Patch version number. -# Should always be defined: zero for, e.g., 2016. -# -# This script provides the following basic version variables that need to be -# maintained manually: -# GMX_VERSION_SUFFIX String suffix to add to numeric version string. -# "-dev" is automatically added when not building from a source package, -# and does not need to be kept here. This mechanism is not quite enough -# for building a tarball, but setting the CMake cache variable -# GMX_BUILD_TARBALL=on will suppress the addition of "-dev" to the -# version string. -# LIBRARY_SOVERSION_MAJOR so major version for the built libraries. -# Should be increased for each binary incompatible release. In GROMACS, -# the typical policy is to increase it at the start of the development -# cycle for each major/minor version change, but not for patch releases, -# even if the latter may not always be fully binary compatible. -# Table of historical values -# GROMACS 5.0 0 -# GROMACS 5.1 1 -# GROMACS 2016 2 -# GROMACS 2018 3 -# GROMACS 2019 4 -# GROMACS 2020 5 -# GROMACS 2021 6 -# GROMACS 2022 7 -# GROMACS 2023 8 -# LIBRARY_SOVERSION_MINOR so minor version for the built libraries. -# Should be increased for each release that changes only the implementation. -# In GROMACS, the typical policy is to increase it for each patch version -# change, even if they may not always be fully binary compatible. -# If it is somehow clear that the ABI implementation has not changed -# in a patch release, this variable should not increase. Release candidate -# and beta versions will not increase this number, since nobody should -# write code against such versions. -# LIBRARY_VERSION Full library version. -# REGRESSIONTEST_BRANCH For builds not from source packages, name of the -# regressiontests branch at gerrit.gromacs.org whose HEAD can test this -# code, *if* this code is recent enough (i.e., contains all changes from -# the corresponding code branch that affects the regression test -# results). Even after a release branch is forked for the source -# repository, the correct regressiontests branch can still be main, -# because we do not fork it until behaviour needs to change. -# REGRESSIONTEST_MD5SUM -# The MD5 checksum of the regressiontest tarball. Only used when building -# from a source package. -# GMX_SOURCE_DOI_ID -# ID collected from Zenodo connected to the doi for a released version -# used to identify the source when building an official released version. -# This ID is used for the source code tarball. -# GMX_MANUAL_DOI_ID -# Same as above, but for the reference manual. -# They are collected into a single section below. -# The following variables are set based on these: -# GMX_VERSION String composed from GMX_VERSION_* numeric variables -# above. Example: 4.6.1, 5.0, 2016 -# GMX_VERSION_STRING String with GMX_VERSION suffixed with the given -# suffix and possibly "-dev" for builds not from a source package. -# GMX_VERSION_NUMERIC Numeric version number (e.g., 40601 for 4.6.1, 20160001 for 2016.1). -# GMX_API_VERSION Numeric API version. -# This is currently set automatically to GMX_VERSION_NUMERIC, but may -# become manually maintained in the future if there will be releases -# where the API does not change, but programs/libraries do. -# In such a case, this should be the first version where the current API -# appeared. -# REGRESSIONTEST_VERSION For source packages, version number of the -# matching regressiontests tarball. Not used for builds not from source -# packages. -# The latter two are used to generate gromacs/version.h to allow software -# written against the GROMACS API to provide some #ifdef'ed code to support -# multiple GROMACS versions. -# -# This script also declares machinery to generate and obtain version -# information from a git repository. This is enabled by default if the source -# tree is a git, but can be disabled with -# GMX_GIT_VERSION_INFO Advanced CMake variable to disable git -# version info generation. -# If the version generation is disabled, then the source and manual doi -# will be based on the stored values for the ID. -# The main interface to this machinery is the gmx_configure_version_file() -# CMake function. The signature is -# gmx_configure_version_file( -# [REMOTE_HASH] -# [TARGET ] -# [COMMENT ]) -# Specify the input and output files as for configure_file(). -# The configuration is done with configure_file(... @ONLY) with -# the following variables defined (as well as all the -# GMX_VERSION* variables from above): -# GMX_VERSION_STRING_FULL -# GMX_VERSION_FULL_HASH -# GMX_VERSION_CENTRAL_BASE_HASH -# The output file is created during build time, so any dependent -# targets should specify it as a dependency. -# REMOTE_HASH Currently, this has no effect, but it signifies that the -# file is using the CENTRAL_BASE_HASH variable. -# This variable is much more expensive to initialize than the -# others, so this allows local changes in this file to only -# compute that value when required if that becomes necessary. -# TARGET By default, this function uses add_custom_command() to -# generate the output file. If TARGET is specified, then -# add_custom_target() is used to create a target with the given -# name that runs this custom command. Use this if -# the same file will be used for multiple downstream targets, -# or if the explicit target for the file is otherwise -# necessary. -# COMMENT Set a custom comment to be shown when building the rule -# (see add_custom_command(... COMMENT )). -# As an alternative to using this script, also the following variables are -# provided (can be useful when generating more complex CMake scripts that do -# build-time tasks): -# VERSION_INFO_CMAKE_SCRIPT -# Absolute path to a CMake script that can be included using include() -# to declare the GMX_VERSION_* variables documented for -# gmx_configure_version_file(). -# VERSION_INFO_DEPS -# If a custom command depends on VERSION_INFO_CMAKE_SCRIPT, then it -# should add ${VERSION_INFO_DEPS} to its DEPENDS list to get the -# appropriate dependencies. -# TODO: If someone wants to add a custom target that depends on -# VERSION_INFO_CMAKE_SCRIPT, a separate variable may be needed for those -# dependencies. -# -# The version string printed by 'gmx -version' (and also printed in the startup -# header) can provide useful information for, e.g., diagnosing bug reports and -# identifying what exact version the user was using. The following formats are -# possible (with examples given for a particular version): -# 2018.1 Plain version number without any suffix signifies a build from -# a released source tarball. -# 2018.1-dev '-dev' suffix signifies all other builds. If there is no other -# information, either the user built the code outside any git -# repository, or disabled the version info generation. -# 2018.1-dev-YYYYMMDD-1234abc -# The YYYYMMDD part shows the commit date (not author date) of -# the HEAD commit from which the code was built. The abbreviated -# hash is the hash of that commit (the full hash is available in -# 'gmx -version' output). -# If the HEAD hash is not identified as coming from branches in -# "authoritative" GROMACS repositories, 'gmx -version' will show -# the nearest ancestor commit that is identified as such (but see -# the '-local' and '-unknown' suffixes below). -# 2018.1-dev-YYYYMMDD-1234abc-dirty -# As above, but there were local modifications in the source tree -# when the code was built. -# 2018.1-dev-YYYYMMDD-1234abc-unknown -# As above, but there were no remotes in the repository that -# could be identified as "authoritative" GROMACS repositories. -# This happens if the code is not cloned from git.gromacs.org -# or gerrit.gromacs.org. -# 2018.1-dev-YYYYMMDD-1234abc-local -# As above, but there were no commits in the recent history of -# the branch that could be identified as coming from -# "authoritative" GROMACS repositories. This should be -# relatively rare. -# -# Other variables set here are not intended for use outside this file. -# The scripts gmxGenerateVersionInfo.cmake and gmxConfigureVersionInfo.cmake -# are used internally by this machinery, as well as VersionInfo.cmake.cmakein. - -##################################################################### -# Derived version info. -# Ref https://cmake.org/cmake/help/latest/command/project.html#command:project -set(GMX_VERSION_MAJOR ${Gromacs_VERSION_MAJOR}) -set(GMX_VERSION_PATCH ${Gromacs_VERSION_MINOR}) - -##################################################################### -# Manually maintained version info - -# The suffix is used mainly for betas and release -# candidates, where it signifies the most recent such release from -# this branch; it will be empty before the first such release, as well -# as after the final release is out. -set(GMX_VERSION_SUFFIX "") - -# Conventionally with libtool, any ABI change must change the major -# version number, the minor version number should change if it's just -# the implementation that has been altered, and the third number -# counts the number of old major versions that will still run if -# linked to this library (i.e. it is not a patch number). See the -# above descriptions of LIBRARY_SOVERSION_* for policy for changes -# here. The important thing is to minimize the chance of third-party -# code being able to dynamically link with a version of libgromacs -# that might not work. -set(LIBRARY_SOVERSION_MAJOR 8) -set(LIBRARY_SOVERSION_MINOR 0) -set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0) - -##################################################################### -# General version management based on manually set numbers - -if (GMX_VERSION_PATCH) - set(GMX_VERSION "${GMX_VERSION_MAJOR}.${GMX_VERSION_PATCH}") -else() - set(GMX_VERSION "${GMX_VERSION_MAJOR}") -endif() -# Set REGRESSIONTEST_VERSION before further modification to version info. -set(REGRESSIONTEST_VERSION "${GMX_VERSION}${GMX_VERSION_SUFFIX}") - -# Initialize version string. -# Note: Forks that use the suffixing feature later change GMX_VERSION_STRING -# Ref: https://gitlab.com/gromacs/gromacs/-/merge_requests/2587 -set(GMX_VERSION_STRING "${REGRESSIONTEST_VERSION}") -set(REGRESSIONTEST_BRANCH "release-2023") -# Follow the relevant part of the release checklist at -# https://gitlab.com/gromacs/gromacs/-/wikis/Release-checklist#how-to-build-a-regressiontests-tarball -# in order to have it build the regressiontests tarball with all the -# right version naming. The version number and suffix goes into the -# directory name within the regressiontests tarball, which affects the -# md5sum of the tarball. The matching md5sum has to go here, and if it -# isn't right the real release workflow will report a failure. -set(REGRESSIONTEST_MD5SUM "f697cb2624e332aa6a4ea990990a4682" CACHE INTERNAL "MD5 sum of the regressiontests tarball for this GROMACS version") - -# If you are making a custom fork of GROMACS, please describe your -# fork, perhaps with its version number, in the value of -# GMX_VERSION_STRING_OF_FORK here. This string will appear in the -# header of log files that mdrun writes. This will help you, your -# users, your system administrators, your maintainers and the -# maintainers of GROMACS core understand how to troubleshoot and -# reproduce potential problems. -# -# If you are distributing a patch to GROMACS, then this change would -# be great as part of your patch. Otherwise for personal use, you can -# also just set a CMake cache variable. -set(GMX_VERSION_STRING_OF_FORK "" CACHE INTERNAL - "Version string for forks of GROMACS to set to describe themselves") -mark_as_advanced(GMX_VERSION_STRING_OF_FORK) -if (GMX_VERSION_STRING_OF_FORK) - # Remove dashes from GMX_VERSION_STRING_OF_FORK to avoid confusing pkg-config. Issue #4363 - string(REPLACE "-" "_" _VERSION_STRING_OF_FORK_CLEAN "${GMX_VERSION_STRING_OF_FORK}") - set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-${_VERSION_STRING_OF_FORK_CLEAN}") -endif() - -option(GMX_BUILD_TARBALL "Build tarball without -dev version suffix" OFF) -mark_as_advanced(GMX_BUILD_TARBALL) -if (NOT SOURCE_IS_SOURCE_DISTRIBUTION AND - NOT GMX_BUILD_TARBALL) - set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-dev") -endif() - -math(EXPR GMX_VERSION_NUMERIC - "${GMX_VERSION_MAJOR}*10000 + ${GMX_VERSION_PATCH}") -set(GMX_API_VERSION ${GMX_VERSION_NUMERIC}) - -# Set those values only in release versions, after getting the identifiers -# from Zenodo for the manual and source code -# Has to be done by hand before every final release -# Use force to override anything given as a cmake command line input -# Actual input depends on the GMX_VERSION_STRING_OF_FORK variable being set or not. -# If it is set, we always default to an empty string, otherwise to the value set for the release build. -if (GMX_VERSION_STRING_OF_FORK) - set(GMX_MANUAL_DOI_INTERNAL "") - set(GMX_SOURCE_DOI_INTERNAL "") -else() - set(GMX_MANUAL_DOI_INTERNAL "10.5281/zenodo.7588711") # Set correct doi string here - set(GMX_SOURCE_DOI_INTERNAL "10.5281/zenodo.7588619") # Set correct doi string here -endif() -set(GMX_MANUAL_DOI ${GMX_MANUAL_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS manual" FORCE) -set(GMX_SOURCE_DOI ${GMX_SOURCE_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS source code" FORCE) - -##################################################################### -# git version info management - -# There can be clusters where git and CMake can run on nodes where the other is -# not available, accessing the same source tree. -# Should be unlikely, but doesn't hurt to check. -set(_git_info_default OFF) -if (SOURCE_IS_GIT_REPOSITORY) - find_package(Git) - if (GIT_FOUND) - set(_git_info_default ON) - endif() -endif() -option(GMX_GIT_VERSION_INFO "Generate git version information" ${_git_info_default}) -mark_as_advanced(GMX_GIT_VERSION_INFO) -# Detect preconditions for version info generation if it is requested. -if (GMX_GIT_VERSION_INFO) - if (NOT SOURCE_IS_GIT_REPOSITORY) - message(FATAL_ERROR - "Cannot generate git version information from source tree not under git. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() - # We need at least git v1.5.3 be able to parse git's date output. - if (NOT GIT_FOUND OR GIT_VERSION_STRING VERSION_LESS "1.5.3") - message(FATAL_ERROR - "No compatible git version found (>= 1.5.3 required). " - "Won't be able to generate development version information. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() -endif() - -include(gmxCustomCommandUtilities) -include(FindPythonModule) -# The first two are also for use outside this file, encapsulating the details -# of how to use the generated VersionInfo.cmake. -set(VERSION_INFO_CMAKE_FILE ${PROJECT_BINARY_DIR}/VersionInfo.cmake) -set(VERSION_INFO_DEPS ${VERSION_INFO_CMAKE_FILE}) -# Capture the location of the necessary files in internal variables for use in -# the function below. -set(VERSION_INFO_CMAKEIN_FILE ${CMAKE_CURRENT_LIST_DIR}/VersionInfo.cmake.cmakein) -set(VERSION_INFO_CONFIGURE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/gmxConfigureVersionInfo.cmake) - -# Rules to create the VersionInfo.cmake file. -# For git info, the sequence is: -# 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo-partial.cmake.cmakein -# - Set all variables that are known at configure time. -# 2. (build time) VersionInfo-partial.cmake.cmakein -> VersionInfo.cmake -# - Set variables that may change as result of repository state changes -# (i.e., everything that requires running git). -# - Runs every time as a git-version-info target, but the output file -# timestamp only changes if its contents actually change. -# - Depending on the native build system, this may run once per build -# or once per each time it is required for step 3. -# 3. (build time) VersionInfo.cmake -> other files -# - Set variables in files specified with gmx_configure_version_file() -# using the values generated in step 2. -# - Each file runs as a custom command that depends on the previous -# steps, and runs only if the VersionInfo.cmake file is newer than the -# output file. -# Without git info, the sequence is: -# 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo.cmake -# - Everything is known at configure time, so the output is generated -# immediately with all variables set (git info will be empty). -# 2. (build time) VersionInfo.cmake -> other files -# - As with git info, processes files from gmx_configure_version_file(). -# - These are again custom commands that depend on the output from -# step 1, so they get regenerated only when the static version info -# changes. -# -# Note that VersionInfo-partial.cmake is also used to transfer version -# information between GitLab CI jobs for release and documentation builds. - -# Configure information known at this time into a partially filled -# version info file. -set(VERSION_INFO_CMAKEIN_FILE_PARTIAL - ${PROJECT_BINARY_DIR}/VersionInfo-partial.cmake.cmakein) -# Leave these to be substituted by the targets below. -set(GMX_VERSION_STRING_FULL "\@GMX_VERSION_STRING_FULL\@") - -if (GMX_GIT_VERSION_INFO) - # Leave these to be substituted by the custom target below. - # Specific for building from git. - set(GMX_VERSION_FULL_HASH "\@GMX_VERSION_FULL_HASH\@") - set(GMX_VERSION_CENTRAL_BASE_HASH "\@GMX_VERSION_CENTRAL_BASE_HASH\@") - # If generating the version info, create a target that runs on every build - # and does the actual git calls, storing the results into a CMake script. - # This needs to be run at build time to update the version information - # properly when the git hash changes, but the build system does not. - # All targets added by gmx_configure_version_file() use the information - # from this script to get their variables from, removing the need to run - # git multiple times and simplifying reuse for other purposes. - gmx_add_custom_output_target(git-version-info RUN_ALWAYS - OUTPUT ${VERSION_INFO_CMAKE_FILE} - COMMAND ${CMAKE_COMMAND} - -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -D PROJECT_VERSION=${GMX_VERSION_STRING} - -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} - -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE} - -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating git version information") - list(APPEND VERSION_INFO_DEPS git-version-info) -else() - # Leave these to be substituted by the custom target below. - # Specific for building from source tarball. - gmx_add_custom_output_target(release-version-info RUN_ALWAYS - OUTPUT ${VERSION_INFO_CMAKE_FILE} - COMMAND ${CMAKE_COMMAND} - -D PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} - -D PROJECT_VERSION=${GMX_VERSION_STRING} - -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} - -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE} - -D VERSION_STRING_OF_FORK=${GMX_VERSION_STRING_OF_FORK} - -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfoWithoutGit.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating release version information") - list(APPEND VERSION_INFO_DEPS release-version-info) -endif() -configure_file(${VERSION_INFO_CMAKEIN_FILE} - ${VERSION_INFO_CMAKEIN_FILE_PARTIAL} - @ONLY) -unset(GMX_VERSION_STRING_FULL) -unset(GMX_VERSION_FULL_HASH) -unset(GMX_VERSION_CENTRAL_BASE_HASH) - -# The main user-visible interface to the machinery. -# See documentation at the top of the script. -function (gmx_configure_version_file INFILE OUTFILE) - include(CMakeParseArguments) - set(_options REMOTE_HASH) - set(_one_value_args COMMENT TARGET) - set(_multi_value_args EXTRA_VARS) - cmake_parse_arguments( - ARG "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) - if (ARG_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}") - endif() - # Some callers may pass partial paths that do not really make sense, - # so create a default comment that only contains the actual file name. - get_filename_component(_basename ${OUTFILE} NAME) - set(_comment "Generating ${_basename}") - if (ARG_COMMENT) - set(_comment ${ARG_COMMENT}) - endif() - # Mimic configure_file() - if (NOT IS_ABSOLUTE ${INFILE}) - set(INFILE ${CMAKE_CURRENT_SOURCE_DIR}/${INFILE}) - endif() - # Create command-line definitions for the requested variables - set(_extra_var_defines) - foreach(_var ${ARG_EXTRA_VARS}) - list(APPEND _extra_var_defines -D "${_var}=${${_var}}") - endforeach() - # The touch command is necessary to ensure that after the target is run, - # the timestamp is newer than in the input files. - add_custom_command(OUTPUT ${OUTFILE} - COMMAND ${CMAKE_COMMAND} - -D VERSION_VARIABLES=${VERSION_INFO_CMAKE_FILE} - -D VERSION_CMAKEIN=${INFILE} - -D VERSION_OUT=${OUTFILE} - ${_extra_var_defines} - -P ${VERSION_INFO_CONFIGURE_SCRIPT} - COMMAND ${CMAKE_COMMAND} -E touch ${OUTFILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${INFILE} ${VERSION_INFO_DEPS} ${VERSION_INFO_CONFIGURE_SCRIPT} - COMMENT "${_comment}" - VERBATIM) - if (ARG_TARGET) - add_custom_target(${ARG_TARGET} DEPENDS ${OUTFILE} VERBATIM) - gmx_set_custom_target_output(${ARG_TARGET} ${OUTFILE}) - endif() -endfunction() diff --git a/patches/patch.sh b/patches/patch.sh index 4a454077d0..c4d04b8f05 100755 --- a/patches/patch.sh +++ b/patches/patch.sh @@ -257,9 +257,10 @@ case "$action" in exit 1 fi fi - if [ -e Plumed.h -o -e Plumed.inc -o -e Plumed.cmake ] + if [ -e Plumed.h ] then - if ( type -t plumed_before_revert 1>/dev/null || type -t plumed_after_revert 1>/dev/null) && ( type -t plumed_before_patch 1>/dev/null || type -t plumed_after_patch 1>/dev/null) + if ( type -t plumed_before_revert 1>/dev/null || type -t plumed_after_revert 1>/dev/null) && \ + ( type -t plumed_before_patch 1>/dev/null || type -t plumed_after_patch 1>/dev/null) then echo "ERROR: you have likely already patched, and your patch seems to need to be reverted." echo "Revert first (-r)" @@ -268,32 +269,20 @@ case "$action" in echo "WARNING: you have likely already patched. Assuming that you can patch multiple times and continuing" fi fi - if [ ! -f "$PLUMED_ROOT/src/lib/Plumed.inc" ] - then - echo "ERROR: cannot find $PLUMED_ROOT/src/lib/Plumed.inc file" - echo "Compile plumed before patching" - exit 1 - fi - if [ ! -f "$PLUMED_ROOT/src/lib/Plumed.cmake.$mode" ] - then - echo "ERROR: cannot find $PLUMED_ROOT/src/lib/Plumed.cmake.$mode file" - echo "Compile a $mode version of plumed before patching, or change patching mode [static|shared|runtime]" - exit 1 - fi if type -t plumed_before_patch 1>/dev/null ; then test -n "$quiet" || echo "Executing plumed_before_patch function" plumed_before_patch fi if test -n "$include" ; then - test -n "$quiet" || echo "Including Plumed.h, Plumed.inc, and Plumed.cmake ($mode mode)" + test -n "$quiet" || echo "Including Plumed.h ($mode mode)" echo "#include \"$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h\"" > Plumed.h - echo "include $PLUMED_ROOT/src/lib/Plumed.inc.$mode" > Plumed.inc - echo "include($PLUMED_ROOT/src/lib/Plumed.cmake.$mode)" > Plumed.cmake + # echo "include $PLUMED_ROOT/src/lib/Plumed.inc.$mode" > Plumed.inc + # echo "include($PLUMED_ROOT/src/lib/Plumed.cmake.$mode)" > Plumed.cmake else - test -n "$quiet" || echo "Linking Plumed.h, Plumed.inc, and Plumed.cmake ($mode mode)" + test -n "$quiet" || echo "Linking Plumed.h ($mode mode)" ln -fs "$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h" Plumed.h - ln -fs "$PLUMED_ROOT/src/lib/Plumed.inc.$mode" Plumed.inc - ln -fs "$PLUMED_ROOT/src/lib/Plumed.cmake.$mode" Plumed.cmake + # ln -fs "$PLUMED_ROOT/src/lib/Plumed.inc.$mode" Plumed.inc + # ln -fs "$PLUMED_ROOT/src/lib/Plumed.cmake.$mode" Plumed.cmake fi if [ -d "$diff" ]; then @@ -351,9 +340,9 @@ case "$action" in fi ;; (save) - if [ ! -e Plumed.h -o ! -e Plumed.inc -o ! -e Plumed.cmake ] + if [ ! -e Plumed.h ] then - echo "ERROR: I cannot find Plumed.h, Plumed.inc, and Plumed.cmake files. You have likely not patched yet." + echo "ERROR: I cannot find Plumed.h file. You have likely not patched yet." exit 1 fi PREPLUMED=$(find . -name "*.preplumed" | sort) @@ -436,12 +425,12 @@ EOF test -n "$quiet" || echo "Executing plumed_before_revert function" plumed_before_revert fi - if [ ! -e Plumed.h -o ! -e Plumed.inc -o ! -e Plumed.cmake ] + if [ ! -e Plumed.h ] then - echo "WARNING: I cannot find Plumed.h, Plumed.inc, and Plumed.cmake files. You have likely not patched yet." + echo "WARNING: I cannot find Plumed.h files. You have likely not patched yet." else - test -n "$quiet" || echo "Removing Plumed.h, Plumed.inc, and Plumed.cmake" - rm Plumed.h Plumed.inc Plumed.cmake + test -n "$quiet" || echo "Removing Plumed.h" + rm Plumed.h fi PREPLUMED=$(find . -name "*.preplumed") if ! test "$PREPLUMED" ; then diff --git a/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 b/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 index ac9925473c..4df0bbaab7 100644 --- a/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 +++ b/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 @@ -18,19 +18,21 @@ SUBROUTINE plugin_ext_forces() USE plugin_flags ! USE cell_base, ONLY : alat, at - USE ions_base, ONLY : tau, nat,amass + USE ions_base, ONLY : tau, nat, amass, ityp USE force_mod, ONLY : force,sigma USE control_flags, ONLY : istep USE ener, ONLY : etot ! IMPLICIT NONE ! - INTEGER:: i,j + INTEGER:: i,j,ia REAL(DP) :: at_plumed(3,3) REAL(DP) :: virial(3,3) REAL(DP) :: volume REAL(DP), ALLOCATABLE :: tau_plumed(:,:) + REAL(DP) :: masses_plumed(nat) ! + masses_plumed = 0.0_DP IF(use_plumed) then IF(ionode)THEN at_plumed=alat*at; ! the cell, rescaled properly @@ -43,9 +45,12 @@ SUBROUTINE plugin_ext_forces() -at_plumed(1,2)*at_plumed(3,3)*at_plumed(2,1) & -at_plumed(1,3)*at_plumed(3,1)*at_plumed(2,2) virial=-sigma*volume - + ! the masses in QE are stored per type, see q-e//Modules/ions_base.f90 + do ia=1,nat + masses_plumed(ia)=amass(ityp(ia)) + end do CALL plumed_f_gcmd("setStep"//char(0),istep) - CALL plumed_f_gcmd("setMasses"//char(0),amass) + CALL plumed_f_gcmd("setMasses"//char(0),masses_plumed) CALL plumed_f_gcmd("setForces"//char(0),force) CALL plumed_f_gcmd("setPositions"//char(0),tau_plumed) CALL plumed_f_gcmd("setBox"//char(0),at_plumed) diff --git a/patches/qespresso-7.0.diff/CMakeLists.txt b/patches/qespresso-7.0.diff/CMakeLists.txt new file mode 100644 index 0000000000..ff573a12b5 --- /dev/null +++ b/patches/qespresso-7.0.diff/CMakeLists.txt @@ -0,0 +1,845 @@ +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) +# CMake < 3.13 cannot install external targets: +# https://gitlab.kitware.com/cmake/cmake/merge_requests/2152 + +# CMake < 3.14 generates incorrect dependency graphs with +# alias targets: +# https://gitlab.kitware.com/cmake/cmake/merge_requests/2521 + +# CMake < 3.20 does not support NVHPC compiler id +# https://cmake.org/cmake/help/latest/release/3.20.html#compilers + +# Policy CMP0048: The project() command manages VERSION variables +set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) + +project(qe + VERSION 7.0 + DESCRIPTION "ESPRESSO: opEn-Source Package for Research in Electronic Structure, Simulation, and Optimization" + LANGUAGES Fortran C CXX) +#added CXX to load plumed libraries + +if(${qe_BINARY_DIR} STREQUAL ${qe_SOURCE_DIR}) + message(FATAL_ERROR "QE source folder cannot be safely used as a build folder!") +endif() + +# CMake < v3.18 cannot discover the ARM Performance Library +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") + if(CMAKE_VERSION VERSION_LESS 3.18.0) + message("-- CMake versions less than 3.18 cannot automatically discover the ARM Performance Library!") + endif() +endif() + +########################################################## +# Define the paths for static libraries and executables +########################################################## +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${qe_BINARY_DIR}/lib + CACHE + PATH "Single output directory for building all libraries.") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${qe_BINARY_DIR}/bin + CACHE + PATH "Single output directory for building all executables.") + +########################################################### +# Build helpers +########################################################### +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") +include(cmake/qeHelpers.cmake) + +########################################################### +# Build Type +# Ensure that a specific, default build type is set when +# none has been explicitly set by the user +########################################################### +qe_ensure_build_type("Release") + +########################################################### +# Modules +########################################################### +include(CheckFunctionExists) +# Must use GNUInstallDirs to install libraries into correct +# locations on all platforms. +include(GNUInstallDirs) + +########################################################### +# Build Options +########################################################### +include(CMakeDependentOption) +option(QE_ENABLE_CUDA + "enable CUDA acceleration on NVIDIA GPUs" OFF) +if(QE_ENABLE_CUDA) + option(QE_ENABLE_OPENACC "enable OpenACC acceleration" ON) + option(QE_ENABLE_LAXLIB_CUSOLVER + "enable CUDA solver acceleration for LAXLib on NVIDIA GPUs" ON) + # OpenMP enabled by default if CUDA is enable + option(QE_ENABLE_OPENMP + "enable distributed execution support via OpenMP" ON) +else() + option(QE_ENABLE_OPENACC "enable OpenACC acceleration" OFF) + option(QE_ENABLE_OPENMP + "enable distributed execution support via OpenMP" OFF) +endif() +option(QE_ENABLE_MPI + "enable distributed execution support via MPI" ON) +option(QE_ENABLE_MPI_GPU_AWARE + "enable GPU aware MPI operations" OFF) +option(QE_ENABLE_TEST + "enable unit and system tests" ON) +cmake_dependent_option(QE_ENABLE_BENCHMARK + "enable benchmark tests" OFF "QE_ENABLE_TEST" OFF) +option(QE_ENABLE_TRACE + "enable execution tracing output" OFF) +option(QE_ENABLE_PROFILE_NVTX + "enable execution of NVIDIA NVTX profiler plugin" OFF) +option(QE_ENABLE_MPI_INPLACE + "enable inplace MPI calls (ignored when QE_ENABLE_MPI=OFF)" OFF) +option(QE_ENABLE_MPI_MODULE + "use MPI via Fortran module instead of mpif.h header inclusion" OFF) +option(QE_ENABLE_BARRIER + "enable global synchronization between execution units" OFF) +option(QE_LAPACK_INTERNAL + "enable internal reference LAPACK" OFF) +option(QE_ENABLE_SCALAPACK + "enable SCALAPACK execution units" OFF) +option(QE_ENABLE_ELPA + "enable ELPA execution units" OFF) +option(QE_ENABLE_LIBXC + "enable LIBXC execution units" OFF) +option(QE_ENABLE_HDF5 + "enable HDF5 data collection" OFF) +option(QE_ENABLE_STATIC_BUILD + "enable fully static build of executables" OFF) +option(QE_ENABLE_DOC + "enable documentation building" OFF) +set(QE_FFTW_VENDOR "AUTO" CACHE + STRING "select a specific FFTW library [Intel_DFTI, Intel_FFTW3, ArmPL, IBMESSL, FFTW3, Internal]") +set(QE_ENABLE_SANITIZER "none" CACHE STRING "none,asan,ubsan,tsan,msan") + +# TODO change all ifdefs throughout code base to match +# cmake options +# TODO symbols beginning with '__' followed by a capital +# character are reserved for standard library use (at +# least in C, not sure about Fortran), change all feature +# macros to avoid weird behaviors + +# Disable all configuration headers used to be generated +# by configure (see /include/) +qe_add_global_compile_definitions(QE_NO_CONFIG_H) + +if(QE_ENABLE_CUDA) + qe_add_global_compile_definitions(__CUDA) +endif() +if(QE_ENABLE_TRACE) + qe_add_global_compile_definitions(__TRACE) +endif() +if(QE_ENABLE_PROFILE_NVTX) + qe_add_global_compile_definitions(__PROFILE_NVTX) +endif() +if(QE_ENABLE_MPI_INPLACE) + qe_add_global_compile_definitions(__USE_INPLACE_MPI) +endif() +if(QE_ENABLE_MPI_MODULE) + qe_add_global_compile_definitions(__MPI_MODULE) +endif() +if(QE_ENABLE_BARRIER) + qe_add_global_compile_definitions(__USE_BARRIER) +endif() +if(QE_ENABLE_MPI) + # OMPI_SKIP_MPICXX: skip CXX APIs on openmpi, cause trouble to C APIs + qe_add_global_compile_definitions(__MPI OMPI_SKIP_MPICXX) + if(QE_ENABLE_MPI_GPU_AWARE) + qe_add_global_compile_definitions(__GPU_MPI) + endif() +endif() +if(QE_ENABLE_SCALAPACK) + qe_add_global_compile_definitions(__SCALAPACK) +endif() +if(QE_ENABLE_HDF5) + qe_add_global_compile_definitions(__HDF5) +endif() + +# Feature checks +check_function_exists(mallinfo HAVE_MALLINFO) +if(HAVE_MALLINFO) + qe_add_global_compile_definitions(HAVE_MALLINFO) +endif() + +# Check options consistency +if(QE_ENABLE_STATIC_BUILD AND BUILD_SHARED_LIBS) + message(FATAL_ERROR "Full static build of QE executables requires static QE internal libraries. QE_ENABLE_STATIC_BUILD and BUILD_SHARED_LIBS cannot be both ON") +endif() +if(QE_ENABLE_ELPA AND NOT QE_ENABLE_SCALAPACK) + message(FATAL_ERROR "ELPA requires SCALAPACK support, enable it with '-DQE_ENABLE_SCALAPACK=ON' or disable ELPA with '-DQE_ENABLE_ELPA=OFF'") +endif() +if(QE_ENABLE_SCALAPACK AND NOT QE_ENABLE_MPI) + message(FATAL_ERROR "SCALAPACK requires MPI support, enable it with '-DQE_ENABLE_MPI=ON' or disable SCALAPACK with '-DQE_ENABLE_SCALAPACK=OFF'") +endif() +if(QE_ENABLE_CUDA AND NOT (CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")) + message(FATAL_ERROR "NVHPC compiler is mandatory when CUDA is enabled due QE is based on CUDA Fortran language") +endif() +if(QE_ENABLE_OPENACC AND NOT (CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")) + message(FATAL_ERROR "NVHPC compiler is mandatory when OpenACC is enabled") +endif() +if(QE_ENABLE_MPI_GPU_AWARE AND NOT (QE_ENABLE_CUDA AND QE_ENABLE_MPI)) + message(FATAL_ERROR "GPU aware MPI requires both MPI and CUDA features enabled") +endif() +if(QE_ENABLE_LAXLIB_CUSOLVER AND (NOT QE_ENABLE_CUDA)) + message(FATAL_ERROR "CUDA Solver for LAXLib requires CUDA support, enable it with '-DQE_ENABLE_CUDA=ON' or disable CUDA Solver for LAXLib with '-DQE_ENABLE_LAXLIB_CUSOLVER=OFF'") +endif() +# if(QE_ENABLE_HDF5 AND NOT QE_ENABLE_MPI) +# message(FATAL_ERROR "HDF5 requires MPI support, enable it with '-DQE_ENABLE_MPI=ON' or disable HDF5 with '-DQE_ENABLE_HDF5=OFF'") +# endif() + +# Add optional sanitizers ASAN, UBSAN, MSAN +set(VALID_SANITIZERS "none" "asan" "ubsan" "tsan" "msan") +# Perform sanitizer option check, only works in debug mode +if(NOT QE_ENABLE_SANITIZER IN_LIST VALID_SANITIZERS) + message(FATAL_ERROR "Invalid -DQE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER}, value must be one of ${VALID_SANITIZERS}") +else() + message(STATUS "Enable sanitizer QE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER}") +endif() +# only GNU works right now +if(NOT QE_ENABLE_SANITIZER STREQUAL "none" AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + message(FATAL_ERROR "-DQE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER} only works with the GNU compiler") +endif() + + +############################################################ +# C preprocessor +# Note: reply on the compiler preprocessor whenever possible +############################################################ +if(DEFINED ENV{CPP}) + set(QE_CPP_DEFAULT $ENV{CPP}) +else() + set(QE_CPP_DEFAULT cpp) +endif() +# QE_CPP_DEFAULT is only effective when cached QE_CPP doesn't exist. +set(QE_CPP ${QE_CPP_DEFAULT} CACHE + STRING "C preprocessor for qe_preprocess_source in qeHelpers.cmake") +find_program(QE_CPP_FULL_PATH NAMES ${QE_CPP} DOC "C preprocessor full path") +if(QE_CPP_FULL_PATH) + message(STATUS "C preprocessor used by qe_preprocess_source in qeHelpers.cmake: ${QE_CPP_FULL_PATH}") +else() + set(QE_CPP_SAVED ${QE_CPP}) + unset(QE_CPP CACHE) + message(FATAL_ERROR "C preprocessor ${QE_CPP_SAVED} not found. Pass a working one to CMake via QE_CPP!") +endif() + +########################################################### +# language standard requirements +########################################################### +# TODO need to require all compilers using the same one +if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + set(CMAKE_C_STANDARD 11) + set(CMAKE_C_STANDARD_REQUIRED ON) + set(CMAKE_C_EXTENSIONS OFF) +endif() + +########################################################### +# check Fortran compiler -isystem option support +########################################################### +include(CheckFortranCompilerFlag) +check_fortran_compiler_flag("-isystem ." Fortran_ISYSTEM_SUPPORTED) +if(NOT Fortran_ISYSTEM_SUPPORTED AND NOT DEFINED CMAKE_NO_SYSTEM_FROM_IMPORTED) + set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) +endif() + +############################################################ +# Compiler vendor specific options +############################################################ +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(GNUFortranCompiler) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + include(NVFortranCompiler) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "XL") + include(IBMFortranCompiler) +endif() + +if(QE_ENABLE_STATIC_BUILD) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") +endif() + +########################################################### +# CUDA +########################################################### +if(QE_ENABLE_CUDA OR QE_ENABLE_PROFILE_NVTX) + if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + add_library(CUDA::cufft INTERFACE IMPORTED) + set_target_properties(CUDA::cufft PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cufft") + add_library(CUDA::cublas INTERFACE IMPORTED) + set_target_properties(CUDA::cublas PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cublas") + add_library(CUDA::cusolver INTERFACE IMPORTED) + set_target_properties(CUDA::cusolver PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cusolver") + add_library(CUDA::curand INTERFACE IMPORTED) + set_target_properties(CUDA::curand PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=curand") + if(QE_ENABLE_PROFILE_NVTX) + add_library(CUDA::nvToolsExt INTERFACE IMPORTED) + set_target_properties(CUDA::nvToolsExt PROPERTIES INTERFACE_LINK_LIBRARIES "-cuda;libnvToolsExt.so") + set(CMAKE_REQUIRED_LIBRARIES "-cuda;libnvToolsExt.so") + check_function_exists(nvtxRangePushEx NVTX_FOUND) + unset(CMAKE_REQUIRED_LIBRARIES) + if(NOT NVTX_FOUND) + message(FATAL_ERROR "Check nvtxRangePushEx in libnvToolsExt.so failed") + endif() + endif() + else() + find_package(CUDAToolkit REQUIRED) + endif() +endif(QE_ENABLE_CUDA OR QE_ENABLE_PROFILE_NVTX) + +########################################################### +# OpenMP +# The following targets will be defined: +add_library(qe_openmp_fortran INTERFACE) +add_library(qe_openmp_c INTERFACE) +qe_install_targets(qe_openmp_fortran qe_openmp_c) +########################################################### +if(QE_ENABLE_OPENMP) + find_package(OpenMP REQUIRED Fortran C) + target_link_libraries(qe_openmp_fortran INTERFACE OpenMP::OpenMP_Fortran) + target_link_libraries(qe_openmp_c INTERFACE OpenMP::OpenMP_C) +endif(QE_ENABLE_OPENMP) + +########################################################### +# OpenACC +# The following targets will be defined: +add_library(qe_openacc_fortran INTERFACE) +add_library(qe_openacc_c INTERFACE) +qe_install_targets(qe_openacc_fortran qe_openacc_c) +########################################################### +if(QE_ENABLE_OPENACC) + if(CMAKE_VERSION VERSION_LESS 3.16.0) + message(FATAL_ERROR "CMake versions >= 3.16 required for QE_ENABLE_OPENACC=ON!") + endif() + find_package(OpenACC REQUIRED Fortran C) + target_link_libraries(qe_openacc_fortran INTERFACE OpenACC::OpenACC_Fortran) + target_link_libraries(qe_openacc_c INTERFACE OpenACC::OpenACC_C) + if(GPU_TARGET_COMPILE_OPTIONS) + target_compile_options(qe_openacc_fortran INTERFACE "${GPU_TARGET_COMPILE_OPTIONS}") + target_compile_options(qe_openacc_c INTERFACE "${GPU_TARGET_COMPILE_OPTIONS}") + endif() +endif(QE_ENABLE_OPENACC) + +########################################################### +# MPI +# The following targets will be defined: +add_library(qe_mpi_fortran INTERFACE) +qe_install_targets(qe_mpi_fortran) +########################################################### +if(QE_ENABLE_MPI) + find_package(MPI REQUIRED Fortran) + target_link_libraries(qe_mpi_fortran + INTERFACE MPI::MPI_Fortran) + message(STATUS "MPI settings used by CTest") + message(" MPIEXEC_EXECUTABLE : ${MPIEXEC_EXECUTABLE}") + message(" MPIEXEC_NUMPROC_FLAG : ${MPIEXEC_NUMPROC_FLAG}") + message(" MPIEXEC_PREFLAGS : ${MPIEXEC_PREFLAGS}") + string(REPLACE ";" " " MPIEXEC_PREFLAGS_PRINT "${MPIEXEC_PREFLAGS}") + message(" Tests run as : ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_PREFLAGS_PRINT} ") +endif(QE_ENABLE_MPI) + +########################################################### +# Git +########################################################### +find_package(Git 2.13 REQUIRED) +if(EXISTS ${qe_SOURCE_DIR}/.git) + message(STATUS "Source files are cloned from a git repository.") + set(IS_GIT_PROJECT 1) + include(GitInfo) +else() + message(STATUS "Source files are not cloned from a git repository.") +endif() + +########################################################### +# Lapack +# The following targets will be defined: +add_library(qe_lapack INTERFACE) +qe_install_targets(qe_lapack) +########################################################### +if(NOT QE_LAPACK_INTERNAL) + if(NOT BLA_VENDOR) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64.*") + message(STATUS "Trying to find LAPACK from Intel MKL") + if(QE_ENABLE_OPENMP) + SET(BLA_VENDOR Intel10_64lp) + else() + SET(BLA_VENDOR Intel10_64lp_seq) + endif() + find_package(LAPACK) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") + message(STATUS "Trying to find LAPACK from Intel MKL - 32bit") + SET(BLA_VENDOR Intel10_32) + find_package(LAPACK) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") + message(STATUS "Trying to find LAPACK from ARM Performance Library") + if(QE_ENABLE_OPENMP) + SET(BLA_VENDOR Arm_mp) + else() + SET(BLA_VENDOR Arm) + endif() + find_package(LAPACK) + endif() + if(NOT LAPACK_FOUND) + message(STATUS "Trying to find alternative LAPACK libraries") + SET(BLA_VENDOR All) + if(QE_ENABLE_OPENMP) + set(CMAKE_REQUIRED_LINK_OPTIONS ${OpenMP_Fortran_FLAGS}) + endif() + find_package(LAPACK) + unset(CMAKE_REQUIRED_LINK_OPTIONS) + endif() + else() + if(QE_ENABLE_OPENMP) + set(CMAKE_REQUIRED_LINK_OPTIONS ${OpenMP_Fortran_FLAGS}) + endif() + find_package(LAPACK) + unset(CMAKE_REQUIRED_LINK_OPTIONS) + endif() + if(LAPACK_FOUND) + list(APPEND _lapack_libs + ${BLAS_LIBRARIES} + ${BLAS_LINKER_FLAGS} + ${LAPACK_LIBRARIES} + ${LAPACK_LINKER_FLAGS}) + if(QE_ENABLE_OPENMP) + list(APPEND _lapack_libs ${OpenMP_Fortran_LIBRARIES}) + endif() + list(REMOVE_DUPLICATES "${_lapack_libs}") + message(STATUS "Found LAPACK: ${_lapack_libs}") + target_link_libraries(qe_lapack INTERFACE ${_lapack_libs}) + set(CMAKE_REQUIRED_LIBRARIES ${_lapack_libs}) + check_fortran_function_exists(zhpev ZHPEV_FOUND) + unset(CMAKE_REQUIRED_LIBRARIES) + if(NOT ZHPEV_FOUND) + unset(ZHPEV_FOUND CACHE) + message(FATAL_ERROR "Incomplete LAPACK! function zhpev not found!") + endif() + else() + message(FATAL_ERROR "Failed to find a complete set of external BLAS/LAPACK library by FindLAPACK. " + "Variables controlling FindLAPACK can be found at CMake online documentation. " + "Alternatively, '-DQE_LAPACK_INTERNAL=ON' may be used to enable reference LAPACK " + "at a performance loss compared to optimized libraries.") + endif() +else() + message(WARNING "Internal reference LAPACK is enabled! It is less performant than vendor optimized libraries.") + if(CMAKE_Fortran_COMPILER_ID MATCHES "XL") + message(FATAL_ERROR "IBM XL compilers cannot build internal LAPACK with QE " + "due to the conflict in flags for free vs fixed format. " + "Please use an optimized LAPACK or build internal reference LAPACK separately.") + endif() + message(STATUS "Installing LAPACK via submodule") + qe_git_submodule_update(external/lapack) + add_subdirectory(external/lapack) + target_link_libraries(qe_lapack INTERFACE lapack) + # make lapack ready for other external libraries like mbd + set(LAPACK_LIBRARIES lapack) +endif() + +########################################################### +# SCALAPACK +# The following targets will be defined: +add_library(qe_scalapack INTERFACE) +qe_install_targets(qe_scalapack) +########################################################### +if(QE_ENABLE_SCALAPACK) + find_package(SCALAPACK REQUIRED QUIET) + message(STATUS "Found SCALAPACK: ${SCALAPACK_LIBRARIES};${SCALAPACK_LINKER_FLAGS}") + target_link_libraries(qe_scalapack + INTERFACE + ${SCALAPACK_LIBRARIES} + ${SCALAPACK_LINKER_FLAGS}) +endif(QE_ENABLE_SCALAPACK) + +########################################################### +# ELPA +# The following targets will be defined: +add_library(qe_elpa INTERFACE) +qe_install_targets(qe_elpa) +########################################################### +if(QE_ENABLE_ELPA) + find_package(ELPA REQUIRED) + + # Check if ELPA version is compatible with QE + if(ELPA_VERSION VERSION_GREATER_EQUAL "2018.11") + set(QE_ELPA_DEFINITIONS __ELPA) + elseif(ELPA_VERSION VERSION_GREATER_EQUAL "2016.11") + set(QE_ELPA_DEFINITIONS __ELPA_2016) + elseif(ELPA_VERSION VERSION_GREATER_EQUAL "2015") + set(QE_ELPA_DEFINITIONS __ELPA_2015) + else() + message(FATAL_ERROR "ELPA verion ${ELPA_VERSION} is not supported.") + endif() + message(STATUS "Add ELPA flag : ${QE_ELPA_DEFINITIONS}") + qe_add_global_compile_definitions(${QE_ELPA_DEFINITIONS}) + + # Add link libraries and include directories + target_link_libraries(qe_elpa + INTERFACE + ${ELPA_LIBRARIES} + ${ELPA_LIBRARIES_DEP} + ${ELPA_LINKER_FLAGS} + qe_scalapack) + target_include_directories(qe_elpa + INTERFACE + ${ELPA_Fortran_MODS_DIR} + ${ELPA_INCLUDE_DIRS} + ${ELPA_INCLUDE_DIRS_DEP}) +endif(QE_ENABLE_ELPA) + +########################################################### +# LIBXC +## The following targets will be defined: +add_library(qe_external_libxc INTERFACE) +qe_install_targets(qe_external_libxc) +########################################################### +if(QE_ENABLE_LIBXC) + target_compile_definitions(qe_external_libxc INTERFACE "__LIBXC") + + find_package(Libxc 5.1.2 COMPONENTS Fortran) + if (NOT Libxc_FOUND) + message(STATUS "Libxc searching failed in CMake Module mode, trying Config mode") + find_package(Libxc 5.1.2 COMPONENTS Fortran CONFIG) + endif() + + if(${Libxc_FOUND}) + if (${Libxc_VERSION} VERSION_GREATER_EQUAL "5.1.2" ) + message(STATUS "Libxc version ${Libxc_VERSION} found.") + else() + message(FATAL_ERROR "Libxc version ${Libxc_VERSION} found. " + "CMake compilation of QE tested for libxc v5.1.2 or later only.") + endif() + target_link_libraries(qe_external_libxc INTERFACE Libxc::xcf03) + target_include_directories(qe_external_libxc INTERFACE ${Libxc_INCLUDE_DIR}) + target_compile_definitions(qe_external_libxc INTERFACE ${Libxc_DEFINITIONS}) + else() + message(FATAL_ERROR "Failed to find Libxc package (>=5.1.2) with Fortran enabled.") + endif() +endif(QE_ENABLE_LIBXC) + +########################################################### +# HDF5 +# The following targets will be defined: +add_library(qe_hdf5_fortran INTERFACE) +add_library(qe_hdf5_c INTERFACE) +qe_install_targets(qe_hdf5_fortran qe_hdf5_c) +########################################################### +if(QE_ENABLE_HDF5) + if(QE_ENABLE_MPI) + option(HDF5_PREFER_PARALLEL "Prefer parallel HDF5" ON) + endif() + if(QE_ENABLE_STATIC_BUILD) + set(HDF5_USE_STATIC_LIBRARIES TRUE) + endif() + find_package(HDF5 REQUIRED Fortran C) + if(NOT HDF5_FOUND) + message(FATAL_ERROR "HDF5 Fortran interface has not been found!") + endif() + + if (NOT HDF5_IS_PARALLEL OR NOT QE_ENABLE_MPI) + message(STATUS "Serial HDF5 enabled!") + qe_add_global_compile_definitions(__HDF5_SERIAL) + else() + message(STATUS "Parallel HDF5 enabled!") + endif() + + target_link_libraries(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_LIBRARIES} + ${HDF5_Fortran_HL_LIBRARIES}) + target_include_directories(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_INCLUDE_DIRS}) + target_compile_definitions(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_DEFINITIONS}) + + target_link_libraries(qe_hdf5_c + INTERFACE + ${HDF5_C_LIBRARIES} + ${HDF5_C_HL_LIBRARIES}) + target_include_directories(qe_hdf5_c + INTERFACE + ${HDF5_C_INCLUDE_DIRS}) + target_compile_definitions(qe_hdf5_c + INTERFACE + ${HDF5_C_DEFINITIONS}) +endif(QE_ENABLE_HDF5) + +########################################################### +# Plumed2 +find_package(Plumed2 REQUIRED) +########################################################### + +########################################################### +# Tests +# Any executable target marked as test runner via +# 'add_test()' will be run by the 'test' make target +########################################################### +if(QE_ENABLE_TEST) + include(cmake/unit_test.cmake) + enable_testing() +endif(QE_ENABLE_TEST) + +########################################################### +# PROFILERS LIBRARIES +# the target for profiler libray will be defined if +# some profiler is enabled +add_library(qe_ext_prof_tool INTERFACE) +qe_install_targets(qe_ext_prof_tool) +########################################################### +# this should work with nvfortran +if(QE_ENABLE_PROFILE_NVTX) + target_link_libraries(qe_ext_prof_tool + INTERFACE + CUDA::nvToolsExt) +endif(QE_ENABLE_PROFILE_NVTX) + +########################################################### +# Components +########################################################### +add_subdirectory(external) +add_subdirectory(FFTXlib) +add_subdirectory(UtilXlib) +add_subdirectory(Modules) +add_subdirectory(LAXlib) +add_subdirectory(XClib) +add_subdirectory(KS_Solvers) +add_subdirectory(dft-d3) +add_subdirectory(PW) +add_subdirectory(CPV) +add_subdirectory(atomic) +add_subdirectory(upflib) +add_subdirectory(COUPLE) +add_subdirectory(LR_Modules) +add_subdirectory(PHonon) +add_subdirectory(PP) +add_subdirectory(EPW) +add_subdirectory(GWW) +add_subdirectory(HP) +add_subdirectory(NEB) +add_subdirectory(PWCOND) +add_subdirectory(TDDFPT) +add_subdirectory(XSpectra) +add_subdirectory(QEHeat) +if(QE_ENABLE_DOC) + add_subdirectory(Doc) +endif() + +########################################################### +# Tests +########################################################### +if(QE_ENABLE_TEST) + message(STATUS "Enabling tests in test-suite") + add_subdirectory(test-suite) +endif() + +########################################################### +# Pkg-config +########################################################### +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/quantum_espresso.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/quantum_espresso.pc + @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/quantum_espresso.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +########################################################### +# Exports +########################################################### +install(EXPORT qeTargets + FILE qeTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qe) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + qeConfigVersion.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY AnyNewerVersion) + +configure_file(cmake/qeConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/qeConfig.cmake @ONLY) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/qeConfigVersion.cmake + ${CMAKE_CURRENT_BINARY_DIR}/qeConfig.cmake + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/qe) + +########################################################### +# Dependency graph generation +# Defines the custom target 'depgraph' +########################################################### +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeGraphVizOptions.cmake + ${CMAKE_CURRENT_BINARY_DIR}/CMakeGraphVizOptions.cmake COPYONLY) +add_custom_target(depgraph + "${CMAKE_COMMAND}" "--graphviz=depgraph" . + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + +########################################################### +# Custom make targets +########################################################### +add_custom_target(pw + DEPENDS + qe_pw_exe + qe_pw_tools_ibrav2cell_exe + qe_pw_tools_cell2ibrav_exe + qe_pw_tools_ev_exe + qe_pw_tools_kpoints_exe + qe_pw_tools_pwi2xsf_exe + COMMENT + "basic code for scf, structure optimization, MD") + +add_custom_target(ph + DEPENDS + qe_phonon_ph_exe + qe_phonon_dynmat_exe + qe_phonon_q2r_exe + qe_phonon_dvscf_q2r_exe + qe_phonon_matdyn_exe + qe_phonon_q2qstar_exe + qe_phonon_lambda_exe + qe_phonon_alpha2f_exe + qe_phonon_epa_exe + qe_phonon_fqha_exe + qe_phonon_fd_exe + qe_phonon_fdef_exe + qe_phonon_fdifc_exe + qe_phonon_postahc_exe + COMMENT + "phonon code, Gamma-only and third-order derivatives") + +add_custom_target(hp + DEPENDS + qe_hp_exe + COMMENT + "calculation of the Hubbard parameters from DFPT") + +add_custom_target(pwcond + DEPENDS + qe_pwcond_exe + COMMENT + "ballistic conductance") + +add_custom_target(neb + DEPENDS + qe_neb_exe + qe_neb_pathinterpolation_exe + COMMENT + "code for Nudged Elastic Band method") + +add_custom_target(pp + DEPENDS + qe_pp_exe + qe_pp_opengrid_exe + qe_pp_average_exe + qe_pp_bands_exe + qe_pp_dos_exe + qe_pp_pawplot_exe + qe_pp_planavg_exe + qe_pp_plotband_exe + qe_pp_plotproj_exe + qe_pp_plotrho_exe + qe_pp_pmw_exe + qe_pp_projwfc_exe + qe_pp_pw2wannier90_exe + qe_pp_pw2critic_exe + qe_pp_wfck2r_exe + qe_pp_initial_state_exe + qe_pp_pw2gw_exe + qe_pp_sumpdos_exe + qe_pp_epsilon_exe + qe_pp_wannierham_exe + qe_pp_wannierplot_exe + qe_pp_molecularpdos_exe + qe_pp_pw2bgw_exe + qe_pp_fermivelocity_exe + qe_pp_fermisurface_exe + qe_pp_fermiproj_exe + qe_pp_ppacf_exe + COMMENT + "postprocessing programs") + +add_custom_target(pwall + DEPENDS + pw + ph + pp + pwcond + neb + COMMENT + "same as \"make pw ph pp pwcond neb\"") + +add_custom_target(cp + DEPENDS + qe_cpv_exe + qe_cpv_manycp_exe + qe_cpv_cppp_exe + qe_cpv_wfdd_exe + COMMENT + "CP code: Car-Parrinello molecular dynamics") + +add_custom_target(tddfpt + DEPENDS + qe_tddfpt_turbolanczos_exe + qe_tddfpt_turbodavidson_exe + qe_tddfpt_turboeels_exe + qe_tddfpt_turbospectrum_exe + qe_tddfpt_turbomagnons_exe + COMMENT + "time dependent dft code") + +add_custom_target(gwl + DEPENDS + qe_gww_util_grap_exe + qe_gww_util_abcoefftoeps_exe + qe_gww_util_memorypw4gww_exe + qe_gww_bse_bse_main_exe + qe_gww_gww_exe + qe_gww_gww_fit_exe + qe_gww_head_exe + qe_gww_simple_bse_exe + qe_gww_simple_ip_exe + COMMENT + "GW with Lanczos chains") + +add_custom_target(ld1 + DEPENDS + qe_atomic_exe + COMMENT + "utilities for pseudopotential generation") + +add_custom_target(upf + DEPENDS + #Library + qe_upflib + #Executables + qe_upflib_virtual_v2_exe + qe_upflib_upfconv_exe + COMMENT + "utilities for pseudopotential conversion") + +add_custom_target(xspectra + DEPENDS + qe_xspectra_exe + qe_xspectra_spectracorrection_exe + qe_xspectra_molecularnexafs_exe + COMMENT + "X-ray core-hole spectroscopy calculations") + +add_custom_target(couple + DEPENDS + qe_couple + COMMENT + "library interface for coupling to external codes") + +add_custom_target(epw + DEPENDS + qe_epw_exe + COMMENT + "electron-Phonon Coupling with wannier functions") +add_custom_target(all_currents + DEPENDS + qe_qeheat_exe + COMMENT + "QEHeat code to compute energy and electronic density currents") diff --git a/patches/qespresso-7.0.diff/CMakeLists.txt.preplumed b/patches/qespresso-7.0.diff/CMakeLists.txt.preplumed new file mode 100644 index 0000000000..eb01a8828f --- /dev/null +++ b/patches/qespresso-7.0.diff/CMakeLists.txt.preplumed @@ -0,0 +1,839 @@ +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) +# CMake < 3.13 cannot install external targets: +# https://gitlab.kitware.com/cmake/cmake/merge_requests/2152 + +# CMake < 3.14 generates incorrect dependency graphs with +# alias targets: +# https://gitlab.kitware.com/cmake/cmake/merge_requests/2521 + +# CMake < 3.20 does not support NVHPC compiler id +# https://cmake.org/cmake/help/latest/release/3.20.html#compilers + +# Policy CMP0048: The project() command manages VERSION variables +set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) + +project(qe + VERSION 7.0 + DESCRIPTION "ESPRESSO: opEn-Source Package for Research in Electronic Structure, Simulation, and Optimization" + LANGUAGES Fortran C) + +if(${qe_BINARY_DIR} STREQUAL ${qe_SOURCE_DIR}) + message(FATAL_ERROR "QE source folder cannot be safely used as a build folder!") +endif() + +# CMake < v3.18 cannot discover the ARM Performance Library +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") + if(CMAKE_VERSION VERSION_LESS 3.18.0) + message("-- CMake versions less than 3.18 cannot automatically discover the ARM Performance Library!") + endif() +endif() + +########################################################## +# Define the paths for static libraries and executables +########################################################## +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${qe_BINARY_DIR}/lib + CACHE + PATH "Single output directory for building all libraries.") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${qe_BINARY_DIR}/bin + CACHE + PATH "Single output directory for building all executables.") + +########################################################### +# Build helpers +########################################################### +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") +include(cmake/qeHelpers.cmake) + +########################################################### +# Build Type +# Ensure that a specific, default build type is set when +# none has been explicitly set by the user +########################################################### +qe_ensure_build_type("Release") + +########################################################### +# Modules +########################################################### +include(CheckFunctionExists) +# Must use GNUInstallDirs to install libraries into correct +# locations on all platforms. +include(GNUInstallDirs) + +########################################################### +# Build Options +########################################################### +include(CMakeDependentOption) +option(QE_ENABLE_CUDA + "enable CUDA acceleration on NVIDIA GPUs" OFF) +if(QE_ENABLE_CUDA) + option(QE_ENABLE_OPENACC "enable OpenACC acceleration" ON) + option(QE_ENABLE_LAXLIB_CUSOLVER + "enable CUDA solver acceleration for LAXLib on NVIDIA GPUs" ON) + # OpenMP enabled by default if CUDA is enable + option(QE_ENABLE_OPENMP + "enable distributed execution support via OpenMP" ON) +else() + option(QE_ENABLE_OPENACC "enable OpenACC acceleration" OFF) + option(QE_ENABLE_OPENMP + "enable distributed execution support via OpenMP" OFF) +endif() +option(QE_ENABLE_MPI + "enable distributed execution support via MPI" ON) +option(QE_ENABLE_MPI_GPU_AWARE + "enable GPU aware MPI operations" OFF) +option(QE_ENABLE_TEST + "enable unit and system tests" ON) +cmake_dependent_option(QE_ENABLE_BENCHMARK + "enable benchmark tests" OFF "QE_ENABLE_TEST" OFF) +option(QE_ENABLE_TRACE + "enable execution tracing output" OFF) +option(QE_ENABLE_PROFILE_NVTX + "enable execution of NVIDIA NVTX profiler plugin" OFF) +option(QE_ENABLE_MPI_INPLACE + "enable inplace MPI calls (ignored when QE_ENABLE_MPI=OFF)" OFF) +option(QE_ENABLE_MPI_MODULE + "use MPI via Fortran module instead of mpif.h header inclusion" OFF) +option(QE_ENABLE_BARRIER + "enable global synchronization between execution units" OFF) +option(QE_LAPACK_INTERNAL + "enable internal reference LAPACK" OFF) +option(QE_ENABLE_SCALAPACK + "enable SCALAPACK execution units" OFF) +option(QE_ENABLE_ELPA + "enable ELPA execution units" OFF) +option(QE_ENABLE_LIBXC + "enable LIBXC execution units" OFF) +option(QE_ENABLE_HDF5 + "enable HDF5 data collection" OFF) +option(QE_ENABLE_STATIC_BUILD + "enable fully static build of executables" OFF) +option(QE_ENABLE_DOC + "enable documentation building" OFF) +set(QE_FFTW_VENDOR "AUTO" CACHE + STRING "select a specific FFTW library [Intel_DFTI, Intel_FFTW3, ArmPL, IBMESSL, FFTW3, Internal]") +set(QE_ENABLE_SANITIZER "none" CACHE STRING "none,asan,ubsan,tsan,msan") + +# TODO change all ifdefs throughout code base to match +# cmake options +# TODO symbols beginning with '__' followed by a capital +# character are reserved for standard library use (at +# least in C, not sure about Fortran), change all feature +# macros to avoid weird behaviors + +# Disable all configuration headers used to be generated +# by configure (see /include/) +qe_add_global_compile_definitions(QE_NO_CONFIG_H) + +if(QE_ENABLE_CUDA) + qe_add_global_compile_definitions(__CUDA) +endif() +if(QE_ENABLE_TRACE) + qe_add_global_compile_definitions(__TRACE) +endif() +if(QE_ENABLE_PROFILE_NVTX) + qe_add_global_compile_definitions(__PROFILE_NVTX) +endif() +if(QE_ENABLE_MPI_INPLACE) + qe_add_global_compile_definitions(__USE_INPLACE_MPI) +endif() +if(QE_ENABLE_MPI_MODULE) + qe_add_global_compile_definitions(__MPI_MODULE) +endif() +if(QE_ENABLE_BARRIER) + qe_add_global_compile_definitions(__USE_BARRIER) +endif() +if(QE_ENABLE_MPI) + # OMPI_SKIP_MPICXX: skip CXX APIs on openmpi, cause trouble to C APIs + qe_add_global_compile_definitions(__MPI OMPI_SKIP_MPICXX) + if(QE_ENABLE_MPI_GPU_AWARE) + qe_add_global_compile_definitions(__GPU_MPI) + endif() +endif() +if(QE_ENABLE_SCALAPACK) + qe_add_global_compile_definitions(__SCALAPACK) +endif() +if(QE_ENABLE_HDF5) + qe_add_global_compile_definitions(__HDF5) +endif() + +# Feature checks +check_function_exists(mallinfo HAVE_MALLINFO) +if(HAVE_MALLINFO) + qe_add_global_compile_definitions(HAVE_MALLINFO) +endif() + +# Check options consistency +if(QE_ENABLE_STATIC_BUILD AND BUILD_SHARED_LIBS) + message(FATAL_ERROR "Full static build of QE executables requires static QE internal libraries. QE_ENABLE_STATIC_BUILD and BUILD_SHARED_LIBS cannot be both ON") +endif() +if(QE_ENABLE_ELPA AND NOT QE_ENABLE_SCALAPACK) + message(FATAL_ERROR "ELPA requires SCALAPACK support, enable it with '-DQE_ENABLE_SCALAPACK=ON' or disable ELPA with '-DQE_ENABLE_ELPA=OFF'") +endif() +if(QE_ENABLE_SCALAPACK AND NOT QE_ENABLE_MPI) + message(FATAL_ERROR "SCALAPACK requires MPI support, enable it with '-DQE_ENABLE_MPI=ON' or disable SCALAPACK with '-DQE_ENABLE_SCALAPACK=OFF'") +endif() +if(QE_ENABLE_CUDA AND NOT (CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")) + message(FATAL_ERROR "NVHPC compiler is mandatory when CUDA is enabled due QE is based on CUDA Fortran language") +endif() +if(QE_ENABLE_OPENACC AND NOT (CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")) + message(FATAL_ERROR "NVHPC compiler is mandatory when OpenACC is enabled") +endif() +if(QE_ENABLE_MPI_GPU_AWARE AND NOT (QE_ENABLE_CUDA AND QE_ENABLE_MPI)) + message(FATAL_ERROR "GPU aware MPI requires both MPI and CUDA features enabled") +endif() +if(QE_ENABLE_LAXLIB_CUSOLVER AND (NOT QE_ENABLE_CUDA)) + message(FATAL_ERROR "CUDA Solver for LAXLib requires CUDA support, enable it with '-DQE_ENABLE_CUDA=ON' or disable CUDA Solver for LAXLib with '-DQE_ENABLE_LAXLIB_CUSOLVER=OFF'") +endif() +# if(QE_ENABLE_HDF5 AND NOT QE_ENABLE_MPI) +# message(FATAL_ERROR "HDF5 requires MPI support, enable it with '-DQE_ENABLE_MPI=ON' or disable HDF5 with '-DQE_ENABLE_HDF5=OFF'") +# endif() + +# Add optional sanitizers ASAN, UBSAN, MSAN +set(VALID_SANITIZERS "none" "asan" "ubsan" "tsan" "msan") +# Perform sanitizer option check, only works in debug mode +if(NOT QE_ENABLE_SANITIZER IN_LIST VALID_SANITIZERS) + message(FATAL_ERROR "Invalid -DQE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER}, value must be one of ${VALID_SANITIZERS}") +else() + message(STATUS "Enable sanitizer QE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER}") +endif() +# only GNU works right now +if(NOT QE_ENABLE_SANITIZER STREQUAL "none" AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + message(FATAL_ERROR "-DQE_ENABLE_SANITIZER=${QE_ENABLE_SANITIZER} only works with the GNU compiler") +endif() + + +############################################################ +# C preprocessor +# Note: reply on the compiler preprocessor whenever possible +############################################################ +if(DEFINED ENV{CPP}) + set(QE_CPP_DEFAULT $ENV{CPP}) +else() + set(QE_CPP_DEFAULT cpp) +endif() +# QE_CPP_DEFAULT is only effective when cached QE_CPP doesn't exist. +set(QE_CPP ${QE_CPP_DEFAULT} CACHE + STRING "C preprocessor for qe_preprocess_source in qeHelpers.cmake") +find_program(QE_CPP_FULL_PATH NAMES ${QE_CPP} DOC "C preprocessor full path") +if(QE_CPP_FULL_PATH) + message(STATUS "C preprocessor used by qe_preprocess_source in qeHelpers.cmake: ${QE_CPP_FULL_PATH}") +else() + set(QE_CPP_SAVED ${QE_CPP}) + unset(QE_CPP CACHE) + message(FATAL_ERROR "C preprocessor ${QE_CPP_SAVED} not found. Pass a working one to CMake via QE_CPP!") +endif() + +########################################################### +# language standard requirements +########################################################### +# TODO need to require all compilers using the same one +if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + set(CMAKE_C_STANDARD 11) + set(CMAKE_C_STANDARD_REQUIRED ON) + set(CMAKE_C_EXTENSIONS OFF) +endif() + +########################################################### +# check Fortran compiler -isystem option support +########################################################### +include(CheckFortranCompilerFlag) +check_fortran_compiler_flag("-isystem ." Fortran_ISYSTEM_SUPPORTED) +if(NOT Fortran_ISYSTEM_SUPPORTED AND NOT DEFINED CMAKE_NO_SYSTEM_FROM_IMPORTED) + set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) +endif() + +############################################################ +# Compiler vendor specific options +############################################################ +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(GNUFortranCompiler) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + include(NVFortranCompiler) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "XL") + include(IBMFortranCompiler) +endif() + +if(QE_ENABLE_STATIC_BUILD) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") +endif() + +########################################################### +# CUDA +########################################################### +if(QE_ENABLE_CUDA OR QE_ENABLE_PROFILE_NVTX) + if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") + add_library(CUDA::cufft INTERFACE IMPORTED) + set_target_properties(CUDA::cufft PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cufft") + add_library(CUDA::cublas INTERFACE IMPORTED) + set_target_properties(CUDA::cublas PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cublas") + add_library(CUDA::cusolver INTERFACE IMPORTED) + set_target_properties(CUDA::cusolver PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=cusolver") + add_library(CUDA::curand INTERFACE IMPORTED) + set_target_properties(CUDA::curand PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_FLAG}lib=curand") + if(QE_ENABLE_PROFILE_NVTX) + add_library(CUDA::nvToolsExt INTERFACE IMPORTED) + set_target_properties(CUDA::nvToolsExt PROPERTIES INTERFACE_LINK_LIBRARIES "-cuda;libnvToolsExt.so") + set(CMAKE_REQUIRED_LIBRARIES "-cuda;libnvToolsExt.so") + check_function_exists(nvtxRangePushEx NVTX_FOUND) + unset(CMAKE_REQUIRED_LIBRARIES) + if(NOT NVTX_FOUND) + message(FATAL_ERROR "Check nvtxRangePushEx in libnvToolsExt.so failed") + endif() + endif() + else() + find_package(CUDAToolkit REQUIRED) + endif() +endif(QE_ENABLE_CUDA OR QE_ENABLE_PROFILE_NVTX) + +########################################################### +# OpenMP +# The following targets will be defined: +add_library(qe_openmp_fortran INTERFACE) +add_library(qe_openmp_c INTERFACE) +qe_install_targets(qe_openmp_fortran qe_openmp_c) +########################################################### +if(QE_ENABLE_OPENMP) + find_package(OpenMP REQUIRED Fortran C) + target_link_libraries(qe_openmp_fortran INTERFACE OpenMP::OpenMP_Fortran) + target_link_libraries(qe_openmp_c INTERFACE OpenMP::OpenMP_C) +endif(QE_ENABLE_OPENMP) + +########################################################### +# OpenACC +# The following targets will be defined: +add_library(qe_openacc_fortran INTERFACE) +add_library(qe_openacc_c INTERFACE) +qe_install_targets(qe_openacc_fortran qe_openacc_c) +########################################################### +if(QE_ENABLE_OPENACC) + if(CMAKE_VERSION VERSION_LESS 3.16.0) + message(FATAL_ERROR "CMake versions >= 3.16 required for QE_ENABLE_OPENACC=ON!") + endif() + find_package(OpenACC REQUIRED Fortran C) + target_link_libraries(qe_openacc_fortran INTERFACE OpenACC::OpenACC_Fortran) + target_link_libraries(qe_openacc_c INTERFACE OpenACC::OpenACC_C) + if(GPU_TARGET_COMPILE_OPTIONS) + target_compile_options(qe_openacc_fortran INTERFACE "${GPU_TARGET_COMPILE_OPTIONS}") + target_compile_options(qe_openacc_c INTERFACE "${GPU_TARGET_COMPILE_OPTIONS}") + endif() +endif(QE_ENABLE_OPENACC) + +########################################################### +# MPI +# The following targets will be defined: +add_library(qe_mpi_fortran INTERFACE) +qe_install_targets(qe_mpi_fortran) +########################################################### +if(QE_ENABLE_MPI) + find_package(MPI REQUIRED Fortran) + target_link_libraries(qe_mpi_fortran + INTERFACE MPI::MPI_Fortran) + message(STATUS "MPI settings used by CTest") + message(" MPIEXEC_EXECUTABLE : ${MPIEXEC_EXECUTABLE}") + message(" MPIEXEC_NUMPROC_FLAG : ${MPIEXEC_NUMPROC_FLAG}") + message(" MPIEXEC_PREFLAGS : ${MPIEXEC_PREFLAGS}") + string(REPLACE ";" " " MPIEXEC_PREFLAGS_PRINT "${MPIEXEC_PREFLAGS}") + message(" Tests run as : ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_PREFLAGS_PRINT} ") +endif(QE_ENABLE_MPI) + +########################################################### +# Git +########################################################### +find_package(Git 2.13 REQUIRED) +if(EXISTS ${qe_SOURCE_DIR}/.git) + message(STATUS "Source files are cloned from a git repository.") + set(IS_GIT_PROJECT 1) + include(GitInfo) +else() + message(STATUS "Source files are not cloned from a git repository.") +endif() + +########################################################### +# Lapack +# The following targets will be defined: +add_library(qe_lapack INTERFACE) +qe_install_targets(qe_lapack) +########################################################### +if(NOT QE_LAPACK_INTERNAL) + if(NOT BLA_VENDOR) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64.*") + message(STATUS "Trying to find LAPACK from Intel MKL") + if(QE_ENABLE_OPENMP) + SET(BLA_VENDOR Intel10_64lp) + else() + SET(BLA_VENDOR Intel10_64lp_seq) + endif() + find_package(LAPACK) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") + message(STATUS "Trying to find LAPACK from Intel MKL - 32bit") + SET(BLA_VENDOR Intel10_32) + find_package(LAPACK) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") + message(STATUS "Trying to find LAPACK from ARM Performance Library") + if(QE_ENABLE_OPENMP) + SET(BLA_VENDOR Arm_mp) + else() + SET(BLA_VENDOR Arm) + endif() + find_package(LAPACK) + endif() + if(NOT LAPACK_FOUND) + message(STATUS "Trying to find alternative LAPACK libraries") + SET(BLA_VENDOR All) + if(QE_ENABLE_OPENMP) + set(CMAKE_REQUIRED_LINK_OPTIONS ${OpenMP_Fortran_FLAGS}) + endif() + find_package(LAPACK) + unset(CMAKE_REQUIRED_LINK_OPTIONS) + endif() + else() + if(QE_ENABLE_OPENMP) + set(CMAKE_REQUIRED_LINK_OPTIONS ${OpenMP_Fortran_FLAGS}) + endif() + find_package(LAPACK) + unset(CMAKE_REQUIRED_LINK_OPTIONS) + endif() + if(LAPACK_FOUND) + list(APPEND _lapack_libs + ${BLAS_LIBRARIES} + ${BLAS_LINKER_FLAGS} + ${LAPACK_LIBRARIES} + ${LAPACK_LINKER_FLAGS}) + if(QE_ENABLE_OPENMP) + list(APPEND _lapack_libs ${OpenMP_Fortran_LIBRARIES}) + endif() + list(REMOVE_DUPLICATES "${_lapack_libs}") + message(STATUS "Found LAPACK: ${_lapack_libs}") + target_link_libraries(qe_lapack INTERFACE ${_lapack_libs}) + set(CMAKE_REQUIRED_LIBRARIES ${_lapack_libs}) + check_fortran_function_exists(zhpev ZHPEV_FOUND) + unset(CMAKE_REQUIRED_LIBRARIES) + if(NOT ZHPEV_FOUND) + unset(ZHPEV_FOUND CACHE) + message(FATAL_ERROR "Incomplete LAPACK! function zhpev not found!") + endif() + else() + message(FATAL_ERROR "Failed to find a complete set of external BLAS/LAPACK library by FindLAPACK. " + "Variables controlling FindLAPACK can be found at CMake online documentation. " + "Alternatively, '-DQE_LAPACK_INTERNAL=ON' may be used to enable reference LAPACK " + "at a performance loss compared to optimized libraries.") + endif() +else() + message(WARNING "Internal reference LAPACK is enabled! It is less performant than vendor optimized libraries.") + if(CMAKE_Fortran_COMPILER_ID MATCHES "XL") + message(FATAL_ERROR "IBM XL compilers cannot build internal LAPACK with QE " + "due to the conflict in flags for free vs fixed format. " + "Please use an optimized LAPACK or build internal reference LAPACK separately.") + endif() + message(STATUS "Installing LAPACK via submodule") + qe_git_submodule_update(external/lapack) + add_subdirectory(external/lapack) + target_link_libraries(qe_lapack INTERFACE lapack) + # make lapack ready for other external libraries like mbd + set(LAPACK_LIBRARIES lapack) +endif() + +########################################################### +# SCALAPACK +# The following targets will be defined: +add_library(qe_scalapack INTERFACE) +qe_install_targets(qe_scalapack) +########################################################### +if(QE_ENABLE_SCALAPACK) + find_package(SCALAPACK REQUIRED QUIET) + message(STATUS "Found SCALAPACK: ${SCALAPACK_LIBRARIES};${SCALAPACK_LINKER_FLAGS}") + target_link_libraries(qe_scalapack + INTERFACE + ${SCALAPACK_LIBRARIES} + ${SCALAPACK_LINKER_FLAGS}) +endif(QE_ENABLE_SCALAPACK) + +########################################################### +# ELPA +# The following targets will be defined: +add_library(qe_elpa INTERFACE) +qe_install_targets(qe_elpa) +########################################################### +if(QE_ENABLE_ELPA) + find_package(ELPA REQUIRED) + + # Check if ELPA version is compatible with QE + if(ELPA_VERSION VERSION_GREATER_EQUAL "2018.11") + set(QE_ELPA_DEFINITIONS __ELPA) + elseif(ELPA_VERSION VERSION_GREATER_EQUAL "2016.11") + set(QE_ELPA_DEFINITIONS __ELPA_2016) + elseif(ELPA_VERSION VERSION_GREATER_EQUAL "2015") + set(QE_ELPA_DEFINITIONS __ELPA_2015) + else() + message(FATAL_ERROR "ELPA verion ${ELPA_VERSION} is not supported.") + endif() + message(STATUS "Add ELPA flag : ${QE_ELPA_DEFINITIONS}") + qe_add_global_compile_definitions(${QE_ELPA_DEFINITIONS}) + + # Add link libraries and include directories + target_link_libraries(qe_elpa + INTERFACE + ${ELPA_LIBRARIES} + ${ELPA_LIBRARIES_DEP} + ${ELPA_LINKER_FLAGS} + qe_scalapack) + target_include_directories(qe_elpa + INTERFACE + ${ELPA_Fortran_MODS_DIR} + ${ELPA_INCLUDE_DIRS} + ${ELPA_INCLUDE_DIRS_DEP}) +endif(QE_ENABLE_ELPA) + +########################################################### +# LIBXC +## The following targets will be defined: +add_library(qe_external_libxc INTERFACE) +qe_install_targets(qe_external_libxc) +########################################################### +if(QE_ENABLE_LIBXC) + target_compile_definitions(qe_external_libxc INTERFACE "__LIBXC") + + find_package(Libxc 5.1.2 COMPONENTS Fortran) + if (NOT Libxc_FOUND) + message(STATUS "Libxc searching failed in CMake Module mode, trying Config mode") + find_package(Libxc 5.1.2 COMPONENTS Fortran CONFIG) + endif() + + if(${Libxc_FOUND}) + if (${Libxc_VERSION} VERSION_GREATER_EQUAL "5.1.2" ) + message(STATUS "Libxc version ${Libxc_VERSION} found.") + else() + message(FATAL_ERROR "Libxc version ${Libxc_VERSION} found. " + "CMake compilation of QE tested for libxc v5.1.2 or later only.") + endif() + target_link_libraries(qe_external_libxc INTERFACE Libxc::xcf03) + target_include_directories(qe_external_libxc INTERFACE ${Libxc_INCLUDE_DIR}) + target_compile_definitions(qe_external_libxc INTERFACE ${Libxc_DEFINITIONS}) + else() + message(FATAL_ERROR "Failed to find Libxc package (>=5.1.2) with Fortran enabled.") + endif() +endif(QE_ENABLE_LIBXC) + +########################################################### +# HDF5 +# The following targets will be defined: +add_library(qe_hdf5_fortran INTERFACE) +add_library(qe_hdf5_c INTERFACE) +qe_install_targets(qe_hdf5_fortran qe_hdf5_c) +########################################################### +if(QE_ENABLE_HDF5) + if(QE_ENABLE_MPI) + option(HDF5_PREFER_PARALLEL "Prefer parallel HDF5" ON) + endif() + if(QE_ENABLE_STATIC_BUILD) + set(HDF5_USE_STATIC_LIBRARIES TRUE) + endif() + find_package(HDF5 REQUIRED Fortran C) + if(NOT HDF5_FOUND) + message(FATAL_ERROR "HDF5 Fortran interface has not been found!") + endif() + + if (NOT HDF5_IS_PARALLEL OR NOT QE_ENABLE_MPI) + message(STATUS "Serial HDF5 enabled!") + qe_add_global_compile_definitions(__HDF5_SERIAL) + else() + message(STATUS "Parallel HDF5 enabled!") + endif() + + target_link_libraries(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_LIBRARIES} + ${HDF5_Fortran_HL_LIBRARIES}) + target_include_directories(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_INCLUDE_DIRS}) + target_compile_definitions(qe_hdf5_fortran + INTERFACE + ${HDF5_Fortran_DEFINITIONS}) + + target_link_libraries(qe_hdf5_c + INTERFACE + ${HDF5_C_LIBRARIES} + ${HDF5_C_HL_LIBRARIES}) + target_include_directories(qe_hdf5_c + INTERFACE + ${HDF5_C_INCLUDE_DIRS}) + target_compile_definitions(qe_hdf5_c + INTERFACE + ${HDF5_C_DEFINITIONS}) +endif(QE_ENABLE_HDF5) + +########################################################### +# Tests +# Any executable target marked as test runner via +# 'add_test()' will be run by the 'test' make target +########################################################### +if(QE_ENABLE_TEST) + include(cmake/unit_test.cmake) + enable_testing() +endif(QE_ENABLE_TEST) + +########################################################### +# PROFILERS LIBRARIES +# the target for profiler libray will be defined if +# some profiler is enabled +add_library(qe_ext_prof_tool INTERFACE) +qe_install_targets(qe_ext_prof_tool) +########################################################### +# this should work with nvfortran +if(QE_ENABLE_PROFILE_NVTX) + target_link_libraries(qe_ext_prof_tool + INTERFACE + CUDA::nvToolsExt) +endif(QE_ENABLE_PROFILE_NVTX) + +########################################################### +# Components +########################################################### +add_subdirectory(external) +add_subdirectory(FFTXlib) +add_subdirectory(UtilXlib) +add_subdirectory(Modules) +add_subdirectory(LAXlib) +add_subdirectory(XClib) +add_subdirectory(KS_Solvers) +add_subdirectory(dft-d3) +add_subdirectory(PW) +add_subdirectory(CPV) +add_subdirectory(atomic) +add_subdirectory(upflib) +add_subdirectory(COUPLE) +add_subdirectory(LR_Modules) +add_subdirectory(PHonon) +add_subdirectory(PP) +add_subdirectory(EPW) +add_subdirectory(GWW) +add_subdirectory(HP) +add_subdirectory(NEB) +add_subdirectory(PWCOND) +add_subdirectory(TDDFPT) +add_subdirectory(XSpectra) +add_subdirectory(QEHeat) +if(QE_ENABLE_DOC) + add_subdirectory(Doc) +endif() + +########################################################### +# Tests +########################################################### +if(QE_ENABLE_TEST) + message(STATUS "Enabling tests in test-suite") + add_subdirectory(test-suite) +endif() + +########################################################### +# Pkg-config +########################################################### +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/quantum_espresso.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/quantum_espresso.pc + @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/quantum_espresso.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +########################################################### +# Exports +########################################################### +install(EXPORT qeTargets + FILE qeTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qe) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + qeConfigVersion.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY AnyNewerVersion) + +configure_file(cmake/qeConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/qeConfig.cmake @ONLY) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/qeConfigVersion.cmake + ${CMAKE_CURRENT_BINARY_DIR}/qeConfig.cmake + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/qe) + +########################################################### +# Dependency graph generation +# Defines the custom target 'depgraph' +########################################################### +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeGraphVizOptions.cmake + ${CMAKE_CURRENT_BINARY_DIR}/CMakeGraphVizOptions.cmake COPYONLY) +add_custom_target(depgraph + "${CMAKE_COMMAND}" "--graphviz=depgraph" . + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + +########################################################### +# Custom make targets +########################################################### +add_custom_target(pw + DEPENDS + qe_pw_exe + qe_pw_tools_ibrav2cell_exe + qe_pw_tools_cell2ibrav_exe + qe_pw_tools_ev_exe + qe_pw_tools_kpoints_exe + qe_pw_tools_pwi2xsf_exe + COMMENT + "basic code for scf, structure optimization, MD") + +add_custom_target(ph + DEPENDS + qe_phonon_ph_exe + qe_phonon_dynmat_exe + qe_phonon_q2r_exe + qe_phonon_dvscf_q2r_exe + qe_phonon_matdyn_exe + qe_phonon_q2qstar_exe + qe_phonon_lambda_exe + qe_phonon_alpha2f_exe + qe_phonon_epa_exe + qe_phonon_fqha_exe + qe_phonon_fd_exe + qe_phonon_fdef_exe + qe_phonon_fdifc_exe + qe_phonon_postahc_exe + COMMENT + "phonon code, Gamma-only and third-order derivatives") + +add_custom_target(hp + DEPENDS + qe_hp_exe + COMMENT + "calculation of the Hubbard parameters from DFPT") + +add_custom_target(pwcond + DEPENDS + qe_pwcond_exe + COMMENT + "ballistic conductance") + +add_custom_target(neb + DEPENDS + qe_neb_exe + qe_neb_pathinterpolation_exe + COMMENT + "code for Nudged Elastic Band method") + +add_custom_target(pp + DEPENDS + qe_pp_exe + qe_pp_opengrid_exe + qe_pp_average_exe + qe_pp_bands_exe + qe_pp_dos_exe + qe_pp_pawplot_exe + qe_pp_planavg_exe + qe_pp_plotband_exe + qe_pp_plotproj_exe + qe_pp_plotrho_exe + qe_pp_pmw_exe + qe_pp_projwfc_exe + qe_pp_pw2wannier90_exe + qe_pp_pw2critic_exe + qe_pp_wfck2r_exe + qe_pp_initial_state_exe + qe_pp_pw2gw_exe + qe_pp_sumpdos_exe + qe_pp_epsilon_exe + qe_pp_wannierham_exe + qe_pp_wannierplot_exe + qe_pp_molecularpdos_exe + qe_pp_pw2bgw_exe + qe_pp_fermivelocity_exe + qe_pp_fermisurface_exe + qe_pp_fermiproj_exe + qe_pp_ppacf_exe + COMMENT + "postprocessing programs") + +add_custom_target(pwall + DEPENDS + pw + ph + pp + pwcond + neb + COMMENT + "same as \"make pw ph pp pwcond neb\"") + +add_custom_target(cp + DEPENDS + qe_cpv_exe + qe_cpv_manycp_exe + qe_cpv_cppp_exe + qe_cpv_wfdd_exe + COMMENT + "CP code: Car-Parrinello molecular dynamics") + +add_custom_target(tddfpt + DEPENDS + qe_tddfpt_turbolanczos_exe + qe_tddfpt_turbodavidson_exe + qe_tddfpt_turboeels_exe + qe_tddfpt_turbospectrum_exe + qe_tddfpt_turbomagnons_exe + COMMENT + "time dependent dft code") + +add_custom_target(gwl + DEPENDS + qe_gww_util_grap_exe + qe_gww_util_abcoefftoeps_exe + qe_gww_util_memorypw4gww_exe + qe_gww_bse_bse_main_exe + qe_gww_gww_exe + qe_gww_gww_fit_exe + qe_gww_head_exe + qe_gww_simple_bse_exe + qe_gww_simple_ip_exe + COMMENT + "GW with Lanczos chains") + +add_custom_target(ld1 + DEPENDS + qe_atomic_exe + COMMENT + "utilities for pseudopotential generation") + +add_custom_target(upf + DEPENDS + #Library + qe_upflib + #Executables + qe_upflib_virtual_v2_exe + qe_upflib_upfconv_exe + COMMENT + "utilities for pseudopotential conversion") + +add_custom_target(xspectra + DEPENDS + qe_xspectra_exe + qe_xspectra_spectracorrection_exe + qe_xspectra_molecularnexafs_exe + COMMENT + "X-ray core-hole spectroscopy calculations") + +add_custom_target(couple + DEPENDS + qe_couple + COMMENT + "library interface for coupling to external codes") + +add_custom_target(epw + DEPENDS + qe_epw_exe + COMMENT + "electron-Phonon Coupling with wannier functions") +add_custom_target(all_currents + DEPENDS + qe_qeheat_exe + COMMENT + "QEHeat code to compute energy and electronic density currents") diff --git a/patches/qespresso-7.0.diff/Modules/CMakeLists.txt b/patches/qespresso-7.0.diff/Modules/CMakeLists.txt new file mode 100644 index 0000000000..6c6f6ad0e0 --- /dev/null +++ b/patches/qespresso-7.0.diff/Modules/CMakeLists.txt @@ -0,0 +1,176 @@ +set(src_modules + additional_kpoints.f90 + autopilot.f90 + basic_algebra_routines.f90 + becmod.f90 + bfgs_module.f90 + bspline.f90 + bz_form.f90 + cell_base.f90 + check_stop.f90 + command_line_options.f90 + compute_dipole.f90 + constants.f90 + constraints_module.f90 + control_flags.f90 + coulomb_vcut.f90 + dist.f90 + electrons_base.f90 + environment.f90 + fd_gradient.f90 + fft_base.f90 + fft_rho.f90 + fsockets.f90 + funct.f90 + generate_function.f90 + gradutils.f90 + gvecw.f90 + input_parameters.f90 + invmat.f90 + io_files.f90 + io_global.f90 + ions_base.f90 + kind.f90 + lmdif.f90 + mdiis.f90 + mm_dispersion.f90 + mp_bands.f90 + mp_exx.f90 + mp_global.f90 + mp_images.f90 + mp_pools.f90 + mp_wave.f90 + mp_world.f90 + noncol.f90 + open_close_input_file.f90 + parameters.f90 + parser.f90 + plugin_flags.f90 + plugin_arguments.f90 + plugin_variables.f90 + pw_dot.f90 + qmmm.f90 + random_numbers.f90 + read_cards.f90 + read_input.f90 + read_namelists.f90 + read_pseudo.f90 + recvec.f90 + recvec_subs.f90 + run_info.f90 + space_group.f90 + set_para_diag.f90 + set_signal.f90 + set_vdw_corr.f90 + setqf.f90 + timestep.f90 + tsvdw.f90 + mbdlib.f90 + version.f90 + wannier_gw.f90 + wannier_new.f90 + wavefunctions.f90 + ws_base.f90 + xc_vdW_DF.f90 + xc_rVV10.f90 + io_base.f90 + qes_types_module.f90 + qes_libs_module.f90 + qes_write_module.f90 + qes_read_module.f90 + qes_reset_module.f90 + qes_init_module.f90 + qes_bcast_module.f90 + qexsd.f90 + qexsd_copy.f90 + qexsd_init.f90 + qexsd_input.f90 + hdf5_qe.f90 + qeh5_module.f90 + fox_init_module.f90 + xsf.f90 + wyckoff.f90 + wypos.f90 + zvscal.f90 + wave_gauge.f90 + # subroutines and functions (not modules) previously found in flib + atom_weight.f90 + capital.f90 + cryst_to_car.f90 + expint.f90 + generate_k_along_lines.f90 + more_functionals.f90 + has_xml.f90 + inpfile.f90 + int_to_char.f90 + latgen.f90 + linpack.f90 + matches.f90 + plot_io.f90 + radial_gradients.f90 + rgen.f90 + recips.f90 + remove_tot_torque.f90 + set_hubbard_l.f90 + set_hubbard_n.f90 + sort.f90 + trimcheck.f90 + test_input_file.f90 + date_and_tim.f90 + volume.f90 + wgauss.f90 + w0gauss.f90 + w1gauss.f90 + deviatoric.f90 + #Plumed module source + ${Plumed2_FORTRAN} + # GPU + wavefunctions_gpu.f90 + becmod_gpu.f90 + becmod_subs_gpu.f90 + random_numbers_gpu.f90 + cuda_subroutines.f90) +qe_enable_cuda_fortran("${src_modules}") +qe_add_library(qe_modules ${src_modules}) + +# subroutines and functions (not modules) previously found in clib +set(src_modules_c + customize_signals.c + qmmm_aux.c + sockets.c + stack.c) +qe_add_library(qe_modules_c ${src_modules_c}) + +if(TARGET gitrev) + add_dependencies(qe_modules gitrev) + target_compile_definitions(qe_modules PRIVATE HAVE_GITREV) + target_include_directories(qe_modules PRIVATE ${qe_BINARY_DIR}) +endif() + +target_link_libraries(qe_modules + PRIVATE + qe_modules_c + qe_openmp_fortran + qe_fftx + qe_lax + qe_mpi_fortran + qe_mbd + qe_xclib + qe_devxlib + Plumed2::sharedplumedMain + PUBLIC + qe_openacc_fortran + qe_hdf5_fortran + qe_upflib + qe_fox + qe_utilx + qe_openacc_fortran) +if(QE_ENABLE_CUDA) + target_link_libraries(qe_modules + PRIVATE + CUDA::curand) +endif() + +########################################################### + +qe_install_targets(qe_modules qe_modules_c) diff --git a/patches/qespresso-7.0.diff/Modules/CMakeLists.txt.preplumed b/patches/qespresso-7.0.diff/Modules/CMakeLists.txt.preplumed new file mode 100644 index 0000000000..dcb925d720 --- /dev/null +++ b/patches/qespresso-7.0.diff/Modules/CMakeLists.txt.preplumed @@ -0,0 +1,173 @@ +set(src_modules + additional_kpoints.f90 + autopilot.f90 + basic_algebra_routines.f90 + becmod.f90 + bfgs_module.f90 + bspline.f90 + bz_form.f90 + cell_base.f90 + check_stop.f90 + command_line_options.f90 + compute_dipole.f90 + constants.f90 + constraints_module.f90 + control_flags.f90 + coulomb_vcut.f90 + dist.f90 + electrons_base.f90 + environment.f90 + fd_gradient.f90 + fft_base.f90 + fft_rho.f90 + fsockets.f90 + funct.f90 + generate_function.f90 + gradutils.f90 + gvecw.f90 + input_parameters.f90 + invmat.f90 + io_files.f90 + io_global.f90 + ions_base.f90 + kind.f90 + lmdif.f90 + mdiis.f90 + mm_dispersion.f90 + mp_bands.f90 + mp_exx.f90 + mp_global.f90 + mp_images.f90 + mp_pools.f90 + mp_wave.f90 + mp_world.f90 + noncol.f90 + open_close_input_file.f90 + parameters.f90 + parser.f90 + plugin_flags.f90 + plugin_arguments.f90 + plugin_variables.f90 + pw_dot.f90 + qmmm.f90 + random_numbers.f90 + read_cards.f90 + read_input.f90 + read_namelists.f90 + read_pseudo.f90 + recvec.f90 + recvec_subs.f90 + run_info.f90 + space_group.f90 + set_para_diag.f90 + set_signal.f90 + set_vdw_corr.f90 + setqf.f90 + timestep.f90 + tsvdw.f90 + mbdlib.f90 + version.f90 + wannier_gw.f90 + wannier_new.f90 + wavefunctions.f90 + ws_base.f90 + xc_vdW_DF.f90 + xc_rVV10.f90 + io_base.f90 + qes_types_module.f90 + qes_libs_module.f90 + qes_write_module.f90 + qes_read_module.f90 + qes_reset_module.f90 + qes_init_module.f90 + qes_bcast_module.f90 + qexsd.f90 + qexsd_copy.f90 + qexsd_init.f90 + qexsd_input.f90 + hdf5_qe.f90 + qeh5_module.f90 + fox_init_module.f90 + xsf.f90 + wyckoff.f90 + wypos.f90 + zvscal.f90 + wave_gauge.f90 + # subroutines and functions (not modules) previously found in flib + atom_weight.f90 + capital.f90 + cryst_to_car.f90 + expint.f90 + generate_k_along_lines.f90 + more_functionals.f90 + has_xml.f90 + inpfile.f90 + int_to_char.f90 + latgen.f90 + linpack.f90 + matches.f90 + plot_io.f90 + radial_gradients.f90 + rgen.f90 + recips.f90 + remove_tot_torque.f90 + set_hubbard_l.f90 + set_hubbard_n.f90 + sort.f90 + trimcheck.f90 + test_input_file.f90 + date_and_tim.f90 + volume.f90 + wgauss.f90 + w0gauss.f90 + w1gauss.f90 + deviatoric.f90 + # GPU + wavefunctions_gpu.f90 + becmod_gpu.f90 + becmod_subs_gpu.f90 + random_numbers_gpu.f90 + cuda_subroutines.f90) +qe_enable_cuda_fortran("${src_modules}") +qe_add_library(qe_modules ${src_modules}) + +# subroutines and functions (not modules) previously found in clib +set(src_modules_c + customize_signals.c + qmmm_aux.c + sockets.c + stack.c) +qe_add_library(qe_modules_c ${src_modules_c}) + +if(TARGET gitrev) + add_dependencies(qe_modules gitrev) + target_compile_definitions(qe_modules PRIVATE HAVE_GITREV) + target_include_directories(qe_modules PRIVATE ${qe_BINARY_DIR}) +endif() + +target_link_libraries(qe_modules + PRIVATE + qe_modules_c + qe_openmp_fortran + qe_fftx + qe_lax + qe_mpi_fortran + qe_mbd + qe_xclib + qe_devxlib + PUBLIC + qe_openacc_fortran + qe_hdf5_fortran + qe_upflib + qe_fox + qe_utilx + qe_openacc_fortran) +if(QE_ENABLE_CUDA) + target_link_libraries(qe_modules + PRIVATE + CUDA::curand) +endif() + +########################################################### + +qe_install_targets(qe_modules qe_modules_c) diff --git a/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 b/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 index 52d35bc5aa..5d4762fb42 100644 --- a/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 +++ b/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 @@ -18,7 +18,7 @@ SUBROUTINE plugin_ext_forces() USE plugin_flags, ONLY : use_plumed ! USE cell_base, ONLY : alat, at - USE ions_base, ONLY : tau, nat,amass + USE ions_base, ONLY : tau, nat, amass, ityp USE force_mod, ONLY : force,sigma USE control_flags, ONLY : istep USE ener, ONLY : etot @@ -27,12 +27,14 @@ SUBROUTINE plugin_ext_forces() ! IMPLICIT NONE ! - INTEGER:: i,j + INTEGER:: i,j,ia REAL(DP) :: at_plumed(3,3) REAL(DP) :: virial(3,3) REAL(DP) :: volume REAL(DP), ALLOCATABLE :: tau_plumed(:,:) + REAL(DP) :: masses_plumed(nat) ! + masses_plumed = 0.0_DP IF(use_plumed) then IF(ionode)THEN at_plumed=alat*at; ! the cell, rescaled properly @@ -46,8 +48,13 @@ SUBROUTINE plugin_ext_forces() -at_plumed(1,3)*at_plumed(3,1)*at_plumed(2,2) virial=-sigma*volume + ! the masses in QE are stored per type, see q-e//Modules/ions_base.f90 + do ia=1,nat + masses_plumed(ia)=amass(ityp(ia)) + end do + CALL plumed_f_gcmd("setStep"//char(0),istep) - CALL plumed_f_gcmd("setMasses"//char(0),amass) + CALL plumed_f_gcmd("setMasses"//char(0),masses_plumed) CALL plumed_f_gcmd("setForces"//char(0),force) CALL plumed_f_gcmd("setPositions"//char(0),tau_plumed) CALL plumed_f_gcmd("setBox"//char(0),at_plumed) diff --git a/regtest/CMakeLists.txt b/regtest/CMakeLists.txt index 36da211d5e..e441f2abde 100644 --- a/regtest/CMakeLists.txt +++ b/regtest/CMakeLists.txt @@ -12,7 +12,7 @@ if(NOT TARGET Plumed2::plumed_bin) #when testing in the build environment set(STANDALONE_TESTS ON) else() - set (Plumed2_DIR "${CMAKE_BINARY_DIR}/lib/cmake/plumed") + set (Plumed2_DIR "${CMAKE_BINARY_DIR}/${DIRS_LIB_INSTALL}/cmake/Plumed2") endif() set(PLUMED_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -159,7 +159,7 @@ function(PLUMED_TEST test_name) if(NOT STANDALONE_TESTS) list(APPEND PLUMED_TEST_EXPORTVARIABLES - "-ePLUMED_ROOT=${CMAKE_BINARY_DIR}/lib/plumed") + "-ePLUMED_ROOT=${CMAKE_BINARY_DIR}/${DIRS_LIB_INSTALL}/plumed") set(PLUMED_TEST_NOT_STANDALONELIB "-l${CMAKE_BINARY_DIR}/src") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c3d4c5626..443fce8e38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,8 +4,6 @@ project(Plumed2 LANGUAGES C CXX) set (CMAKE_CXX_STANDARD 11) -include(GNUInstallDirs) - #some settingsvalues set(program_name "plumed" CACHE STRING "the name of the main executable") string(REPLACE "." "" soextension ${CMAKE_SHARED_LIBRARY_SUFFIX}) diff --git a/src/cmake/CMakeLists.txt b/src/cmake/CMakeLists.txt index 40a75f2c6d..30ef1b61eb 100644 --- a/src/cmake/CMakeLists.txt +++ b/src/cmake/CMakeLists.txt @@ -2,6 +2,7 @@ ##########################Creating PlumedConfig.cmake########################### ################################################################################ include(CMakePackageConfigHelpers) +set (DIRS_CMAKE_BINARY ${CMAKE_BINARY_DIR}/${DIRS_CMAKE_INSTALL}) set (EXTERNAL_PACKAGES) #when package are found in src/* the ${dep}_FOUND should be made PARENT_SCOPE @@ -18,11 +19,26 @@ foreach(opt endforeach() #these packages are called with find_package(name) without options -foreach(dep BLAS LAPACK OpenMP MPI GSL ZLIB Backtrace Torch) - if(${dep}_FOUND) - list(APPEND EXTERNAL_PACKAGES "find_dependency(${dep})") - endif() -endforeach() +# foreach(dep BLAS LAPACK OpenMP MPI GSL ZLIB Backtrace Torch) +# if(${dep}_FOUND) +# list(APPEND EXTERNAL_PACKAGES "find_dependency(${dep})") +# endif() +# endforeach() + +#see this https://stackoverflow.com/a/68838772 +get_property(packages GLOBAL PROPERTY PACKAGES_FOUND) +foreach (pkg IN LISTS packages) + get_property(is_transitive GLOBAL PROPERTY _CMAKE_${pkg}_TRANSITIVE_DEPENDENCY) + if (is_transitive) + continue() + elseif (${pkg}_VERSION) + list(APPEND EXTERNAL_PACKAGES "find_dependency(${pkg} ${${pkg}_VERSION})") + else () + list(APPEND EXTERNAL_PACKAGES "find_dependency(${pkg})") + endif() +endforeach () + + if(PkgConfig_FOUND) list(APPEND EXTERNAL_PACKAGES "\nfind_dependency(PkgConfig)") @@ -68,10 +84,10 @@ set(DIRS_INCLUDE_INSTALL ${CMAKE_BINARY_DIR}/includesource/plumed ${CMAKE_BINARY #This is the build version configure_package_config_file( PlumedConfig.cmake.in - "${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2Config.cmake" + "${DIRS_CMAKE_BINARY}/Plumed2Config.cmake" NO_SET_AND_CHECK_MACRO INSTALL_DESTINATION - ${CMAKE_BINARY_DIR}/lib/cmake/plumed/ + ${DIRS_CMAKE_BINARY} PATH_VARS DIRS_INCLUDE_INSTALL DIRS_LIB_INSTALL @@ -86,31 +102,31 @@ unset (tmp) ################################################################################ ######################Creating Plumed2ConfigVersion.cmake####################### ################################################################################ -write_basic_package_version_file("${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2ConfigVersion.cmake" +write_basic_package_version_file("${DIRS_CMAKE_BINARY}/Plumed2ConfigVersion.cmake" VERSION ${PLUMED_VERSION_MAJOR}.${PLUMED_VERSION_MINOR}.${PLUMED_VERSION_PATCH} #COMPATIBILITY COMPATIBILITY SameMinorVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Plumed2Config.cmake - ${CMAKE_BINARY_DIR}/lib/cmake/plumed/Plumed2ConfigVersion.cmake + ${DIRS_CMAKE_BINARY}/Plumed2ConfigVersion.cmake PlumedUserMacros.cmake #This installs the macros for the user DESTINATION ${DIRS_CMAKE_INSTALL} ) #this is needed to have PlumedUserMacros.cmake avaiable in the build configuration file(COPY PlumedUserMacros.cmake - DESTINATION ${CMAKE_BINARY_DIR}/lib/cmake/plumed/ + DESTINATION ${DIRS_CMAKE_BINARY} ) foreach(exportetTargets Plumed2MODULES Plumed2WRAPPERS Plumed2LIBS Plumed2EXEC) install(EXPORT ${exportetTargets} NAMESPACE Plumed2:: DESTINATION ${DIRS_CMAKE_INSTALL} - ) +) export(EXPORT ${exportetTargets} NAMESPACE Plumed2:: - FILE "${CMAKE_BINARY_DIR}/lib/cmake/plumed/${exportetTargets}.cmake" - ) + FILE "${DIRS_CMAKE_BINARY}/${exportetTargets}.cmake" +) endforeach(exportetTargets ) diff --git a/src/lib/modulefile.in b/src/lib/modulefile.in index 4e650fa9dc..33d36fa816 100644 --- a/src/lib/modulefile.in +++ b/src/lib/modulefile.in @@ -39,6 +39,9 @@ prepend-path LIBRARY_PATH $libdir # path for VIM syntax setenv PLUMED_VIMPATH $libdir/$progname/vim +# path for CMake +prepend-path CMAKE_PREFIX_PATH $libdir/cmake/ + # path for pkgconfig prepend-path PKG_CONFIG_PATH $libdir/pkgconfig/