Explicit ODR job, with parameter bounds, user-supplied derivatives, and output of work arrays.
Type | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|
type(odrpack_model) | :: | model | ||||
real(kind=dp), | allocatable | :: | beta(:) | |||
real(kind=dp), | allocatable | :: | lower(:) | |||
real(kind=dp), | allocatable | :: | upper(:) | |||
real(kind=dp), | allocatable | :: | x(:,:) | |||
real(kind=dp), | allocatable | :: | y(:,:) | |||
real(kind=dp), | allocatable | :: | rwork(:) | |||
integer, | allocatable | :: | iwork(:) | |||
integer | :: | np | ||||
integer | :: | n | ||||
integer | :: | m | ||||
integer | :: | q | ||||
integer | :: | job | ||||
integer | :: | lrwork | ||||
integer | :: | liwork |
program example5 !! Explicit ODR job, with parameter bounds, user-supplied derivatives, and output of work !! arrays. use odrpack_kinds, only: dp use odrpack, only: odr, odrpack_model, workspace_dimensions use example5_model, only: fcn implicit none type(odrpack_model) :: model real(dp), allocatable :: beta(:), lower(:), upper(:), x(:, :), y(:, :), rwork(:) integer, allocatable :: iwork(:) integer :: np, n, m, q, job integer :: lrwork, liwork !, i model%fcn => fcn job = 20 np = 2 n = 4 m = 1 q = 1 allocate (beta(np), lower(np), upper(np), x(n, m), y(n, q)) beta(1:2) = [2.0_dp, 0.5_dp] lower(1:2) = [0.0_dp, 0.0_dp] upper(1:2) = [10.0_dp, 0.9_dp] x(1:4, 1) = [0.982_dp, 1.998_dp, 4.978_dp, 6.01_dp] y(1:4, 1) = [2.7_dp, 7.4_dp, 148.0_dp, 403.0_dp] ! Manual allocation of work arrays ! Not required! Just to show it can be done if so desired call workspace_dimensions(n, m, q, np, .true., lrwork, liwork) allocate (iwork(liwork)) allocate (rwork(lrwork)) call odr(model, n, m, q, np, beta, y, x, & lower=lower, upper=upper, & job=job, iwork=iwork, rwork=rwork) ! Remove the comments to print out 'iwork' ! print *, "iwork" ! do i=1, size(iwork) ! print *, i, iwork(i) ! end do end program example5