Skip to content

Conversation

@Zaneham
Copy link
Owner

@Zaneham Zaneham commented Jan 19, 2026

Interpolation (49 tests):

  • L1: 9/9 PASS - DBINT4, DBVALU, DPCHIM, DPCHFE, DPLINT, DPOLVL
  • L2: 14/17 PASS - B-spline issues identified, PCHIP and polynomial OK
  • L3: 4/4 PASS - IBM 360 golden values via Hercules/TK4-
  • L4: 19/19 PASS - Runge phenomenon, subnormals, cancellation

Diff_Integ (43 tests):

  • L1: 12/12 PASS - DGAUS8, DQAGS, DQAGI, DQNG
  • L2: 17/17 PASS - Gauss-Kronrod exactness, classical integrals
  • L3: 2/2 PASS - Trapezoidal rule (QUADPACK post-1983, N/A)
  • L4: 12/12 PASS - Extreme values, oscillatory, reproducibility

Total test count: 464/471 (3 B-spline mathematical issues documented)

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suites for interpolation and differentiation/integration routines across four test levels (regression, mathematical verification, historical baseline, and hostile/portability).
    • Expanded test coverage with 19 interpolation tests and 12 differentiation/integration tests at the advanced level.
  • Documentation

    • Updated test documentation and results to reflect new test coverage, mathematical properties, and test outcomes.

✏️ Tip: You can customize this high-level summary in your review settings.

Interpolation (49 tests):
- L1: 9/9 PASS - DBINT4, DBVALU, DPCHIM, DPCHFE, DPLINT, DPOLVL
- L2: 14/17 PASS - B-spline issues identified, PCHIP and polynomial OK
- L3: 4/4 PASS - IBM 360 golden values via Hercules/TK4-
- L4: 19/19 PASS - Runge phenomenon, subnormals, cancellation

Diff_Integ (43 tests):
- L1: 12/12 PASS - DGAUS8, DQAGS, DQAGI, DQNG
- L2: 17/17 PASS - Gauss-Kronrod exactness, classical integrals
- L3: 2/2 PASS - Trapezoidal rule (QUADPACK post-1983, N/A)
- L4: 12/12 PASS - Extreme values, oscillatory, reproducibility

Total test count: 464/471 (3 B-spline mathematical issues documented)
@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This pull request adds comprehensive test suites for interpolation and differentiation/integration routines across all four test levels (Level 1 regression, Level 2 mathematical verification, Level 3 historical baseline, and Level 4 hostile environments). Documentation files are updated to reflect new test coverage, statuses, and detailed test results.

Changes

Cohort / File(s) Summary
Documentation Updates
TESTING.md, TEST_RESULTS.md
Updated test outcomes reporting Diff_Integ and Interpolation as PASS in Level 1 and Level 2 sections; added detailed test result reporting sections, new contribution guidance, historical context narratives, and module coverage summaries; adjusted timestamps and added note about 3 documented B-spline mathematical issues.
Level 1 Regression Tests
test/level1_regression/README.md, test/level1_regression/test_l1_interpolation.f90, test/level1_regression/test_l1_diff_integ.f90
Added new interpolation and diff_integ regression test entries to coverage table; extended README with compilation/execution commands including MINPACK, BLAS, Interpolation, and Diff_Integ tests. New test modules implement basic functional tests for DBINT4/DBVALU (B-spline), DPCHIM/DPCHFE/DPCHIA (PCHIP), DPLINT/DPOLVL/DPOLCF (polynomials), and DGAUS8/DQAGS/DQAGI/DQNG (integration).
Level 2 Mathematical Tests
test/level2_mathematical/README.md, test/level2_mathematical/test_l2_interpolation.f90, test/level2_mathematical/test_l2_diff_integ.f90
Added interpolation and diff_integ mathematical property verification tables with reference materials and status markers (several B-spline FAILs, PCHIP/polynomial PASSes). New test modules validate mathematical properties including Gauss-Kronrod exactness, classical definite integrals, special function integrals, endpoint singularities, and infinite intervals; B-spline interpolation conditions and PCHIP monotonicity preservation.
Level 3 Historical Tests
test/level3_historical/README.md, test/level3_historical/test_l3_interpolation.f90, test/level3_historical/test_l3_diff_integ.f90
Added test file tables and status documentation for interpolation and diff_integ with references to IBM System/360 baselines. New test modules verify IBM 360 golden values for polynomial interpolation via DPLINT/DPOLVL and basic trapezoidal rule integration; PCHIP and B-spline marked as not applicable for historical Level 3.
Level 4 Hostile Tests
test/level4_hostile/README.md, test/level4_hostile/test_l4_interpolation.f90, test/level4_hostile/test_l4_diff_integ.f90
Added interpolation and diff_integ hostile-category test tables with 19/19 and 12/12 pass counts respectively; updated total test count from 110 to 141. New test modules exercise edge cases including closely spaced data, extreme domain values, Runge phenomenon, catastrophic cancellation, subnormal values, narrow peaks, discontinuities, and oscillatory behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop through tests new and grand,
Four levels spanning every land,
Interpolation, integration's dance,
From IBM dreams to hostile chance,
With properties checked and edge cases spanned! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add L1-L4 tests for interpolation and diff_integ modules' directly and clearly describes the main change: adding comprehensive test suites (Levels 1-4) for two specific modules (interpolation and diff_integ). It is concise, specific, and accurately reflects the core purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Fix all issues with AI agents
In `@TEST_RESULTS.md`:
- Line 3: Convert the emphasized line "*Comprehensive test execution log — 18
January 2026*" into a proper Markdown heading to satisfy MD036; replace the
asterisks with a heading marker (e.g., prefix with "#" or "##") so the line
becomes a heading like "## Comprehensive test execution log — 18 January 2026",
ensuring it renders as a heading rather than emphasis.

