nitsol_mod Module

Provides an explicit interface to the NITSOL package. Variables held in common blocks which can be used to control NITSOL are also provided here. At some point I may produce a proper object oriented interface for it.

Also present is an interface to the GMRES solver provided by NITSOL. Both a direct interface and a wrapper are provided. The wrapper offers a somewhat more general and F90-ish presentation of the routine.


Uses

  • module~~nitsol_mod~~UsesGraph module~nitsol_mod nitsol_mod iso_fortran_env iso_fortran_env module~nitsol_mod->iso_fortran_env

Used by

  • module~~nitsol_mod~~UsedByGraph module~nitsol_mod nitsol_mod module~ice_shelf_mod ice_shelf_mod module~ice_shelf_mod->module~nitsol_mod module~glacier_mod glacier_mod module~ice_shelf_mod->module~glacier_mod module~cryosphere_mod cryosphere_mod module~cryosphere_mod->module~nitsol_mod module~cryosphere_mod->module~glacier_mod module~basal_surface_mod basal_surface_mod module~cryosphere_mod->module~basal_surface_mod module~glacier_mod->module~nitsol_mod module~ode_solvers_mod ode_solvers_mod module~ode_solvers_mod->module~nitsol_mod module~basal_surface_mod->module~nitsol_mod module~finite_difference_block_mod finite_difference_block_mod module~finite_difference_block_mod->module~nitsol_mod module~ground_mod ground_mod module~ground_mod->module~basal_surface_mod module~asymmetric_plume_mod asymmetric_plume_mod module~asymmetric_plume_mod->module~ode_solvers_mod module~asymmetric_plume_mod->module~basal_surface_mod module~ice_sheet_mod ice_sheet_mod module~ice_sheet_mod->module~glacier_mod module~static_plume_mod static_plume_mod module~static_plume_mod->module~ode_solvers_mod module~static_plume_mod->module~basal_surface_mod module~plume_mod plume_mod module~plume_mod->module~ode_solvers_mod module~plume_mod->module~basal_surface_mod

Contents


Common Blocks

Type AttributesNameInitial
integer :: iplvl
integer :: ipunit
Type AttributesNameInitial
real(kind=r8) :: avrate
real(kind=r8) :: fcurnrm
integer :: instep
integer :: newstep
integer :: krystat
Type AttributesNameInitial
real(kind=r8) :: choice1_exp
real(kind=r8) :: choice2_exp
real(kind=r8) :: choice2_coef
real(kind=r8) :: eta_cutoff
real(kind=r8) :: etamax
real(kind=r8) :: thmin
real(kind=r8) :: thmax
real(kind=r8) :: etafixed

Interfaces

