This document records bugs discovered and fixed during the GOTO elimination and modernisation effort.
Discovery Date: 2025-12-20
Severity: High (numerical accuracy)
Affected Routines: dbsknu.f90, besknu.f90
Reference: Temme, N.M., J. Comp. Physics 19, 1975, pp. 324-337
- K Bessel function values showed relative error of approximately 4×10⁻⁵
- Example: K₄(1) computed as 44.2324 instead of correct value 44.2341
During GOTO elimination, the control flow for the power series computation (X ≤ 2) was incorrectly structured. The original SLATEC code used:
! After series computation
GOTO 20 ! Skip to forward recursion
...
! Coefficient/asymptotic/Miller code
...
20 ck = (dnu+dnu+2._DP)/X ! Forward recursionThe modernised code removed the GOTO but failed to skip the coefficient/asymptotic/Miller section. This caused the already-computed series values (s1, s2) to be overwritten by the coefficient calculation code.
Added a series_done logical flag:
LOGICAL :: series_done
...
series_done = .FALSE.
...
! After series computation
series_done = .TRUE.
...
! Coefficient/asymptotic/Miller section
IF( .NOT. series_done ) THEN
! ... coefficient/asymptotic/Miller code ...
END IFAfter the fix, the relative error dropped from ~4×10⁻⁵ to ~1×10⁻¹⁴ (machine precision).
Discovery Date: 2025-12-20
Severity: Medium (compilation failure)
Affected Routines: dcov.inc, scov.inc (MINPACK covariance routines)
Compilation error: Name 'process' in EXIT statement at (1) is unknown
During GOTO elimination, a named BLOCK construct was introduced to replace a labelled error exit, but the opening process: BLOCK statement was missing whilst END BLOCK process remained.
Added the missing process: BLOCK statement before the main IF block.
Discovery Date: 2025-12-20 Severity: Medium (compilation failure) Affected Routines: Data handling sort routines
Compilation error: Syntax error in END DO statement
A nested DO loop was missing its END DO statement. The code had:
main_sort: DO
...
DO ! Inner loop
...
END DO main_sort ! Wrong! This closes outer loop, not innerAdded the missing END DO for the inner loop:
main_sort: DO
...
DO ! Inner loop
...
END DO ! Closes inner loop
END DO main_sort ! Now correctly closes outer loopDiscovery Date: 2025-12-20 Severity: Low (compilation failure) Affected Routines: PCHIP interpolation routines
Compilation error: Symbol 'ierr' at (1) has no IMPLICIT type
During GOTO elimination, error return code assignments (Ierr = -3) were left in place but the subsequent line was changed to ERROR STOP. The variable assignment became redundant and the variable was never declared.
Removed the redundant Ierr assignments since the ERROR STOP statements make them unreachable.
The following issues were discovered but predate the modernisation effort:
- PCHSP.inc: Contains GOTOs (20, 50) that were never converted
- PCHFE.inc: Contains multiple unconverted GOTOs (100, 200, 300, 320, 350, 400, 600)
- Various PCHIP routines: Unused labels (100, 200) generating warnings
These require additional GOTO elimination work in the interpolation module.
The following structural issues were addressed to enable compilation:
-
Include files as .f90: Files intended for inclusion via Fortran
includestatements were named.f90, causing fpm to attempt standalone compilation. Renamed to.inc. -
Module dependencies: Several modules (blas, lapack, linpack) needed to be extracted to separate files to ensure correct compilation order.
-
Missing USE statements: Some module files lacked explicit
USEstatements for their dependencies, preventing fpm from determining the correct build order.