In `@test/level1_regression/test_l1_diff_integ.f90`:
- Line 96: The long FORMAT print statements using the literal format
"(A,ES15.8,A,ES15.8)" (e.g., the line containing print '(A,ES15.8,A,ES15.8)', ' 
[FAIL] integral(sin(x), 0, pi) = ', result, ' expected ', exact and the similar
one at line 108) exceed 100 characters; break the string into multiple
concatenated literals or use Fortran line continuation so no source line exceeds
100 chars—e.g., split the message into two prints or use & continuation to split
the arguments across lines while keeping the same format specifier and variables
(result, exact) to preserve output.

In `@test/level2_mathematical/README.md`:
- Line 68: The heading "#### Interpolation Test Results (2025-01-18)" contains
the wrong year; update that header string to "#### Interpolation Test Results
(2026-01-18)" so the README date matches the PR context and intended 2026-01-18
date.

In `@test/level2_mathematical/test_l2_diff_integ.f90`:
- Line 196: The long FORTRAN print statements using the format
'(A,ES22.15,A,ES22.15)' (e.g. printing "  [FAIL] int(x^5*exp(-x), 0, inf) = "
with result and exact) exceed the 100‑char lint rule; split these into shorter
lines by concatenating string literals or using multiple print calls while
preserving the same format descriptors and output order — update the offending
print using '(A,ES22.15,A,ES22.15)' and the similar fail messages elsewhere (the
other occurrences using the same format/message pattern) so every source line is
under 100 characters.
- Around line 12-16: The header incorrectly claims tests for DQK41/51/61 while
the file only exercises DQK15, DQK21 and DQK31; either add test cases that call
and validate DQK41, DQK51 and DQK61 (mirroring the existing DQK15/21/31 test
patterns) or change the header comment to list only DQK15/21/31 so it accurately
reflects coverage; update the header block in test_l2_diff_integ.f90 (the
comment listing "DQK15/21/31/41/51/61") accordingly and ensure any new tests
follow the same style and assertions as the existing DQK* tests if you choose to
add them.

In `@test/level4_hostile/test_l4_diff_integ.f90`:
- Around line 340-377: The reproducibility test (subroutine
test_reproducibility) currently compares result1/result2/result3 but never
checks the DQAGS error code (ier); add the same ier checks used elsewhere: after
each call to DQAGS(f_exp_neg_x2, ...) inspect ier and if ier /= 0 print a
failure message including the ier value, increment failed, and exit the
subroutine (or return) so a failing integration doesn't allow a false-positive
reproducibility pass. Ensure you reference the existing variables (ier, failed,
result1/result2/result3) and the DQAGS calls when adding these checks.

In `@test/level4_hostile/test_l4_interpolation.f90`:
- Around line 466-523: The test does not check DPCHIM and DPCHFE return codes;
after each call to DPCHIM(...) and DPCHFE(...) inspect ierr and if ierr < 0
print an error message, increment failed, and return immediately to fail fast;
reference the existing variables ierr, failed, passed, and the routines DPCHIM
and DPCHFE so you add the checks right after those calls (e.g., if (ierr < 0)
then print '... error ...', failed = failed + 1; return; end if).
🧹 Nitpick comments (12)
test/level1_regression/test_l1_diff_integ.f90 (2)

