Performs linear interpolation on a uniform 1D grid y(x)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(:) | :: | x | The abscissa values of |
|
real(kind=Float64), | intent(in), | dimension(:) | :: | y | Values at abscissa values |
|
real(kind=Float64), | intent(in) | :: | xout | Abscissa value to interpolate |
||
real(kind=Float64), | intent(out) | :: | yout | Interpolant: y(xout) |
||
integer, | intent(out), | optional | :: | err | Error code |
|
type(InterpolCoeffs1D), | intent(in), | optional | :: | coeffs | Precomputed Linear Interpolation Coefficients |
subroutine interpol1D_arr(x, y, xout, yout, err, coeffs)
!+ Performs linear interpolation on a uniform 1D grid y(x)
real(Float64), dimension(:), intent(in) :: x
!+ The abscissa values of `y`
real(Float64), dimension(:), intent(in) :: y
!+ Values at abscissa values `x`: y(x)
real(Float64), intent(in) :: xout
!+ Abscissa value to interpolate
real(Float64), intent(out) :: yout
!+ Interpolant: y(xout)
integer, intent(out), optional :: err
!+ Error code
type(InterpolCoeffs1D), intent(in), optional :: coeffs
!+ Precomputed Linear Interpolation Coefficients
type(InterpolCoeffs1D) :: c
integer :: i, err_status
err_status = 1
if(present(coeffs)) then
c = coeffs
err_status = 0
else
call interpol_coeff(x,xout,c,err_status)
endif
if(err_status.eq.0) then
i = c%i
yout = c%b1*y(i) + c%b2*y(i+1)
else
yout = 0.d0
endif
if(present(err)) err = err_status
end subroutine interpol1D_arr