Performs bilinear interpolation on a 2D grid z(x,y)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(:) | :: | x | The abscissa values of |
|
real(kind=Float64), | intent(in), | dimension(:) | :: | y | The ordinate values of |
|
real(kind=Float64), | intent(in), | dimension(:,:) | :: | z | Values at the abscissa/ordinates: z(x,y) |
|
real(kind=Float64), | intent(in) | :: | xout | The abscissa value to interpolate |
||
real(kind=Float64), | intent(in) | :: | yout | The ordinate value to interpolate |
||
real(kind=Float64), | intent(out) | :: | zout | Interpolant: z(xout,yout) |
||
integer, | intent(out), | optional | :: | err | Error code |
|
type(InterpolCoeffs2D), | intent(in), | optional | :: | coeffs | Precomputed Linear Interpolation Coefficients |
subroutine interpol2D_arr(x, y, z, xout, yout, zout, err, coeffs)
!+ Performs bilinear interpolation on a 2D grid z(x,y)
real(Float64), dimension(:), intent(in) :: x
!+ The abscissa values of `z`
real(Float64), dimension(:), intent(in) :: y
!+ The ordinate values of `z`
real(Float64), dimension(:,:), intent(in) :: z
!+ Values at the abscissa/ordinates: z(x,y)
real(Float64), intent(in) :: xout
!+ The abscissa value to interpolate
real(Float64), intent(in) :: yout
!+ The ordinate value to interpolate
real(Float64), intent(out) :: zout
!+ Interpolant: z(xout,yout)
integer, intent(out), optional :: err
!+ Error code
type(InterpolCoeffs2D), intent(in), optional :: coeffs
!+ Precomputed Linear Interpolation Coefficients
type(InterpolCoeffs2D) :: c
integer :: i, j, err_status
err_status = 1
if(present(coeffs)) then
c = coeffs
err_status = 0
else
call interpol_coeff(x,y,xout,yout,c,err_status)
endif
if(err_status.eq.0) then
i = c%i
j = c%j
zout = c%b11*z(i,j) + c%b12*z(i,j+1) + c%b21*z(i+1,j) + c%b22*z(i+1,j+1)
else
zout = 0.d0
endif
if(present(err)) err = err_status
end subroutine interpol2D_arr