17-17: Consider implicit none (type, external) for stricter checks.

Fortitude C003 suggests adding the external specifier for implicit typing of externals.

💡 Suggested change
-  implicit none
+  implicit none (type, external)

Also applies to: 364-364


363-363: Prefer only on the module use to limit namespace exposure.

This keeps the program scope tight.

💡 Suggested change
-  use test_diff_integ_level1
+  use test_diff_integ_level1, only: run_all_tests
test/level1_regression/test_l1_interpolation.f90 (2)

19-19: Consider implicit none (type, external) for stricter checks.

Fortitude C003 suggests explicitly disabling implicit externals.

💡 Suggested change
-  implicit none
+  implicit none (type, external)

Also applies to: 437-437


121-122: Name end subroutine statements to satisfy Fortitude S061.

This is a style/consistency lint rule. Consider naming each end subroutine.

💡 Example change
-  end subroutine
+  end subroutine test_dbint4_runs

Also applies to: 156-157, 189-190, 241-242, 281-282, 314-315, 364-365, 397-398, 428-429

test/level2_mathematical/test_l2_diff_integ.f90 (2)

21-21: Consider implicit none (type, external) for stricter checks.

Fortitude C003 recommends disabling implicit externals explicitly.

💡 Suggested change
-  implicit none
+  implicit none (type, external)

Also applies to: 516-516


515-515: Prefer only on the module use to limit namespace exposure.

This keeps the program scope tight.

💡 Suggested change
-  use test_diff_integ_level2
+  use test_diff_integ_level2, only: run_all_tests
test/level2_mathematical/test_l2_interpolation.f90 (2)

1-26: Well-structured module header with clear documentation.

The module is well-documented with references to authoritative sources (de Boor, Fritsch & Carlson, Burden & Faires). The tolerance tol_dp = 1.0e-10_dp is appropriate for double precision comparisons.

Minor note: sp => real32 is imported at line 18 but never used in this file.

🔧 Remove unused import
-  use, intrinsic :: iso_fortran_env, only: dp => real64, sp => real32
+  use, intrinsic :: iso_fortran_env, only: dp => real64

621-628: Consider adding explicit imports for clarity.

The main program is functional. For better clarity and to satisfy the static analysis hint, consider using an explicit only clause.

🔧 Add explicit import
 program run_level2_interpolation
-  use test_interpolation_level2
+  use test_interpolation_level2, only: run_all_tests
   implicit none
   integer :: passed, failed
   call run_all_tests(passed, failed)
   if (failed > 0) stop 1
 end program run_level2_interpolation
test/level3_historical/test_l3_interpolation.f90 (2)

27-37: Unused parameters defined.

sp => real32 (line 28) and tol_hex (line 36) are defined but never used in this file. Consider removing them for cleaner code.

🔧 Remove unused definitions
 module test_interpolation_level3
-  use, intrinsic :: iso_fortran_env, only: dp => real64, sp => real32
+  use, intrinsic :: iso_fortran_env, only: dp => real64
   implicit none
   private

   public :: run_all_tests

-  ! Tolerances account for IBM Hex vs IEEE 754 differences
   real(dp), parameter :: tol_dp = 1.0e-12_dp
-  real(dp), parameter :: tol_hex = 1.0e-10_dp  ! Looser for hex comparisons

233-246: Consider adding explicit imports.

Similar to the Level 2 test, consider using an explicit only clause for clarity.

🔧 Add explicit import
 program run_level3_interpolation
-  use test_interpolation_level3
+  use test_interpolation_level3, only: run_all_tests
   implicit none
test/level3_historical/test_l3_diff_integ.f90 (2)

73-131: Unused variable exact.

The variable exact is declared at line 78 and assigned values at lines 103 and 120, but it is never used. This appears to be dead code, possibly left over from earlier development where exact values were compared.

🔧 Remove unused variable
   subroutine test_polynomial_integrals_ibm360(passed, failed)
     integer, intent(out) :: passed, failed
     integer :: i
     integer, parameter :: n = 100
     real(dp) :: h, x, sum_trap
-    real(dp) :: exact, result
+    real(dp) :: result

And remove the assignments:

     result = sum_trap * h

