From 373d0dd7541c00227661fc19f29bf9facfb27ce8 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 18 Jul 2023 16:32:19 -0400 Subject: [PATCH 01/16] Step up container versions --- .github/workflows/backend-template.yml | 3 ++- .github/workflows/test-library.yml | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend-template.yml b/.github/workflows/backend-template.yml index 8642237db..dd6e622eb 100644 --- a/.github/workflows/backend-template.yml +++ b/.github/workflows/backend-template.yml @@ -82,7 +82,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.apptainer - key: Linux-x86_64-containers-build-2022-10-11 + key: Linux-x86_64-containers-build-2023-07-20 - name: Checkout OpenMM (for Lepton library) uses: actions/checkout@v3 @@ -131,6 +131,7 @@ jobs: apptainer remote status SylabsCloud || apptainer remote add --no-login SylabsCloud cloud.sylabs.io apptainer remote use SylabsCloud apptainer pull CentOS7-devel.sif library://giacomofiorin/default/colvars_development:centos7 + apptainer pull CentOS9-devel.sif library://giacomofiorin/default/colvars_development:centos9 - name : Get spiff shell: bash diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 23fd0e834..a717394e6 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -88,7 +88,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.apptainer - key: Linux-x86_64-containers-build-doc-2022-09-03 + key: Linux-x86_64-containers-build-doc-2023-07-19 - name: Install Apptainer shell: bash @@ -102,7 +102,7 @@ jobs: run: | apptainer remote status SylabsCloud || apptainer remote add --no-login SylabsCloud cloud.sylabs.io apptainer remote use SylabsCloud - apptainer pull Fedora35-texlive.sif library://giacomofiorin/default/colvars_development:fedora35_texlive + apptainer pull texlive.sif library://giacomofiorin/default/colvars_development:texlive - name: Checkout website repository uses: actions/checkout@v3 @@ -115,7 +115,7 @@ jobs: env: COLVARSDIR: ${{ github.workspace }} FORCE: 1 # Ignore error if branch isn't master - run: apptainer exec ${COLVARSDIR}/devel-tools/Fedora35-texlive.sif make + run: apptainer exec ${COLVARSDIR}/devel-tools/texlive.sif make codeql: @@ -174,7 +174,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.apptainer - key: Linux-x86_64-containers-build-2022-10-11 + key: Linux-x86_64-containers-build-2023-07-20 - name: Get small downloadable packages uses: actions/checkout@v3 @@ -196,6 +196,7 @@ jobs: apptainer remote status SylabsCloud || apptainer remote add --no-login SylabsCloud cloud.sylabs.io apptainer remote use SylabsCloud apptainer pull CentOS7-devel.sif library://giacomofiorin/default/colvars_development:centos7 + apptainer pull CentOS9-devel.sif library://giacomofiorin/default/colvars_development:centos9 - name: GCC 4.8, C++11 env: @@ -340,7 +341,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.apptainer - key: Linux-x86_64-containers-build-2022-10-11 + key: Linux-x86_64-containers-build-2023-07-20 - name: Checkout Sun compiler (Oracle Developer Studio) uses: actions/checkout@v3 @@ -370,6 +371,7 @@ jobs: apptainer remote status SylabsCloud || apptainer remote add --no-login SylabsCloud cloud.sylabs.io apptainer remote use SylabsCloud apptainer pull CentOS7-devel.sif library://giacomofiorin/default/colvars_development:centos7 + apptainer pull CentOS9-devel.sif library://giacomofiorin/default/colvars_development:centos9 - name: Build library with Sun compiler (Oracle Developer Studio) shell: bash From b86ee6b869445badb4c2e1e1efc398062aae3b70 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 18 Jul 2023 16:40:03 -0400 Subject: [PATCH 02/16] Test new GCC and Clang versions --- .github/workflows/test-library.yml | 136 ++++++++++++++++++----------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index a717394e6..139d72bd2 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -198,7 +198,7 @@ jobs: apptainer pull CentOS7-devel.sif library://giacomofiorin/default/colvars_development:centos7 apptainer pull CentOS9-devel.sif library://giacomofiorin/default/colvars_development:centos9 - - name: GCC 4.8, C++11 + - name: GCC 4.8, C++11 (CentOS 7) env: CXX_STANDARD: 11 CXX: g++ @@ -208,29 +208,7 @@ jobs: apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 8, C++17 - env: - CXX_STANDARD: 17 - CXX: g++ - CXX_VERSION: 8 - CC: gcc - run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ - scl enable devtoolset-${CXX_VERSION} -- \ - cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - - name: GCC 11, C++20 - env: - CXX_STANDARD: 20 - CXX: g++ - CXX_VERSION: 11 - CC: gcc - run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ - scl enable devtoolset-${CXX_VERSION} -- \ - cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - - name: Clang 3.4, C++11 + - name: Clang 3.4, C++11 (CentOS 7) env: CXX_STANDARD: 11 CXX: clang++ @@ -240,7 +218,7 @@ jobs: apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: Clang 7, C++17 + - name: Clang 7, C++17 (CentOS 7) env: CXX_STANDARD: 17 CXX: clang++ @@ -251,29 +229,29 @@ jobs: scl enable llvm-toolset-${CXX_VERSION} -- \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 11, C++17 + - name: GCC 8, C++14 (CentOS 7) env: - CXX_STANDARD: 17 + CXX_STANDARD: 14 CXX: g++ - CXX_VERSION: 11 + CXX_VERSION: 8 CC: gcc run: | apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ scl enable devtoolset-${CXX_VERSION} -- \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 10, C++17 + - name: GCC 8, C++17 (CentOS 7) env: CXX_STANDARD: 17 CXX: g++ - CXX_VERSION: 10 + CXX_VERSION: 8 CC: gcc run: | apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ scl enable devtoolset-${CXX_VERSION} -- \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 9, C++14 + - name: GCC 9, C++14 (CentOS 7) env: CXX_STANDARD: 14 CXX: g++ @@ -284,49 +262,109 @@ jobs: scl enable devtoolset-${CXX_VERSION} -- \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 8, C++14 + - name: GCC 10, C++17 (CentOS 7) env: - CXX_STANDARD: 14 + CXX_STANDARD: 17 CXX: g++ - CXX_VERSION: 8 + CXX_VERSION: 10 CC: gcc run: | apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ scl enable devtoolset-${CXX_VERSION} -- \ cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 8, C++11 + + - name: GCC 11, C++11 (CentOS 9) env: CXX_STANDARD: 11 CXX: g++ - CXX_VERSION: 8 + CXX_VERSION: 11 CC: gcc run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ - scl enable devtoolset-${CXX_VERSION} -- \ - cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 7, C++14 + - name: GCC 11, C++14 (CentOS 9) env: CXX_STANDARD: 14 CXX: g++ - CXX_VERSION: 7 + CXX_VERSION: 11 CC: gcc run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ - scl enable devtoolset-${CXX_VERSION} -- \ - cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake - - name: GCC 7, C++11 + - name: GCC 11, C++17 (CentOS 9) + env: + CXX_STANDARD: 17 + CXX: g++ + CXX_VERSION: 11 + CC: gcc + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: GCC 11, C++20 (CentOS 9) + env: + CXX_STANDARD: 20 + CXX: g++ + CXX_VERSION: 11 + CC: gcc + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: GCC 12, C++11 (CentOS 9) env: CXX_STANDARD: 11 CXX: g++ - CXX_VERSION: 7 + CXX_VERSION: 12 CC: gcc run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ - scl enable devtoolset-${CXX_VERSION} -- \ - cmake3 -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + scl enable gcc-toolset-12 -- \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: GCC 12, C++20 (CentOS 9) + env: + CXX_STANDARD: 20 + CXX: g++ + CXX_VERSION: 12 + CC: gcc + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + scl enable gcc-toolset-12 -- \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: Clang 16, C++11 (CentOS 9) + env: + CXX_STANDARD: 11 + CXX: clang++ + CXX_VERSION: 16 + CC: clang + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: Clang 16, C++17 (CentOS 9) + env: + CXX_STANDARD: 17 + CXX: clang++ + CXX_VERSION: 16 + CC: clang + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake + + - name: Clang 16, C++20 (CentOS 9) + env: + CXX_STANDARD: 20 + CXX: clang++ + CXX_VERSION: 16 + CC: clang + run: | + apptainer exec ${{github.workspace}}/devel-tools/CentOS9-devel.sif \ + cmake -D CMAKE_CXX_STANDARD=${CXX_STANDARD} -P devel-tools/build_test_library.cmake build-linux-x86_64-sun: From 29b6696924fc4791df1ab2815361646643bd06b9 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 18 Jul 2023 17:03:21 -0400 Subject: [PATCH 03/16] Do not build NAMD with unsupported Pythons --- devel-tools/compile-namd.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/devel-tools/compile-namd.sh b/devel-tools/compile-namd.sh index d1dc3ae28..6f206b64a 100755 --- a/devel-tools/compile-namd.sh +++ b/devel-tools/compile-namd.sh @@ -72,7 +72,14 @@ EOF cmd+=(--tcl-prefix ${TCL_HOME:-/usr}) cmd+=(--with-fftw3 --fftw-prefix ${FFTW_HOME:-/usr}) - cmd+=(--with-python) + + local python_version=$(python3 --version 2> /dev/null | cut -d' ' -f 2) + python_version=${python_version%.*} + if [ "x${python_version}" == "x3.6" ] || [ "x${python_version}" == "x3.7" ] || \ + [ "x${python_version}" == "x3.8" ] ; then + # Currently does not build with >= 3.9 API + cmd+=(--with-python) + fi eval ${cmd[@]} From 8872267bdfbf31a9c78155d2c63353c762594eb3 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 18 Jul 2023 18:05:51 -0400 Subject: [PATCH 04/16] Exit on first error when patching --- update-colvars-code.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/update-colvars-code.sh b/update-colvars-code.sh index 8c9a9ea80..7f84fbebe 100755 --- a/update-colvars-code.sh +++ b/update-colvars-code.sh @@ -1,6 +1,8 @@ #!/bin/bash # -*- sh-basic-offset: 2; sh-indentation: 2; -*- +set -e + # Script to update a NAMD, VMD, LAMMPS or GROMACS source tree with the latest Colvars # version. From bc515e7fe5fc09bb2796ad4cbe33fdcf4e0dccfe Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Wed, 19 Jul 2023 15:22:37 -0400 Subject: [PATCH 05/16] Add container definition files for Apptainer/Singularity --- devel-tools/containers/CentOS7-devel.def | 49 ++++++++++++++++++++++++ devel-tools/containers/CentOS9-devel.def | 48 +++++++++++++++++++++++ devel-tools/containers/README.md | 12 ++++++ 3 files changed, 109 insertions(+) create mode 100644 devel-tools/containers/CentOS7-devel.def create mode 100644 devel-tools/containers/CentOS9-devel.def create mode 100644 devel-tools/containers/README.md diff --git a/devel-tools/containers/CentOS7-devel.def b/devel-tools/containers/CentOS7-devel.def new file mode 100644 index 000000000..16aaf68bc --- /dev/null +++ b/devel-tools/containers/CentOS7-devel.def @@ -0,0 +1,49 @@ +BootStrap: library +From: centos:7 + + +%help + Development environment for CentOS 7 + + +%post + yum -y update + yum -y install epel-release centos-release-scl + yum -y install \ + redhat-lsb-core "@Development Tools" \ + ncurses which bc man-db vim emacs screen tmux \ + gcc gcc-c++ gcc-gfortran glibc-static libstdc++-static clang cppcheck \ + autoconf automake cvs git git-cvs cvsps subversion mercurial \ + rh-git227 devtoolset-{7..11} llvm-toolset-7 cmake3 ccache ninja \ + doxygen \ + openmpi-devel fftw-devel tcl-devel \ + python-{devel,virtualenv} numpy scipy tkinter \ + python3-{devel,tkinter} python36-{virtualenv,numpy,scipy} \ + rh-python38-python-{devel,tkinter,numpy,scipy} \ + boost169-devel \ + ncurses-devel \ + rlwrap \ + tk-devel fltk-devel \ + sqlite-devel netcdf-devel expat-devel hdf5-devel tng-devel \ + mesa-dri-drivers mesa-libGL-devel libglvnd-devel \ + libXi-devel libXinerama-devel libpng-devel \ + xfce4-terminal \ + texlive-latex texlive-epstopdf texlive-pdftex latex2html \ + texlive-graphics texlive-metafont \ + texlive-collection-latexrecommended texlive-collection-fontsrecommended + + # Build Charm++ + umask 022 + git clone --single-branch --depth=1 -b v7.0.0 https://github.com/UIUC-PPL/charm.git /opt/charm && \ + cd /opt/charm && \ + ./build charm++ mpi-linux-x86_64 -j\$(nproc) --with-production && \ + ./build charm++ multicore-linux-x86_64 -j\$(nproc) --with-production && \ + ./build charm++ netlrts-linux-x86_64 -j\$(nproc) --with-production + + # Load Git 2.27 + cat > /etc/profile.d/git.sh < Date: Sun, 20 Aug 2023 15:20:55 +0200 Subject: [PATCH 06/16] Specify container name when building a backend --- .github/workflows/backend-template.yml | 22 +++++++++++++--------- .github/workflows/test-backends.yml | 7 +++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/backend-template.yml b/.github/workflows/backend-template.yml index dd6e622eb..804f6b656 100644 --- a/.github/workflows/backend-template.yml +++ b/.github/workflows/backend-template.yml @@ -25,6 +25,10 @@ on: description: "Name of the branch of the backend repository" required: true type: string + container_name: + description: "Name of the container used to build on" + required: true + type: string vmd_plugins_repo: description: "Name of the VMD plugins repository" required: false @@ -71,7 +75,7 @@ jobs: with: path: | ~/.ccache - ~/ccache_CentOS7-devel + ~/ccache_${{ inputs.container_name }} key: ${{ runner.os }}-build-${{ inputs.backend_name }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-build-${{ inputs.backend_name }}- @@ -122,11 +126,11 @@ jobs: wget https://github.com/apptainer/apptainer/releases/download/v1.0.3/apptainer_1.0.3_amd64.deb sudo apt-get -y install ./apptainer_1.0.3_amd64.deb - - name: Get container image of backends' dependencies + - name: Get container images for build dependencies shell: bash working-directory: devel-tools run: | - # Pull CentOS 7 container used to build backends + # Pull all containers used to build backends # (contains build tools, OpenMPI, FFTW, Tcl/Tk and Charm++) apptainer remote status SylabsCloud || apptainer remote add --no-login SylabsCloud cloud.sylabs.io apptainer remote use SylabsCloud @@ -136,16 +140,16 @@ jobs: - name : Get spiff shell: bash working-directory: devel-tools - run: sudo cp -f $(apptainer exec CentOS7-devel.sif ./get_spiff) /usr/local/bin + run: sudo cp -f $(apptainer exec ${{ inputs.container_name }}.sif ./get_spiff) /usr/local/bin - name: Update and build ${{ inputs.backend_name }} shell: bash env: OPENMM_SOURCE: ${{ github.workspace }}/openmm-source run: | - apptainer exec devel-tools/CentOS7-devel.sif ./update-colvars-code.sh -f ${{ inputs.backend_name }}-source - CCACHE_DIR=~/ccache_CentOS7-devel \ - apptainer exec devel-tools/CentOS7-devel.sif \ + apptainer exec devel-tools/${{ inputs.container_name }}.sif ./update-colvars-code.sh -f ${{ inputs.backend_name }}-source + CCACHE_DIR=~/ccache_${{ inputs.container_name }} \ + apptainer exec devel-tools/${{ inputs.container_name }}.sif \ bash ${{ inputs.path_compile_script }} ${{ inputs.backend_name }}-source @@ -158,7 +162,7 @@ jobs: shell: bash working-directory: ${{ inputs.test_lib_directory }} run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ + apptainer exec ${{github.workspace}}/devel-tools/${{ inputs.container_name }}.sif \ ./run_tests.sh ${{github.workspace}}/${{ inputs.backend_name }}-source/${{ inputs.rpath_exe }} 0??_* - name: Run regression tests for ${{ inputs.backend_name }} interface code @@ -166,5 +170,5 @@ jobs: shell: bash working-directory: ${{ inputs.test_interface_directory }} run: | - apptainer exec ${{github.workspace}}/devel-tools/CentOS7-devel.sif \ + apptainer exec ${{github.workspace}}/devel-tools/${{ inputs.container_name }}.sif \ ./run_tests.sh ${{github.workspace}}/${{ inputs.backend_name }}-source/${{ inputs.rpath_exe }} diff --git a/.github/workflows/test-backends.yml b/.github/workflows/test-backends.yml index 62e10e7b4..266972893 100644 --- a/.github/workflows/test-backends.yml +++ b/.github/workflows/test-backends.yml @@ -26,6 +26,7 @@ jobs: backend_name: LAMMPS backend_repo: lammps/lammps backend_repo_ref: develop + container_name: CentOS7-devel path_compile_script: devel-tools/compile-lammps.sh test_lib_directory: lammps/tests/library test_interface_directory: lammps/tests/interface @@ -43,6 +44,7 @@ jobs: backend_name: NAMD backend_repo: Colvars/namd backend_repo_ref: master + container_name: CentOS7-devel path_compile_script: devel-tools/compile-namd.sh test_lib_directory: namd/tests/library test_interface_directory: namd/tests/interface @@ -68,6 +70,7 @@ jobs: # Interface tests disabled until map variables are merged into NAMD3 # test_interface_directory: namd/tests/interface rpath_exe: Linux-x86_64-g++.multicore/namd3 + container_name: CentOS7-devel secrets: # Choice of license by UIUC prevents sharing the code, hence the secret private_key: ${{ secrets.PULL_NAMD_KEY }} @@ -84,6 +87,7 @@ jobs: backend_name: VMD backend_repo: Colvars/vmd backend_repo_ref: master + container_name: CentOS7-devel # Special variable for VMD test case since it's the only one # which needs to checkout 2 repos vmd_plugins_repo: Colvars/vmd-plugins @@ -103,6 +107,7 @@ jobs: backend_name: GROMACS-2020 backend_repo: gromacs/gromacs backend_repo_ref: release-2020 + container_name: CentOS7-devel path_compile_script: devel-tools/compile-gromacs.sh test_lib_directory: gromacs/tests/library # Gromacs need to be compiled in double precision to pass the tests @@ -116,6 +121,7 @@ jobs: backend_name: GROMACS-2021 backend_repo: gromacs/gromacs backend_repo_ref: release-2021 + container_name: CentOS9-devel path_compile_script: devel-tools/compile-gromacs.sh test_lib_directory: gromacs/tests/library rpath_exe: install/bin/gmx_d @@ -128,6 +134,7 @@ jobs: backend_name: GROMACS-2022 backend_repo: gromacs/gromacs backend_repo_ref: release-2022 + container_name: CentOS9-devel path_compile_script: devel-tools/compile-gromacs.sh test_lib_directory: gromacs/tests/library rpath_exe: install/bin/gmx_d From e571f47332965a7972d45b2f57cb7ef35b8add6e Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Sun, 20 Aug 2023 21:59:08 +0200 Subject: [PATCH 07/16] Fix NAMD Makefile update command --- update-colvars-code.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-colvars-code.sh b/update-colvars-code.sh index 7f84fbebe..8932391de 100755 --- a/update-colvars-code.sh +++ b/update-colvars-code.sh @@ -365,7 +365,7 @@ then condcopy "${source}/namd/lepton/Makefile.namd" \ "${target}/lepton/Makefile.namd" - if ! grep -q lepton/Makefile.namd "${target}/lepton/Makefile.namd" ; then + if ! grep -q lepton/Makefile.namd "${target}/Makefile" ; then patch -p1 -N -d ${target} < namd/Makefile.patch fi From 28f5f6b203e2f026181211fe52607d38c3255e1c Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Thu, 13 Jul 2023 10:04:59 -0400 Subject: [PATCH 08/16] Initialize the list of variables early to restore --list-variables option Fixes a regression due to #479 --- colvartools/plot_colvars_traj.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/colvartools/plot_colvars_traj.py b/colvartools/plot_colvars_traj.py index b396b70e0..00f3e42ab 100644 --- a/colvartools/plot_colvars_traj.py +++ b/colvartools/plot_colvars_traj.py @@ -3,7 +3,7 @@ # Invoke this script with --help for documentation. # Download link: https://github.com/Colvars/colvars/blob/master/colvartools/plot_colvars_traj.py?raw=true -# This version was modified on: 2022-09-12 +# This version was modified on: 2023-07-13 # Contact: giacomo.fiorin@gmail.com from __future__ import print_function @@ -143,6 +143,8 @@ def _parse_comment_line(self, line): self._keys = new_keys # Find the boundaries of each column for i in range(1, len(self._keys)): + if (self._keys[i] not in self._colvars): + self._colvars[self._keys[i]] = Colvar_traj(self._keys[i]) if i == 1: pos = line.find(' '+self._keys[i]+' ') else: @@ -152,7 +154,6 @@ def _parse_comment_line(self, line): self._end[self._keys[i-1]] = pos self._end[self._keys[-1]] = -1 - def _parse_line(self, line, dict_buffer): """ Read in a data line from a colvars.traj file @@ -226,10 +227,8 @@ def read_files(self, filenames, list_variables=False, last_step = step for key in dict_buffer: - if (key not in self._colvars): - self._colvars[key] = Colvar_traj(key) - self._colvars[key]._set_num_dimensions(dict_buffer[key]['dimension']) cv = self._colvars[key] + cv._set_num_dimensions(dict_buffer[key]['dimension']) cv._step = np.concatenate((cv.steps, dict_buffer[key]['cv_step']), axis=0) cv._colvar = np.concatenate((cv.values, dict_buffer[key]['cv_values']), axis=0) f.close() From 21f1195af08b86bbfd56e77c72a5fe1e255f65ca Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Thu, 20 Jul 2023 15:59:09 -0400 Subject: [PATCH 09/16] Separate checking the name of the bias from reading its state data --- src/colvarbias.cpp | 37 +++++++++++++++++++++---------------- src/colvarbias.h | 3 +++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/colvarbias.cpp b/src/colvarbias.cpp index 18969fc53..97c0c40e4 100644 --- a/src/colvarbias.cpp +++ b/src/colvarbias.cpp @@ -462,17 +462,15 @@ std::string const colvarbias::get_state_params() const } -int colvarbias::set_state_params(std::string const &conf) +int colvarbias::check_matching_state(std::string const &conf) { - matching_state = false; - std::string check_name = ""; colvarparse::get_keyval(conf, "name", check_name, std::string(""), colvarparse::parse_silent); if (check_name.size() == 0) { - cvm::error("Error: \""+bias_type+"\" block within the restart file " - "has no identifiers.\n", COLVARS_INPUT_ERROR); + return cvm::error("Error: \""+bias_type+"\" block within the state file " + "has no identifiers.\n", COLVARS_INPUT_ERROR); } if (check_name != this->name) { @@ -480,11 +478,17 @@ int colvarbias::set_state_params(std::string const &conf) cvm::log("Ignoring state of bias \""+check_name+ "\": this bias is named \""+name+"\".\n"); } - return COLVARS_OK; + matching_state = false; + } else { + matching_state = true; } - matching_state = true; + return COLVARS_OK; +} + +int colvarbias::set_state_params(std::string const &conf) +{ colvarparse::get_keyval(conf, "step", state_file_step, cvm::step_absolute(), colvarparse::parse_silent); @@ -515,41 +519,42 @@ std::ostream & colvarbias::write_state(std::ostream &os) std::istream & colvarbias::read_state(std::istream &is) { - std::streampos const start_pos = is.tellg(); + auto const start_pos = is.tellg(); std::string key, brace, conf; if ( !(is >> key) || !(key == state_keyword || key == bias_type) || !(is >> brace) || !(brace == "{") || !(is >> colvarparse::read_block("configuration", &conf)) || - (set_state_params(conf) != COLVARS_OK) ) { + (check_matching_state(conf) != COLVARS_OK) ) { cvm::error("Error: in reading state configuration for \""+bias_type+ "\" bias \""+ this->name+"\" at position "+ cvm::to_str(static_cast(is.tellg()))+ " in stream.\n", COLVARS_INPUT_ERROR); is.clear(); - is.seekg(start_pos, std::ios::beg); + is.seekg(start_pos); is.setstate(std::ios::failbit); return is; } - if (matching_state == false) { - // This state is not for this bias - is.seekg(start_pos, std::ios::beg); + if (!matching_state) { + // No errors reading, but this state is not for this bias; rewind + is.seekg(start_pos); return is; } cvm::log("Restarting "+bias_type+" bias \""+name+"\" from step number "+ cvm::to_str(state_file_step)+".\n"); - if (!read_state_data(is)) { + if ((set_state_params(conf) != COLVARS_OK) || !read_state_data(is)) { cvm::error("Error: in reading state data for \""+bias_type+"\" bias \""+ this->name+"\" at position "+ cvm::to_str(static_cast(is.tellg()))+ " in stream.\n", COLVARS_INPUT_ERROR); + auto state = is.rdstate(); is.clear(); - is.seekg(start_pos, std::ios::beg); - is.setstate(std::ios::failbit); + is.seekg(start_pos); + is.setstate(state); } is >> brace; diff --git a/src/colvarbias.h b/src/colvarbias.h index e865902be..de7b04b51 100644 --- a/src/colvarbias.h +++ b/src/colvarbias.h @@ -133,6 +133,9 @@ class colvarbias /// Write the values of specific mutable properties to a string virtual std::string const get_state_params() const; + /// Check the name of the bias vs. the given string, set the matching_state flag accordingly + int check_matching_state(std::string const &conf); + /// Read the values of specific mutable properties from a string virtual int set_state_params(std::string const &state_conf); From e703c509fd64ac8dc31af7479eabf3a718e6e431 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Mon, 21 Aug 2023 09:34:03 +0200 Subject: [PATCH 10/16] Update version strings --- doc/cv_version.tex | 2 +- src/colvars_version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cv_version.tex b/doc/cv_version.tex index f6a2281ea..3f2af9429 100644 --- a/doc/cv_version.tex +++ b/doc/cv_version.tex @@ -1 +1 @@ -\newcommand{\cvversion}{2023-07-21} +\newcommand{\cvversion}{2023-08-21} diff --git a/src/colvars_version.h b/src/colvars_version.h index d0f63e717..0aa4e60d1 100644 --- a/src/colvars_version.h +++ b/src/colvars_version.h @@ -1,3 +1,3 @@ #ifndef COLVARS_VERSION -#define COLVARS_VERSION "2023-07-21" +#define COLVARS_VERSION "2023-08-21" #endif From cc97e6a337ef7a3a06cf30852ee43bbda0ca6711 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 22 Aug 2023 11:40:52 +0200 Subject: [PATCH 11/16] Use Clang early when testing builds --- .github/workflows/test-library.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 139d72bd2..6ae56e84a 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -33,7 +33,7 @@ jobs: - name: Install build dependencies for library run: | - sudo apt-get -y install ccache tcl8.6-dev + sudo apt -y install ccache tcl8.6-dev clang - name: Test build recipes run: bash devel-tools/check_build_recipes @@ -48,7 +48,7 @@ jobs: exit 1 fi - - name: Build and test library with CMake + - name: Build and test library (GCC) env: CCACHE: ccache run: cmake -P devel-tools/build_test_library.cmake @@ -63,6 +63,13 @@ jobs: exit 1 fi + - name: Build and test library (Clang) + env: + CCACHE: ccache + CXX: clang++ + CC: clang + run: cmake -P devel-tools/build_test_library.cmake + - name: Build library with debug flags enabled env: CCACHE: ccache From 110b08fb075a575432a41b6db4d84023375cc716 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 22 Aug 2023 11:50:28 +0200 Subject: [PATCH 12/16] Use distinct build directory --- .github/workflows/test-library.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 6ae56e84a..3b81d5050 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -65,6 +65,7 @@ jobs: - name: Build and test library (Clang) env: + CMAKE_BUILD_DIR: build-clang CCACHE: ccache CXX: clang++ CC: clang From 0292804742e8635d2997c7c7efce39aefff0b045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20H=C3=A9nin?= Date: Sat, 19 Aug 2023 10:28:43 +0200 Subject: [PATCH 13/16] Set CVC description consistently --- src/colvarcomp.cpp | 26 ++++++++++++++++++++------ src/colvarcomp.h | 3 +++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/colvarcomp.cpp b/src/colvarcomp.cpp index abe522a24..151a25569 100644 --- a/src/colvarcomp.cpp +++ b/src/colvarcomp.cpp @@ -43,6 +43,22 @@ colvar::cvc::cvc(std::string const &conf) } +int colvar::cvc::update_description() +{ + if (name.size() > 0) { + description = "cvc " + name; + } else { + description = "unnamed cvc"; + } + if (function_type.size() > 0) { + description += " of type \"" + function_type + "\""; + } else { + description += " of unset type"; + } + return COLVARS_OK; +} + + int colvar::cvc::set_function_type(std::string const &type) { function_type = type; @@ -53,6 +69,8 @@ int colvar::cvc::set_function_type(std::string const &type) function_types.push_back(function_type); } } + update_description(); + for (size_t i = function_types.size()-1; i > 0; i--) { cvm::main()->cite_feature(function_types[i]+" colvar component"+ " (derived from "+function_types[i-1]+")"); @@ -74,11 +92,6 @@ int colvar::cvc::init(std::string const &conf) } if (get_keyval(conf, "name", name, name)) { - if (name.size() > 0) { - description = "cvc \"" + name + "\" of type " + function_type; - } else { - description = "unnamed cvc"; - } if ((name != old_name) && (old_name.size() > 0)) { cvm::error("Error: cannot rename component \""+old_name+ "\" after initialization (new name = \""+name+"\")", @@ -86,6 +99,7 @@ int colvar::cvc::init(std::string const &conf) name = old_name; } } + update_description(); get_keyval(conf, "componentCoeff", sup_coeff, sup_coeff); get_keyval(conf, "componentExp", sup_np, sup_np); @@ -314,7 +328,7 @@ int colvar::cvc::init_dependencies() { int colvar::cvc::setup() { - description = "cvc " + name; + update_description(); return COLVARS_OK; } diff --git a/src/colvarcomp.h b/src/colvarcomp.h index c89143bc0..e475d815c 100644 --- a/src/colvarcomp.h +++ b/src/colvarcomp.h @@ -278,6 +278,9 @@ class colvar::cvc protected: + /// Update the description string based on name and type + int update_description(); + /// Record the type of this class as well as those it is derived from std::vector function_types; From c65dfd419165dfcfbe5003d8305e1932700b4564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20H=C3=A9nin?= Date: Tue, 29 Aug 2023 13:30:38 +0200 Subject: [PATCH 14/16] Move Python, C_fortran, stubs to misc_interfaces/ --- {C_fortran => misc_interfaces/C_fortran}/C_test.c | 0 {C_fortran => misc_interfaces/C_fortran}/Makefile | 6 +++--- {C_fortran => misc_interfaces/C_fortran}/colvarproxy_C.cpp | 0 {C_fortran => misc_interfaces/C_fortran}/colvarproxy_C.h | 1 + .../C_fortran}/colvarproxy_C_interface.h | 0 {C_fortran => misc_interfaces/C_fortran}/colvars.py | 0 {C_fortran => misc_interfaces/C_fortran}/fortran_test.f90 | 0 {python => misc_interfaces/python}/colvars.py | 0 {tests => misc_interfaces}/stubs/colvarproxy_stub.cpp | 0 {tests => misc_interfaces}/stubs/colvarproxy_stub.h | 0 tests/functional/CMakeLists.txt | 2 +- tests/unittests/CMakeLists.txt | 2 +- 12 files changed, 6 insertions(+), 5 deletions(-) rename {C_fortran => misc_interfaces/C_fortran}/C_test.c (100%) rename {C_fortran => misc_interfaces/C_fortran}/Makefile (85%) rename {C_fortran => misc_interfaces/C_fortran}/colvarproxy_C.cpp (100%) rename {C_fortran => misc_interfaces/C_fortran}/colvarproxy_C.h (98%) rename {C_fortran => misc_interfaces/C_fortran}/colvarproxy_C_interface.h (100%) rename {C_fortran => misc_interfaces/C_fortran}/colvars.py (100%) rename {C_fortran => misc_interfaces/C_fortran}/fortran_test.f90 (100%) rename {python => misc_interfaces/python}/colvars.py (100%) rename {tests => misc_interfaces}/stubs/colvarproxy_stub.cpp (100%) rename {tests => misc_interfaces}/stubs/colvarproxy_stub.h (100%) diff --git a/C_fortran/C_test.c b/misc_interfaces/C_fortran/C_test.c similarity index 100% rename from C_fortran/C_test.c rename to misc_interfaces/C_fortran/C_test.c diff --git a/C_fortran/Makefile b/misc_interfaces/C_fortran/Makefile similarity index 85% rename from C_fortran/Makefile rename to misc_interfaces/C_fortran/Makefile index 09c2aa49d..cd5361a49 100644 --- a/C_fortran/Makefile +++ b/misc_interfaces/C_fortran/Makefile @@ -3,8 +3,8 @@ # This Makefile is useful for compilation tests only. To use the library, # please use instead the build recipes of the packages that include it. -COLVARS_LIB = ../src/libcolvars.a -COLVARS_SRC_DIR = ../src +COLVARS_LIB = ../../src/libcolvars.a +COLVARS_SRC_DIR = ../../src IF_OBJ = colvarproxy_C.o CXXFLAGS := -std=c++11 -pedantic -g -O2 -fPIC @@ -26,7 +26,7 @@ C_test.o: C_test.c gcc -c $< -pedantic -g -I$(COLVARS_SRC_DIR) $(COLVARS_LIB): - make -f $(COLVARS_SRC_DIR)/Makefile -C $(COLVARS_SRC_DIR) libcolvars.a -j20 + make -C $(COLVARS_SRC_DIR) libcolvars.a -j20 %.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -I$(COLVARS_SRC_DIR) diff --git a/C_fortran/colvarproxy_C.cpp b/misc_interfaces/C_fortran/colvarproxy_C.cpp similarity index 100% rename from C_fortran/colvarproxy_C.cpp rename to misc_interfaces/C_fortran/colvarproxy_C.cpp diff --git a/C_fortran/colvarproxy_C.h b/misc_interfaces/C_fortran/colvarproxy_C.h similarity index 98% rename from C_fortran/colvarproxy_C.h rename to misc_interfaces/C_fortran/colvarproxy_C.h index 39946a465..8babb0c42 100644 --- a/C_fortran/colvarproxy_C.h +++ b/misc_interfaces/C_fortran/colvarproxy_C.h @@ -1,6 +1,7 @@ // Test linking Colvars through a C interface #include "colvarproxy.h" +#include /// \brief Communication between colvars and LAMMPS /// (implementation of \link colvarproxy \endlink) diff --git a/C_fortran/colvarproxy_C_interface.h b/misc_interfaces/C_fortran/colvarproxy_C_interface.h similarity index 100% rename from C_fortran/colvarproxy_C_interface.h rename to misc_interfaces/C_fortran/colvarproxy_C_interface.h diff --git a/C_fortran/colvars.py b/misc_interfaces/C_fortran/colvars.py similarity index 100% rename from C_fortran/colvars.py rename to misc_interfaces/C_fortran/colvars.py diff --git a/C_fortran/fortran_test.f90 b/misc_interfaces/C_fortran/fortran_test.f90 similarity index 100% rename from C_fortran/fortran_test.f90 rename to misc_interfaces/C_fortran/fortran_test.f90 diff --git a/python/colvars.py b/misc_interfaces/python/colvars.py similarity index 100% rename from python/colvars.py rename to misc_interfaces/python/colvars.py diff --git a/tests/stubs/colvarproxy_stub.cpp b/misc_interfaces/stubs/colvarproxy_stub.cpp similarity index 100% rename from tests/stubs/colvarproxy_stub.cpp rename to misc_interfaces/stubs/colvarproxy_stub.cpp diff --git a/tests/stubs/colvarproxy_stub.h b/misc_interfaces/stubs/colvarproxy_stub.h similarity index 100% rename from tests/stubs/colvarproxy_stub.h rename to misc_interfaces/stubs/colvarproxy_stub.h diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index e86a6228d..cfcade4d9 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -1,4 +1,4 @@ -set(COLVARS_STUBS_DIR ${COLVARS_SOURCE_DIR}/tests/stubs/) +set(COLVARS_STUBS_DIR ${COLVARS_SOURCE_DIR}/misc_interfaces/stubs/) add_library(colvars_stubs OBJECT ${COLVARS_STUBS_DIR}/colvarproxy_stub.cpp) target_include_directories(colvars_stubs PRIVATE ${COLVARS_SOURCE_DIR}/src) diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index f4653cb2b..e2804ae75 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -17,7 +17,7 @@ endif() # Last test requires the stubs proxy add_executable(read_xyz_traj read_xyz_traj.cpp) -set(COLVARS_STUBS_DIR ${COLVARS_SOURCE_DIR}/tests/stubs/) +set(COLVARS_STUBS_DIR ${COLVARS_SOURCE_DIR}/misc_interfaces/stubs/) target_link_libraries(read_xyz_traj PRIVATE colvars colvars_stubs) target_include_directories(read_xyz_traj PRIVATE ${COLVARS_SOURCE_DIR}/src) target_include_directories(read_xyz_traj PRIVATE ${COLVARS_STUBS_DIR}) From 747a669bfc6a7c39ab6b8f2a3ecea6afd73aeab0 Mon Sep 17 00:00:00 2001 From: HanatoK Date: Mon, 28 Aug 2023 09:45:11 -0500 Subject: [PATCH 15/16] Fix #569 and allow mixing scalar and vector CVCs --- src/colvarcomp_combination.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/colvarcomp_combination.cpp b/src/colvarcomp_combination.cpp index 7d5079701..974cc870c 100644 --- a/src/colvarcomp_combination.cpp +++ b/src/colvarcomp_combination.cpp @@ -33,22 +33,8 @@ colvar::linearCombination::linearCombination(std::string const &conf): cvc(conf) " expects one or more nesting components.\n"); return; } else { - // TODO: Maybe we can add an option to allow mixing scalar and vector types, - // but that's a bit complicated so we just require a consistent type - // of nesting CVs. x.type(cv[0]->value()); x.reset(); - for (size_t i_cv = 1; i_cv < cv.size(); ++i_cv) { - const auto type_i = cv[i_cv]->value().type(); - if (type_i != x.type()) { - cvm::error("Error: the type of sub-CVC " + cv[i_cv]->name + - " is " + colvarvalue::type_desc(type_i) + ", which is " - "different to the type of the first sub-CVC. Currently " - "only sub-CVCs of the same type are supported to be " - "nested.\n"); - return; - } - } } use_explicit_gradients = true; for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) { @@ -317,7 +303,8 @@ void colvar::customColvar::apply_force(colvarvalue const &force) { } } else { const colvarvalue& current_cv_value = cv[i_cv]->value(); - colvarvalue cv_force(current_cv_value.type()); + colvarvalue cv_force(current_cv_value); + cv_force.reset(); const cvm::real factor_polynomial = getPolynomialFactorOfCVGradient(i_cv); for (size_t j_elem = 0; j_elem < current_cv_value.size(); ++j_elem) { for (size_t c = 0; c < x.size(); ++c) { From 870718f433bfdf02d9b1d242befee757864cc0d3 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Mon, 28 Aug 2023 17:15:52 +0200 Subject: [PATCH 16/16] Add clarifying note in the code doc --- src/colvarvalue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/colvarvalue.h b/src/colvarvalue.h index 9ab8dbe31..6bc7a57c7 100644 --- a/src/colvarvalue.h +++ b/src/colvarvalue.h @@ -120,7 +120,8 @@ class colvarvalue { /// number and always behaves like it unless you change its type colvarvalue(); - /// Constructor from a type specification + /// Constructor from a type flag (note: type_vector also needs the vector length to be set) + /// \param[in] vti Value of the \link Type \endlink enum colvarvalue(Type const &vti); /// Copy constructor from real base type