yac: link LAPACKE when YAC is used for coupling - #1022
Open
k202077 wants to merge 2 commits into
Open
Conversation
added 2 commits
August 25, 2026 13:37
YAC's C core calls the LAPACKE C interface (LAPACKE_dgesv,
LAPACKE_dsytrf_work, LAPACKE_dsytri_work), which lives in a different
library from the Fortran LAPACK that find_package(LAPACK) reports.
BuildYAC.cmake only put ${LAPACK_LIBRARIES} on YAC::yac's interface, so
on a system where YAC's own configure selects the Netlib LAPACKE those
symbols stayed undefined in libyac.a/libyac_core.a and linking fesom.x
failed at 100% with no indication of the cause.
Look for the LAPACKE library and append it, so it lands after the YAC
static archives that reference it. Keep it optional: YAC also resolves
the interface through MKL or falls back to its bundled clapack, and in
both of those cases no extra library is needed. When it is missing, say
so at configure time instead of leaving the failure to the linker.
Not caught by CI because the preset builds run in the fesom2_ci
container, whose LAPACK already covers LAPACKE.
Assisted-by: Claude Code:claude-opus-5
Same gap as the previous commit, reached through the other route. When OASIS3-MCT is built against YAC instead of SCRIP, FindOASISYAC.cmake puts OASIS's libyac_core.a on the link line, and that archive calls LAPACKE_dgesv, LAPACKE_dsytrf_work and LAPACKE_dsytri_work. Nothing else on the line defines them, so linking fesom.x fails with undefined LAPACKE_* symbols. Look for the LAPACKE library and append it to YACCORE_Fortran_LIBRARIES, and keep it optional for the same reason as in BuildYAC.cmake: a YAC built against MKL, or one using its bundled clapack, needs no extra library. Assisted-by: Claude Code:claude-opus-5
JanStreffing
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linking
fesom.xfails with undefinedLAPACKE_dgesv,LAPACKE_dsytrf_workand
LAPACKE_dsytri_workwhenever YAC ends up on the link line via one of thetwo cmake modules below. YAC's C core calls the LAPACKE C interface, which
lives in a different library from the Fortran LAPACK that
find_package(LAPACK)reports, and neither module put that library on theline.
The failure surfaces at 100% of the build with no indication of the cause,
which is what makes it worth fixing rather than documenting.
What changed
Two commits, one per route into the same gap:
cmake/BuildYAC.cmake—BUILD_YAC=ON. Only${LAPACK_LIBRARIES}wason
YAC::yac's interface. The LAPACKE library is now appended, landingafter the YAC static archives that reference it.
cmake/FindOASISYAC.cmake—OASIS_WITH_YAC=ON. Same gap reachedthrough OASIS:
libyac_core.acomes from the OASIS tree and nothing elsedefines those symbols. Appended to
YACCORE_Fortran_LIBRARIES.Both lookups are optional by design. YAC also resolves the interface
through MKL, or falls back to building its bundled clapack, and in both of
those cases the symbols are already satisfied and no extra library is needed.
When LAPACKE is genuinely missing, cmake now says so at configure time instead
of leaving it to the linker.
Why this did not surface earlier
Four things had to line up, and until recently they rarely did.
The default YAC route was never affected. With a pre-installed YAC
(
yac_DIR),FindYAC.cmakegoes through pkg-config and takes${PC_yac_LDFLAGS}verbatim fromyac.pc— which already carries whateverLAPACKE flags YAC's own configure settled on. That path gets this right for
free. Only the two modules touched here assemble the library list by hand, and
so only they could omit it.
Those hand-rolled paths are new.
BUILD_YACandBuildYAC.cmakelandedin
6e00c208(#776) on 2026-03-03, so the from-source route has had a fewmonths of exposure, mostly through the CI preset.
BuildYAC.cmakecannot use the file that has the answer. YAC's configurerecords its LAPACKE flags in
yac.pc, but underBUILD_YACtheyac-externalExternalProjectis built at build time —yac.pcdoes not exist yet whenthis cmake code runs. Hence the separate
find_libraryrather than reusingpkg-config as
FindYAC.cmakedoes.Every environment that does exercise these paths already supplies LAPACKE.
The
coupled_yacpreset is in the CI matrix and builds green, so the LAPACK inghcr.io/fesom/fesom2_docker:fesom2_ci-masterevidently resolves the LAPACKEsymbols. HPC targets are covered too, since MKL provides the interface. What is
left is the case that actually broke: a distro-package host where Netlib ships
LAPACKE separately from LAPACK (
liblapacke-devvsliblapack-devonDebian/Ubuntu) and YAC's configure selects the Netlib LAPACKE instead of
falling back to its bundled clapack.
Notes for reviewers
appends a library that was previously missing, and skips it when absent.
integration tests (
tests/integration/CMakeLists.txtskips them underUSE_YAC), so this is build-time verification by construction.coupled_yacrun does not confirmthe fix. Verifying it means a host with
liblapack-devbut withoutliblapacke-devinstalled (reproduce), then with it (fix).