-    exact = 1.0_dp / 3.0_dp
     if (abs(result - int_x2_trap) < 1.0e-10_dp) then
     result = sum_trap * h

-    exact = 0.25_dp
     if (abs(result - int_x3_trap) < 1.0e-10_dp) then

165-178: Consider adding explicit imports.

Consistent with the other test files, consider using an explicit only clause.

🔧 Add explicit import
 program run_level3_diff_integ
-  use test_diff_integ_level3
+  use test_diff_integ_level3, only: run_all_tests
   implicit none

# SLATEC-Modern Test Results

*Comprehensive test execution log — 1 January 2026*
*Comprehensive test execution log — 18 January 2026*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use a heading instead of emphasis to satisfy markdownlint.

MD036 flags emphasis as a heading. Consider converting this line to a proper heading.

💡 Suggested change
-*Comprehensive test execution log — 18 January 2026*
+### Comprehensive test execution log — 18 January 2026
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
*Comprehensive test execution log — 18 January 2026*
### Comprehensive test execution log — 18 January 2026
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

3-3: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🤖 Prompt for AI Agents
In `@TEST_RESULTS.md` at line 3, Convert the emphasized line "*Comprehensive test
execution log — 18 January 2026*" into a proper Markdown heading to satisfy
MD036; replace the asterisks with a heading marker (e.g., prefix with "#" or
"##") so the line becomes a heading like "## Comprehensive test execution log —
18 January 2026", ensuring it renders as a heading rather than emphasis.

print '(A,ES15.8)', ' [PASS] integral(sin(x), 0, pi) = ', result
passed = passed + 1
else
print '(A,ES15.8,A,ES15.8)', ' [FAIL] integral(sin(x), 0, pi) = ', result, ' expected ', exact
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Wrap long print lines to satisfy the 100‑char lint rule.

These lines exceed the limit flagged by Fortitude S001.

💡 Example wrap
-      print '(A,ES15.8,A,ES15.8)', '  [FAIL] integral(sin(x), 0, pi) = ', result, ' expected ', exact
+      print '(A,ES15.8,A,ES15.8)', &
+            '  [FAIL] integral(sin(x), 0, pi) = ', result, ' expected ', exact

Also applies to: 108-108

🧰 Tools
🪛 Fortitude (0.7.5)

[error] 96-96: line length of 101, exceeds maximum 100

(S001)

🤖 Prompt for AI Agents
In `@test/level1_regression/test_l1_diff_integ.f90` at line 96, The long FORMAT
print statements using the literal format "(A,ES15.8,A,ES15.8)" (e.g., the line
containing print '(A,ES15.8,A,ES15.8)', '  [FAIL] integral(sin(x), 0, pi) = ',
result, ' expected ', exact and the similar one at line 108) exceed 100
characters; break the string into multiple concatenated literals or use Fortran
line continuation so no source line exceeds 100 chars—e.g., split the message
into two prints or use & continuation to split the arguments across lines while
keeping the same format specifier and variables (result, exact) to preserve
output.

| Polynomial uniqueness theorem | Burden & Faires Thm 3.2 | ✓ PASS |
| Polynomial exactness for degree ≤ n-1 | Burden & Faires Cor 3.3 | ✓ PASS |

#### Interpolation Test Results (2025-01-18)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Date inconsistency.

The date "2025-01-18" appears incorrect. Based on the PR context (created 2026-01-19), this should likely be "2026-01-18".

📝 Fix date
-#### Interpolation Test Results (2025-01-18)
+#### Interpolation Test Results (2026-01-18)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#### Interpolation Test Results (2025-01-18)
#### Interpolation Test Results (2026-01-18)
🤖 Prompt for AI Agents
In `@test/level2_mathematical/README.md` at line 68, The heading "####
Interpolation Test Results (2025-01-18)" contains the wrong year; update that
header string to "#### Interpolation Test Results (2026-01-18)" so the README
date matches the PR context and intended 2026-01-18 date.

Comment on lines +12 to +16
!> Routines tested:
!> - DGAUS8: Verifies Gauss-Legendre quadrature exactness
!> - DQAGS: Verifies handling of endpoint singularities
!> - DQAGI: Verifies infinite interval integration
!> - DQK15/21/31/41/51/61: Verifies Gauss-Kronrod rule exactness
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's read the test file to see the header and understand the structure
head -100 test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 3605


🏁 Script executed:

# Search for actual calls to each QK routine in the test file
rg "call DQK(15|21|31|41|51|61)" test/level2_mathematical/test_l2_diff_integ.f90 -A 1

