Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(out) | :: | ResultX | |||
real(kind=r64), | intent(in) | :: | Tol | |||
real(kind=r64), | intent(inout) | :: | X0 | |||
real(kind=r64), | intent(inout) | :: | Y0 | |||
real(kind=r64), | intent(inout) | :: | X1 | |||
real(kind=r64), | intent(inout) | :: | Y1 | |||
integer, | intent(in) | :: | Iter | |||
integer, | intent(out) | :: | Cnvg |
SUBROUTINE ITERATE(ResultX,Tol,X0,Y0,X1,Y1,Iter,Cnvg)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Liesen
! DATE WRITTEN March 2004
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Iterately solves for the value of X which satisfies Y(X)=0.
! The subroutine tests for convergence and provides a new guess for the value of the
! independent variable X.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! Linear Correction based on the RegulaFalsi routine in EnergyPlus
! USE STATEMENTS:
USE DataPrecisionGlobals
!unused0909 use dataglobals, only: outputfiledebug
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
REAL(r64), INTENT(Out) :: ResultX !ResultX is the final Iteration result passed back to the calling routine
REAL(r64), INTENT(In) :: Tol !Tolerance for Convergence
REAL(r64), INTENT(InOut) :: X0 !Current value of X
REAL(r64), INTENT(InOut) :: Y0 !Current value of the function Y(X)
REAL(r64), INTENT(InOut) :: X1 !First Previous values of X
REAL(r64), INTENT(InOut) :: Y1 !First Previous values of Y(X1)
Integer, Intent(In) :: Iter !Number of iterations
Integer, Intent(Out):: Cnvg !Convergence flag Cnvg = 0: Not converged
! Cnvg = 1: Converged
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: small = 1.d-9 !Small Number used to approximate zero
REAL(r64), PARAMETER :: Perturb=0.1d0 !Perturbation applied to X to initialize iteration
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: Dy !Linear fit result
! FLOW:
! Check for convergence by comparing change in X
IF (Iter .ne. 1) THEN
IF (ABS(X0-X1) .LT. Tol .OR. Y0 .EQ. 0.0d0) THEN
ResultX = X0
Cnvg=1
RETURN
ENDIF
ENDIF
! Not converged.
Cnvg=0
IF (Iter .EQ. 1) THEN
! New guess is specified by Perturb
IF (ABS(X0) .GT. small) THEN
ResultX = X0*(1.0d0+Perturb)
ELSE
ResultX = Perturb
ENDIF
ELSE
! New guess calculated from LINEAR FIT of most recent two points
DY = Y0 - Y1
IF (ABS(DY) < SMALL) DY = SMALL
! new estimation
ResultX = (Y0 * X1 - Y1 * X0 ) / DY
ENDIF
X1=X0
Y1=Y0
RETURN
END SUBROUTINE ITERATE