Skip to content

Make x a mutable integration cursor in stiff3 (intent(inout)) and propagate endpoint/interrupt semantics - #49

Merged
ivan-pi merged 3 commits into
mainfrom
copilot/update-x-to-inout-parameter
May 12, 2026
Merged

Make x a mutable integration cursor in stiff3 (intent(inout)) and propagate endpoint/interrupt semantics#49
ivan-pi merged 3 commits into
mainfrom
copilot/update-x-to-inout-parameter

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

stiff3 previously treated both x and xend as intent(in), which prevented returning the actual integration position. This change makes x an in/out cursor so callers receive x == xend on successful completion, or the last accepted step when integration exits early.

  • Solver API contract

    • Updated stiff3_auto, stiff3_work, and stiff3_core to take x as intent(inout).
    • Kept xend as intent(in).
    • Ensured all solver return paths write back the current x (normal completion and early callback interruption).
  • Behavioral semantics

    • Successful integration now returns the terminal coordinate via x.
    • Early return from solout now returns the most recent accepted coordinate via x, preserving restartability from that point.
  • Call-site compatibility updates

    • Updated examples/tests that passed parameter constants as the first integration bound to instead pass a mutable local variable initialized from the start value.
    • This affects benchmark-style examples and dense-output tests where x0 was previously immutable.
  • Docs and usage updates

    • Updated API comments and README usage text to reflect mutable x semantics and clarify hmax default interpretation relative to the initial x.
  • Targeted assertions

    • Extended tests to assert:
      • x == xend on normal completion.
      • x equals last accepted step on early exit.
real(wp) :: x, xend, y(n), h0, eps, w(n)

x    = 0.0_wp
xend = 1.0_wp
call stiff3(n, fun, x, y, xend, jac, h0, eps, w)

! On success: x == xend
! On early interrupt: x is the last accepted step

Copilot AI and others added 3 commits May 12, 2026 08:32
@ivan-pi
ivan-pi marked this pull request as ready for review May 12, 2026 08:51
@ivan-pi
ivan-pi merged commit 78d2989 into main May 12, 2026
2 of 4 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.

2 participants