Repository: Zaneham/SLATEC

Length of output: 363


🏁 Script executed:

# Comprehensive search for all DQK routine calls in the file
rg "call DQK(41|51|61)" test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 40


🏁 Script executed:

# Let's check the entire file to confirm which routines are actually tested
wc -l test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 109


🏁 Script executed:

# Search for DQK41, DQK51, DQK61 separately to confirm they're not used
grep -n "DQK41\|DQK51\|DQK61" test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 153


🏁 Script executed:

# Let's verify the test_gauss_kronrod_exactness subroutine more thoroughly
sed -n '58,120p' test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 2570


🏁 Script executed:

# Search more in the test_gauss_kronrod_exactness subroutine
sed -n '120,180p' test/level2_mathematical/test_l2_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 2379


Header lists DQK15/21/31/41/51/61, but tests only exercise DQK15/21/31.

Either add coverage for DQK41/51/61 or update the header to match actual test scope and avoid overstating coverage.

Suggested doc alignment
-!>   - DQK15/21/31/41/51/61: Verifies Gauss-Kronrod rule exactness
+!>   - DQK15/21/31: Verifies Gauss-Kronrod rule exactness
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
!> Routines tested:
!> - DGAUS8: Verifies Gauss-Legendre quadrature exactness
!> - DQAGS: Verifies handling of endpoint singularities
!> - DQAGI: Verifies infinite interval integration
!> - DQK15/21/31/41/51/61: Verifies Gauss-Kronrod rule exactness
!> Routines tested:
!> - DGAUS8: Verifies Gauss-Legendre quadrature exactness
!> - DQAGS: Verifies handling of endpoint singularities
!> - DQAGI: Verifies infinite interval integration
!> - DQK15/21/31: Verifies Gauss-Kronrod rule exactness
🤖 Prompt for AI Agents
In `@test/level2_mathematical/test_l2_diff_integ.f90` around lines 12 - 16, The
header incorrectly claims tests for DQK41/51/61 while the file only exercises
DQK15, DQK21 and DQK31; either add test cases that call and validate DQK41,
DQK51 and DQK61 (mirroring the existing DQK15/21/31 test patterns) or change the
header comment to list only DQK15/21/31 so it accurately reflects coverage;
update the header block in test_l2_diff_integ.f90 (the comment listing
"DQK15/21/31/41/51/61") accordingly and ensure any new tests follow the same
style and assertions as the existing DQK* tests if you choose to add them.

print '(A,ES22.15)', ' [PASS] int(x^5*exp(-x), 0, inf) = ', result
passed = passed + 1
else
print '(A,ES22.15,A,ES22.15)', ' [FAIL] int(x^5*exp(-x), 0, inf) = ', result, ' expected ', exact
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Wrap long print lines to satisfy the 100‑char lint rule.

These lines exceed the Fortitude S001 limit.

💡 Example wrap
-      print '(A,ES22.15,A,ES22.15)', '  [FAIL] int(x^5*exp(-x), 0, inf) = ', result, ' expected ', exact
+      print '(A,ES22.15,A,ES22.15)', &
+            '  [FAIL] int(x^5*exp(-x), 0, inf) = ', result, ' expected ', exact

Also applies to: 336-336, 384-384, 396-396

🧰 Tools
🪛 Fortitude (0.7.5)

[error] 196-196: line length of 104, exceeds maximum 100

(S001)

🤖 Prompt for AI Agents
In `@test/level2_mathematical/test_l2_diff_integ.f90` at line 196, The long
FORTRAN print statements using the format '(A,ES22.15,A,ES22.15)' (e.g. printing
"  [FAIL] int(x^5*exp(-x), 0, inf) = " with result and exact) exceed the
100‑char lint rule; split these into shorter lines by concatenating string
literals or using multiple print calls while preserving the same format
descriptors and output order — update the offending print using
'(A,ES22.15,A,ES22.15)' and the similar fail messages elsewhere (the other
occurrences using the same format/message pattern) so every source line is under
100 characters.

Comment on lines +340 to +377
subroutine test_reproducibility(passed, failed)
integer, intent(out) :: passed, failed
integer, parameter :: limit = 500, lenw = 4*limit
real(dp) :: result1, result2, result3, abserr
integer :: neval, ier, last
integer :: iwork(limit)
real(dp) :: work(lenw)

passed = 0
failed = 0

print '(A)', 'Reproducibility'
print '(A)', '---------------'

