Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | DataPoint | |||
real(kind=r64), | DIMENSION(:) | :: | FunctionArray | |||
real(kind=r64), | DIMENSION(:) | :: | Ordinate | |||
integer, | intent(in) | :: | ISPT | |||
integer, | intent(in) | :: | IEPT | |||
real(kind=r64), | intent(out) | :: | ALAG |
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_Lagrange(DataPoint,FunctionArray,Ordinate,ISPT,IEPT,ALAG)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Raustad, FSEC
! DATE WRITTEN July 2010
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
!
! Solves the lagrange polynomial equation for interpolation. For second-order:
! F(x) = y1 * ((x-x2)(x-x3) / (x1-x2)(x1-x3)) +
! y2 * ((x-x1)(x-x3) / (x2-x1)(x2-x3)) +
! y3 * ((x-x1)(x-x2) / (x3-x1)(x3-x2))
! where xn, yn represent data points 1-n, and x represents the interpolation point.
!
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
REAL(r64), INTENT(IN) :: DataPoint ! point used for interpolating output (x)
REAL(r64), DIMENSION(:) :: FunctionArray ! array of output data (Y's)
REAL(r64), DIMENSION(:) :: Ordinate ! array of input data (X's)
! DIMENSION FunctionAry(IEPT),Ordinate(IEPT)
INTEGER, INTENT(IN) :: ISPT ! the starting point in the interpolated array
INTEGER, INTENT(IN) :: IEPT ! the ending point in the interpolated array
REAL(r64), INTENT(OUT) :: ALAG ! the interpolated output (y or F(x) in equation above)
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: Lagrange ! intermediate variable
INTEGER :: J, K ! loop coungters
ALAG = 0.0D0
DO J=ISPT,IEPT
Lagrange=1.0d0
DO K=ISPT,IEPT
IF (K .NE. J) THEN
Lagrange = Lagrange*((DataPoint-Ordinate(K))/(Ordinate(J)-Ordinate(K)))
END IF
END DO
ALAG = ALAG + Lagrange*FunctionArray(J)
END DO
RETURN
END SUBROUTINE Interpolate_Lagrange