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.
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 BracketRoot( RootFinderData, XNext )
! FUNCTION INFORMATION:
! AUTHOR Dimitri Curtil (LBNL)
! DATE WRITTEN February 2006
! MODIFIED
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function attempts to compute a new point that will bracket the root
! using the secant formula to take advantage of the slope between the last 2
! iterates.
!
! Returns TRUE if successfully computed a new bracket in XNext.
! Else returns FASLE and does not update the XNext argument.
!
! Should only be used while in braketing mode (iMethodBracket).
! When the lower and upper brackets are detected then the FUNCTION SecantMethod
! should be used instead.
!
! PRECONDITION:
! na
!
! POSTCONDITION:
! - MinPoint%X <= XNext <= MaxPoint%X
! - LowerPoint%X < XNext < UpperPoint%X
!
! 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 ! Next value
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
! na
! FLOW:
! Cannot use Secant method unless there are at least 2 points
! Also do not use Secant method more than once, i.e. NumHistory==3, in order to avoid
! the pathological case whereby the secant method always comes up short of bracketting
! the root because the function slope flattens as we come closer to either min/max point.
IF ( RootFinderData%NumHistory /= 2 ) THEN
BracketRoot = .FALSE.
RETURN
END IF
! Should not use Secant method if the last 2 points produced a warning
IF ( RootFinderData%StatusFlag == iStatusWarningSingular .OR. &
RootFinderData%StatusFlag == iStatusWarningNonMonotonic ) THEN
BracketRoot = .FALSE.
RETURN
END IF
! Try to compute next root candidate using Secant formula
IF ( SecantFormula( RootFinderData, XNext ) ) THEN
! Check that next candidate is consistent with min/max constraints and lower/upper brackets
IF ( CheckRootFinderCandidate( RootFinderData, XNext ) ) THEN
BracketRoot = .TRUE.
RETURN
END IF
END IF
BracketRoot = .FALSE.
RETURN
END FUNCTION BracketRoot