FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_jadm_44.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
7 
9  use hecmw_util
10  use m_hecmw_comm_f
11  implicit none
12 
13  private
14 
15  public :: hecmw_jad_init_44
16  public :: hecmw_jad_finalize_44
17  public :: hecmw_jad_matvec_44
18 
19  !C---------------------- AU&AL
20  real(kind=kreal), allocatable :: ajad(:)
21  integer(kind=kint), allocatable :: JAJAD(:)
22  integer(kind=kint), allocatable :: JADORD(:)
23  integer(kind=kint), allocatable :: IAJAD(:)
24  integer(kind=kint) :: MJAD
25  real(kind=kreal), allocatable :: wp1(:), wp2(:), wp3(:), wp4(:)
26  integer(kind=kint) :: INITIALIZED = 0
27 
28 contains
29 
30  subroutine hecmw_jad_init_44(hecMAT)
31  type(hecmwst_matrix) :: hecmat
32  allocate(wp1(hecmat%NP), wp2(hecmat%NP), wp3(hecmat%NP), wp4(hecmat%NP))
33  allocate(ajad((hecmat%NPL+hecmat%NPU)*16))
34  allocate(jajad(hecmat%NPL+hecmat%NPU))
35  allocate(jadord(hecmat%NP))
36  allocate(iajad(hecmat%NP+1))
37  call repack(hecmat%N, hecmat, mjad, ajad, jajad, iajad, jadord)
38  initialized = 1
39  end subroutine hecmw_jad_init_44
40 
41  subroutine hecmw_jad_finalize_44()
42  deallocate(ajad)
43  deallocate(jajad)
44  deallocate(jadord)
45  deallocate(iajad)
46  deallocate(wp1,wp2,wp3,wp4)
47  initialized = 0
48  end subroutine hecmw_jad_finalize_44
49 
50  subroutine hecmw_jad_matvec_44(hecMESH, hecMAT, X, Y, COMMtime)
51  type(hecmwst_local_mesh), intent(in) :: hecmesh
52  type(hecmwst_matrix), intent(in), target :: hecmat
53  real(kind=kreal), intent(in) :: x(:)
54  real(kind=kreal), intent(out) :: y(:)
55  real(kind=kreal), intent(inout) :: commtime
56  real(kind=kreal) :: start_time, end_time
57  real(kind=kreal), pointer :: d(:)
58  integer(kind=kint) :: i
59  real(kind=kreal) :: x1, x2, x3, x4
60 
61  start_time= hecmw_wtime()
62  call hecmw_update_r (hecmesh, x, hecmat%NP, 4)
63  end_time= hecmw_wtime()
64  commtime = commtime + end_time - start_time
65 
66  d => hecmat%D
67 
68  !$OMP PARALLEL PRIVATE(i)
69  !$OMP DO
70  do i= 1, hecmat%N
71  x1= x(4*i-3)
72  x2= x(4*i-2)
73  x3= x(4*i-1)
74  x4= x(4*i )
75  y(4*i-3)= d(16*i-15)*x1 + d(16*i-14)*x2 + d(16*i-13)*x3 + d(16*i-12)*x4
76  y(4*i-2)= d(16*i-11)*x1 + d(16*i-10)*x2 + d(16*i- 9)*x3 + d(16*i- 8)*x4
77  y(4*i-1)= d(16*i- 7)*x1 + d(16*i- 6)*x2 + d(16*i- 5)*x3 + d(16*i- 4)*x4
78  y(4*i )= d(16*i- 3)*x1 + d(16*i- 2)*x2 + d(16*i- 1)*x3 + d(16*i- 0)*x4
79  enddo
80  !$OMP END DO
81  !$OMP END PARALLEL
82  call matjad(hecmat%N, mjad, iajad, jajad, ajad, jadord, x, y, wp1, wp2, wp3, wp4)
83  end subroutine hecmw_jad_matvec_44
84 
85  subroutine repack(N, hecMAT, MJAD, AJAD, JAJAD, IAJAD, JADORD)
86  use hecmw_util
87  !C---------------------------------
88  type (hecmwst_matrix) :: hecmat
89  !C----------------------
90  integer(kind = kint) :: n, mjad
91  real(kind = kreal), dimension(*) :: ajad
92  integer(kind = kint), dimension(*) :: jajad
93  integer(kind = kint), dimension(*) :: iajad
94  integer(kind = kint), dimension(*) :: jadord
95 
96  integer(kind = kint) :: ijad, maxnz, minnz
97  integer(kind = kint) :: i, j, js, je, in, jc
98  integer(kind = kint), allocatable :: len(:), lenz(:), jadreord(:)
99 
100  allocate(len(n))
101  allocate(jadreord(n))
102  do i=1,n
103  len(i)= hecmat%indexL(i) - hecmat%indexL(i-1) &
104  & + hecmat%indexU(i) - hecmat%indexU(i-1)
105  end do
106  maxnz=maxval(len(1:n))
107  minnz=minval(len(1:n))
108  mjad =maxnz
109  allocate(lenz(0:mjad))
110  lenz = 0
111  do i=1,n
112  lenz(len(i))=lenz(len(i))+1
113  enddo
114  do i=maxnz-1,minnz,-1
115  lenz(i)=lenz(i)+lenz(i+1)
116  enddo
117  do i=1,n
118  jadord(i)=lenz(len(i))
119  lenz(len(i))=lenz(len(i))-1
120  enddo
121  do i=1,n
122  jadreord(jadord(i))=i
123  enddo
124  do i=1,n
125  lenz(len(jadreord(i)))=i
126  enddo
127  do i=maxnz-1,1,-1
128  lenz(i)=max(lenz(i+1),lenz(i))
129  enddo
130  iajad(1)=1
131  do i=1,maxnz
132  iajad(i+1)=iajad(i)+lenz(i)
133  enddo
134  len=0
135  do i= 1, n
136  ijad=jadord(i)
137  js= hecmat%indexL(i-1) + 1
138  je= hecmat%indexL(i )
139  do j=js,je
140  in = hecmat%itemL(j)
141  len(ijad)=len(ijad)+1
142  jc=iajad(len(ijad))+ijad-1
143  ajad(jc*16-15:jc*16) = hecmat%AL(16*j-15:16*j)
144  jajad(jc) = in
145  end do
146  end do
147  do i= 1, n
148  ijad=jadord(i)
149  js= hecmat%indexU(i-1) + 1
150  je= hecmat%indexU(i )
151  do j=js,je
152  in = hecmat%itemU(j)
153  len(ijad)=len(ijad)+1
154  jc=iajad(len(ijad))+ijad-1
155  ajad(jc*16-15:jc*16) = hecmat%AU(16*j-15:16*j)
156  jajad(jc) = in
157  end do
158  end do
159  deallocate(len)
160  deallocate(jadreord)
161  deallocate(lenz)
162  end subroutine repack
163 
164  subroutine matjad(N, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W1, W2, W3, W4)
165  use hecmw_util
166  integer(kind=kint) :: N, MJAD
167  integer(kind=kint) :: IAJAD(*), JAJAD(*), JADORD(*)
168  real(kind=kreal) :: ajad(*), x(*), y(*), w1(*), w2(*), w3(*), w4(*)
169 
170  integer(kind=kint) :: I, K, NZ, IXX
171  real(kind=kreal) :: x1, x2, x3, x4
172 
173  !$OMP PARALLEL PRIVATE(I,K,X1,X2,X3,X4,IXX)
174  !$OMP DO
175  do i=1,n
176  w1(i)=0.d0
177  w2(i)=0.d0
178  w3(i)=0.d0
179  w4(i)=0.d0
180  enddo
181  !$OMP END DO
182 
183  do nz=1,mjad
184  !$OMP DO
185  do k=iajad(nz),iajad(nz+1)-1
186  x1=x(jajad(k)*4-3)
187  x2=x(jajad(k)*4-2)
188  x3=x(jajad(k)*4-1)
189  x4=x(jajad(k)*4 )
190  ixx = k-iajad(nz)+1
191  w1(ixx)=w1(ixx) + ajad(k*16-15)*x1 + ajad(k*16-14)*x2 + ajad(k*16-13)*x3 + ajad(k*16-12)*x4
192  w2(ixx)=w2(ixx) + ajad(k*16-11)*x1 + ajad(k*16-10)*x2 + ajad(k*16- 9)*x3 + ajad(k*16- 8)*x4
193  w3(ixx)=w3(ixx) + ajad(k*16- 7)*x1 + ajad(k*16- 6)*x2 + ajad(k*16- 5)*x3 + ajad(k*16- 4)*x4
194  w4(ixx)=w4(ixx) + ajad(k*16- 3)*x1 + ajad(k*16- 2)*x2 + ajad(k*16- 1)*x3 + ajad(k*16- 0)*x4
195  enddo
196  !$OMP END DO
197  enddo
198 
199  !$OMP DO
200  do i=1,n
201  y(4*i-3)=y(4*i-3)+w1(jadord(i))
202  y(4*i-2)=y(4*i-2)+w2(jadord(i))
203  y(4*i-1)=y(4*i-1)+w3(jadord(i))
204  y(4*i )=y(4*i )+w4(jadord(i))
205  enddo
206  !$OMP END DO
207  !$OMP END PARALLEL
208  end subroutine matjad
209 
210 end module hecmw_jad_type_44
Jagged Diagonal Matrix storage for vector processors. Original code was provided by JAMSTEC.
subroutine, public hecmw_jad_init_44(hecMAT)
subroutine, public hecmw_jad_matvec_44(hecMESH, hecMAT, X, Y, COMMtime)
subroutine, public hecmw_jad_finalize_44()
subroutine matjad(N, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W1, W2, W3, W4)
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=4), parameter kreal
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_update_r(hecMESH, val, n, m)