Replace FFTW with fortnum fft_c2c and drop the FFTW dependency (4/5)#32
Open
krystophny wants to merge 6 commits into
Open
Replace FFTW with fortnum fft_c2c and drop the FFTW dependency (4/5)#32krystophny wants to merge 6 commits into
krystophny wants to merge 6 commits into
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.
fa2e524 to
6d6cc8b
Compare
1c548fc to
73bfe4c
Compare
Route the a = 1 confluent hypergeometric evaluation through the fortnum C ABI: the boundary integral uses fortnum_integrate_qag with the Gauss-Kronrod 21 rule, and the Kummer-series acceleration uses fortnum_levin_u_accel. Both fortnum routines take the integrand plus an opaque context, so the existing quad_params struct is forwarded unchanged and no workspace is allocated. Add float.h for DBL_EPSILON, which was previously pulled in transitively through a GSL header.
Move the remaining C-side GSL call sites onto the fortnum C ABI. The Gauss-Legendre nodes and weights on the unit interval now come from fortnum_gauss_legendre_ab, which folds the table allocation and the [a, b] mapping into one call. Drop gsl_errno_msg and the gsl_set_error_handler registration: fortnum routines report failures through return codes rather than a global GSL error handler, so the dedicated GSL message hook and its forward declaration are no longer reachable. After this change libmephit.so resolves no GSL symbols.
Move the fft_t one-dimensional forward transform onto fortnum's fft_c2c, which matches the FFTW sign convention (sign = -1, unnormalized). The type now owns an allocatable samples buffer instead of FFTW-allocated pointers and an opaque plan; apply transforms a copy in place so the caller's samples survive, then extracts and normalizes the requested mode range exactly as before. Remove src/fftw3.f90, the cmake/FindFFTW.cmake module, and the empty FFTW_LIBRARIES link entry. MEPHIT no longer references any FFTW symbol; libmephit.so and the executables link without FFTW.
6d6cc8b to
b9da627
Compare
73bfe4c to
83ac593
Compare
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.
Fourth in the fortnum migration stack (base: the C-quadrature PR). Removes MEPHIT's FFTW usage.
Dependency removed: FFTW. The fft_t one-dimensional forward transform in src/mephit_util.f90 moves onto fortnum's fft_c2c, which matches the FFTW sign convention (sign = -1, unnormalized). The type now owns an allocatable samples buffer instead of FFTW-allocated pointers and an opaque plan; apply transforms a copy in place so the caller's samples survive, then extracts and normalizes the requested mode range exactly as before. src/fftw3.f90, the cmake/FindFFTW.cmake module, and the empty FFTW_LIBRARIES link entry are removed. find_package(FFTW) was never invoked in this repo, so FFTW_LIBRARIES expanded to nothing and the FFTW symbols from src/fftw3.f90 were unresolved at executable link time; dropping that source fixes the link.
Verification
Full build at this tip, including the executables that did not link on the earlier tips and on main:
MEPHIT references no FFTW symbol and uses fortnum's transform instead:
Before this PR the executable link failed: