Skip to content

Commit 83da099

Browse files
Copilotivan-pi
andauthored
Unify RHS and SOLOUT user interrupts under a single idid exit path (#52)
* Add RHS callback interrupt path Agent-Logs-Url: https://github.com/ivan-pi/stiff3/sessions/4b6afe5b-daf3-4c54-a604-ea10ab860a5b Co-authored-by: ivan-pi <21085643+ivan-pi@users.noreply.github.com> * Verify RHS interrupt regression coverage Agent-Logs-Url: https://github.com/ivan-pi/stiff3/sessions/4b6afe5b-daf3-4c54-a604-ea10ab860a5b Co-authored-by: ivan-pi <21085643+ivan-pi@users.noreply.github.com> * Finalize unified callback interrupt handling Agent-Logs-Url: https://github.com/ivan-pi/stiff3/sessions/4b6afe5b-daf3-4c54-a604-ea10ab860a5b Co-authored-by: ivan-pi <21085643+ivan-pi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ivan-pi <21085643+ivan-pi@users.noreply.github.com>
1 parent d394805 commit 83da099

23 files changed

Lines changed: 155 additions & 43 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ program vanpol
133133
134134
contains
135135
136-
subroutine fun(n,y,f)
136+
subroutine fun(n,y,f, ires)
137137
integer, intent(in) :: n
138138
real(wp), intent(in) :: y(n)
139139
real(wp), intent(inout) :: f(n)
140+
integer, intent(inout) :: ires
140141
f(1) = y(2)
141142
f(2) = mu*(1.0_wp - y(1)**2)*y(2) - y(1)
142143
end subroutine
@@ -191,7 +192,7 @@ The integer exit flag `idid` reports solver status:
191192

192193
- `0` — successful completion at `x1`
193194
- `-1` — LU factorization failed because the Jacobian system matrix was singular
194-
- `-2` — integration interrupted by the user `solout` callback (`irtrn < 0`)
195+
- `-2` — integration interrupted by a user callback (`ires < 0` in `fun` or `irtrn < 0` in `solout`)
195196
- `-3` — step-size underflow occurred during bisection (`abs(h) <= spacing(x_current)`)
196197

197198
When using this explicit-workspace overload together with `solout`, accepted-step dense output is available through the generic interface `stiff3_interp`:

example/e5_chemical.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ function ycoord(value, ymin, ymax, height, top, bottom) result(yplot)
219219
(value - ymin)*(real(height,wp) - top - bottom)/(ymax - ymin)
220220
end function
221221

222-
subroutine fun(n, y, f)
222+
subroutine fun(n, y, f, ires)
223223
integer, intent(in) :: n
224224
real(wp), intent(in) :: y(n)
225225
real(wp), intent(inout) :: f(n)
226+
integer, intent(inout) :: ires
226227
real(wp) :: prod1, prod2, prod3, prod4
227228

228229
prod1 = 7.89e-10_wp*y(1)

example/hires.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ subroutine write_gnuplot_data(filename, eps, cpu, err, stats)
107107
close(unit)
108108
end subroutine
109109

110-
subroutine fun(n, y, f)
110+
subroutine fun(n, y, f, ires)
111111
integer, intent(in) :: n
112112
real(wp), intent(in) :: y(n)
113113
real(wp), intent(inout) :: f(n)
114-
114+
integer, intent(inout) :: ires
115115
f(1) = -1.71_wp*y(1) + 0.43_wp*y(2) + 8.32_wp*y(3) + 0.0007_wp
116116
f(2) = 1.71_wp*y(1) - 8.75_wp*y(2)
117117
f(3) = -10.03_wp*y(3) + 0.43_wp*y(4) + 0.035_wp*y(5)

example/lorenz.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ program lorenz
2525

2626
contains
2727

28-
subroutine fun(n,y,f)
28+
subroutine fun(n,y,f, ires)
2929
integer, intent(in) :: n
3030
real(wp), intent(in) :: y(n)
3131
real(wp), intent(inout) :: f(n)
32+
integer, intent(inout) :: ires
3233
f(1) = sigma*(y(2) - y(1))
3334
f(2) = y(1)*(rho - y(3)) - y(2)
3435
f(3) = y(1)*y(2) - beta*y(3)

example/oregonator.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ function ycoord(value, ymin, ymax, height, top, bottom) result(yplot)
253253
(value - ymin)*(real(height,wp) - top - bottom)/(ymax - ymin)
254254
end function
255255

256-
subroutine fun(n, y, f)
256+
subroutine fun(n, y, f, ires)
257257
integer, intent(in) :: n
258258
real(wp), intent(in) :: y(n)
259259
real(wp), intent(inout) :: f(n)
260-
260+
integer, intent(inout) :: ires
261261
f(1) = 77.27_wp*(y(2) + y(1)*(1.0_wp - 8.375e-6_wp*y(1) - y(2)))
262262
f(2) = (y(3) - (1.0_wp + y(1))*y(2))/77.27_wp
263263
f(3) = 0.161_wp*(y(1) - y(3))

example/pendant_drop.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ program pendant_drop
3636

3737
contains
3838

39-
subroutine fun(n,y,f)
39+
subroutine fun(n,y,f, ires)
4040
integer, intent(in) :: n
4141
real(wp), intent(in) :: y(n)
4242
real(wp), intent(inout) :: f(n)
43+
integer, intent(inout) :: ires
4344
f(1) = pL - drho*y(3) - sin(y(1))/y(2)
4445
f(2) = cos(y(1))
4546
f(3) = sin(y(1))

example/predator_prey.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ program predator_prey
2626

2727
contains
2828

29-
subroutine fun(n,y,f)
29+
subroutine fun(n,y,f, ires)
3030
integer, intent(in) :: n
3131
real(wp), intent(in) :: y(n)
3232
real(wp), intent(inout) :: f(n)
33+
integer, intent(inout) :: ires
3334
f(1) = alpha*y(1) - beta*y(1)*y(2)
3435
f(2) = delta*y(1)*y(2) - gamma*y(2)
3536
end subroutine

example/ring_modulator.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ subroutine write_gnuplot_data(filename, eps, cpu, err, stats)
115115
close(unit)
116116
end subroutine
117117

118-
subroutine fun(n, y, f)
118+
subroutine fun(n, y, f, ires)
119119
integer, intent(in) :: n
120120
real(wp), intent(in) :: y(n)
121121
real(wp), intent(inout) :: f(n)
122-
122+
integer, intent(inout) :: ires
123123
real(wp), parameter :: c = 1.6e-8_wp
124124
real(wp), parameter :: cs = 2.0e-12_wp
125125
real(wp), parameter :: cp = 1.0e-8_wp

example/robertson.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ module robertson_rate
99
!
1010
! Robertson rate equations
1111
!
12-
subroutine fun(n,y,f)
12+
subroutine fun(n,y,f, ires)
1313
integer, intent(in) :: n
1414
real(wp), intent(in) :: y(n)
1515
real(wp), intent(inout) :: f(n)
16+
integer, intent(inout) :: ires
1617
f(1) = -4.e-2_wp*y(1)+1.e4_wp*y(2)*y(3)
1718
f(2) = -f(1)-3.e7_wp*y(2)**2
1819
f(3) = 3.e7_wp*y(2)**2

example/three_equation_system.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ program three_equation_system
2929

3030
contains
3131

32-
subroutine fun(n,y,f)
32+
subroutine fun(n,y,f, ires)
3333
integer, intent(in) :: n
3434
real(wp), intent(in) :: y(n)
3535
real(wp), intent(inout) :: f(n)
36-
36+
integer, intent(inout) :: ires
3737
f(1) = -k1*y(1) - k2*y(1)*y(3)
3838
f(2) = -k3*y(2)*y(3)
3939
f(3) = -k1*y(1) - k2*y(1)*y(3) - k3*y(2)*y(3)

0 commit comments

Comments
 (0)