Skip to content

Drop the GSL find_package, the fgsl path, and d1mach (5/5)#33

Open
krystophny wants to merge 8 commits into
mainfrom
drop-gsl-fortnum-plumbing
Open

Drop the GSL find_package, the fgsl path, and d1mach (5/5)#33
krystophny wants to merge 8 commits into
mainfrom
drop-gsl-fortnum-plumbing

Conversation

@krystophny

@krystophny krystophny commented Jun 14, 2026

Copy link
Copy Markdown
Member

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.


Last in the fortnum migration stack (base: the FFTW PR). Removes the now-unused GSL build wiring and the last SLATEC machine-constant routine.

Dependencies removed: GSL (find_package(GSL), the GSL::gsl link entry, the fgsl prebuilt-path hint in cmake/SetupCODE.cmake) and src/external/d1mach.f. With no source referencing GSL after PRs 1 to 3, the package search and link entry are dead. The only d1mach call, the largest relative spacing d1mach(4) in the vendored netlib zeroin routine, is replaced by the Fortran intrinsic epsilon(1.0d0), and the d1mach source is dropped.

Verification

Clean configure and full build at the stack tip:

$ cmake -S . -B build -G Ninja
-- Configuring done
-- Generating done
$ cmake --build build
[274/276] Linking Fortran executable bin/mephit_test.x
[275/276] Linking Fortran executable bin/mephit_post.x
[276/276] Linking C executable bin/mephit_run.x

libmephit.so resolves no GSL, FFTW, AMOS, SLATEC, or d1mach symbol, and the executables carry no GSL or FFTW dynamic dependency:

$ nm -DC build/lib/libmephit.so | grep -ic gsl
0
$ nm -DC build/lib/libmephit.so | grep -ic fftw
0
$ nm -DC build/lib/libmephit.so | grep -icE 'zbesi|zbesk|zbesj|d1mach|dgamln|slatec'
0
$ ldd build/bin/mephit_run.x | grep -iE 'gsl|fftw' || echo NONE
NONE

The fortnum routines that MEPHIT now depends on (modified Bessel, adaptive and fixed-rule quadrature, Levin acceleration, c2c FFT) are covered by fortnum's own suite at tag 92de6e9:

$ ctest --test-dir <fortnum-build>
100% tests passed, 0 tests failed out of 68

MEPHIT registers no ctest tests; mephit_test.x is an integration driver that requires an HDF5 equilibrium and mesh data file as input, not available in this environment.

Note: fortnum pin updated to current main (92de6e9) after a fortnum history rewrite; old shas no longer resolve.

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 krystophny force-pushed the drop-gsl-fortnum-fftw branch from 1c548fc to 73bfe4c Compare June 14, 2026 09:33
@krystophny krystophny force-pushed the drop-gsl-fortnum-plumbing branch from ecaa9a2 to 7d756dc Compare June 14, 2026 09:33
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.
Finalize the fortnum migration on the build side. With no source referencing
GSL, remove find_package(GSL), the GSL::gsl link entry, and the optional fgsl
prebuilt-path hint. Replace the only d1mach call, the largest relative spacing
d1mach(4) in the vendored zeroin routine, with the intrinsic epsilon(1.0d0),
and drop src/external/d1mach.f. MEPHIT now configures, builds, and links with
no GSL or FFTW dependency of its own.
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