C+ C NAME: C ArrR4Interpolate C PURPOSE: C Interpolate on 1-dim real*4 array. C CALLING SEQUENCE: function ArrR4Interpolate(N,A,X) C INPUTS: C N integer # points in array C A(N) real Array of function values C X real Function value where interpolated position is needed C OUTPUTS: C ArrR4Interpolate C real interpolated index in [1,N] C A BadR4 value is returned if X lies outside the C range of input array A. C CALLS: C BadR4 C RESTRICTIONS: C A must be a monotonically increasing array. C PROCEDURE: C For given X the pair of indices I-1 and I are located C where A(I-1) < X <= A(I). Then a linear interpolation between these C two points gives the return floating point index. C MODIFICATION HISTORY: C SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer N real A(*) real X if (A(1) .le. X .and. X .le. A(N)) then I = 1 do while (I .le. N .and. X .gt. A(I)) I = I+1 end do ArrR4Interpolate = float(I) if (I .ne. 1) ArrR4Interpolate = ArrR4Interpolate-(X-A(I))/(A(I-1)-A(I)) else ArrR4Interpolate = BadR4() end if return end