# regrid_solvers module reference¶

Solvers of linear systems.

More…

## Functions/Subroutines¶

 solve_linear_system() Solve the linear system AX = R by Gaussian elimination. linear_solver() Solve the linear system AX = R by Gaussian elimination. solve_tridiagonal_system() Solve the tridiagonal system AX = R. solve_diag_dominant_tridiag() Solve the tridiagonal system AX = R.

## Detailed Description¶

This module contains solvers of linear systems. These routines have now been updated for greater efficiency, especially in special cases.

## Function/Subroutine Documentation¶

subroutine regrid_solvers/solve_linear_system(A, R, X, N, answers_2018)

Solve the linear system AX = R by Gaussian elimination.

This routine uses Gauss’s algorithm to transform the system’s original matrix into an upper triangular matrix. Back substitution yields the answer. The matrix A must be square, with the first index varing down the column.

Parameters
• n :: [in] The size of the system

• a :: [inout] The matrix being inverted [nondim]

• r :: [inout] system right-hand side [A]

• x :: [inout] solution vector [A]

• answers_2018 :: [in] If true or absent use older, less efficient expressions.

Call to

mom_error_handler::mom_error

subroutine regrid_solvers/linear_solver(N, A, R, X)

Solve the linear system AX = R by Gaussian elimination.

This routine uses Gauss’s algorithm to transform the system’s original matrix into an upper triangular matrix. Back substitution then yields the answer. The matrix A must be square, with the first index varing along the row.

Parameters
• n :: [in] The size of the system

• a :: [inout] The matrix being inverted [nondim]

• r :: [inout] system right-hand side [A]

• x :: [inout] solution vector [A]

Call to

mom_error_handler::mom_error

subroutine regrid_solvers/solve_tridiagonal_system(Al, Ad, Au, R, X, N, answers_2018)

Solve the tridiagonal system AX = R.

This routine uses Thomas’s algorithm to solve the tridiagonal system AX = R. (A is made up of lower, middle and upper diagonals)

Parameters
• n :: [in] The size of the system

• ad :: [in] Matrix center diagonal

• al :: [in] Matrix lower diagonal

• au :: [in] Matrix upper diagonal

• r :: [in] system right-hand side

• x :: [out] solution vector

• answers_2018 :: [in] If true use older, less acccurate expressions.

Called from
subroutine regrid_solvers/solve_diag_dominant_tridiag(Al, Ac, Au, R, X, N)

Solve the tridiagonal system AX = R.

This routine uses a variant of Thomas’s algorithm to solve the tridiagonal system AX = R, in a form that is guaranteed to avoid dividing by a zero pivot. The matrix A is made up of lower (Al) and upper diagonals (Au) and a central diagonal Ad = Ac+Al+Au, where Al, Au, and Ac are all positive (or negative) definite. However when Ac is smaller than roundoff compared with (Al+Au), the answers are prone to inaccuracy.

Parameters
• n :: [in] The size of the system

• ac :: [in] Matrix center diagonal offset from Al + Au

• al :: [in] Matrix lower diagonal

• au :: [in] Matrix upper diagonal

• r :: [in] system right-hand side

• x :: [out] solution vector

Called from