interface

  • public subroutine nitsol(n, x, f, jacv, ftol, stptol, input, info, rwork, rpar, ipar, iterm, dinpr, dnorm)

    An explicit interface to the nitsol Newton iterative nonlinear solver.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(inout), dimension(n):: x

    Vector of length n, initial guess on input and final approximate solution on output

    procedure(f_intr) :: f

    User-supplied subroutine for evaluating the function the zero of which is sought.

    procedure(jacv_intr) :: jacv

    User-supplied subroutine for optionally evaluating or , where is the Jacobian of and is a right preconditioning operator. If neither analytic evaluations nor right preconditioning is used, this can be a dummy subroutine; if right preconditioning is used but not analytic evaluations, this need only evaluate .

    real(kind=r8), intent(in) :: ftol

    Stopping tolerance of the f-norm

    real(kind=r8), intent(in) :: stptol

    Stopping tolerance of the step-length

    integer, intent(in), dimension(10):: input

    Array containing various user-specified inputs; see above

    integer, intent(out), dimension(6):: info

    Array containing various outputs; see above

    real(kind=r8), intent(inout), dimension(*):: rwork

    Work array with length depending on the solver used as follows:

    GMRES
    , where kdmax is the maximum Krylove subspace dimension, either the default value of 20 or another value specified by the user
    BiCGSTAB
    TFQMR
    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array passed to the f and jacv routines

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array passed to the f and jacv routines

    integer, intent(out) :: iterm

    Termination flag. Values have the following meanings:

    -k
    illegal value in input(k)
    0
    normal termination: or
    1
    nnimax nonlinar iterations reached without success
    2
    failure to evaluate
    3
    in nitjv, failure
    4
    in nitjv, failure
    5
    in nitdrv, insufficient initial model norm reduction for adequate progress. Note: This can occur for several reasons; examine itrmks on return from the Krylov solver for further information. (This will be printed out if ; see the discussion of optional common blocks below.)
    6
    in nitbt, failure to reach an acceptable step through backtracking
    procedure(dinpr_intr) :: dinpr

    User-supplied function for calculating vector inner products. This has the same interace as the BLAS routine ddot. If the Euclidean inner product is desired then user can link to a local BLAS library and provide the name ddot to nitsol. dinpr must be declared as an external function that returns a double precision in the calling program.

    procedure(dnorm_intr) :: dnorm

    User-supplied function for calculating vector norms. This has the same interface as the BLAS routine dnrm2; if the Euclidean norm is desired the user can link to a local BLAS library and provide the name dnrm2 to nitsol. dnorm must be declared as an external function that returns a double precision value in the calling program.

interface

  • public subroutine nitgm2(n, xcur, fcur, step, eta, f, jacv, rpar, ipar, ijacv, irpre, iksmax, iresup, ifdord, nfe, njve, nrpre, nli, kdmax, kdmaxp1, vv, rr, svbig, svsml, w, rwork, rsnrm, dinpr, dnorm, itrmks)

    An interface to my modified versino of the nitsol implementation of the generalised minimal residual method (GMRES) for iteratively solving linear systems. It has been modified so that the user provides a non-zero initial guess of the solution.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(in), dimension(n):: xcur

    Array of length n containing the current value

    real(kind=r8), intent(in), dimension(n):: fcur

    Array of length n containing current approximate solution

    real(kind=r8), intent(inout), dimension(n):: step

    Vector of of length n containing trial step

    real(kind=r8), intent(in) :: eta

    Relative residual reduction factor

    procedure(f_intr) :: f

    User-supplied subroutine for evaluating the function the zero of which is sought.

    procedure(jacv_intr) :: jacv

    User-supplied subroutine for optionally evaluating or , where is the Jacobian of and is a right preconditioning operator. If neither analytic evaluations nor right preconditioning is used, this can be a dummy subroutine; if right preconditioning is used but not analytic evaluations, this need only evaluate .

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array passed to the f and jacv routines

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array passed to the f and jacv routines

    integer, intent(in) :: ijacv

    Flag for determining method of evaluation. 0 (default) indicates finite-difference evaluation, while 1 indicates analytic evaluation.

    integer, intent(in) :: irpre

    Flag for right preconditioning. 0 indicates no preconditioning, while 1 inidcates right preconditioning.

    integer, intent(in) :: iksmax

    Maximum allowable number of GMRES iterations

    integer, intent(in) :: iresup

    Residual update flag. On GMRES restarts, the residual can be updated using a linear combination (iresup == 0) or by direct evaluation (iresup == 1). The first is cheap (one n-vector saxpy) but may lose accuracy with extreme residual reduction; the second retains accuracy better but costs one product.

    integer, intent(in) :: ifdord

    Order of the finite-difference formula (sometimes) used on GMRES restarts when products are evaluated using finite- differences. When ijacv = 0 on input to nitsol, ifdord is set to 1, 2, or 4 in nitsol; otherwise, it is irrelevant. When ijacv = 0 on input to this subroutine, the precise meaning is as follows:

    With GMRES, ifdord matters only if iresup = 1, in which case
    it determines the order of the finite-difference formula used in evaluating the initial residual at each GMRES restart
    (default 2). If iresup = 1 and ijacv = 0 on input to this
    subroutine, then ijacv is temporarily reset to -1 at each
    restart below to force a finite-difference evaluation of order ifdord. NOTE: This only affects initial residuals at restarts; first-order differences are always used within each GMRES
    cycle. Using higher-order differences at restarts only should give the same accuracy as if higher-order differences were
    used throughout; see K. Turner and H. F. Walker, "Efficient
    high accuracy solutions with GMRES(m)," SIAM J. Sci. Stat.
    Comput., 13 (1992), pp. 815--825.

    integer, intent(inout) :: nfe

    Number of function evaluations

    integer, intent(inout) :: njve

    Number of evaluations

    integer, intent(inout) :: nrpre

    Number of evaluations

    integer, intent(inout) :: nli

    Number of linear iterations

    integer, intent(in) :: kdmax

    Maximum Krylov subspace dimension; default 10.

    integer, intent(in) :: kdmaxp1

    kdmax + 1

    real(kind=r8), intent(out), dimension(n, kdmaxp1):: vv

    Matrix for storage of Krylov basis in GMRES; on return, the residual vector is contained in the first column.

    real(kind=r8), intent(out), dimension(kdmax, kdmax):: rr

    Matrix for storage of triangular matrix in GMRES.

    real(kind=r8), intent(out), dimension(kdmax):: svbig

    Vector for storage of estimate of singular vector of rr with largest singular value.

    real(kind=r8), intent(out), dimension(kdmax):: svsml

    Vector for storage of estimate of singular vector of rr with smallest singular value.

    real(kind=r8), intent(out), dimension(kdmax):: w

    Vector containing right-hand side of triangular system and least-squares residual norm in GMRES.

    real(kind=r8), intent(out), dimension(n):: rwork

    Work array

    real(kind=r8), intent(out) :: rsnrm

    GMRES residual norm on return

    procedure(dinpr_intr) :: dinpr

    Inner-product routine, either user-supplied or BLAS ddot.

    procedure(dnorm_intr) :: dnorm

    Norm routine, either user supplied or BLAS dnrm2.

    integer, intent(out) :: itrmks

    Termination flag. Values have the following meanings:

    0
    normal termination: acceptable step found
    1
    failure in nitjv
    2
    failure in nitjv
    3
    Acceptable step not found in iksmax GMRES iterations
    4
    Insignificant residual norm reduction of a cycle of kdmax steps (stagnation) before an acceptable step has been found.
    5
    Dangerous ill-conditioning detected before an acceptable step has been found.

