18 integer(kind=kint) :: nrows
19 integer(kind=kint) :: ncols
20 integer(kind=kint) :: nttbr
21 integer(kind=kint) :: ndeg
22 integer(kind=kint),
pointer :: ia(:)
23 integer(kind=kint),
pointer :: ja(:)
24 real(kind=
kreal),
pointer :: val(:,:)
32 integer(kind=kint),
intent(in) :: ndeg
33 integer(kind=kint),
intent(in) :: nttbr
34 integer(kind=kint),
intent(in) :: irow(:)
35 integer(kind=kint),
intent(in) :: jcol(:)
36 integer(kind=kint),
intent(in) :: ncols
37 integer(kind=kint),
intent(in) :: nrows
39 type (crs_matrix),
intent(out) :: c
42 integer(kind=kint),
allocatable :: istat(:), jrapt(:), jcolno(:)
43 integer(kind=kint) :: ntt
45 integer(kind=kint) :: ipass, i,j,k,l,m,n
49 allocate(istat(nrows))
50 allocate(jrapt(nttbr))
51 allocate(jcolno(nttbr))
61 call reserv(i,j,istat,jrapt,jcolno,ntt)
72 call stiajac(c,istat,jrapt,jcolno)
74 deallocate(istat,jrapt,jcolno)
80 subroutine irjctocrs(ndeg, nttbr, irow, jcol, val, ncols, nrows, c)
84 integer(kind=kint),
intent(in) :: ndeg
85 integer(kind=kint),
intent(in) :: nttbr
86 integer(kind=kint),
intent(in) :: irow(:)
87 integer(kind=kint),
intent(in) :: jcol(:)
88 real(kind=
kreal),
intent(in) :: val(:,:)
89 integer(kind=kint),
intent(in) :: ncols
90 integer(kind=kint),
intent(in) :: nrows
92 type (crs_matrix),
intent(out) :: c
95 integer(kind=kint),
allocatable :: istat(:), jrapt(:), jcolno(:)
96 integer(kind=kint) :: ntt
98 integer(kind=kint) :: ipass, i,j,k,l,m,n
102 allocate(istat(nrows))
103 allocate(jrapt(nttbr))
104 allocate(jcolno(nttbr))
117 call reserv(i,j,istat,jrapt,jcolno,ntt)
120 call stval(c,i,j,val(:,l),0)
131 call crsallocation(c)
133 call stiajac(c,istat,jrapt,jcolno)
135 deallocate(istat,jrapt,jcolno)
143 subroutine reserv(i,j,istat,jrapt,jcolno,k)
146 integer(kind=kint) :: jrapt(:)
147 integer(kind=kint) :: jcolno(:)
148 integer(kind=kint) :: istat(:)
149 integer(kind=kint) :: i,j,k,l, locr, loc
153 if(loc.eq.0)
goto 120
154 if(jcolno(loc).eq.j)
then
156 elseif(jcolno(loc).gt.j)
then
183 end subroutine reserv
187 subroutine crsallocation(c)
189 type (crs_matrix) :: c
191 if (0 >= c%nrows)
then
192 call errtrp(
'set positive nrows')
193 else if (0 >= c%ndeg)
then
194 call errtrp(
'set positive ndeg')
195 else if (0 >= c%nttbr)
then
196 call errtrp(
'set positive nttbr')
199 allocate(c%ia(c%nrows+1))
200 allocate(c%ja(c%nttbr))
201 allocate(c%val(c%ndeg*c%ndeg,c%nttbr))
204 end subroutine crsallocation
208 subroutine stiajac(c,istat,jrapt,jcolno)
211 type (crs_matrix) :: c
212 integer(kind=kint) :: istat(:)
213 integer(kind=kint) :: jrapt(:)
214 integer(kind=kint) :: jcolno(:)
215 integer(kind=kint) :: i,j,k,l, ii, loc,
idbg
217 if (0 >= c%ncols)
then
218 call errtrp(
'set positive ncols')
219 else if (0 >= c%nrows)
then
220 call errtrp(
'set positive nrows')
221 else if (0 >= c%nttbr)
then
222 call errtrp(
'set positive nttbr')
223 else if (.not.
associated(c%ia))
then
224 call errtrp(
'ia is not allocated')
225 else if (.not.
associated(c%ja))
then
226 call errtrp(
'ja is not allocated')
227 else if (c%nrows+1 /=
size(c%ia))
then
228 call errtrp(
'ia size unmatched with nrows')
229 else if (c%nttbr /=
size(c%ja))
then
230 call errtrp(
'ja size unmatched with nttbr')
231 else if ((c%ndeg*c%ndeg /=
size(c%val, dim=1)) .or. (c%nttbr /=
size(c%val, dim=2)))
then
232 call errtrp(
'ja size unmatched with ndeg, nttbr')
241 if(loc.eq.0)
goto 120
251 write(20,60) (c%ia(i),i=1,c%nrows+1)
253 write(20,60) (c%ja(i),i=1,c%ja(c%nrows+1))
257 end subroutine stiajac
261 subroutine stval(c,i,j,val,itrans)
265 type (crs_matrix) :: c
266 real(kind=
kreal),
dimension(:) :: val
267 integer(kind=kint) :: ndeg,itrans
268 integer(kind=kint) :: i,j,k,m,n
272 do k=c%ia(i),c%ia(i+1)-1
273 if(j.eq.c%ja(k))
then
279 c%val(m + (n-1)*ndeg,k)=val((m-1)*ndeg + n)
286 write(6,*)
"something wrong"
295 type (crs_matrix),
intent(in) :: c
296 integer(kind=kint),
intent(in) :: k
297 real(kind=
kreal),
dimension(:),
intent(out) :: v
299 integer(kind=kint) :: ndeg, nndeg, i, idx, jcol, iofset
304 jcol = (k+ndeg-1) / ndeg
305 iofset = mod(k+ndeg-1, ndeg)
307 do i=c%ia(jcol),c%ia(jcol+1)-1
309 v(ndeg*(idx-1)+1:ndeg*(idx-1)+ndeg) &
310 & =c%val(ndeg*iofset + 1 : ndeg*iofset + ndeg ,i)
318 subroutine errtrp(mes)
320 write(*,*)
'Error in m_crs_matrix: ', mes
322 end subroutine errtrp