Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(RootFinderDataType), | intent(inout) | :: | RootFinderData | |||
real(kind=r64), | intent(in) | :: | X | |||
real(kind=r64), | intent(in) | :: | Y |
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.
SUBROUTINE UpdateRootFinder( RootFinderData, X, Y )
! SUBROUTINE INFORMATION:
! AUTHOR Dimitri Curtil (LBNL)
! DATE WRITTEN February 2006
! MODIFIED
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine updates the root finder internal data to account for
! the current iterate (X,Y):
! - Lower / Upper support points
! - Increments for successive iterates
! - Convergence rate
!
! METHODOLOGY EMPLOYED:
!
! PRECONDITION:
! - The current iterate (X,Y) must be a valid iterate:
! MinPoint%X <= LowerPoint%X < X < UpperPoint%X <= MaxPoint%X
! - Invoke UpdateRootFinder() only if:
! - CheckRootFinderCandidate() returned TRUE
! - CheckNonSingularity() returned TRUE
! - CheckSlope() returned TRUE
!
! POSTCONDITION:
! - RootFinderData%LowerPoint possibly updated
! - RootFinderData%UpperPoint possibly updated
! - RootFinderData%CurrentPoint updated with current iterate (X,Y)
! - RootFinderData%History(:) updated with last 3 best iterates
! - RootFinderData%Increment updated
! - RootFinderData%ConvergenceRate updated
!
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
TYPE(RootFinderDataType), INTENT(INOUT) :: RootFinderData ! Data used by root finding algorithm
REAL(r64), INTENT(IN) :: X ! X value for current iterate
REAL(r64), INTENT(IN) :: Y ! Y value for current iterate, F(X)=Y
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! na
! FLOW:
! Update history with best iterates so that:
! ABS(History(1)%Y) <= ABS(History(2)%Y) <= ABS(History(3)%Y)
!
! Note that we must update the history before updating the lower/upper points
CALL UpdateHistory( RootFinderData, X, Y )
! Update lower and upper points
CALL UpdateBracket( RootFinderData, X, Y )
! Update increments and convergence rate
IF ( RootFinderData%CurrentPoint%DefinedFlag ) THEN
RootFinderData%Increment%DefinedFlag = .TRUE.
RootFinderData%Increment%X = X - RootFinderData%CurrentPoint%X
RootFinderData%Increment%Y = Y - RootFinderData%CurrentPoint%Y
IF ( ABS(RootFinderData%CurrentPoint%Y) > 0.0d0 ) THEN
! NOTE: Should be smaller than one for convergent process
RootFinderData%ConvergenceRate = ABS(Y) / ABS(RootFinderData%CurrentPoint%Y)
ELSE
! NOTE: Should never happen
RootFinderData%ConvergenceRate = -1.0d0
END IF
END IF
! Finally update CurrentPoint (must be done last)
RootFinderData%CurrentPoint%DefinedFlag = .TRUE.
RootFinderData%CurrentPoint%X = X
RootFinderData%CurrentPoint%Y = Y
RETURN
END SUBROUTINE UpdateRootFinder