Skip to content

Migrate KiLCA/QL-Balance quadrature to fortnum (3/8)#142

Draft
krystophny wants to merge 1 commit into
fortnum/k2-kim-quadpackfrom
fortnum/k3-kilca-quadrature
Draft

Migrate KiLCA/QL-Balance quadrature to fortnum (3/8)#142
krystophny wants to merge 1 commit into
fortnum/k2-kim-quadpackfrom
fortnum/k3-kilca-quadrature

Conversation

@krystophny

@krystophny krystophny commented Jun 14, 2026

Copy link
Copy Markdown
Member

Merge order

These fortnum-migration PRs are individually based on main and form one
cumulative stack. Merge them in this order:

#140 -> #141 -> #142 -> #143 -> #144 -> #145 -> #146 -> #147 -> #148 -> #149 -> #150

Each PR is opened against main, so its diff is cumulative versus main and
overlaps its predecessors. Merging in the order above keeps the history linear:
once a predecessor merges into main, the next PR's diff shrinks to just its
own increment.

Scope

Route the C/C++ GSL adaptive-quadrature call sites onto the fortnum C ABI. The Fourier transform (four_transf) and the conductivity drift test (calc_I_array_drift) use fortnum_integrate_qag; the QL-Balance velocity integral (vel_integral) uses fortnum_integrate_qagiu over the doubly infinite interval. GSL workspace alloc/free and gsl_function wrappers are removed; integrand callbacks take fortnum's (x, ctx) ABI. Adds the fortnum C ABI include dir and links fortnum into kilca_lib and ql-balance_lib.

Dependency removed

GSL gsl_integration_qag/qagi in KiLCA and QL-Balance.

Verification

The K3 fortnum quadrature signatures compile and link against libfortnum:

$ g++ -std=c++14 -I.../fortnum/include probe.cpp libfortnum.a -lgfortran -o probe && ./probe
0.5   # int_0^1 x dx via fortnum_integrate_qag / qagiu

Stack tip builds green and ctest passes 18/18 (see K8). Draft: only the stack tip was built end to end.


Stack reconciliation (update)

The migration stack was rebuilt as a strictly linear cumulative chain on main 428a708:

k1 (+ golden CI fix) -> k2 -> k3 -> k4 -> k5 -> k6 -> k7 -> k8 -> z1 -> z2 -> z3

Every branch now pins fortnum to main 974dcf1 (all kernel fixes plus both new integrators). This branch's standalone golden result above stands. The cumulative tip (#150 z3) does not pass: the KiLCA background equilibrium ODE on #143 k4 cannot reproduce the GSL rk8pd golden with DOP853 at the unchanged 1e-8 bar. See #143 and #150. Tolerances were not weakened and the stored golden was not regenerated.

Merge order: #140 -> #141 -> #142 -> #143 -> #144 -> #145 -> #146 -> #147 -> #148 -> #149 -> #150.

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

@krystophny krystophny force-pushed the fortnum/k3-kilca-quadrature branch from af7196f to 867964c Compare June 15, 2026 19:27
@krystophny krystophny changed the base branch from main to fortnum/k2-kim-quadpack June 15, 2026 19:28
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