interface

  • public subroutine nittfq2(n, xcur, fcur, step, eta, f, jacv, rpar, ipar, ijacv, irpre, iksmax, ifdord, nfe, njve, nrpre, nli, r, rcgs, rtil, d, p, q, u, v, y, rwork1, rwork2, rsnrm, dinpr, dnorm, itrmks)

    An interface to my modified versino of the nitsol implementation of the transpose-free quasi-minimal residual method (TFQMR) for iteratively solving linear systems. It has been modified so that the user provides a non-zero initial guess of the solution.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(in), dimension(n):: xcur

    Array of length n containing the current value

    real(kind=r8), intent(in), dimension(n):: fcur

    Array of length n containing current approximate solution

    real(kind=r8), intent(inout), dimension(n):: step

    Vector of of length n containing trial step

    real(kind=r8), intent(in) :: eta

    Relative residual reduction factor

    procedure(f_intr) :: f

    User-supplied subroutine for evaluating the function the zero of which is sought.

    procedure(jacv_intr) :: jacv

    User-supplied subroutine for optionally evaluating or , where is the Jacobian of and is a right preconditioning operator. If neither analytic evaluations nor right preconditioning is used, this can be a dummy subroutine; if right preconditioning is used but not analytic evaluations, this need only evaluate .

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array passed to the f and jacv routines

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array passed to the f and jacv routines

    integer, intent(in) :: ijacv

    Flag for determining method of evaluation. 0 (default) indicates finite-difference evaluation, while 1 indicates analytic evaluation.

    integer, intent(in) :: irpre

    Flag for right preconditioning. 0 indicates no preconditioning, while 1 inidcates right preconditioning.

    integer, intent(in) :: iksmax

    Maximum allowable number of TFQMR iterations

    integer, intent(in) :: ifdord

    Order of the finite-difference formula used in TFQMR when J*v products are evaluated using finite-differences. When ijacv = 0 on input to nitsol, ifdord is set to 1, 2, or 4 in nitsol; otherwise, it is irrelevant. When ijacv = 0 on input to this subroutine, ifdord determines the order of the finite-difference formula used at each TFQMR iteration (default 1). In this case, ijacv is set to -1 below to signal to nitjv that the order of the finite-difference formula is to be determined by ifdord. The original value ijacv = 0 is restored on return.

    integer, intent(inout) :: nfe

    Number of function evaluations

    integer, intent(inout) :: njve

    Number of evaluations

    integer, intent(inout) :: nrpre

    Number of evaluations

    integer, intent(inout) :: nli

    Number of linear iterations

    real(kind=r8), intent(out), dimension(n):: r

    Residual vector (for the QMR process)

    real(kind=r8), intent(out), dimension(n):: rcgs

    Residual vector (of the underlying CGS process)

    real(kind=r8), intent(out), dimension(n):: rtil

    'Shadow' residual vector used in bi-orthogonalization

    real(kind=r8), intent(out), dimension(n):: d

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: p

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: q

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: u

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: v

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: y

    Vector used in TFQMR

    real(kind=r8), intent(out), dimension(n):: rwork1

    Work vector, passed on to nitjv

    real(kind=r8), intent(out), dimension(n):: rwork2

    Work vector, passed on to nitjv

    real(kind=r8), intent(out) :: rsnrm

    TFQMR residual norm on return

    procedure(dinpr_intr) :: dinpr

    Inner-product routine, either user-supplied or BLAS ddot.

    procedure(dnorm_intr) :: dnorm

    Norm routine, either user supplied or BLAS dnrm2.

    integer, intent(out) :: itrmks

    Termination flag. Values have the following meanings:

    0
    normal termination: acceptable step found
    1
    failure in nitjv
    2
    failure in nitjv
    3
    Acceptable step not found in iksmax TFQMR iterations
    4
    TFQMR breakdown
    5
    Floating point error (the underlying CGS iteration has probably blown up)

