ROMS
Loading...
Searching...
No Matches
lubksb.F
Go to the documentation of this file.
1
#include "cppdefs.h"
2
SUBROUTINE
lubksb
(a, n, np, indx, b)
3
!
4
!git $Id$
5
!================================================== Hernan G. Arango ===
6
! Copyright (c) 2002-2025 The ROMS Group !
7
! Licensed under a MIT/X style license !
8
! See License_ROMS.md !
9
!=======================================================================
10
! !
11
! Solves the set of N linear equations A X = B. Here A is input, !
12
! not as the matrix A but rather as its LU decomposition, set by !
13
! routine LUDCMP. INDX is input as the permutation vector returned !
14
! by LUDCMP. B is input as the right-hand side vector B, and !
15
! returns with the solution vector X. A,N,NP,INDX are not modified !
16
! by this routine and can be left in place for successive calls !
17
! with different right-hand sides B. This routine takes into !
18
! account the possiblility that B will begin with many zero !
19
! elements, so is efficient for use in matrix inversion. !
20
! !
21
! Reference: Press, W.H, et al., 1989: Numerical Recipes, The Art !
22
! of Scientific Computing, pp 31-37. !
23
! !
24
!=======================================================================
25
!
26
USE
mod_kinds
27
!
28
! Imported variable declarations.
29
!
30
integer
,
intent(in)
:: n, np
31
32
integer
,
intent(in)
:: indx(n)
33
34
real
(r8),
intent(in)
:: a(np,np)
35
real
(r8),
intent(inout)
:: b(n)
36
!
37
! Local variable declarations.
38
!
39
integer
:: i, ii, j, ll
40
41
real
(r8) :: MySum
42
!
43
!-----------------------------------------------------------------------
44
! Solve set of linear equation by LU decomposition.
45
!-----------------------------------------------------------------------
46
!
47
ii=0
48
DO
i=1,n
49
ll=indx(i)
50
mysum=b(ll)
51
b(ll)=b(i)
52
IF
(ii.ne.0)
THEN
53
DO
j=ii,i-1
54
mysum=mysum-a(i,j)*b(j)
55
END DO
56
ELSE
IF
(mysum.ne.0.0_r8)
THEN
57
ii=i
58
END IF
59
b(i)=mysum
60
END DO
61
DO
i=n,1,-1
62
mysum=b(i)
63
IF
(i.lt.n)
THEN
64
DO
j=i+1,n
65
mysum=mysum-a(i,j)*b(j)
66
END DO
67
END IF
68
b(i)=mysum/a(i,i)
69
END DO
70
71
RETURN
72
END SUBROUTINE
lubksb
lubksb
subroutine lubksb(a, n, np, indx, b)
Definition
lubksb.F:3
mod_kinds
Definition
mod_kinds.F:2
ROMS
Utility
lubksb.F
Generated by
1.12.0