FV3 Bundle
gsw_util_xinterp1.f90
Go to the documentation of this file.
1 !==========================================================================
2 pure function gsw_util_xinterp1 (x, y, x0)
3 !==========================================================================
4 !
5 ! Linearly interpolate a real monotonic array.
6 !
7 ! x : x array (must be monotonically increasing)
8 ! y : y array
9 ! x0 : x value to be interpolated
10 !
11 ! xinterp1 : linearly interpolated y value
12 !--------------------------------------------------------------------------
13 
15 
16 use gsw_mod_kinds
17 
18 implicit none
19 
20 real (r8), intent(in) :: x0
21 real (r8), intent(in) :: x(:), y(:)
22 
23 real (r8) :: gsw_util_xinterp1
24 
25 integer :: k
26 real (r8) :: r
27 
28 k = gsw_util_indx(x,x0)
29 r = (x0-x(k))/(x(k+1)-x(k))
30 gsw_util_xinterp1 = y(k) + r*(y(k+1)-y(k))
31 
32 return
33 end function
34 
35 !--------------------------------------------------------------------------
pure real(r8) function gsw_util_xinterp1(x, y, x0)