interface

  • public subroutine nitstb2(n, xcur, fcur, step, eta, f, jacv, rpar, ipar, ijacv, irpre, iksmax, ifdord, nfe, njve, nrpre, nli, r, rtil, p, phat, v, t, rwork1, rwork2, rsnrm, dinpr, dnorm, itrmks)

    An interface to my modified versino of the nitsol implementation of the biconjugate gradient stabilized method (BiCGSTAB) for iteratively solving linear systems. It has been modified so that the user provides a non-zero initial guess of the solution.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(in), dimension(n):: xcur

    Array of length n containing the current value

    real(kind=r8), intent(in), dimension(n):: fcur

    Array of length n containing current approximate solution

    real(kind=r8), intent(inout), dimension(n):: step

    Vector of of length n containing trial step

    real(kind=r8), intent(in) :: eta

    Relative residual reduction factor

    procedure(f_intr) :: f

    User-supplied subroutine for evaluating the function the zero of which is sought.

    procedure(jacv_intr) :: jacv

    User-supplied subroutine for optionally evaluating or , where is the Jacobian of and is a right preconditioning operator. If neither analytic evaluations nor right preconditioning is used, this can be a dummy subroutine; if right preconditioning is used but not analytic evaluations, this need only evaluate .

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array passed to the f and jacv routines

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array passed to the f and jacv routines

    integer, intent(in) :: ijacv

    Flag for determining method of evaluation. 0 (default) indicates finite-difference evaluation, while 1 indicates analytic evaluation.

    integer, intent(in) :: irpre

    Flag for right preconditioning. 0 indicates no preconditioning, while 1 inidcates right preconditioning.

    integer, intent(in) :: iksmax

    Maximum allowable number of BiCGSTAB iterations

    integer, intent(in) :: ifdord

    Order of the finite-difference formula used in BiCGSTAB when J*v products are evaluated using finite-differences. When ijacv = 0 on input to nitsol, ifdord is set to 1, 2, or 4 in nitsol; otherwise, it is irrelevant. When ijacv = 0 on input to this subroutine, ifdord determines the order of the finite-difference formula used at each BiCGSTAB iteration (default 1). In this case, ijacv is set to -1 below to signal to nitjv that the order of the finite-difference formula is to be determined by ifdord. The original value ijacv = 0 is restored on return.

    integer, intent(inout) :: nfe

    Number of function evaluations

    integer, intent(inout) :: njve

    Number of evaluations

    integer, intent(inout) :: nrpre

    Number of evaluations

    integer, intent(inout) :: nli

    Number of linear iterations

    real(kind=r8), intent(out), dimension(n):: r

    Residual vector

    real(kind=r8), intent(out), dimension(n):: rtil

    vector used in BiCGSTAB

    real(kind=r8), intent(out), dimension(n):: p

    Vector used in BiCGSTAB

    real(kind=r8), intent(out), dimension(n):: phat

    Vector used in BiCGSTAB

    real(kind=r8), intent(out), dimension(n):: v

    Vector used in BiCGSTAB

    real(kind=r8), intent(out), dimension(n):: t

    Vector used in BiCGSTAB

    real(kind=r8), intent(out), dimension(n):: rwork1

    Work vector, passed on to nitjv

    real(kind=r8), intent(out), dimension(n):: rwork2

    Work vector, passed on to nitjv

    real(kind=r8), intent(out) :: rsnrm

    BiCGSTAB residual norm on return

    procedure(dinpr_intr) :: dinpr

    Inner-product routine, either user-supplied or BLAS ddot.

    procedure(dnorm_intr) :: dnorm

    Norm routine, either user supplied or BLAS dnrm2.

    integer, intent(out) :: itrmks

    Termination flag. Values have the following meanings:

    0
    normal termination: acceptable step found
    1
    failure in nitjv
    2
    failure in nitjv
    3
    Acceptable step not found in iksmax BiCGSTAB iterations
    4
    BiCGSTAB breakdown

interface

  • public function ddot(n, x, sx, y, sy)

    An interface to the BLAS routine for calculating Euclidean inner product. This can be passed to nitsol for the argument dinpr.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n
    real(kind=r8), intent(in), dimension(*):: x
    integer, intent(in) :: sx
    real(kind=r8), intent(in), dimension(*):: y
    integer, intent(in) :: sy

    Return Value real(kind=r8)

interface

  • public function dnrm2(n, x, sx)

    An interface to the BLAS routine for calculating Euclidean norm. This can be passed to nitsol for the argument dnorm.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n
    real(kind=r8), intent(in), dimension(*):: x
    integer, intent(in) :: sx

    Return Value real(kind=r8)


Abstract Interfaces

abstract interface

  • public function dinpr_intr(n, x, sx, y, sy)

    Interface for function which calculates vector inner products. This has the same interace as the BLAS routine ddot.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The length of the vectors

    real(kind=r8), intent(in), dimension(*):: x

    The first input vector

    integer, intent(in) :: sx

    The stride in memory between successive elements of x

    real(kind=r8), intent(in), dimension(*):: y

    The second input vector

    integer, intent(in) :: sy

    The stride in memory between successive elements of y

    Return Value real(kind=r8)

    Inner product of x and y

