Skip to content

Commit 3235614

Browse files
committed
kenref: auto-fetch a GROMACS source when none is provided
The build scripts otherwise REQUIRE --gromacs-src, on the grounds that `plumed patch` rewrites the tree in place so the user should dedicate one consciously. This branch relaxes that: when no source is given, fetch GROMACS_GIT_TAG (default: newest v2025.x) into ${PLUMED_ROOT}/build/gromacs-src and reuse it. This is the ONLY difference between kenref-plumed-downloads and kenref-plumed-master. It is kept separate because auto-downloading a multi-GB tree from someone else's project is not something a ./configure should do behind the user's back, so it must not reach the upstream contribution.
1 parent e90a785 commit 3235614

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

src/kenref/_common.sh

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ KENREF_GIT_TAG="${KENREF_GIT_TAG:-master}"
3636
# install). BUILD and FETCH dirs stay in the source trees — they are artefacts, not installs.
3737
KENREF_PREFIX="" # kenref_core install prefix (default: /usr/local/kenref)
3838
PLUMED_PREFIX="/usr/local"
39-
# GROMACS (batch script): a PROVIDED 2025.x source. KEnRef is fetched when absent (it is our own, small,
40-
# and the module cannot be built without it); GROMACS deliberately is NOT — a multi-GB clone of somebody
41-
# else's tree is not something a `./configure` should start behind the user's back, and `plumed patch`
42-
# rewrites that tree in place.
39+
# GROMACS (batch script): use a provided source, else fetch one to a PLUMED-related dir (separate tree).
40+
# NB: this auto-fetch is exactly what makes this the "downloads" branch; kenref-plumed-master omits it.
4341
GROMACS_SRC=""
4442
GROMACS_PREFIX="/usr/local/gromacs"
43+
GROMACS_GIT_URL="${GROMACS_GIT_URL:-https://gitlab.com/gromacs/gromacs.git}"
44+
GROMACS_GIT_TAG="${GROMACS_GIT_TAG:-latest-2025}" # 'latest-2025' => newest v2025.x
45+
GROMACS_FETCH_DIR="${PLUMED_ROOT}/build/gromacs-src" # plumed-related; persisted+reused
4546
PATCH_ENGINE="" # empty => auto (newest gromacs-2025.x shipped with this PLUMED)
4647

4748
say() { printf '\n\033[1;34m==> %s\033[0m\n' "$*"; }
@@ -105,7 +106,7 @@ Usage: src/kenref/${KN_SCRIPT:-build}.sh [options] (no options => interactive)
105106
--accel A AVX_512 | AVX_256 | AVX2_256 (default: auto-detect)
106107
--jobs N parallel build jobs (default: ${JOBS})
107108
$( [ "${KN_BATCHES:-0}" = 1 ] && cat <<G
108-
--gromacs-src DIR GROMACS 2025.x source (REQUIRED — GROMACS is never auto-downloaded)
109+
--gromacs-src DIR GROMACS 2025.x source (omit to auto-fetch ${GROMACS_GIT_TAG})
109110
--gromacs-prefix DIR GROMACS install prefix (default: ${GROMACS_PREFIX})
110111
--patch-engine E plumed patch -e engine (default: auto)
111112
G
@@ -241,13 +242,26 @@ build_plumed() {
241242

242243
# ---- STEP 3: GROMACS 2025.x, batched with THIS PLUMED's `plumed patch` -------
243244
build_gromacs() {
244-
# A PROVIDED GROMACS 2025.x source is required: `plumed patch` REWRITES the tree in place, so it must
245-
# be a checkout the user has consciously dedicated to the plumed path (not, say, the one kenref-gmx
246-
# builds against). We never pick one for them, and we never download one.
247-
[ -n "$GROMACS_SRC" ] || ask_val GROMACS_SRC "GROMACS 2025.x source (required)"
248-
[ -n "$GROMACS_SRC" ] || die "no GROMACS source provided. Pass --gromacs-src DIR (a GROMACS 2025.x
249-
checkout, preferably 2025.4). GROMACS is never auto-downloaded: 'plumed patch' rewrites the tree in
250-
place, so it must be one you have dedicated to this purpose."
245+
# Provided source, else FETCH one to a plumed-related dir (separate from any kenref-gmx gromacs).
246+
# `plumed patch` REWRITES the tree in place, which is why a fetched copy lives under the build dir.
247+
if [ -z "$GROMACS_SRC" ] && interactive; then
248+
ask_val GROMACS_SRC "GROMACS 2025.x source (blank = fetch ${GROMACS_GIT_TAG})"
249+
fi
250+
if [ -z "$GROMACS_SRC" ]; then
251+
GROMACS_SRC="$GROMACS_FETCH_DIR"
252+
if [ ! -f "${GROMACS_SRC}/CMakeLists.txt" ]; then
253+
local tag="$GROMACS_GIT_TAG"
254+
if [ "$tag" = "latest-2025" ]; then
255+
tag="$(git ls-remote --tags --refs "$GROMACS_GIT_URL" 2>/dev/null | grep -oE 'v2025\.[0-9]+' | sort -V | tail -1)"
256+
[ -z "$tag" ] && tag="v2025.4"
257+
fi
258+
say "fetching GROMACS ${tag} -> ${GROMACS_SRC} (plumed-related)"
259+
git clone --depth 1 --branch "$tag" "$GROMACS_GIT_URL" "$GROMACS_SRC" \
260+
|| die "GROMACS clone failed; provide one with --gromacs-src DIR."
261+
else
262+
say "reusing fetched GROMACS at ${GROMACS_SRC}"
263+
fi
264+
fi
251265
[ -f "${GROMACS_SRC}/CMakeLists.txt" ] || die "--gromacs-src '${GROMACS_SRC}' is not a GROMACS source tree."
252266

253267
local ver

0 commit comments

Comments
 (0)