! Test: Same integral computed three times should give identical results
call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
result1, abserr, neval, ier, limit, lenw, last, iwork, work)

call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
result2, abserr, neval, ier, limit, lenw, last, iwork, work)

call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
result3, abserr, neval, ier, limit, lenw, last, iwork, work)

if (result1 == result2 .and. result2 == result3) then
print '(A)', ' [PASS] Three identical calls give identical results'
passed = passed + 1
else
print '(A)', ' [FAIL] Results differ between identical calls!'
print '(A,ES22.15)', ' Run 1: ', result1
print '(A,ES22.15)', ' Run 2: ', result2
print '(A,ES22.15)', ' Run 3: ', result3
failed = failed + 1
end if

print '(A)', ''

end subroutine test_reproducibility
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

head -n 400 test/level4_hostile/test_l4_diff_integ.f90 | tail -n 70

Repository: Zaneham/SLATEC

Length of output: 2421


🏁 Script executed:

# Also check nearby context to understand the full subroutine structure
sed -n '330,390p' test/level4_hostile/test_l4_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 2155


🏁 Script executed:

# Check if there are error-handling patterns for ier elsewhere in the test file
rg -n "ier\s*[/!=<>]" test/level4_hostile/test_l4_diff_integ.f90

Repository: Zaneham/SLATEC

Length of output: 968


🏁 Script executed:

# Also search for any documentation or comments about DQAGS error codes
rg -i "ier.*error\|error.*ier" . -t f --max-count=10

Repository: Zaneham/SLATEC

Length of output: 83


Add error-status checks for DQAGS calls in reproducibility test.

The test only compares numerical results across three runs but does not validate the DQAGS error code (ier). If all three calls fail identically, the test will incorrectly pass. Every other test in this file checks ier == 0 after DQAGS invocation. Add the same error-handling pattern here to fail fast when DQAGS reports an error.

Suggested adjustment
     call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
                result1, abserr, neval, ier, limit, lenw, last, iwork, work)
+    if (ier /= 0) then
+      print '(A,I3)', '  [FAIL] DQAGS failed (run 1), ier=', ier
+      failed = failed + 1
+      return
+    end if
 
     call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
                result2, abserr, neval, ier, limit, lenw, last, iwork, work)
+    if (ier /= 0) then
+      print '(A,I3)', '  [FAIL] DQAGS failed (run 2), ier=', ier
+      failed = failed + 1
+      return
+    end if
 
     call DQAGS(f_exp_neg_x2, 0.0_dp, 1.0_dp, 0.0_dp, 1.0e-12_dp, &
                result3, abserr, neval, ier, limit, lenw, last, iwork, work)
+    if (ier /= 0) then
+      print '(A,I3)', '  [FAIL] DQAGS failed (run 3), ier=', ier
+      failed = failed + 1
+      return
+    end if
🤖 Prompt for AI Agents
In `@test/level4_hostile/test_l4_diff_integ.f90` around lines 340 - 377, The
reproducibility test (subroutine test_reproducibility) currently compares
result1/result2/result3 but never checks the DQAGS error code (ier); add the
same ier checks used elsewhere: after each call to DQAGS(f_exp_neg_x2, ...)
inspect ier and if ier /= 0 print a failure message including the ier value,
increment failed, and exit the subroutine (or return) so a failing integration
doesn't allow a false-positive reproducibility pass. Ensure you reference the
existing variables (ier, failed, result1/result2/result3) and the DQAGS calls
when adding these checks.

Comment on lines +466 to +523
subroutine test_reproducibility(passed, failed)
use interpolation, only: DPCHIM, DPCHFE
integer, intent(out) :: passed, failed
integer, parameter :: n = 7
integer, parameter :: incfd = 1
integer, parameter :: nruns = 3
integer :: i, run, ierr, ne
real(dp) :: x(n), f(incfd,n), d(incfd,n)
real(dp) :: xe(5), fe(5), fe_prev(5)
logical :: skip, is_reproducible

passed = 0
failed = 0

print '(A)', 'REPRODUCIBILITY'
print '(A)', '---------------'
print '(A)', 'Tests that identical inputs give identical outputs'
print '(A)', ''

! Setup test data
do i = 1, n
x(i) = real(i-1, dp) * 0.5_dp
f(1,i) = exp(-x(i))
end do

xe = [0.25_dp, 0.75_dp, 1.25_dp, 1.75_dp, 2.25_dp]
ne = 5