abstract interface

  • public function dnorm_intr(n, x, sx)

    Interface for function which calculates vector norms. This has the same interface as the BLAS routine dnrm2.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The length of the array

    real(kind=r8), intent(in), dimension(*):: x

    The input vector

    integer, intent(in) :: sx

    The stride in memory between consecutive elements of x

    Return Value real(kind=r8)

    The vector norm of x

abstract interface

  • public function mat_mult(v, xcur, rhs, rpar, ipar, success)

    Interface for operations representing the multiplication of a vector by a matrix, such as that for a linear operator or a preconditioner.

    Arguments

    Type IntentOptional AttributesName
    real(kind=r8), intent(in), dimension(:):: v

    The vector to be multiplied

    real(kind=r8), intent(in), dimension(:):: xcur

    Array containing the current estimate of the independent variables in the linear system. This may not be needed, but is provided just in case.

    real(kind=r8), intent(in), dimension(:):: rhs

    Array containing the right hand side of the linear system. This may not be needed, but is provided just in case.

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array

    logical, intent(out) :: success

    Indicates whether operation was completed succesfully

    Return Value real(kind=r8), dimension(size(xcur))

    Result of the operation

abstract interface

  • public subroutine f_intr(n, xcur, fcur, rpar, ipar, itrmf)

    Interface for a subroutine which evaluates the function the zero of which is sought.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(in), dimension(n):: xcur

    Array of length n containing the current value

    real(kind=r8), intent(out), dimension(n):: fcur

    Array of length n containing f(xcur) on output

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array

    integer, intent(out) :: itrmf

    Termination flag. 0 means normal termination, 1 means failure to produce f(xcur)

abstract interface

  • public subroutine jacv_intr(n, xcur, fcur, ijob, v, z, rpar, ipar, itrmjv)

    Interface for a subroutine which optionally evaluates or , where is the Jacobian of and is a right preconditioning operator.

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Dimension of the problem

    real(kind=r8), intent(in), dimension(n):: xcur

    Array of length n containing the current value

    real(kind=r8), intent(in), dimension(n):: fcur

    Array of length n containing the current value

    integer, intent(in) :: ijob

    Integer flag indicating which product is desired. 0 indicates . 1 indicates .

    real(kind=r8), intent(in), dimension(n):: v

    An array of length n to be multiplied

    real(kind=r8), intent(out), dimension(n):: z

    An array of length n containing the desired product on output.

    real(kind=r8), intent(inout), dimension(*):: rpar

    Parameter/work array

    integer, intent(inout), dimension(*):: ipar

    Parameter/work array

    integer, intent(out) :: itrmjv

    Termination flag. 0 indcates normal termination, 1 indicatesfailure to prodce , and 2 indicates failure to produce


Subroutines

public subroutine dummy_jacv(n, xcur, fcur, ijob, v, z, rpar, ipar, itrmjv)

Author
Chris MacMackin
Date
November 2016

A dummy subroutine which does not apply a preconditioner or calculate an analytic Jacobian. This can be passed to nitsol for the argument jacv.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: n
real(kind=r8), intent(in), dimension(n):: xcur
real(kind=r8), intent(in), dimension(n):: fcur
integer, intent(in) :: ijob
real(kind=r8), intent(in), dimension(n):: v
real(kind=r8), intent(out), dimension(n):: z
real(kind=r8), intent(inout), dimension(*):: rpar
integer, intent(inout), dimension(*):: ipar
integer, intent(out) :: itrmjv

public subroutine dummy_f(n, xcur, fcur, rpar, ipar, itrmf)

Author
Chris MacMackin
Date
March 2017

A dummy subroutine which does not calculate the function.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: n

Dimension of the problem

real(kind=r8), intent(in), dimension(n):: xcur

Array of length n containing the current value

real(kind=r8), intent(out), dimension(n):: fcur

