66 class(PetscMatrixType) :: this
67 type(sparsematrix) :: sparse
68 character(len=*) :: mem_path
69
70 petscerrorcode :: ierr
71 integer(I4B) :: i, ierror
72 mat :: local_mat
73 integer(I4B), dimension(:), pointer :: ia_tmp, ja_tmp
74 integer(I4B) :: nrows_local
75 logical(LGP) :: done
76
77 this%memory_path = mem_path
78 this%nrow = sparse%nrow
79 this%ncol = sparse%ncol
80 this%nnz = sparse%nnz
81 this%nnz_local = sparse%nnz - sparse%nnz_od
82 this%offset = sparse%offset
83
84
85 call mem_allocate(this%ia_local, this%nrow + 1, 'IA_LOCAL', this%memory_path)
86 call mem_allocate(this%ja_local, this%nnz_local, 'JA_LOCAL', this%memory_path)
87 call mem_allocate(this%amat_local, this%nnz_local, 'AMAT_LOCAL', &
88 this%memory_path)
89 call mem_allocate(this%ia_petsc, this%nrow + 1, 'IA_PETSC', this%memory_path)
90 call mem_allocate(this%ja_petsc, this%nnz, 'JA_PETSC', this%memory_path)
91 call mem_allocate(this%amat_petsc, this%nnz, 'AMAT_PETSC', this%memory_path)
92
93 call sparse%sort(with_csr=.true.)
94 call sparse%filliaja(this%ia_petsc, this%ja_petsc, ierror)
95
96
97 do i = 1, this%nrow + 1
98 this%ia_petsc(i) = this%ia_petsc(i) - 1
99 end do
100 do i = 1, this%nnz
101 this%ja_petsc(i) = this%ja_petsc(i) - 1
102 this%amat_petsc(i) = dzero
103 end do
104
105
107 this%is_parallel = .true.
108 call matcreatempiaijwitharrays(petsc_comm_world, &
109 sparse%nrow, sparse%nrow, &
110 sparse%ncol, sparse%ncol, &
111 this%ia_petsc, this%ja_petsc, &
112 this%amat_petsc, this%mat, &
113 ierr)
114 else
115 this%is_parallel = .false.
116 call matcreateseqaijwitharrays(petsc_comm_world, &
117 sparse%nrow, sparse%ncol, &
118 this%ia_petsc, this%ja_petsc, &
119 this%amat_petsc, this%mat, &
120 ierr)
121 end if
122 chkerrq(ierr)
123
124
125 nrows_local = 0
126 call matgetdiagonalblock(this%mat, local_mat, ierr)
127 chkerrq(ierr)
128
129 call matgetrowijf90(local_mat, 1, petsc_false, petsc_false, &
130 nrows_local, ia_tmp, ja_tmp, &
131 done, ierr)
132 chkerrq(ierr)
133
134 do i = 1, size(ia_tmp)
135 this%ia_local(i) = ia_tmp(i)
136 end do
137 do i = 1, size(ja_tmp) - 1
138 this%ja_local(i) = ja_tmp(i)
139 end do
140
141 call matrestorerowijf90(local_mat, 1, petsc_false, petsc_false, &
142 nrows_local, ia_tmp, ja_tmp, done, ierr)
143 chkerrq(ierr)
144
This module contains simulation variables.
character(len=linelength) simulation_mode