is_reproducible = .true.

do run = 1, nruns
call DPCHIM(n, x, f, d, incfd, ierr)
skip = .false.
call DPCHFE(n, x, f, d, incfd, skip, ne, xe, fe, ierr)

if (run > 1) then
do i = 1, ne
if (fe(i) /= fe_prev(i)) then
is_reproducible = .false.
exit
end if
end do
end if

fe_prev = fe
end do

if (is_reproducible) then
print '(A,I2,A)', ' [PASS] PCHIP reproducible over ', nruns, ' runs'
passed = passed + 1
else
print '(A)', ' [FAIL] PCHIP not reproducible (parallel reduction variance?)'
failed = failed + 1
end if

print '(A)', ''

end subroutine test_reproducibility
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check the test file to confirm the current state
cat -n test/level4_hostile/test_l4_interpolation.f90 | sed -n '466,523p'

Repository: Zaneham/SLATEC

Length of output: 1948


🏁 Script executed:

# Search for DPCHIM and DPCHFE function definitions and documentation
find . -name "*.f90" -o -name "*.f" | head -20

Repository: Zaneham/SLATEC

Length of output: 873


🏁 Script executed:

# Search for DPCHIM and DPCHFE in the codebase to understand their signatures
rg "subroutine DPCHIM|subroutine DPCHFE" -A 5

Repository: Zaneham/SLATEC

Length of output: 40


🏁 Script executed:

# Look for other tests that use DPCHIM or DPCHFE and see how they handle errors
rg "DPCHIM|DPCHFE" test/ -B 2 -A 5

Repository: Zaneham/SLATEC

Length of output: 24447


🏁 Script executed:

# Check the interpolation module to understand error codes
rg "DPCHIM|DPCHFE" src/modern/interpolation/ -B 2 -A 3 | head -100

Repository: Zaneham/SLATEC

Length of output: 7041


🏁 Script executed:

# Look at the closely_spaced_data test to see error handling pattern
sed -n '370,430p' test/level4_hostile/test_l4_interpolation.f90

Repository: Zaneham/SLATEC

Length of output: 1983


🏁 Script executed:

# Check test_l2_mathematical pattern more closely
sed -n '85,130p' test/level2_mathematical/test_l2_interpolation.f90

Repository: Zaneham/SLATEC

Length of output: 1410


🏁 Script executed:

# Look at DPCHIM implementation to understand error codes
sed -n '1,150p' src/modern/interpolation/pchip/dpchim.inc | tail -50

Repository: Zaneham/SLATEC

Length of output: 2518


🏁 Script executed:

# Check the full DPCHIM implementation for error code handling
cat src/modern/interpolation/pchip/dpchim.inc | grep -A 50 "ERROR STOP" | head -60

Repository: Zaneham/SLATEC

Length of output: 1721


🏁 Script executed:

# Examine the test_reproducibility context - what's before and after it
sed -n '450,530p' test/level4_hostile/test_l4_interpolation.f90

Repository: Zaneham/SLATEC

Length of output: 2460


🏁 Script executed:

# Look at DPCHIM return behavior more closely
grep -A 200 "Ierr = 0" src/modern/interpolation/pchip/dpchim.inc | head -30

Repository: Zaneham/SLATEC

Length of output: 902


🏁 Script executed:

# Check if DPCHFE also sets error codes similarly
grep -B 5 -A 10 "Ierr" src/modern/interpolation/pchip/dpchfe.inc | head -50

Repository: Zaneham/SLATEC

Length of output: 1357


🏁 Script executed:

# Verify error handling in a comparable level4 test
sed -n '200,260p' test/level4_hostile/test_l4_interpolation.f90

Repository: Zaneham/SLATEC

Length of output: 2003


Add error checking for DPCHIM and DPCHFE to fail fast on errors.

The reproducibility test calls both routines but doesn't check if they succeed. If either returns ierr < 0, the test can still "pass" because it only compares if outputs are identical—not whether the computations succeeded. Add error checks and return early on failure to ensure errors are caught immediately.

Suggested fix
    do run = 1, nruns
      call DPCHIM(n, x, f, d, incfd, ierr)
+      if (ierr < 0) then
+        print '(A,I4)', '  [FAIL] DPCHIM failed, ierr=', ierr
+        failed = failed + 1
+        return
+      end if
      skip = .false.
      call DPCHFE(n, x, f, d, incfd, skip, ne, xe, fe, ierr)
