nearest_1d Subroutine

private pure subroutine nearest_1d(me, x, f, istat)

1D nearest neighbor interpolation routine.

Type Bound

nearest_interp_1d

Arguments

Type IntentOptional Attributes Name
class(nearest_interp_1d), intent(inout) :: me
real(kind=wp), intent(in) :: x
real(kind=wp), intent(out) :: f

Nearest

integer, intent(out), optional :: istat

0 : no problems, -1 : class has not been initialized


Calls

proc~~nearest_1d~~CallsGraph proc~nearest_1d linear_interpolation_module::nearest_interp_1d%nearest_1d f f proc~nearest_1d->f proc~dintrv linear_interpolation_module::dintrv proc~nearest_1d->proc~dintrv

Source Code

    pure subroutine nearest_1d(me,x,f,istat)

    implicit none

    class(nearest_interp_1d),intent(inout) :: me
    real(wp),intent(in)                    :: x
    real(wp),intent(out)                   :: f     !! Nearest \( f(x) \)
    integer,intent(out),optional           :: istat !! `0`  : no problems,
                                                    !! `-1` : class has not been initialized

    integer :: mflag
    integer,dimension(2) :: ix
    integer :: i

    if (me%initialized) then

        call dintrv(me%x,x,me%ilox,ix(1),ix(2),mflag,i)

        f = me%f(i)
        if (present(istat)) istat = 0

    else

        if (present(istat)) istat = -1
        f = zero

    end if

    end subroutine nearest_1d