Skip to content

Commit bd15ecb

Browse files
committed
Allow passing of user data for callback procedure
1 parent d5dbbaf commit bd15ecb

12 files changed

+110
-71
lines changed

examples/example_hybrd.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ program example_hybrd
7070
contains
7171

7272
!> Subroutine fcn for hybrd example.
73-
subroutine fcn(n, x, fvec, iflag)
73+
subroutine fcn(n, x, fvec, iflag, udata)
7474

7575
implicit none
7676
integer, intent(in) :: n
7777
integer, intent(inout) :: iflag
7878
double precision, intent(in) :: x(n)
7979
double precision, intent(out) :: fvec(n)
80+
class(*), intent(inout), optional :: udata
8081

8182
integer k
8283
double precision one, temp, temp1, temp2, three, two, zero

examples/example_hybrd1.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ program example_hybrd1
5454
contains
5555

5656
!> Subroutine fcn for hybrd1 example.
57-
subroutine fcn(n, x, fvec, iflag)
57+
subroutine fcn(n, x, fvec, iflag, udata)
5858

5959
implicit none
6060
integer, intent(in) :: n
6161
integer, intent(inout) :: iflag
6262
double precision, intent(in) :: x(n)
6363
double precision, intent(out) :: fvec(n)
64+
class(*), intent(inout), optional :: udata
6465

6566
integer k
6667
double precision one, temp, temp1, temp2, three, two, zero

examples/example_lmder1.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ module testmod_der1
77

88
contains
99

10-
subroutine fcn(m, n, x, fvec, fjac, ldfjac, iflag)
10+
subroutine fcn(m, n, x, fvec, fjac, ldfjac, iflag, udata)
1111
integer, intent(in) :: m, n, ldfjac
1212
integer, intent(inout) :: iflag
1313
real(dp), intent(in) :: x(n)
1414
real(dp), intent(inout) :: fvec(m), fjac(ldfjac, n)
15+
class(*), intent(inout), optional :: udata
1516

1617
integer :: i
1718
real(dp) :: tmp1, tmp2, tmp3, tmp4, y(15)

examples/example_lmdif1.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ module testmod_dif1
77

88
contains
99

10-
subroutine fcn(m, n, x, fvec, iflag)
10+
subroutine fcn(m, n, x, fvec, iflag, udata)
1111
integer, intent(in) :: m, n
1212
integer, intent(inout) :: iflag
1313
real(dp), intent(in) :: x(n)
1414
real(dp), intent(out) :: fvec(m)
15+
class(*), intent(inout), optional :: udata
1516

1617
integer :: i
1718
real(dp) :: tmp1, tmp2, tmp3, y(15)

examples/example_primes.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ function expr(x, pars) result(y)
5050

5151
contains
5252

53-
subroutine fcn(m, n, x, fvec, iflag)
53+
subroutine fcn(m, n, x, fvec, iflag, udata)
5454
integer, intent(in) :: m, n
5555
integer, intent(inout) :: iflag
5656
real(dp), intent(in) :: x(n)
5757
real(dp), intent(out) :: fvec(m)
58+
class(*), intent(inout), optional :: udata
5859
! Suppress compiler warning:
5960
fvec(1) = iflag
6061
fvec = data_y - expr(data_x, x)

0 commit comments

Comments
 (0)