Array of length n containing f(xcur) on output

real(kind=r8), intent(inout), dimension(*):: rpar

Parameter/work array

integer, intent(inout), dimension(*):: ipar

Parameter/work array

integer, intent(out) :: itrmf

Termination flag. 0 means normal termination, 1 means failure to produce f(xcur)

public subroutine gmres_solve(solution, lhs, rhs, resid_norm, flag, nlhs, nrpre, nli, tol, precond, rpar, ipar, resid_update, iter_max, krylov_dim, inner_prod, norm)

Author
Chris MacMackin
Date
March 2017

A wraper for the nitsol implementation of the generalised minimal residual method (GMRES) for iteratively solving linear systems. This provides a more general interface not specifically intended for use with Newton iteration. It also uses Fortran 90 features to provide a more convenient call signature.

Arguments

Type IntentOptional AttributesName
real(kind=r8), intent(inout), dimension(:):: solution

On input, an initial guess of the solution to the linear system. On output, the iteratively determined solution.

procedure(mat_mult) :: lhs

The linear operator on the left hand side of the linear system.

real(kind=r8), intent(in), dimension(:):: rhs

The right hand side of the linear system being solved

real(kind=r8), intent(out) :: resid_norm

GMRES residual norm on return

integer, intent(out) :: flag

Termination flag. Values have the following meanings:

Read more…
integer, intent(out), optional :: nlhs

Number of evaluations of the left hand side of the system

integer, intent(out), optional :: nrpre

Number of evaluations of the right-preconditioner

integer, intent(out), optional :: nli

Number of iterations

real(kind=r8), intent(in), optional :: tol

The tolerance for the solution. Default is size(solution) * 1e-8.

procedure(mat_mult), optional :: precond

A right-preconditioner which may be used to improve convergence of the solution.

real(kind=r8), intent(inout), optional dimension(*):: rpar

Parameter/work array passed to the lhs and precond routines.

integer, intent(inout), optional dimension(*):: ipar

Parameter/work array passed to the lhs and precond routines

integer, intent(in), optional :: resid_update

Residual update flag. On GMRES restarts, the residual can be updated using a linear combination (iresup == 0) or by direct evaluation (iresup == 1). The first is cheap (one n-vector saxpy) but may lose accuracy with extreme residual reduction; the second retains accuracy better but costs one product. Default is 0.

integer, intent(in), optional :: iter_max

Maximum allowable number of GMRES iterations. Default is 1000.

integer, intent(in), optional :: krylov_dim

Maximum Krylov subspace dimension; default 10.

procedure(dinpr_intr), optional :: inner_prod

Inner-product routine, either user-supplied or BLAS ddot.

procedure(dnorm_intr), optional :: norm

Norm routine, either user supplied or BLAS dnrm2.

public subroutine tfqmr_solve(solution, lhs, rhs, resid_norm, flag, nlhs, nrpre, nli, tol, precond, rpar, ipar, resid_update, iter_max, krylov_dim, inner_prod, norm)

Author
Chris MacMackin
Date
March 2017

A wraper for the nitsol implementation of the transpose-free quasi-minimal residual method (TFQMR) for iteratively solving linear systems. This provides a more general interface not specifically intended for use with Newton iteration. It also uses Fortran 90 features to provide a more convenient call signature.

Arguments

Type IntentOptional AttributesName
real(kind=r8), intent(inout), dimension(:):: solution

On input, an initial guess of the solution to the linear system. On output, the iteratively determined solution.

procedure(mat_mult) :: lhs

The linear operator on the left hand side of the linear system.

real(kind=r8), intent(in), dimension(:):: rhs

The right hand side of the linear system being solved

real(kind=r8), intent(out) :: resid_norm

TFQMR residual norm on return

integer, intent(out) :: flag

Termination flag. Values have the following meanings:

Read more…
integer, intent(out), optional :: nlhs

Number of evaluations of the left hand side of the system

