Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(RootFinderDataType), | intent(in) | :: | RootFinderData | |||
real(kind=r64), | intent(out) | :: | XNext |
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.
LOGICAL FUNCTION SecantFormula( RootFinderData, XNext )
! FUNCTION INFORMATION:
! AUTHOR Dimitri Curtil (LBNL)
! DATE WRITTEN April 2006
! MODIFIED
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function computes the next iterate using the secant formula.
! If the new iterate cannot be computed the function returns FALSE, else TRUE.
!
! Convergence rate is at best superlinear.
!
! PRECONDITION:
! There must be at least 2 history points so that RootFinderData%Increment is defined.
!
! POSTCONDITION:
! XNext contains the result from applying the Secant formula.
! If XNext could not be computed then leave XNext unchanged.
!
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
TYPE(RootFinderDataType), INTENT(IN) :: RootFinderData ! Data used by root finding algorithm
REAL(r64), INTENT(OUT) :: XNext ! Result from Secant formula if possible to compute
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: Num
REAL(r64) :: Den
! FLOW:
Num = RootFinderData%Increment%X
Den = RootFinderData%Increment%Y
! Cannot use secant with infinite slope (Den==0).
! Cannot use secant with null slope (Num==0).
IF ( Den /= 0.0d0 .AND. Num /= 0.0d0 ) THEN
XNext = RootFinderData%CurrentPoint%X - RootFinderData%CurrentPoint%Y * Num/Den
SecantFormula = .TRUE.
ELSE
SecantFormula = .FALSE.
END IF
RETURN
END FUNCTION SecantFormula