Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_pastix.F90
Go to the documentation of this file.
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 #define MPI_MASTER 0
4 #include "pastix_fortran.h"
5 #include "sll_working_precision.h"
6 #include "sll_memory.h"
7 
8  use sll_m_collective, only: &
13 
14  implicit none
15 
16  public :: &
17  pastix_solver, &
18  initialize, &
19  factorize, &
20  solve, &
21  delete
22 
23  private
24 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25  type :: pastix_solver
26  pastix_data_ptr_t :: pastix_data
27  pastix_int_t :: ncols
28  pastix_int_t, pointer :: colptr(:)
29  pastix_int_t, pointer :: row(:)
30  pastix_float_t, pointer :: avals(:)
31  pastix_int_t, pointer :: perm(:)
32  pastix_int_t, pointer :: invp(:)
33  pastix_float_t, pointer :: rhs(:)
34  pastix_int_t :: nrhs
35  pastix_int_t :: iparm(iparm_size) ! sll_int32 parameters
36  double precision :: dparm(dparm_size) ! Floating poin parameters
37  sll_int32 :: nbthread
38  sll_int32 :: verbose
39  end type pastix_solver
40 
41  interface initialize
42  module procedure init_pastix
43  end interface initialize
44 
45  interface solve
46  module procedure solve_pastix_with_rhs
47  module procedure solve_pastix_without_rhs
48  end interface solve
49 
50  interface factorize
51  module procedure factorize_pastix
52  end interface factorize
53 
54  interface delete
55  module procedure free_pastix
56  end interface delete
57 
58 contains
59 
60  subroutine init_pastix(self, n, nnzeros, row_ptr, col_ind, val)
61 
62  type(pastix_solver) :: self
63  sll_int32, intent(in) :: n
64  pastix_int_t, intent(in) :: nnzeros
65  sll_int32, intent(in), target :: row_ptr(:)
66  sll_int32, intent(in), target :: col_ind(:)
67  sll_real64, intent(in), target :: val(:)
68  sll_int32 :: error
69  sll_int32 :: comm
70  sll_int32 :: prank
71  sll_int32 :: psize
72 
73  if (.not. associated(sll_v_world_collective)) then
75  end if
76  self%ncols = n
79  comm = sll_v_world_collective%comm
80 
81  ! Get options ftom command line
82  self%nbthread = 1
83  self%verbose = api_verbose_no
84 
85  ! Allocating
86  self%colptr => row_ptr
87  self%row => col_ind
88  self%avals => val
89  sll_clear_allocate(self%rhs(nnzeros), error)
90 
91  ! First PaStiX call to initiate parameters
92 
93  self%pastix_data = 0
94  self%nrhs = 1
95  self%iparm(iparm_modify_parameter) = api_no
96  self%iparm(iparm_start_task) = api_task_init
97  self%iparm(iparm_end_task) = api_task_init
98 
99  sll_allocate(self%perm(n), error)
100  sll_allocate(self%invp(n), error)
101 
102  call pastix_fortran(self%pastix_data, comm, n, self%colptr, self%row, &
103  self%avals, self%perm, self%invp, self%rhs, &
104  self%nrhs, self%iparm, self%dparm)
105 
106  ! Customize some parameters
107 
108  self%iparm(iparm_thread_nbr) = self%nbthread
109  self%iparm(iparm_verbose) = self%verbose
110 
111  self%iparm(iparm_sym) = api_sym_no !API_SYM_YES !API_SYM_NO
112  self%iparm(iparm_factorization) = api_fact_lu !API_FACT_LDLT
113 
114  self%iparm(iparm_matrix_verification) = api_yes
115 
116  !The matrix is in CSR format, we transpose to get CSC
117  self%iparm(iparm_transpose_solve) = api_yes
118 
119  end subroutine init_pastix
120 
121  subroutine factorize_pastix(self)
122 
123  type(pastix_solver) :: self
124  sll_int32 :: comm
125 
126  comm = sll_v_world_collective%comm
127  ! Call PaStiX first steps (Scotch - Fax - Blend)
128  self%iparm(iparm_start_task) = api_task_ordering
129  self%iparm(iparm_end_task) = api_task_analyse
130 
131  call pastix_fortran(self%pastix_data, &
132  comm, &
133  self%ncols, &
134  self%colptr, &
135  self%row, &
136  self%avals, &
137  self%perm, &
138  self%invp, &
139  self%rhs, &
140  self%nrhs, &
141  self%iparm, &
142  self%dparm)
143 
144  ! Call PaStiX factorization
145  self%iparm(iparm_start_task) = api_task_numfact
146  self%iparm(iparm_end_task) = api_task_numfact
147 
148  call pastix_fortran(self%pastix_data, &
149  comm, &
150  self%ncols, &
151  self%colptr, &
152  self%row, &
153  self%avals, &
154  self%perm, &
155  self%invp, &
156  self%rhs, &
157  self%nrhs, &
158  self%iparm, &
159  self%dparm)
160 
161  end subroutine factorize_pastix
162 
163  subroutine solve_pastix_without_rhs(self, sol)
164 
165  type(pastix_solver) :: self
166  sll_real64, dimension(:), target :: sol
167  sll_int32 :: comm
168 
169  comm = sll_v_world_collective%comm
170 
171  self%rhs => sol
172 
173  ! Call PaStiX updown and refinement
174  self%iparm(iparm_start_task) = api_task_solve
175  self%iparm(iparm_end_task) = api_task_refine
176  ! rhs will be changed to solution
177  call pastix_fortran(self%pastix_data, comm, &
178  self%ncols, self%colptr, self%row, &
179  self%avals, self%perm, self%invp, &
180  self%rhs, self%nrhs, self%iparm, self%dparm)
181 
182  sol = self%rhs
183 
184  end subroutine solve_pastix_without_rhs
185 
186  subroutine solve_pastix_with_rhs(self, rhs, sol)
187 
188  type(pastix_solver) :: self
189  sll_real64, dimension(:) :: rhs
190  sll_real64, dimension(:) :: sol
191  sll_int32 :: comm
192 
193  comm = sll_v_world_collective%comm
194 
195  self%rhs = rhs
196 
197  ! Call PaStiX updown and refinement
198  self%iparm(iparm_start_task) = api_task_solve
199  self%iparm(iparm_end_task) = api_task_refine
200  ! rhs will be changed to solution
201  call pastix_fortran(self%pastix_data, comm, &
202  self%ncols, self%colptr, self%row, &
203  self%avals, self%perm, self%invp, &
204  self%rhs, self%nrhs, self%iparm, self%dparm)
205 
206  sol = self%rhs
207 
208  end subroutine solve_pastix_with_rhs
209 
210  subroutine free_pastix(self)
211 
212  type(pastix_solver) :: self
213  sll_int32 :: comm
214 
215  comm = sll_v_world_collective%comm
216 
217  ! Call PaStiX clean
218  self%iparm(iparm_start_task) = api_task_clean
219  self%iparm(iparm_end_task) = api_task_clean
220 
221  call pastix_fortran(self%pastix_data, comm, &
222  self%ncols, self%colptr, self%row, &
223  self%avals, self%perm, self%invp, &
224  self%rhs, self%nrhs, self%iparm, self%dparm)
225 
226  deallocate (self%colptr)
227  deallocate (self%row)
228  deallocate (self%avals)
229  deallocate (self%perm)
230  deallocate (self%invp)
231  deallocate (self%rhs)
232 
233  end subroutine free_pastix
234 
235 end module sll_m_pastix
Parallelizing facility.
integer(kind=i32) function, public sll_f_get_collective_rank(col)
Determines the rank of the calling process in the communicator.
subroutine, public sll_s_boot_collective(required)
Starts the paralell environment.
type(sll_t_collective_t), pointer, public sll_v_world_collective
Control of subset assignment. Processes with the same color are in the same new communicator.
integer(kind=i32) function, public sll_f_get_collective_size(col)
Determines the size of the group associated with a communicator.
subroutine init_pastix(self, n, nnzeros, row_ptr, col_ind, val)
subroutine solve_pastix_without_rhs(self, sol)
subroutine factorize_pastix(self)
subroutine solve_pastix_with_rhs(self, rhs, sol)
subroutine free_pastix(self)
subroutine sol(vkgs, vkgd, vkgi, vfg, kld, vu, neq, mp, ifac, isol, nsym, energ, ier, nsky)
Definition: sol.f:3
    Report Typos and Errors