integer, intent(out), optional :: nrpre

Number of evaluations of the right-preconditioner

integer, intent(out), optional :: nli

Number of iterations

real(kind=r8), intent(in), optional :: tol

The tolerance for the solution. Default is size(solution) * 1e-8.

procedure(mat_mult), optional :: precond

A right-preconditioner which may be used to improve convergence of the solution.

real(kind=r8), intent(inout), optional dimension(*):: rpar

Parameter/work array passed to the lhs and precond routines.

integer, intent(inout), optional dimension(*):: ipar

Parameter/work array passed to the lhs and precond routines

integer, intent(in), optional :: resid_update

Residual update flag. On GMRES restarts, the residual can be updated using a linear combination (iresup == 0) or by direct evaluation (iresup == 1). The first is cheap (one n-vector saxpy) but may lose accuracy with extreme residual reduction; the second retains accuracy better but costs one product. Meaningless in this routine, but kept for consistent interface.

integer, intent(in), optional :: iter_max

Maximum allowable number of TFQMR iterations. Default is 1000.

integer, intent(in), optional :: krylov_dim

Maximum Krylov subspace dimension; default 10.

procedure(dinpr_intr), optional :: inner_prod

Inner-product routine, either user-supplied or BLAS ddot.

procedure(dnorm_intr), optional :: norm

Norm routine, either user supplied or BLAS dnrm2.

public subroutine bicgstab_solve(solution, lhs, rhs, resid_norm, flag, nlhs, nrpre, nli, tol, precond, rpar, ipar, resid_update, iter_max, krylov_dim, inner_prod, norm)

Author
Chris MacMackin
Date
March 2017

A wraper for the nitsol implementation of the biconjugate gradient stabilized method (BiCGSTAB) for iteratively solving linear systems. This provides a more general interface not specifically intended for use with Newton iteration. It also uses Fortran 90 features to provide a more convenient call signature.

Arguments

Type IntentOptional AttributesName
real(kind=r8), intent(inout), dimension(:):: solution

On input, an initial guess of the solution to the linear system. On output, the iteratively determined solution.

procedure(mat_mult) :: lhs

The linear operator on the left hand side of the linear system.

real(kind=r8), intent(in), dimension(:):: rhs

The right hand side of the linear system being solved

real(kind=r8), intent(out) :: resid_norm

BiCGSTAB residual norm on return

integer, intent(out) :: flag

Termination flag. Values have the following meanings:

Read more…
integer, intent(out), optional :: nlhs

Number of evaluations of the left hand side of the system

integer, intent(out), optional :: nrpre

Number of evaluations of the right-preconditioner

integer, intent(out), optional :: nli

Number of iterations

real(kind=r8), intent(in), optional :: tol

The tolerance for the solution. Default is size(solution) * 1e-8.

procedure(mat_mult), optional :: precond

A right-preconditioner which may be used to improve convergence of the solution.

real(kind=r8), intent(inout), optional dimension(*):: rpar

Parameter/work array passed to the lhs and precond routines.

integer, intent(inout), optional dimension(*):: ipar

Parameter/work array passed to the lhs and precond routines

integer, intent(in), optional :: resid_update

Residual update flag. On GMRES restarts, the residual can be updated using a linear combination (iresup == 0) or by direct evaluation (iresup == 1). The first is cheap (one n-vector saxpy) but may lose accuracy with extreme residual reduction; the second retains accuracy better but costs one product. Meaningless in this routine, but kept for consistent interface.

integer, intent(in), optional :: iter_max

Maximum allowable number of TFQMR iterations. Default is 1000.

integer, intent(in), optional :: krylov_dim

Maximum Krylov subspace dimension; default 10.

procedure(dinpr_intr), optional :: inner_prod

Inner-product routine, either user-supplied or BLAS ddot.

procedure(dnorm_intr), optional :: norm

Norm routine, either user supplied or BLAS dnrm2.