Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_choleski.F90
Go to the documentation of this file.
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 #include "sll_working_precision.h"
4 
5  implicit none
6 
7  public :: &
8  sll_s_choles, &
10 
11  private
12 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 
14 contains
15 
16 !
17 !factoriser 'cholesky' la matrice profil "ae" dans "as"
18 !
19 !in:
20 !
21 ! mudl,ae - pointeur,matrice(symetrique definie >0)
22 ! eps - test pour les pivots
23 !
24 !out:
25 !
26 ! as - matrice factorisee
27 ! ntest - = 0 si aucun pivot < eps
28 ! - = 1 sinon
29 !
30 ! programmeur :
31 ! f hecht - juin 84 inria
32 !
33  subroutine sll_s_choles(mudl, ae, as)
34 
35 !**********************************************************************
36 
37  sll_int32, dimension(:), intent(in) :: mudl
38  sll_real64, dimension(:), intent(in) :: ae
39  sll_real64, dimension(:), intent(inout) :: as
40 
41  sll_int32 :: kj, jid, jmi, ij, jj, id, imi, ii, ntest
42  sll_int32 :: i, j
43  sll_real64 :: s, xii
44 
45  sll_real64, parameter :: eps = 1.0e-10_f64
46 
47  ntest = 0
48  as(1) = sqrt(ae(1))
49  ii = mudl(1)
50 
51 !--- 1.0 --- Matrice symetrique ---------------------------------------
52 
53  do i = 2, size(mudl)
54 
55  xii = 0.0_f64
56  imi = ii + 1
57  ii = mudl(i)
58  id = i - ii
59  jj = mudl(imi + id - 1)
60 
61  do ij = imi, ii - 1
62  j = ij + id
63  jmi = jj + 1
64  jj = mudl(j)
65  jid = j - jj - id
66  s = 0.0_f64
67 
68  do kj = max(jmi, imi - jid), jj - 1
69  s = s + as(kj)*as(kj + jid)
70  end do
71 
72  as(ij) = (ae(ij) - s)/as(jj)
73  xii = xii + as(ij)*as(ij)
74  end do
75 
76  xii = ae(ii) - xii
77  if (xii < eps*abs(ae(ii))) then
78  write (6, 900) i, eps
79  write (6, 901) xii, eps, ae(ii)
80  ntest = 1
81  end if
82 
83  as(ii) = sqrt(xii)
84 
85  end do
86 
87  if (ntest == 1) then
88  write (6, 902)
89  stop "sll_m_choleski"
90  end if
91 
92 !--- 9.0 --- Formats ---------------------------------------------------
93 
94 900 format(/10x, 'resultats a verifier : le coefficient diagonal du dl' &
95  , i6, ' est inferieur au seuil de precision', e14.7)
96 901 format(/10x, 'xii:', e14.7, e14.7, e14.7)
97 902 format(/10x, '************ Erreur dans sll_s_choles *************'/)
98 
99  end subroutine sll_s_choles
100 
101 !Function: sll_s_desrem
102 !descente et/ou remontee d'un systeme lineaire ( cholesky )
103 !
104 ! in:
105 ! mudl,a,ntdl - pointeur,matrice et son ordre
106 ! be - le second membre
107 !
108 ! out:
109 ! bs - le resultat
110 !
111 ! programmeur:
112 !f hecht - juin 84 inria , f. hermeline aout 89 cel/v
113  subroutine sll_s_desrem(mudl, a, be, ntdl, bs)
114 
115  sll_int32, intent(in) :: mudl(0:*)
116  sll_real64, intent(in) :: a(*)
117  sll_real64, intent(in) :: be(*)
118  sll_int32, intent(in) :: ntdl
119  sll_real64, intent(inout) :: bs(*)
120 
121  sll_int32 :: ii, ij, kj, il, i, j
122  sll_real64 :: y
123 
124  ii = mudl(1)
125 
126 !**********************************************************************
127 ! matrice symetrique
128 !**********************************************************************
129 ! descentes
130 
131  do i = 1, ntdl
132  ij = ii + 1
133  ii = mudl(i)
134  kj = i - ii
135  y = 0.0_f64
136  do il = ij, ii - 1
137  y = y + a(il)*bs(il + kj)
138  end do
139  bs(i) = (be(i) - y)/a(ii)
140  end do
141 
142 ! remontees
143 
144  ij = mudl(ntdl) + 1
145 
146  do i = ntdl, 1, -1
147  ii = ij - 1
148  ij = mudl(i - 1) + 1
149  kj = ii - i
150  bs(i) = bs(i)/a(ii)
151  do j = ij - kj, i - 1
152  bs(j) = bs(j) - a(j + kj)*bs(i)
153  end do
154  end do
155 
156  end subroutine sll_s_desrem
157 
158 end module sll_m_choleski
subroutine, public sll_s_choles(mudl, ae, as)
subroutine, public sll_s_desrem(mudl, a, be, ntdl, bs)
    Report Typos and Errors