20 #include "sll_working_precision.h"
21 #include "sll_memory.h"
22 #include "sll_assert.h"
61 local_to_global_row, &
63 local_to_global_col, &
67 sll_int32,
intent(in) :: num_rows
68 sll_int32,
intent(in) :: num_cols
69 sll_int32,
intent(in) :: num_patch
70 sll_int32,
dimension(:),
intent(in) :: num_elements
71 sll_int32,
dimension(:, :, :),
intent(in) :: local_to_global_row
72 sll_int32,
dimension(:),
intent(in) :: num_local_dof_row
73 sll_int32,
dimension(:, :, :),
intent(in) :: local_to_global_col
74 sll_int32,
dimension(:),
intent(in) :: num_local_dof_col
76 sll_allocate(mat, ierr)
83 local_to_global_row, &
85 local_to_global_col, &
110 local_to_global_row, &
112 local_to_global_col, &
115 sll_int32,
intent(in) :: num_rows
116 sll_int32,
intent(in) :: num_cols
117 sll_int32,
intent(in) :: num_patch
118 sll_int32,
dimension(:),
intent(in) :: num_elements
119 sll_int32,
dimension(:, :, :),
intent(in) :: local_to_global_row
120 sll_int32,
dimension(:),
intent(in) :: num_local_dof_row
121 sll_int32,
dimension(:, :, :),
intent(in) :: local_to_global_col
122 sll_int32,
dimension(:),
intent(in) :: num_local_dof_col
125 sll_int32,
dimension(:, :),
pointer :: lpi_columns
126 sll_int32,
dimension(:),
pointer :: lpi_occ
129 sll_int32 :: max_nen_c
135 max_nen_c = maxval(num_local_dof_col(:))
137 sll_allocate(lpi_columns(num_rows, 0:li_coef*max_nen_c), ierr)
138 sll_allocate(lpi_occ(num_rows + 1), ierr)
139 lpi_columns(:, :) = 0
148 local_to_global_col, &
150 local_to_global_row, &
155 mat%num_rows = num_rows
156 mat%num_cols = num_cols
159 sll_allocate(mat%row_ptr(num_rows + 1), ierr)
160 sll_allocate(mat%col_ind(num_nz), ierr)
161 sll_allocate(mat%val(num_nz), ierr)
163 print *,
'#num_rows=', num_rows
164 print *,
'#num_nz=', num_nz
172 local_to_global_col, &
174 local_to_global_row, &
180 sll_deallocate_array(lpi_columns, ierr)
181 sll_deallocate_array(lpi_occ, ierr)
201 sll_int32 :: ai_npatch
202 sll_int32,
dimension(:) :: api_nel
203 sll_int32,
dimension(:, :, :),
intent(in) :: lm_columns, lm_rows
204 sll_int32,
dimension(:),
intent(in) :: nen_c, nen_r
205 sll_int32,
dimension(:, :),
pointer :: api_columns
206 sll_int32,
dimension(:),
pointer :: api_occ
211 sll_int32 :: li_nen_c
212 sll_int32 :: li_nen_r
218 sll_int32 :: li_result
221 sll_int32,
dimension(2) :: lpi_size
222 sll_int32,
dimension(:, :),
pointer :: lpi_columns
224 do li_id = 1, ai_npatch
226 li_nel = api_nel(li_id)
231 li_nen_c = nen_c(li_id)
232 do li_b_c = 1, li_nen_c
234 li_a_c = lm_columns(li_id, li_b_c, li_e)
235 if (li_a_c == 0)
then
239 li_nen_r = nen_r(li_id)
240 do li_b_r = 1, li_nen_r
242 li_a_r = lm_rows(li_id, li_b_r, li_e)
243 if (li_a_r == 0)
then
249 do li_i = 1, api_columns(li_a_c, 0)
251 if (api_columns(li_a_c, li_i) /= li_a_r)
then
260 if (.not. ll_done)
then
262 api_occ(li_a_c) = api_occ(li_a_c) + 1
266 api_columns(li_a_c, 0) = api_columns(li_a_c, 0) + 1
267 api_columns(li_a_c, api_columns(li_a_c, 0)) = li_a_r
270 lpi_size(1) =
SIZE(api_columns, 1)
271 lpi_size(2) =
SIZE(api_columns, 2)
272 if (lpi_size(2) < api_columns(li_a_c, 0))
then
273 sll_allocate(lpi_columns(lpi_size(1), lpi_size(2)), ierr)
274 lpi_columns = api_columns
276 sll_deallocate(api_columns, ierr)
278 sll_allocate(api_columns(lpi_size(1), 2*lpi_size(2)), ierr)
279 api_columns(1:lpi_size(1), 1:lpi_size(2)) = lpi_columns(1:lpi_size(1), 1:lpi_size(2))
281 sll_deallocate(lpi_columns, ierr)
295 li_result = sum(api_occ(1:ai_nr))
300 sll_assert(ai_nc > 0)
321 sll_int32 :: ai_npatch
322 sll_int32,
dimension(:) :: api_nel
323 sll_int32,
dimension(:),
intent(in) :: nen_c, nen_r
324 sll_int32,
dimension(:, :, :),
intent(in) :: lm_columns, lm_rows
325 sll_int32,
dimension(:, :),
pointer :: api_columns
326 sll_int32,
dimension(:),
pointer :: api_occ
338 sll_int32 :: li_nen_c
341 sll_int32,
dimension(:),
pointer :: lpr_tmp
346 do li_i = 1, self%num_rows
348 self%row_ptr(li_i + 1) = self%row_ptr(1) + sum(api_occ(1:li_i))
353 DO li_id = 1, ai_npatch
355 li_nel = api_nel(li_id)
360 li_nen_c = nen_c(li_id)
361 do li_b_c = 1, li_nen_c
363 li_a_c = lm_columns(li_id, li_b_c, li_e)
366 if (li_a_c == 0)
then
370 if (api_columns(li_a_c, 0) == 0)
then
374 li_size = api_columns(li_a_c, 0)
376 allocate (lpr_tmp(li_size), stat=li_err)
377 if (li_err .ne. 0) li_flag = 10
379 lpr_tmp(1:li_size) = api_columns(li_a_c, 1:li_size)
385 self%col_ind(self%row_ptr(li_a_c) + li_i - 1) = lpr_tmp(li_i)
389 api_columns(li_a_c, 0) = 0
399 sll_assert(ai_nc > 0)
400 sll_assert(ai_nr > 0)
401 print *,
size(lm_rows, 1)
recursive subroutine, public sll_s_qsortc(A)
integer function sll_count_non_zero_elts_mp(ai_nR, ai_nC, ai_npatch, api_nel, LM_Columns, nen_C, LM_Rows, nen_R, api_columns, api_occ)
type(sll_t_csr_matrix) function, pointer, public sll_f_new_csr_matrix_mp(num_rows, num_cols, num_patch, num_elements, local_to_global_row, num_local_dof_row, local_to_global_col, num_local_dof_col)
allocates the memory space for a new CSR type on the heap,
subroutine sll_init_sparsematrix_mp(self, ai_nR, ai_nC, ai_npatch, api_nel, LM_Columns, nen_C, LM_Rows, nen_R, api_columns, api_occ)
subroutine, public sll_s_csr_matrix_mp_init(mat, num_rows, num_cols, num_patch, num_elements, local_to_global_row, num_local_dof_row, local_to_global_col, num_local_dof_col)
initialization of CSR matrix type
Sparse matrix linear solver utilities.