1D linear interpolation routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linear_interp_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
integer, | intent(out), | optional | :: | istat |
|
pure subroutine interp_1d(me,x,f,istat) implicit none class(linear_interp_1d),intent(inout) :: me real(wp),intent(in) :: x real(wp),intent(out) :: f !! Interpolated \( f(x) \) integer,intent(out),optional :: istat !! `0` : no problems, !! `-1` : class has not been initialized integer,dimension(2) :: ix real(wp) :: p1 real(wp) :: q1 integer :: mflag if (me%initialized) then call dintrv(me%x,x,me%ilox,ix(1),ix(2),mflag) q1 = (x-me%x(ix(1)))/(me%x(ix(2))-me%x(ix(1))) p1 = one-q1 f = p1*me%f(ix(1)) + q1*me%f(ix(2)) if (present(istat)) istat = 0 else if (present(istat)) istat = -1 f = zero end if end subroutine interp_1d