Given a set of piecewise-continuous line segments defined by set of values (these must be monotonically increasing) and a corresponding set of values, and given also a single value, this subroutine performs a linear interpolation to return the associated value. If is outside the range of values, or in other pathological cases, 0 is returned.
function linearInterpolate(x, y, xSample) result(ySample) real(single), intent(in) :: x(:), y(size(x)), xSample real(single) :: ySample end function linearInterpolate