returns interpolated value at guven u_ point number of points and ascending order of x is not checked since ispline is called after "spline" where these checks are done
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | u_ |
point at which the tabulated value is interpolated |
||
integer(kind=int32), | intent(in) | :: | N_ |
number of grid points |
||
real(kind=dp), | intent(in) | :: | x_(N_) |
grid points |
||
real(kind=dp), | intent(in) | :: | y_(N_) |
tabulated values |
||
real(kind=dp), | intent(in) | :: | b_(N_) |
arrays with coefficients of the spline function |
||
real(kind=dp), | intent(in) | :: | c_(N_) |
arrays with coefficients of the spline function |
||
real(kind=dp), | intent(in) | :: | d_(N_) |
arrays with coefficients of the spline function |
interpolated value at u_
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=dp), | public | :: | dx_ | ||||
integer(kind=int32), | public | :: | k_ | ||||
integer(kind=int32), | public | :: | l_ | ||||
integer(kind=int32), | public | :: | mid_ |
function ispline(u_, N_, x_, y_, b_, c_, d_) result(spl_result)
!! returns interpolated value at guven u_ point
!! number of points and ascending order of x is not checked since
!! ispline is called after "spline" where these checks are done
!---------------------------------------------------------------------!
real(dp), intent(in) :: u_
!! point at which the tabulated value is interpolated
integer(int32), intent(in) :: N_
!! number of grid points
real(dp), intent(in) :: x_(N_)
!! grid points
real(dp), intent(in) :: y_(N_)
!! tabulated values
real(dp), intent(in) :: b_(N_), c_(N_), d_(N_)
!! arrays with coefficients of the spline function
real(dp) :: spl_result
!! interpolated value at u_
!---------------------------------------------------------------------!
integer(int32) :: k_, l_, mid_
real(dp) :: dx_
!---------------------------------------------------------------------!
if (u_ > x_(N_)) then
call write_warning("ispline: point u_ = " // &
trim(adjustl(float_to_character(u_))) // &
" exceeds the original " // "grid: x(N) = " // &
trim(adjustl(float_to_character(x_(N_)))))
spl_result = y_(N_)
else if (u_ < x_(1) ) then
call write_warning("ispline: point u_ = " // &
trim(adjustl(float_to_character(u_))) // &
" exceeds the original " // "grid: x(1) = " // &
trim(adjustl(float_to_character(x_(1)))))
spl_result = y_(1)
else
!------------------------------------------------------------------!
l_ = 1
k_ = N_+1
do while (k_ > l_+1)
mid_ = nint( (l_ + k_) / 2.0_dp )
if (x_(mid_) > u_) then
k_ = mid_
else
l_ = mid_
endif
end do
dx_ = u_ - x_(l_)
spl_result = y_(l_) + dx_ * (b_(l_) + dx_ * (c_(l_) + d_(l_) * dx_))
!------------------------------------------------------------------!
endif
!---------------------------------------------------------------------!
end function ispline