Migrate off GSL onto the fortnum numerical core#139
Closed
krystophny wants to merge 1 commit into
Closed
Conversation
Remove the GSL dependency from KAMEL (KIM, KiLCA, QL-Balance) and route
every numerical call through fortnum, fetched from lazy-fortran/fortnum.
No shipped binary links GSL; every install/bin and tests/*.x executable
has zero gsl_ symbols.
KIM (Fortran):
- gsl_sf_bessel_In -> fortnum bessel_in in FLR2_asymptotics.f90 (negative
orders handled by bessel_in via I_{-n}=I_n).
- gsl_sf_erf -> the Fortran 2008 erf intrinsic (integrands.f90,
integrands_adaptive.f90, numerics_utils.f90); the aliased import is
dropped so the intrinsic resolves.
- gsl_mod.f90 deleted (the gsl_sf_erfc / gsl_sf_dawson bindings were dead).
- KIM_lib links the Fortran fortnum target; find_package(GSL) and the GSL
link/include are removed.
KiLCA / QL-Balance (C/C++), via the fortnum C ABI (fortnum.h):
- gsl_odeiv rk8pd evolve loops -> fortnum_ode_integrate_dop in
calc_back.cpp, incompressible.cpp, compressible_flow.cpp. The historical
rhs_* callbacks are forwarded through small fortnum_ode_rhs adapters; the
returned mesh is replayed exactly as the evolve loop stored each step.
- gsl_integration_qag -> fortnum_integrate_qag (four_transf.cpp,
calc_I_array_drift.cpp); gsl_integration_qagi -> fortnum_integrate_qagiu
with inf=2 (vel_integral.cpp).
- gsl_root_fsolver brent -> fortnum_root_brent (calc_mode.cpp).
- gsl_multiroot_fdfsolver hybridsj -> fortnum_multiroot_hybrid
(calc_eigmode.cpp); eval_det is reexpressed on the fortnum_vector_fn ABI
and the finite-difference Jacobian moves into the solver. The dead
qng-based calc_circle_integral_gkq and the gsl_multiroot print helpers
are removed.
- gsl_deriv_central -> fortnum_deriv_central (incompressible.cpp,
compressible_flow.cpp).
- gsl_heapsort_index -> fortnum_argsort via a sort_index_doubles helper in
shared.cpp (calc_cond.cpp, sysmat_profs.cpp, adaptive_grid.cpp).
- KiLCA hyper1F1 quadrature path -> fortnum_hyperg_1f1_a1; the GSL-only
Levin variant (marked "do not use" upstream) is removed.
- Public interfaces (rhs_*, jac_*, Afunc/Bfunc helpers) are preserved so
callers compile unchanged; only the GSL internals are replaced.
Build:
- cmake/FetchFortnum.cmake fetches fortnum via FetchContent from
git@github.com:lazy-fortran/fortnum.git (GIT_TAG main), guarded by
if(NOT TARGET fortnum) so a transitive pull does not double-declare it.
The Fortran fortnum target backs the Fortran sources;
${fortnum_SOURCE_DIR}/include is on the C/C++ include path for fortnum.h.
- cmake/FetchGSL.cmake deleted and include(FetchGSL) removed; gsl/gslcblas
dropped from the KiLCA, KIM, and QL-Balance link lists and include paths.
- KIM_exe and the KIM KiLCA-dependent tests link the freshly built
kilca_lib target instead of a hardcoded stale prebuilt archive.
- GSL removed from setup scripts, the standalone KiLCA build helpers, and
the dependency lists in the READMEs.
The bundled AMOS complex Bessel (zbesj/zbesi/zbesk in hmedium.f90,
calc_D_array_*.f90, bessel.f90) is unaffected: it is not GSL and stays in
place pending a separate migration to fortnum bessel_*_complex.
Closed
Member
Author
|
Superseded by a stack of eight atomic PRs that re-cut this migration off
Verification (stack tip, all eight applied): full CMake/Ninja build green, |
Member
Author
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.
Supersedes #135.
Addresses #134. KAMEL is MIT-licensed but linked GSL (GPL-2.0+). This PR removes GSL entirely and routes every numerical call through the fortnum library (fetched from
lazy-fortran/fortnum), the single numerical core for the group. Where #135 reimplemented the GSL routines in-tree and pulled Bessel from libneo, this PR depends on fortnum directly. No shipped binary links GSL.What moved
KIM (Fortran)
gsl_sf_bessel_In-> fortnumbessel_ininFLR2_asymptotics.f90(negative orders viaI_{-n}=I_n, handled insidebessel_in).gsl_sf_erf-> the Fortran 2008erfintrinsic (integrands.f90,integrands_adaptive.f90,numerics_utils.f90).gsl_mod.f90deleted (thegsl_sf_erfc/gsl_sf_dawsonbindings were dead).KIM_liblinks the Fortranfortnumtarget;find_package(GSL)and the GSL link/include are gone.KiLCA / QL-Balance (C/C++), via the fortnum C ABI (
fortnum.h)gsl_odeivrk8pd evolve loops ->fortnum_ode_integrate_dop(calc_back.cpp,incompressible.cpp,compressible_flow.cpp). The historicalrhs_*callbacks forward through smallfortnum_ode_rhsadapters; the returned mesh is replayed exactly as the evolve loop stored each accepted step.gsl_integration_qag->fortnum_integrate_qag(four_transf.cpp,calc_I_array_drift.cpp);gsl_integration_qagi->fortnum_integrate_qagiuwithinf=2(vel_integral.cpp).gsl_root_fsolverbrent ->fortnum_root_brent(calc_mode.cpp).gsl_multiroot_fdfsolverhybridsj ->fortnum_multiroot_hybrid(calc_eigmode.cpp);eval_detis reexpressed on thefortnum_vector_fnABI and the finite-difference Jacobian moves into the solver. The dead qng-basedcalc_circle_integral_gkqand thegsl_multirootprint helpers are removed.gsl_deriv_central->fortnum_deriv_central(incompressible.cpp,compressible_flow.cpp).gsl_heapsort_index->fortnum_argsortvia asort_index_doubleshelper inshared.cpp(calc_cond.cpp,sysmat_profs.cpp,adaptive_grid.cpp).hyper1F1quadrature path ->fortnum_hyperg_1f1_a1; the GSL-only Levin variant (marked "do not use" upstream) is removed.rhs_*,jac_*, theAfunc/Bfunchelpers) are preserved so callers compile unchanged; only the GSL internals are replaced.Build
cmake/FetchFortnum.cmakefetches fortnum via FetchContent fromgit@github.com:lazy-fortran/fortnum.git(GIT_TAG main), guarded byif(NOT TARGET fortnum)so a transitive pull (e.g. through libneo) does not double-declare the target. The Fortranfortnumtarget backs the Fortran sources;${fortnum_SOURCE_DIR}/includeis on the C/C++ include path forfortnum.h.cmake/FetchGSL.cmakedeleted andinclude(FetchGSL)removed;gsl/gslcblasdropped from the KiLCA, KIM, and QL-Balance link lists and include paths.KIM_exeand the KIM KiLCA-dependent tests link the freshly builtkilca_libtarget instead of a hardcoded stale prebuilt archive underbuild/.This depends on the fortnum C ABI forwarding a user
void* ctxto the callbacks (fortnum_integrate_*,fortnum_root_brent,fortnum_deriv_central,fortnum_multiroot_hybrid,fortnum_ode_*); that small ABI addition is committed on fortnummain(dc277b5).Verification
Linux x86_64, gfortran/gcc 16.1.1, CMake 4.3.3, Ninja, fortnum
main. All dependencies (LAPACK, SuiteSparse, SUNDIALS, NetCDF, HDF5, fortnum) resolved; no GSL fetched or built.Before (origin/main):
cmake/FetchGSL.cmakefetches and builds GSL 2.4; KiLCA/KIM/QL-Balance linkgsl/gslcblas.After (this branch): full build succeeds, no GSL symbol in any shipped binary.
ctest (18/18 pass), including the KiLCA-math tests that now run through fortnum:
fortnum's own suite (67/67) passes against the C-ABI ctx change, including a new context-forwarding check in the C smoke test:
Remaining
zbesj/zbesi/zbeskinhmedium.f90,calc_D_array_*.f90,bessel.f90, plus theKiLCA/math/bessel/amostree) is not GSL and is untouched here. Migrating it to fortnumbessel_j_complex/bessel_i_complex/bessel_k_complexand deleting the bundled AMOS is a separate follow-up; it does not affect the GSL removal.fun_input.f90,wkb_dispersion.f90) callzbesifrom the bundled SLATEC (not GSL); also untouched.