From b1391f3268a44da3569056483c3a50a5890de2bb Mon Sep 17 00:00:00 2001 From: Christopher Albert Date: Wed, 1 Jul 2026 18:50:59 +0200 Subject: [PATCH] Initialize interpolation index before Neville evaluation loop interp_profile passed the local integer ind to eval_neville_polynom without initializing it. ind is the in/out warm-start window index; on the first call it was read uninitialized (and could drive an out-of-bounds read of the grid array), making the interpolated background profiles depend on stack garbage and the whole solve non-deterministic run to run. Set ind = 0 before the loop in both copies of interp_profile. Verified on the ql-balance f_6_2 case: - valgrind memcheck: 22 "uninitialised value" reads in eval_neville_polynom (origin: interp_profile ind) -> 0. - 5/5 fresh single-thread runs now produce byte-identical EB.dat; before, run-to-run EB differed by ~7e-4 relative. --- KiLCA/interface/wave_code_data_64bit.f90 | 1 + QL-Balance/src/base/wave_code_data_64bit.f90 | 1 + 2 files changed, 2 insertions(+) diff --git a/KiLCA/interface/wave_code_data_64bit.f90 b/KiLCA/interface/wave_code_data_64bit.f90 index 453665a1..beecae6a 100644 --- a/KiLCA/interface/wave_code_data_64bit.f90 +++ b/KiLCA/interface/wave_code_data_64bit.f90 @@ -802,6 +802,7 @@ subroutine interp_profile(dim_old, r_old, q_old, dim_new, r_new, q_new) integer :: deg = 15, Dmin = 0, Dmax = 0, l, ind; +ind = 0; do l = 1,dim_new call eval_neville_polynom(dim_old, r_old, q_old, deg, r_new(l), Dmin, Dmax, ind, q_new(l)); diff --git a/QL-Balance/src/base/wave_code_data_64bit.f90 b/QL-Balance/src/base/wave_code_data_64bit.f90 index ca11f2f7..1e7562e8 100644 --- a/QL-Balance/src/base/wave_code_data_64bit.f90 +++ b/QL-Balance/src/base/wave_code_data_64bit.f90 @@ -738,6 +738,7 @@ subroutine interp_profile(dim_old, r_old, q_old, dim_new, r_new, q_new) real(8), dimension(dim_new) :: r_new, q_new; integer :: deg = 9, Dmin = 0, Dmax = 0, l, ind; + ind = 0; do l = 1, dim_new call eval_neville_polynom(dim_old, r_old, q_old, deg, r_new(l), Dmin, Dmax, ind, q_new(l)); end do