19 integer(kind=kint) :: nrows
20 integer(kind=kint) :: ncols
21 integer(kind=kint) :: nttbr
22 integer(kind=kint) :: ndeg
23 integer(kind=kint),
pointer :: ia(:)
24 integer(kind=kint),
pointer :: ja(:)
25 real(kind=
kreal),
pointer :: val(:,:)
33 integer(kind=kint),
intent(in) :: ndeg
34 integer(kind=kint),
intent(in) :: nttbr
35 integer(kind=kint),
intent(in) :: irow(:)
36 integer(kind=kint),
intent(in) :: jcol(:)
37 integer(kind=kint),
intent(in) :: ncols
38 integer(kind=kint),
intent(in) :: nrows
40 type (crs_matrix),
intent(out) :: c
43 integer(kind=kint),
allocatable :: istat(:), jrapt(:), jcolno(:)
44 integer(kind=kint) :: ntt
46 integer(kind=kint) :: ipass, i,j,k,l,m,n
50 allocate(istat(nrows))
51 allocate(jrapt(nttbr))
52 allocate(jcolno(nttbr))
62 call reserv(i,j,istat,jrapt,jcolno,ntt)
73 call stiajac(c,istat,jrapt,jcolno)
75 deallocate(istat,jrapt,jcolno)
81 subroutine irjctocrs(ndeg, nttbr, irow, jcol, val, ncols, nrows, c)
85 integer(kind=kint),
intent(in) :: ndeg
86 integer(kind=kint),
intent(in) :: nttbr
87 integer(kind=kint),
intent(in) :: irow(:)
88 integer(kind=kint),
intent(in) :: jcol(:)
89 real(kind=
kreal),
intent(in) :: val(:,:)
90 integer(kind=kint),
intent(in) :: ncols
91 integer(kind=kint),
intent(in) :: nrows
93 type (crs_matrix),
intent(out) :: c
96 integer(kind=kint),
allocatable :: istat(:), jrapt(:), jcolno(:)
97 integer(kind=kint) :: ntt
99 integer(kind=kint) :: ipass, i,j,k,l,m,n
103 allocate(istat(nrows))
104 allocate(jrapt(nttbr))
105 allocate(jcolno(nttbr))
118 call reserv(i,j,istat,jrapt,jcolno,ntt)
121 call stval(c,i,j,val(:,l),0)
132 call crsallocation(c)
134 call stiajac(c,istat,jrapt,jcolno)
136 deallocate(istat,jrapt,jcolno)
144 subroutine reserv(i,j,istat,jrapt,jcolno,k)
147 integer(kind=kint) :: jrapt(:)
148 integer(kind=kint) :: jcolno(:)
149 integer(kind=kint) :: istat(:)
150 integer(kind=kint) :: i,j,k,l, locr, loc
154 if(loc.eq.0)
goto 120
155 if(jcolno(loc).eq.j)
then
157 elseif(jcolno(loc).gt.j)
then
184 end subroutine reserv
188 subroutine crsallocation(c)
190 type (crs_matrix) :: c
192 if (0 >= c%nrows)
then
193 call errtrp(
'set positive nrows')
194 else if (0 >= c%ndeg)
then
195 call errtrp(
'set positive ndeg')
196 else if (0 >= c%nttbr)
then
197 call errtrp(
'set positive nttbr')
200 allocate(c%ia(c%nrows+1))
201 allocate(c%ja(c%nttbr))
202 allocate(c%val(c%ndeg*c%ndeg,c%nttbr))
205 end subroutine crsallocation
209 subroutine stiajac(c,istat,jrapt,jcolno)
212 type (crs_matrix) :: c
213 integer(kind=kint) :: istat(:)
214 integer(kind=kint) :: jrapt(:)
215 integer(kind=kint) :: jcolno(:)
216 integer(kind=kint) :: i,j,k,l, ii, loc,
idbg
218 if (0 >= c%ncols)
then
219 call errtrp(
'set positive ncols')
220 else if (0 >= c%nrows)
then
221 call errtrp(
'set positive nrows')
222 else if (0 >= c%nttbr)
then
223 call errtrp(
'set positive nttbr')
224 else if (.not.
associated(c%ia))
then
225 call errtrp(
'ia is not allocated')
226 else if (.not.
associated(c%ja))
then
227 call errtrp(
'ja is not allocated')
228 else if (c%nrows+1 /=
size(c%ia))
then
229 call errtrp(
'ia size unmatched with nrows')
230 else if (c%nttbr /=
size(c%ja))
then
231 call errtrp(
'ja size unmatched with nttbr')
232 else if ((c%ndeg*c%ndeg /=
size(c%val, dim=1)) .or. (c%nttbr /=
size(c%val, dim=2)))
then
233 call errtrp(
'ja size unmatched with ndeg, nttbr')
242 if(loc.eq.0)
goto 120
252 write(20,60) (c%ia(i),i=1,c%nrows+1)
254 write(20,60) (c%ja(i),i=1,c%ja(c%nrows+1))
258 end subroutine stiajac
262 subroutine stval(c,i,j,val,itrans)
266 type (crs_matrix) :: c
267 real(kind=
kreal),
dimension(:) :: val
268 integer(kind=kint) :: ndeg,itrans
269 integer(kind=kint) :: i,j,k,m,n
273 do k=c%ia(i),c%ia(i+1)-1
274 if(j.eq.c%ja(k))
then
280 c%val(m + (n-1)*ndeg,k)=val((m-1)*ndeg + n)
287 write(6,*)
"something wrong"
296 type (crs_matrix),
intent(in) :: c
297 integer(kind=kint),
intent(in) :: k
298 real(kind=
kreal),
dimension(:),
intent(out) :: v
300 integer(kind=kint) :: ndeg, nndeg, i, idx, jcol, iofset
305 jcol = (k+ndeg-1) / ndeg
306 iofset = mod(k+ndeg-1, ndeg)
308 do i=c%ia(jcol),c%ia(jcol+1)-1
310 v(ndeg*(idx-1)+1:ndeg*(idx-1)+ndeg) &
311 & =c%val(ndeg*iofset + 1 : ndeg*iofset + ndeg ,i)
319 subroutine errtrp(mes)
321 write(*,*)
'Error in m_crs_matrix: ', mes
323 end subroutine errtrp