Replace GSL Bessel I_n with fortnum (1/5) - #29
Draft
krystophny wants to merge 4 commits into
Draft
Conversation
Drop the gsl_sf_bessel_In_array C binding in mephit_pert and compute the
modified Bessel functions through fortnum's bessel_in_array. fortnum fills
I_0..I_nmax in one pass, so the orders |m|-1, |m|, |m|+1 are recovered with
the symmetry I_{-n}(x) = I_n(x); for pol_mode = 0 the order -1 maps to I_1.
Wire fortnum via CMake FetchContent at the pinned tag, guarded so a build that
also pulls fortnum transitively through libneo does not declare the target
twice. Add the fortnum include directory for the C/C++ sources and link the
fortnum target. GSL stays linked until the remaining call sites move over.
krystophny
marked this pull request as draft
June 14, 2026 07:56
This was referenced Jun 14, 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.
Merge order
Stack sequence: #29 -> #30 -> #31 -> #32 -> #33.
Each PR is now based on main individually, so its diff is cumulative against main and shares code with its stack neighbors. Merge in the sequence above. Once a predecessor merges into main, the next PR rebases onto it and its diff shrinks to its own increment.
First in a five-PR stack migrating MEPHIT off GSL (and FFTW) onto the fortnum numerical core. Merged in order, the stack composes to the full migration; this PR wires fortnum via CMake FetchContent and moves the modified-Bessel call site in mephit_pert.
Dependency removed: the gsl_sf_bessel_In_array C binding. fortnum's bessel_in_array fills I_0..I_nmax in one pass; the orders |m|-1, |m|, |m|+1 are recovered with the symmetry I_{-n}(x) = I_n(x), so pol_mode = 0 maps order -1 to I_1. fortnum is declared with FetchContent at the pinned tag 92de6e9, guarded by if(NOT TARGET fortnum) because libneo also pulls it in transitively. The fortnum include dir is added for the C/C++ sources and the fortnum target is linked. GSL stays linked until the remaining call sites move over in the later PRs of this stack.
Verification
Configure and build the shared library at this tip (out-of-source build):
fortnum is pinned at the required tag:
The GSL Bessel symbol is gone and fortnum's routine is now linked:
Note: the .x executables do not link at this tip, and they also do not link on main: find_package(FFTW) is never called, so the FFTW_LIBRARIES link variable is empty and the FFTW symbols pulled in by src/fftw3.f90 are unresolved at the executable link step. PR 4 of this stack removes that FFTW usage and the executables link. The shared library, the verifiable artifact for this aspect, builds.
Note: fortnum pin updated to current main (92de6e9) after a fortnum history rewrite; old shas no longer resolve.