Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64) | :: | x(npts) | ||||
real(kind=r64) | :: | y(npts) | ||||
integer | :: | npts | ||||
real(kind=r64) | :: | xin | ||||
real(kind=r64) | :: | yout |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE Interpolate (x, y, npts, xin, yout)
! SUBROUTINE INFORMATION:
! AUTHOR Adapted by F.Winkelmann from WINDOW 5 subroutine interp
! DATE WRITTEN August 1999
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Linearly interpolates between data points. Outputs yout, interpolated
! value of y corresponding to xin
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: npts ! Number of data pairs
REAL(r64) :: x(npts) ! Array of data points for independent variable
REAL(r64) :: y(npts) ! Array of data points for dependent variable
INTEGER :: i ! Counter
REAL(r64) :: xin ! Given value of x
REAL(r64) :: yout ! Interpolated value of y at xin
! FLOW
do i = 1, npts
if (xin .LE. x(i)) THEN
if (i .EQ. 1) then
yout = y(1)
else
yout = y(i-1) + (y(i) - y(i-1))*(xin - x(i-1))/(x(i) - x(i-1))
endif
RETURN
END IF
END DO
! Past the end of the array, so return endpoint
yout = y(npts)
RETURN
END SUBROUTINE Interpolate