newton_solve Subroutine

public subroutine newton_solve(fun, x, tol, max_iter, its, info)

newton_solve

Solve a nonlinear system by damped Newton iteration.

Description

Forms the Newton direction from , then applies backtracking to reduce the squared-residual merit function. info=0 indicates residual convergence (max-norm below tol); info=1 indicates the iteration limit.

Examples

See the module-level callback example.

Arguments

Type IntentOptional Attributes Name
public subroutine fun(x, f, J)
Arguments
Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x(:)

Current unknown vector.

real(kind=dp), intent(out) :: f(:)

Residual vector.

real(kind=dp), intent(out) :: J(:,:)

Residual Jacobian.

real(kind=dp), intent(inout) :: x(:)

Initial guess; last iterate on return.

real(kind=dp), intent(in) :: tol

Absolute residual convergence tolerance.

integer, intent(in) :: max_iter

Maximum Newton iterations.

integer, intent(out) :: its

Iteration count at termination.

integer, intent(out) :: info

0 = converged (max-norm of residuals below tol), 1 = iteration limit reached


Calls

proc~~newton_solve~~CallsGraph proc~newton_solve newton_solve proc~solve_system solve_system proc~newton_solve->proc~solve_system none~dgesv dgesv proc~solve_system->none~dgesv

Variables

Type Visibility Attributes Name Initial
real(kind=dp), public :: J(size(X),size(X))

Jacobian matrix

real(kind=dp), public :: Jp(size(X))
real(kind=dp), public :: alpha

Backtracking step length

real(kind=dp), public :: dx(size(X))
real(kind=dp), public :: f(size(X))

Residual or scalar equation value.

real(kind=dp), public :: f_norm
real(kind=dp), public :: ftrial(size(X))
real(kind=dp), public :: grad_phi_p
integer, public :: k

Loop/index or term index.

integer, public :: n

Number of unknowns

real(kind=dp), public :: phi_trial
real(kind=dp), public :: phi_x
real(kind=dp), public :: xtrial(size(X))