+      if (ierr < 0) then
+        print '(A,I4)', '  [FAIL] DPCHFE failed, ierr=', ierr
+        failed = failed + 1
+        return
+      end if
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
subroutine test_reproducibility(passed, failed)
use interpolation, only: DPCHIM, DPCHFE
integer, intent(out) :: passed, failed
integer, parameter :: n = 7
integer, parameter :: incfd = 1
integer, parameter :: nruns = 3
integer :: i, run, ierr, ne
real(dp) :: x(n), f(incfd,n), d(incfd,n)
real(dp) :: xe(5), fe(5), fe_prev(5)
logical :: skip, is_reproducible
passed = 0
failed = 0
print '(A)', 'REPRODUCIBILITY'
print '(A)', '---------------'
print '(A)', 'Tests that identical inputs give identical outputs'
print '(A)', ''
! Setup test data
do i = 1, n
x(i) = real(i-1, dp) * 0.5_dp
f(1,i) = exp(-x(i))
end do
xe = [0.25_dp, 0.75_dp, 1.25_dp, 1.75_dp, 2.25_dp]
ne = 5
is_reproducible = .true.
do run = 1, nruns
call DPCHIM(n, x, f, d, incfd, ierr)
skip = .false.
call DPCHFE(n, x, f, d, incfd, skip, ne, xe, fe, ierr)
if (run > 1) then
do i = 1, ne
if (fe(i) /= fe_prev(i)) then
is_reproducible = .false.
exit
end if
end do
end if
fe_prev = fe
end do
if (is_reproducible) then
print '(A,I2,A)', ' [PASS] PCHIP reproducible over ', nruns, ' runs'
passed = passed + 1
else
print '(A)', ' [FAIL] PCHIP not reproducible (parallel reduction variance?)'
failed = failed + 1
end if
print '(A)', ''
end subroutine test_reproducibility
subroutine test_reproducibility(passed, failed)
use interpolation, only: DPCHIM, DPCHFE
integer, intent(out) :: passed, failed
integer, parameter :: n = 7
integer, parameter :: incfd = 1
integer, parameter :: nruns = 3
integer :: i, run, ierr, ne
real(dp) :: x(n), f(incfd,n), d(incfd,n)
real(dp) :: xe(5), fe(5), fe_prev(5)
logical :: skip, is_reproducible
passed = 0
failed = 0
print '(A)', 'REPRODUCIBILITY'
print '(A)', '---------------'
print '(A)', 'Tests that identical inputs give identical outputs'
print '(A)', ''
! Setup test data
do i = 1, n
x(i) = real(i-1, dp) * 0.5_dp
f(1,i) = exp(-x(i))
end do
xe = [0.25_dp, 0.75_dp, 1.25_dp, 1.75_dp, 2.25_dp]
ne = 5
is_reproducible = .true.
do run = 1, nruns
call DPCHIM(n, x, f, d, incfd, ierr)
if (ierr < 0) then
print '(A,I4)', ' [FAIL] DPCHIM failed, ierr=', ierr
failed = failed + 1
return
end if
skip = .false.
call DPCHFE(n, x, f, d, incfd, skip, ne, xe, fe, ierr)
if (ierr < 0) then
print '(A,I4)', ' [FAIL] DPCHFE failed, ierr=', ierr
failed = failed + 1
return
end if
if (run > 1) then
do i = 1, ne
if (fe(i) /= fe_prev(i)) then
is_reproducible = .false.
exit
end if
end do
end if
fe_prev = fe
end do
if (is_reproducible) then
print '(A,I2,A)', ' [PASS] PCHIP reproducible over ', nruns, ' runs'
passed = passed + 1
else
print '(A)', ' [FAIL] PCHIP not reproducible (parallel reduction variance?)'
failed = failed + 1
end if
print '(A)', ''
end subroutine test_reproducibility
🤖 Prompt for AI Agents
In `@test/level4_hostile/test_l4_interpolation.f90` around lines 466 - 523, The
test does not check DPCHIM and DPCHFE return codes; after each call to
DPCHIM(...) and DPCHFE(...) inspect ierr and if ierr < 0 print an error message,
increment failed, and return immediately to fail fast; reference the existing
variables ierr, failed, passed, and the routines DPCHIM and DPCHFE so you add
the checks right after those calls (e.g., if (ierr < 0) then print '... error
...', failed = failed + 1; return; end if).

@Zaneham Zaneham merged commit 4091da0 into main Jan 19, 2026
4 of 5 checks passed
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