Skip to content

Automatically downloads and creates path_names lists for different Socrates versions using new Socrates github - #301

Draft
sit23 wants to merge 3 commits into
ExeClim:masterfrom
sit23:socrates_opensource_auto
Draft

Automatically downloads and creates path_names lists for different Socrates versions using new Socrates github#301
sit23 wants to merge 3 commits into
ExeClim:masterfrom
sit23:socrates_opensource_auto

Conversation

@sit23

@sit23 sit23 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

One of the significant problems with Isca's use of Socrates is that it has required the user to manually download Socrates themselves, and also to create a list of path_names. This P/R changes both - it uses the Met Office's new github repo for Socrates to automatically checkout Socrates if it is not already present, and then works out which path_names should be used for that version. This was built off the old socrates_versions branch of my fork, with new functionality built and tested by Claude. Claude has done a significant amount of testing of this new functionalityy, but this P/R will remain a draft until I have manually tested the functionality.

sit23 and others added 3 commits August 11, 2026 14:33
Socrates was closed-source until now; the Met Office have open-sourced it
at github.com/MetOffice/socrates under BSD-3-Clause. Registering it as a
submodule lets GitHub's dependency graph show the relationship and gives
users a standard way to fetch the matching source
(`git submodule update --init`), instead of the old manual download from
the Met Office Science Repository Service.

The submodule is intentionally left uninitialized by a plain clone (git's
default submodule behaviour) since the upstream repo is ~290MB, almost
all of it example/data files Isca's build never touches. The codebase.py
auto-fetch path added in a later commit performs a sparse partial clone
of just src/ and make/ instead, which is what most users will actually
hit.
… setup

Socrates is now pinned as a git submodule and fetched automatically
(sparse partial clone) on first compile if not already present, replacing
the old workflow of manually downloading a release and pointing GFDL_SOC
at a single hardcoded `trunk` checkout -- the same design whose dangling
symlink crashed a trip_test run when GFDL_SOC pointed at a missing
directory. GFDL_SOC_DIR now lets multiple versions be cached and takes
priority over the legacy single-version GFDL_SOC override.

The hand-maintained per-version path_names file, which broke on every
Socrates release as files moved or were renamed, is replaced by
isca.socrates_paths: it derives the needed file list from Socrates' own
Makefile manifests plus a dependency-closure scan seeded from Isca's
interface code. A handful of tested versions are committed at
src/extra/model/socrates/socrates_version_paths/<version>; any other
version is generated on the fly.

Validated by real compiles (not just the generator), which surfaced and
fixed three bugs along the way:
- an INTERFACE block's restated call signature was miscounted as a second
  definition of the callee, making it look ambiguous and silently
  defeating the check that excludes files depending on out-of-scope code
- Socrates' own aux/seaalbedo.f is both an independent manifest entry and
  textually INCLUDEd wholesale by aux/seaalbedo_driver.f, so compiling
  both duplicated every symbol seaalbedo.f defines
- auto-fetching the default (submodule-pinned) version placed a plain
  symlink at the path .gitmodules registers as a submodule, which
  corrupts `git status`/`git diff` for the whole superproject; that
  version now always goes through a real (filtered, sparse) `git
  submodule update --init` instead

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
GitHub Actions' default checkout doesn't run `git submodule update
--init`, but still leaves an empty directory at the submodule's path
(unlike a bare `git clone` run manually, which was what local testing
used) -- ensure_socrates_source() treated that as an unexpected/invalid
state and raised, instead of recognising it as safe to populate.

Separately, aux/seaalbedo_driver.f inherits a real module dependency
(spline_evaluate_mod) from aux/seaalbedo.f's content via a plain Fortran
INCLUDE. mkmf's automatic dependency detection only scans each compiled
file's own literal USE/MODULE statements, never the text of files it
INCLUDEs, so that dependency is invisible to it and seaalbedo_driver.o's
build order relative to spline_evaluate.o is unconstrained -- whether a
single `make` pass succeeds depends on incidental scheduling (confirmed
by reproducing both a pass and a fail from the identical checkout).
Worked around with an opt-in best-effort `make -k` pass before the normal
one, scoped to SocratesCodeBase/SocColumnCodeBase via a new
make_retry_keep_going flag, rather than changing compile.sh's behaviour
for every other codebase.

Both fixes verified against a real fresh clone (no --recurse-submodules,
matching actions/checkout) through a full compile of both
SocratesCodeBase and SocColumnCodeBase.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sit23

sit23 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

CI is now passing, and this now includes (for the first time) Socrates-specific compile tests, with the Socrates code downloaded from Github as part of the CI. Going to do some manual testing and then will convert to non-draft P/R.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant