FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_jadm_33.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_33
16  public :: hecmw_jad_finalize_33
17  public :: hecmw_jad_matvec_33
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(:)
26  integer(kind=kint) :: INITIALIZED = 0
27 
28 contains
29 
30  subroutine hecmw_jad_init_33(hecMAT)
31  type(hecmwst_matrix) :: hecmat
32  allocate(wp1(hecmat%NP), wp2(hecmat%NP), wp3(hecmat%NP))
33  allocate(ajad((hecmat%NPL+hecmat%NPU)*9))
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_33
40 
41  subroutine hecmw_jad_finalize_33()
42  deallocate(ajad)
43  deallocate(jajad)
44  deallocate(jadord)
45  deallocate(iajad)
46  deallocate(wp1,wp2,wp3)
47  initialized = 0
48  end subroutine hecmw_jad_finalize_33
49 
50  subroutine hecmw_jad_matvec_33(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
60 
61  start_time= hecmw_wtime()
62  call hecmw_update_r (hecmesh, x, hecmat%NP, 3)
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(3*i-2)
72  x2= x(3*i-1)
73  x3= x(3*i )
74  y(3*i -2)= d(9*i-8)*x1 + d(9*i-7)*x2 + d(9*i-6)*x3
75  y(3*i -1)= d(9*i-5)*x1 + d(9*i-4)*x2 + d(9*i-3)*x3
76  y(3*i )= d(9*i-2)*x1 + d(9*i-1)*x2 + d(9*i )*x3
77  enddo
78  !$OMP END DO
79  !$OMP END PARALLEL
80 
81  call matjad(hecmat%N, mjad, iajad, jajad, ajad, jadord, x, y, wp1, wp2, wp3)
82  end subroutine hecmw_jad_matvec_33
83 
84  subroutine repack(N, hecMAT, MJAD, AJAD, JAJAD, IAJAD, JADORD)
85  use hecmw_util
86  !C---------------------------------
87  type (hecmwst_matrix) :: hecmat
88  !C----------------------
89  integer(kind = kint) :: n, mjad
90  real(kind = kreal), dimension(*) :: ajad
91  integer(kind = kint), dimension(*) :: jajad
92  integer(kind = kint), dimension(*) :: iajad
93  integer(kind = kint), dimension(*) :: jadord
94 
95  integer(kind = kint) :: ijad, maxnz, minnz
96  integer(kind = kint) :: i, j, js, je, in, jc
97  integer(kind = kint), allocatable :: len(:), lenz(:), jadreord(:)
98 
99  allocate(len(n))
100  allocate(jadreord(n))
101  do i=1,n
102  len(i)= hecmat%indexL(i) - hecmat%indexL(i-1) &
103  & + hecmat%indexU(i) - hecmat%indexU(i-1)
104  end do
105  maxnz=maxval(len(1:n))
106  minnz=minval(len(1:n))
107  mjad =maxnz
108  allocate(lenz(0:mjad))
109  lenz = 0
110  do i=1,n
111  lenz(len(i))=lenz(len(i))+1
112  enddo
113  do i=maxnz-1,minnz,-1
114  lenz(i)=lenz(i)+lenz(i+1)
115  enddo
116  do i=1,n
117  jadord(i)=lenz(len(i))
118  lenz(len(i))=lenz(len(i))-1
119  enddo
120  do i=1,n
121  jadreord(jadord(i))=i
122  enddo
123  do i=1,n
124  lenz(len(jadreord(i)))=i
125  enddo
126  do i=maxnz-1,1,-1
127  lenz(i)=max(lenz(i+1),lenz(i))
128  enddo
129  iajad(1)=1
130  do i=1,maxnz
131  iajad(i+1)=iajad(i)+lenz(i)
132  enddo
133  len=0
134  do i= 1, n
135  ijad=jadord(i)
136  js= hecmat%indexL(i-1) + 1
137  je= hecmat%indexL(i )
138  do j=js,je
139  in = hecmat%itemL(j)
140  len(ijad)=len(ijad)+1
141  jc=iajad(len(ijad))+ijad-1
142  ajad(jc*9-8:jc*9) = hecmat%AL(9*j-8:9*j)
143  jajad(jc) = in
144  end do
145  end do
146  do i= 1, n
147  ijad=jadord(i)
148  js= hecmat%indexU(i-1) + 1
149  je= hecmat%indexU(i )
150  do j=js,je
151  in = hecmat%itemU(j)
152  len(ijad)=len(ijad)+1
153  jc=iajad(len(ijad))+ijad-1
154  ajad(jc*9-8:jc*9) = hecmat%AU(9*j-8:9*j)
155  jajad(jc) = in
156  end do
157  end do
158  deallocate(len)
159  deallocate(jadreord)
160  deallocate(lenz)
161  end subroutine repack
162 
163  subroutine matjad(N, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W1, W2, W3)
164  use hecmw_util
165  integer(kind=kint) :: N, MJAD
166  integer(kind=kint) :: IAJAD(*), JAJAD(*), JADORD(*)
167  real(kind=kreal) :: ajad(*), x(*), y(*), w1(*), w2(*), w3(*)
168 
169  integer(kind=kint) :: I, K, NZ, IXX
170  real(kind=kreal) :: x1, x2, x3
171 
172  !$OMP PARALLEL PRIVATE(I,K,X1,X2,X3,IXX)
173  !$OMP DO
174  do i=1,n
175  w1(i)=0.d0
176  w2(i)=0.d0
177  w3(i)=0.d0
178  enddo
179  !$OMP END DO
180 
181  do nz=1,mjad
182  !$OMP DO
183  do k=iajad(nz),iajad(nz+1)-1
184  x1=x(jajad(k)*3-2)
185  x2=x(jajad(k)*3-1)
186  x3=x(jajad(k)*3 )
187  ixx = k-iajad(nz)+1
188  w1(ixx)=w1(ixx) + ajad(k*9-8)*x1 + ajad(k*9-7)*x2 + ajad(k*9-6)*x3
189  w2(ixx)=w2(ixx) + ajad(k*9-5)*x1 + ajad(k*9-4)*x2 + ajad(k*9-3)*x3
190  w3(ixx)=w3(ixx) + ajad(k*9-2)*x1 + ajad(k*9-1)*x2 + ajad(k*9-0)*x3
191  enddo
192  !$OMP END DO
193  enddo
194 
195  !$OMP DO
196  do i=1,n
197  y(3*i-2)=y(3*i-2)+w1(jadord(i))
198  y(3*i-1)=y(3*i-1)+w2(jadord(i))
199  y(3*i )=y(3*i )+w3(jadord(i))
200  enddo
201  !$OMP END DO
202  !$OMP END PARALLEL
203  end subroutine matjad
204 
205 end module hecmw_jad_type_33
Jagged Diagonal Matrix storage for vector processors. Original code was provided by JAMSTEC.
subroutine, public hecmw_jad_matvec_33(hecMESH, hecMAT, X, Y, COMMtime)
subroutine matjad(N, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W1, W2, W3)
subroutine, public hecmw_jad_init_33(hecMAT)
subroutine, public hecmw_jad_finalize_33()
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)