diff --git a/.github/workflows/cmakeAndTest.yml b/.github/workflows/cmakeAndTest.yml index 78e8a37196..9ca472c111 100644 --- a/.github/workflows/cmakeAndTest.yml +++ b/.github/workflows/cmakeAndTest.yml @@ -10,6 +10,7 @@ env: jobs: buildAndTest: strategy: + fail-fast: false matrix: compiler: [gcc] mpi: [mpi, nompi] @@ -179,14 +180,11 @@ jobs: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install" -Doption_relaxed_dependencies=ON - -Dallmodules_activate=ON -Denable_boost_serialization=ON - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dallmodules_activate=ON - -Denable_boost_serialization=ON - -Denable_warnings_basic=OFF - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install"; + -Denable_warnings_basic=OFF ; ccache -s -M 100M - name: Build diff --git a/.github/workflows/localcmakeTests.yml b/.github/workflows/localcmakeTests.yml index 23cb8497ea..c29bb63693 100644 --- a/.github/workflows/localcmakeTests.yml +++ b/.github/workflows/localcmakeTests.yml @@ -5,6 +5,10 @@ on: branches: - 'cmake**' jobs: - runBasicTests: - uses: ./.github/workflows/cmakeAndTest.yml + # runBasicTests: + # uses: ./.github/workflows/cmakeAndTest.yml + # secrets: inherit + + mac: + uses: ./.github/workflows/macWF.yml secrets: inherit diff --git a/.github/workflows/macWF.yml b/.github/workflows/macWF.yml index 3ba17ad760..a2d9316c03 100644 --- a/.github/workflows/macWF.yml +++ b/.github/workflows/macWF.yml @@ -14,68 +14,94 @@ env: jobs: - macports: - runs-on: macos-11 - strategy: - fail-fast: false - matrix: - variant: [ "" , "+allmodules" ] - # see https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 for possible exclusions - env: - PYVERS: "py37 py38 py39 py310" - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/.macports-ci-ccache - key: ccache-macports-${{ matrix.variant }}-${{ github.sha }} - restore-keys: ccache-macports-${{ matrix.variant }}- - - name: Install MacPorts - run: | - wget https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci - source ./macports-ci install - source ./macports-ci ccache - - name: Build local Portfile - run: | - make macports - source ./macports-ci localports macports - - name: Build PLUMED - run: | - sudo port -N -k install plumed ${{ matrix.variant }} - plumed config show - for p in $PYVERS ; do - sudo port -N install $p-plumed - done - source ./macports-ci ccache --save - - name: Run tests - run: | - sudo port -N -d test plumed ${{ matrix.variant }} - - name: Run python tests - run: | - for p in $PYVERS ; do - sudo port test $p-plumed - done + # macports: + # runs-on: macos-11 + # strategy: + # fail-fast: false + # matrix: + # variant: [ "" , "+allmodules" ] + # # see https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 for possible exclusions + # env: + # PYVERS: "py37 py38 py39 py310" + # steps: + # - uses: actions/checkout@v3 + # - uses: actions/cache@v3 + # with: + # path: ~/.macports-ci-ccache + # key: ccache-macports-${{ matrix.variant }}-${{ github.sha }} + # restore-keys: ccache-macports-${{ matrix.variant }}- + # - name: Install MacPorts + # run: | + # wget https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci + # source ./macports-ci install + # source ./macports-ci ccache + # - name: Build local Portfile + # run: | + # make macports + # source ./macports-ci localports macports + # - name: Build PLUMED + # run: | + # sudo port -N -k install plumed ${{ matrix.variant }} + # plumed config show + # for p in $PYVERS ; do + # sudo port -N install $p-plumed + # done + # source ./macports-ci ccache --save + # - name: Run tests + # run: | + # sudo port -N -d test plumed ${{ matrix.variant }} + # - name: Run python tests + # run: | + # for p in $PYVERS ; do + # sudo port test $p-plumed + # done macsimple: runs-on: macos-11 + env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release steps: - uses: actions/checkout@v3 - name: Set paths run: | - echo "$HOME/opt/bin" >> $GITHUB_PATH - echo "CPATH=$HOME/opt/include:$CPATH" >> $GITHUB_ENV - echo "INCLUDE=$HOME/opt/include:$INCLUDE" >> $GITHUB_ENV - echo "LIBRARY_PATH=$HOME/opt/lib:$LIBRARY_PATH" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - - name: Build PLUMED + echo "$HOME/opt/bin:${{github.workspace}}/install/bin" >> $GITHUB_PATH + echo "CPATH=$HOME/opt/include:${{github.workspace}}/install/include:$CPATH" >> $GITHUB_ENV + echo "INCLUDE=$HOME/opt/include:${{github.workspace}}/install/include:$INCLUDE" >> $GITHUB_ENV + echo "LIBRARY_PATH=$HOME/opt/lib:${{github.workspace}}/install/lib:$LIBRARY_PATH" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=$HOME/opt/lib:${{github.workspace}}/install/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV + - name: Update the environment run: | brew update > /dev/null brew install gawk - ./configure --disable-dependency-tracking --prefix="$HOME/opt" - make -j 4 - make install - - name: Run tests - run: | - make --no-print-directory -C regtest - # these can fail for numerical reasons - make -C regtest checkfail + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + #set up without warnings + run: > + cmake -B ${{github.workspace}}/build + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install" + -Doption_relaxed_dependencies=ON + -DCMAKE_INSTALL_LIBDIR=lib + -Denable_warnings_basic=OFF + + + - name: Build + working-directory: ${{github.workspace}}/build + # Build your program with the given configuration + run: cmake --build . --config ${{env.BUILD_TYPE}} --parallel 4 + + - name: Checking the tests + working-directory: ${{github.workspace}}/build + #does only the tests marked with the label "testIntegrity". + #These checks ensure that the test suite works as intended, + #if these do not pass there is something very wrong! + run: ctest --output-on-failure -L testIntegrity + + - name: Test + id: tests + working-directory: ${{github.workspace}}/build + + run: ctest -j4 --output-on-failure diff --git a/.gitignore b/.gitignore index e85ec29741..48a520e718 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ makefile.dep /config.* /autom4* /stamp-h +#the cmake standard build dir +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index bcc9fb9b3c..79cd8f6cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ add_subdirectory(src) add_subdirectory(scripts) add_subdirectory(fortran) add_subdirectory(vim) +add_subdirectory(macports) install(DIRECTORY patches DESTINATION ${DIRS_EXTRA_INSTALL}) diff --git a/macports/CMakeLists.txt b/macports/CMakeLists.txt new file mode 100644 index 0000000000..a9b435bec5 --- /dev/null +++ b/macports/CMakeLists.txt @@ -0,0 +1,139 @@ +add_custom_command(OUTPUT + science/plumed/Portfile + python/py-plumed/Portfile + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-portfile.sh $ ${PLUMEDVIM_BINARY_DIR} + DEPENDS Plumed2::plumed_bin + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating vim syntax files") + +add_custom_target(macports +DEPENDS science/plumed/Portfile +python/py-plumed/Portfile + ) +set (_REVISION_ 0) +set (_VERSION_ ${PLUMED_VERSION_GIT}) +FILE(CONFIGURE OUTPUT science/plumed/Portfile +CONTENT +[=[# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 + +PortSystem 1.0 +PortGroup mpi 1.0 +PortGroup linear_algebra 1.0 +PortGroup debug 1.0 +PortGroup cmake 1.1 + +version @_VERSION_@ +revision @_REVISION_@ +name plumed +categories science + +# Most of the PLUMED code is L-GPL3. However, PLUMED containts +# molfile plugins from VMD that are released with a BSD-like license +# http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/ +license LGPL-3 BSD +maintainers {gmail.com:giovanni.bussi @GiovanniBussi} openmaintainer +description PLUMED is a plugin for molecular dynamics +long_description PLUMED is a plugin for molecular dynamics that can be used \ + in combination with popular molecular dynamics codes to perform biased simulations. \ + Additionally, it can be used as a standalone tool to analyze trajectories. + +platforms darwin + +homepage http://www.plumed.org/ + +fetch.type git +git.url @GIT_URL@ +git.branch @GIT_VERSION@ + +### This is required so that patch made with "git format-patch" work correctly +# patch.pre_args -p1 +### In case patches from github should be included to fix behavior on macports one should +### - put patch files (as obtained with git format-patch) in files/ directory +### - list their name here: +# patchfiles file1 \ +# file2 +### etc + +# Disable additional features. +# --disable-doc: Do not create documentation, and avoid searching for Doxygen. +# --disable-libsearch: Avoid searching libraries using their default names. +# This forces the libraries names to be explicitly passed (e.g. "-lz"). +# It has the advantage that during compilation from source it does not +# link packages that are not explicitely required. +# --disable-static-patch: Avoid a number of tests that are only required when linking plumed +# statically to an MD code. +# --disable-mpi: Do not search for MPI compiler (replaced when enabling mpi, see below) +# --disable-python: Python wrappers will be installed with a separate python port +configure.args-append \ + -DCMAKE_BUILD_TYPE=Release \ + -Doption_relaxed_dependencies=ON \ + -Denable_mpi=OFF \ + -Denable_python=OFF \ + -Denable_static_linking=OFF \ + -Denable_doc=OFF + +# install bash completions +#configure.args-append -DBASH_COMPLETION_DIR=${prefix}/share/bash-completion/completions + +# Hardcode path for libplumedKernel.dylib. +# This allows to patch MD codes using the --runtime option but using as +# default kernel the installed one. In this way, MacPorts users +# can just use patched MD codes with the installed plumed or replace it +# by setting PLUMED_KERNEL at runtime +configure.cppflags-append "-D__PLUMED_DEFAULT_KERNEL=${prefix}/lib/libplumedKernel.dylib" + +compilers.choose cc cxx +compiler.cxx_standard 2011 + +mpi.setup + +# To enable mpi, replace a configure flag +if {[mpi_variant_isset]} { + configure.args-replace -Denable_mpi=OFF -Denable_mpi=ON +# command should be included in a pre-configure block to access properly the mpi.exec variable +# pre-configure { +# # MPIEXEC is stored so that it can be used to perform tests +# configure.args-append MPIEXEC="${mpi.exec}" +# } +} + +# Libraries. +# Library names are specified here to make sure that +# only requested packages are linked. + +depends_lib-append port:fftw-3 \ + port:gawk \ + port:gsl \ + port:zlib + +# C++ library +# Required in order to use clang with gcc library on old OSX versions. +# See https://github.com/macports/macports-ports/pull/1254 +if {[string match *clang* ${configure.compiler}]} { + configure.ldflags-append -stdlib=${configure.cxx_stdlib} +} + +# This variant enables optional modules in PLUMED. +# Notice that one of the optional modules (drr) requires boost_serialization +variant allmodules description {Enable all optional modules} { + configure.args-append \ + -Dallmodules_activate=ON \ + -Denable_boost_serialization=ON + #configure.ldflags-append -lboost_serialization-mt + depends_lib-append port:boost +} + +# Link lapack/blas libraries +# pre-configure { +# # commands should be included in a pre-configure block to access tcl variables +# configure.ldflags-append ${linalglib} +# } + +# Allow running tests from MacPorts +test.run yes +test.target check + +]=] +@ONLY +) +#TODO: Bash completitions diff --git a/regtest/basic/rt-make-8/main.cpp b/regtest/basic/rt-make-8/main.cpp index 1512cb66a4..f49cb209ec 100644 --- a/regtest/basic/rt-make-8/main.cpp +++ b/regtest/basic/rt-make-8/main.cpp @@ -24,9 +24,9 @@ int main(){ } int inca=1; int incb=1; - ofs</dev/null) files=$(ls ./*.cpp ./*.f90 ./*.c 2>/dev/null) if [[ -n ${filesf90} ]]; then - otherLang="${otherLang}enable_language (Fortran)\n" + otherLang=$(cat << EOF +${otherLang} +include(CheckLanguage) +check_language(Fortran) +if(NOT CMAKE_Fortran_COMPILER) + message (FATAL_ERROR "NOT_APPLICABLE (Fortran compiler not found)") +endif() +enable_language (Fortran) +EOF +) if [[ $compiler_language = "fortran08" ]]; then otherLang=$( cat <CMakeLists.txt cmake_minimum_required(VERSION 3.20) project(exe-test CXX) +set (CMAKE_CXX_STANDARD 11) $(echo -e "$otherLang") find_package(Plumed2 REQUIRED) $(echo -e "$compileLibs") @@ -341,7 +351,7 @@ check() { # ASCII and diff will be shown in the log test "$(head -c 10 "$file")" = "#! FIELDS " && DIFFOPT="-a" out="$(diff $DIFFOPT "$file" "$new.zfix")" - diff $DIFFOPT "$file" "$new.zfix" + test -n "$out" && { echo FAILURE echo "Diff for ${file%.reference}:" @@ -360,9 +370,8 @@ check() { return $exitcode } -#this settings make the pipe exit with failure code of any command -#so the program exits with the exit state of the scripta and not the -#one of tee +#this settings make the pipe exit with failure code of any command so the +#program exits with the exit state of the script and not the one of tee set -o pipefail { if test -n "$PLUMED_PREPEND_PATH"; then @@ -411,12 +420,13 @@ set -o pipefail # this is the executable used for getting the configuration: plumed_nompi="$plumed --no-mpi" cat < referenceFile diff --git a/src/blas/CMakeLists.txt b/src/blas/CMakeLists.txt index a39c54ab1d..ae900c9695 100644 --- a/src/blas/CMakeLists.txt +++ b/src/blas/CMakeLists.txt @@ -22,6 +22,7 @@ if (BLAS_FOUND) PUBLIC __PLUMED_HAS_EXTERNAL_BLAS=1) include(CheckCXXSourceCompiles) + include(CheckCXXSourceRuns) #From the manual:The check is only performed once, with the result cached in #the variable named by . Every subsequent CMake run will re-use #this cached value rather than performing the check again, even if the @@ -47,18 +48,72 @@ if (BLAS_FOUND) ]] noUnderscodeBlas ) - unset(CMAKE_REQUIRED_LIBRARIES) - + set(CMAKE_REQUIRED_DEFINITIONS -DSDOTtype=float) if(noUnderscodeBlas) target_compile_definitions(${module_name} PUBLIC F77_NO_UNDERSCORE) + set(CMAKE_REQUIRED_DEFINITIONS -DF77_NO_UNDERSCORE -DSDOTtype=float) elseif(NOT noUnderscodeBlas AND NOT UnderscodeBlas) message(WARNING "both srtog_ and srtog are not linkable") # elseif(noUnderscodeBlas AND UnderscodeBlas) - # message(WARNING "both srtog_ and srtog are linkable") - # if both can be linked, use the underscore version + # message(WARNING "both srtog_ and srtog are linkable") + # if both can be linked, use the underscore version endif(noUnderscodeBlas) + set (sdot_check_source + [[ +#if ! defined(F77_NO_UNDERSCORE) +#define sdot sdot_ +#endif +extern "C"{ + SDOTtype sdot(int *n, float *dx, int *incx, float *dy, int *incy); +} + +int main(){ + int size=5; + float af[5],bf[5]; + for(unsigned i=0;i "$3"