25 integer(kind=kint) :: N
26 real(kind=
kreal),
pointer :: d(:) => null()
27 real(kind=
kreal),
pointer :: al(:) => null()
28 real(kind=
kreal),
pointer :: au(:) => null()
29 integer(kind=kint),
pointer :: indexL(:) => null()
30 integer(kind=kint),
pointer :: indexU(:) => null()
31 integer(kind=kint),
pointer :: itemL(:) => null()
32 integer(kind=kint),
pointer :: itemU(:) => null()
33 real(kind=
kreal),
pointer :: alu(:) => null()
35 integer(kind=kint) :: NColor
36 integer(kind=kint),
pointer :: COLORindex(:) => null()
37 integer(kind=kint),
pointer :: perm(:) => null()
38 integer(kind=kint),
pointer :: iperm(:) => null()
40 logical,
save :: isFirst = .true.
42 logical,
save :: INITIALIZED = .false.
49 integer(kind=kint ) :: npl, npu, npcl, npcu
50 real (kind=
kreal),
allocatable :: cd(:)
51 integer(kind=kint ) :: ncolor_in
52 real (kind=
kreal) :: sigma_diag
53 real (kind=
kreal) :: alutmp(hecmat%NDOF,hecmat%NDOF), pw(hecmat%NDOF)
54 integer(kind=kint ) :: ii, i, j, k, ndof, ndof2
55 integer(kind=kint ) :: nthreads = 1
56 integer(kind=kint ),
allocatable :: perm_tmp(:)
63 if (hecmat%Iarray(98) == 1)
then
65 else if (hecmat%Iarray(97) == 1)
then
81 if (nthreads == 1)
then
83 allocate(colorindex(0:1), perm(n), iperm(n))
91 allocate(colorindex(0:n), perm_tmp(n), perm(n), iperm(n))
93 hecmat%indexU, hecmat%itemU, perm_tmp, iperm)
96 hecmat%indexU, hecmat%itemU, perm_tmp, &
97 ncolor_in, ncolor, colorindex, perm, iperm)
104 npl = hecmat%indexL(n)
105 npu = hecmat%indexU(n)
106 allocate(indexl(0:n), indexu(0:n), iteml(npl), itemu(npu))
108 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
109 indexl, indexu, iteml, itemu)
114 allocate(d(ndof2*n), al(ndof2*npl), au(ndof2*npu))
116 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
117 hecmat%AL, hecmat%AU, hecmat%D, &
118 indexl, indexu, iteml, itemu, al, au, d)
124 allocate(alu(ndof2*n))
136 alutmp(i,j) = alu(ndof2*(ii-1)+(i-1)*ndof+j)
137 if (i==j) alutmp(i,j)=alutmp(i,j)*sigma_diag
141 alutmp(k,k)= 1.d0/alutmp(k,k)
143 alutmp(i,k)= alutmp(i,k) * alutmp(k,k)
145 pw(j)= alutmp(i,j) - alutmp(i,k)*alutmp(k,j)
154 alu(ndof2*(ii-1)+(i-1)*ndof+j)= alutmp(i,j)
164 hecmat%Iarray(98) = 0
165 hecmat%Iarray(97) = 0
174 real(kind=
kreal),
intent(inout) :: zp(:)
175 integer(kind=kint) :: ic, i, iold, j, isl, iel, isu, ieu, k, ndof, ndof2, idof,jdof
176 real(kind=
kreal) :: sw(ndof), x(ndof)
179 integer(kind=kint),
parameter :: numofblockperthread = 100
180 integer(kind=kint),
save :: numofthread = 1, numofblock
181 integer(kind=kint),
save,
allocatable :: ictoblockindex(:)
182 integer(kind=kint),
save,
allocatable :: blockindextocolorindex(:)
183 integer(kind=kint),
save :: sectorcachesize0, sectorcachesize1
184 integer(kind=kint) :: blockindex, elementcount, numofelement, ii
185 real(kind=
kreal) :: numofelementperblock
186 integer(kind=kint) :: my_rank
191 numofblock = numofthread * numofblockperthread
192 if (
allocated(ictoblockindex))
deallocate(ictoblockindex)
193 if (
allocated(blockindextocolorindex))
deallocate(blockindextocolorindex)
194 allocate (ictoblockindex(0:ncolor), &
195 blockindextocolorindex(0:numofblock + ncolor))
196 numofelement = n + indexl(n) + indexu(n)
197 numofelementperblock = dble(numofelement) / numofblock
200 ictoblockindex(0) = 0
201 blockindextocolorindex = -1
202 blockindextocolorindex(0) = 0
211 do i = colorindex(ic-1)+1, colorindex(ic)
212 elementcount = elementcount + 1
213 elementcount = elementcount + (indexl(i) - indexl(i-1))
214 elementcount = elementcount + (indexu(i) - indexu(i-1))
215 if (elementcount > ii * numofelementperblock &
216 .or. i == colorindex(ic))
then
218 blockindex = blockindex + 1
219 blockindextocolorindex(blockindex) = i
224 ictoblockindex(ic) = blockindex
226 numofblock = blockindex
229 sectorcachesize0, sectorcachesize1 )
248 do blockindex = ictoblockindex(ic-1)+1, ictoblockindex(ic)
249 do i = blockindextocolorindex(blockindex-1)+1, &
250 blockindextocolorindex(blockindex)
253 sw(idof) = zp(ndof*(iold-1)+idof)
260 x(idof) = zp(ndof*(k-1)+idof)
264 sw(idof) = sw(idof) - al(ndof2*(j-1)+ndof*(idof-1)+jdof)*x(jdof)
272 x(idof) = x(idof) - alu(ndof2*(i-1)+ndof*(idof-1)+jdof )*x(jdof)
275 do idof = ndof, 1, -1
276 do jdof = ndof, idof+1, -1
277 x(idof) = x(idof) - alu(ndof2*(i-1)+ndof*(idof-1)+jdof)*x(jdof)
279 x(idof) = alu(ndof2*(i-1)+(ndof+1)*(idof-1)+1)*x(idof)
281 zp(ndof*(iold-1)+1:ndof*(iold-1)+ndof) = x(1:ndof)
291 do blockindex = ictoblockindex(ic), ictoblockindex(ic-1)+1, -1
292 do i = blockindextocolorindex(blockindex), &
293 blockindextocolorindex(blockindex-1)+1, -1
304 x(idof) = zp(ndof*(k-1)+idof)
308 sw(idof) = sw(idof) + au(ndof2*(j-1)+ndof*(idof-1)+jdof)*x(jdof)
316 x(idof) = x(idof) - alu(ndof2*(i-1)+ndof*(idof-1)+k)*x(k)
319 do idof = ndof, 1, -1
320 do k = ndof, idof+1, -1
321 x(idof) = x(idof) - alu(ndof2*(i-1)+ndof*(idof-1)+k)*x(k)
323 x(idof) = alu(ndof2*(i-1)+(ndof+1)*(idof-1)+1)*x(idof)
327 zp(ndof*(iold-1)+idof) = zp(ndof*(iold-1)+idof) - x(idof)
345 integer(kind=kint ) :: nthreads = 1
347 if (
associated(colorindex))
deallocate(colorindex)
348 if (
associated(perm))
deallocate(perm)
349 if (
associated(iperm))
deallocate(iperm)
350 if (
associated(alu))
deallocate(alu)
351 if (nthreads >= 1)
then
352 if (
associated(d))
deallocate(d)
353 if (
associated(al))
deallocate(al)
354 if (
associated(au))
deallocate(au)
355 if (
associated(indexl))
deallocate(indexl)
356 if (
associated(indexu))
deallocate(indexu)
357 if (
associated(iteml))
deallocate(iteml)
358 if (
associated(itemu))
deallocate(itemu)
371 initialized = .false.
374 subroutine write_debug_info
376 integer(kind=kint) :: my_rank, ic, in
379 if (my_rank.eq.0)
then
380 write(*,*)
'DEBUG: Output fort.19000+myrank and fort.29000+myrank for coloring information'
382 write(19000+my_rank,
'(a)')
'#NCOLORTot'
383 write(19000+my_rank,*) ncolor
384 write(19000+my_rank,
'(a)')
'#ic COLORindex(ic-1)+1 COLORindex(ic)'
386 write(19000+my_rank,*) ic, colorindex(ic-1)+1,colorindex(ic)
388 write(29000+my_rank,
'(a)')
'#n_node'
389 write(29000+my_rank,*) n
390 write(29000+my_rank,
'(a)')
'#in OLDtoNEW(in) NEWtoOLD(in)'
392 write(29000+my_rank,*) in, iperm(in), perm(in)
393 if (perm(iperm(in)) .ne. in)
then
394 write(29000+my_rank,*)
'** WARNING **: NEWtoOLD and OLDtoNEW: ',in
397 end subroutine write_debug_info
399 subroutine check_ordering
401 integer(kind=kint) :: ic, i, j, k
402 integer(kind=kint),
allocatable :: iicolor(:)
404 if (ncolor.gt.1)
then
407 do i= colorindex(ic-1)+1, colorindex(ic)
413 do i= colorindex(ic-1)+1, colorindex(ic)
414 do j= indexl(i-1)+1, indexl(i)
416 if (iicolor(i).eq.iicolor(k))
then
417 write(*,*) .eq.
'** ERROR **: L-part: iicolor(i)iicolor(k)',i,k,iicolor(i)
424 do i= colorindex(ic), colorindex(ic-1)+1, -1
425 do j= indexu(i-1)+1, indexu(i)
427 if (iicolor(i).eq.iicolor(k))
then
428 write(*,*) .eq.
'** ERROR **: U-part: iicolor(i)iicolor(k)',i,k,iicolor(i)
436 end subroutine check_ordering