Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_mumps.F90
Go to the documentation of this file.
1 module sll_m_mumps
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 #define MPI_MASTER 0
4 #include "sll_working_precision.h"
5 #include "sll_memory.h"
6 
7  use sll_m_collective, only: &
12 
13  implicit none
14 
15  public :: &
16  mumps_solver, &
17  initialize, &
18  factorize, &
19  solve, &
20  delete
21 
22  private
23 
24  include 'dmumps_struc.h'
25 
26 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27  type :: mumps_solver
28  type(dmumps_struc) :: mumps_par
29  end type mumps_solver
30 
31  interface initialize
32  module procedure init_mumps
33  end interface initialize
34 
35  interface solve
36  module procedure solve_mumps_without_rhs
37  end interface solve
38 
39  interface factorize
40  module procedure factorize_mumps
41  end interface factorize
42 
43  interface delete
44  module procedure free_mumps
45  end interface delete
46 
47 contains
48 
49  subroutine init_mumps(self, n, nnzeros, row_ptr, col_ind, val)
50 
51  type(mumps_solver) :: self
52  sll_int32, intent(in) :: n
53  sll_int32, intent(in) :: nnzeros
54  sll_int32, intent(in), target :: row_ptr(:)
55  sll_int32, intent(in), target :: col_ind(:)
56  sll_real64, intent(in), target :: val(:)
57  sll_int32 :: error
58  sll_int32 :: prank
59  sll_int32 :: psize
60 
61  if (.not. associated(sll_v_world_collective)) then
63  end if
66  ! Define a communicator for the package.
67  self%mumps_par%comm = sll_v_world_collective%comm
68 
69  ! Initialize an instance of the package
70  ! for L U factorization (sym = 0, with working host)
71  self%mumps_par%JOB = -1
72  self%mumps_par%SYM = 0
73  self%mumps_par%PAR = 1
74  call dmumps(self%mumps_par)
75 
76  if (self%mumps_par%infog(1) .LT. 0) then
77  write (6, '(A,A,I6,A,I9)') " ERROR RETURN: ", &
78  " mumps_par%infog(1)= ", self%mumps_par%infog(1), &
79  " mumps_par%infog(2)= ", self%mumps_par%infog(2)
80  stop
81  end if
82 
83  self%mumps_par%N = n
84  self%mumps_par%NZ = nnzeros
85  sll_allocate(self%mumps_par%IRN(self%mumps_par%NZ), error)
86  sll_allocate(self%mumps_par%JCN(self%mumps_par%NZ), error)
87  sll_allocate(self%mumps_par%A(self%mumps_par%NZ), error)
88  sll_allocate(self%mumps_par%rhs(self%mumps_par%N), error)
89 
90  self%mumps_par%rhs = 0.0_f64
91 
92  end subroutine init_mumps
93 
94  subroutine factorize_mumps(self)
95 
96  type(mumps_solver) :: self
97 
98  self%mumps_par%JOB = 4
99  call dmumps(self%mumps_par)
100  if (self%mumps_par%infog(1) < 0) then
101  write (6, '(A,A,I6,A,I9)') " ERROR RETURN: ", &
102  " mumps_par%infog(1)= ", self%mumps_par%infog(1), &
103  " mumps_par%infog(2)= ", self%mumps_par%infog(2)
104  end if
105 
106  end subroutine factorize_mumps
107 
108  subroutine solve_mumps_without_rhs(self, sol)
109 
110  type(mumps_solver) :: self
111  sll_real64, dimension(:) :: sol
112 
113  self%mumps_par%rhs = sol
114  ! Call package for solution
115  self%mumps_par%JOB = 3
116  call dmumps(self%mumps_par)
117  if (self%mumps_par%infog(1) < 0) then
118  write (6, '(A,A,I6,A,I9)') " ERROR RETURN: ", &
119  " mumps_par%infog(1)= ", self%mumps_par%infog(1), &
120  " mumps_par%infog(2)= ", self%mumps_par%infog(2)
121  else
122  sol = self%mumps_par%rhs
123  end if
124 
125  end subroutine solve_mumps_without_rhs
126 
127  subroutine free_mumps(self)
128 
129  type(mumps_solver) :: self
130 
131  ! Deallocate user data
132  if (self%mumps_par%MYID == 0) then
133  deallocate (self%mumps_par%IRN)
134  deallocate (self%mumps_par%JCN)
135  deallocate (self%mumps_par%A)
136  deallocate (self%mumps_par%rhs)
137  end if
138  ! Destroy the instance (deallocate internal data structures)
139  self%mumps_par%JOB = -2
140  call dmumps(self%mumps_par)
141  IF (self%mumps_par%infog(1) .LT. 0) THEN
142  write (6, '(A,A,I6,A,I9)') " ERROR RETURN: ", &
143  " mumps_par%infog(1)= ", self%mumps_par%infog(1), &
144  " mumps_par%infog(2)= ", self%mumps_par%infog(2)
145  end if
146 
147  end subroutine free_mumps
148 
149 end module sll_m_mumps
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 free_mumps(self)
subroutine solve_mumps_without_rhs(self, sol)
subroutine init_mumps(self, n, nnzeros, row_ptr, col_ind, val)
Definition: sll_m_mumps.F90:50
subroutine factorize_mumps(self)
Definition: sll_m_mumps.F90:95
subroutine sol(vkgs, vkgd, vkgi, vfg, kld, vu, neq, mp, ifac, isol, nsym, energ, ier, nsky)
Definition: sol.f:3
    Report Typos and Errors