1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19      subroutine createblock_struct(neq,ipointers,icolpardiso,aupardiso,
20     &  nestart,num_cpus,ja,nz_num)
21!
22!     generates num_cpu blocks
23!
24      integer neq,ipointers(*),icolpardiso(*),nestart(*),num_cpus,ja(*),
25     &  numd,i,j,k,m,icol,isubtract,nz_num
26!
27      real*8 aupardiso(*)
28!
29!     nestart(i) points to the element before the block for which
30!     cpu i is responsible
31!
32      numd=int(neq/num_cpus)+1
33      nestart(1)=0
34      do i=2,num_cpus
35         nestart(i)=nestart(i-1)+numd
36      enddo
37      nestart(num_cpus+1)=neq
38!
39!     ipointers(i) points to the first entry of row i in icolpardiso
40!     ja(i) points to the entry in icolpardiso before the start of row i
41!
42      j=0
43!
44      do k=1,num_cpus
45         do i=nestart(k)+1,nestart(k+1)
46            ja(i)=j
47            do m=ipointers(i),ipointers(i+1)-1
48               icol=icolpardiso(m)
49               if((icol.gt.nestart(k)).and.
50     &            (icol.le.nestart(k+1))) then
51                  j=j+1
52                  icolpardiso(j)=icol
53                  aupardiso(j)=aupardiso(m)
54               endif
55             enddo
56          enddo
57       enddo
58       ja(neq+1)=j
59       nz_num=j
60!
61!     subtracting from iam the number of elements belonging
62!     to the preceding blocks
63!
64      do k=2,num_cpus
65         isubtract=nestart(k)
66         do i=nestart(k)+1,nestart(k+1)
67            do j=ja(i)+1,ja(i+1)
68               icolpardiso(j)=icolpardiso(j)-isubtract
69            enddo
70         enddo
71      enddo
72!
73      return
74      end
75