FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_jadm_nn.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_nn
16  public :: hecmw_jad_finalize_nn
17  public :: hecmw_jad_matvec_nn
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 :: wp(:,:)
26  integer(kind=kint) :: INITIALIZED = 0
27 
28 contains
29 
30  subroutine hecmw_jad_init_nn(hecMAT)
31  type(hecmwst_matrix) :: hecmat
32  allocate(wp(hecmat%NDOF,hecmat%NP))
33  allocate(ajad((hecmat%NPL+hecmat%NPU)*hecmat%NDOF*hecmat%NDOF))
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_nn
40 
41  subroutine hecmw_jad_finalize_nn()
42  deallocate(ajad)
43  deallocate(jajad)
44  deallocate(jadord)
45  deallocate(iajad)
46  deallocate(wp)
47  initialized = 0
48  end subroutine hecmw_jad_finalize_nn
49 
50  subroutine hecmw_jad_matvec_nn(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,idof,jdof,ndof,ndof2
59 
60  start_time= hecmw_wtime()
61  call hecmw_update_r (hecmesh, x, hecmat%NP,hecmat%NDOF)
62  end_time= hecmw_wtime()
63  commtime = commtime + end_time - start_time
64 
65  d => hecmat%D
66  ndof = hecmat%NDOF
67  ndof2 = ndof*ndof
68  y=0.0d0
69 
70  !$OMP PARALLEL PRIVATE(i, idof, jdof)
71  !$OMP DO
72  do i= 1, hecmat%N
73  do idof=1,hecmat%NDOF
74  do jdof=1,hecmat%NDOF
75  y(ndof*(i-1)+idof) = y(ndof*(i-1)+idof) + d(ndof2*(i-1)+ndof*(idof-1)+jdof)*x(ndof*(i-1)+jdof)
76  end do
77  end do
78  enddo
79  !$OMP END DO
80  !$OMP END PARALLEL
81  call matjad(hecmat%N,hecmat%NDOF, mjad, iajad, jajad, ajad, jadord, x, y, wp)
82  end subroutine hecmw_jad_matvec_nn
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,ndof,ndof2
96  integer(kind = kint) :: i, j, js, je, in, jc
97  integer(kind = kint), allocatable :: len(:), lenz(:), jadreord(:)
98  ndof = hecmat%NDOF;ndof2=ndof*ndof
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(ndof2*(jc-1)+1:ndof2*(jc)) = hecmat%AL(ndof2*(j-1)+1:ndof2*(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(ndof2*(jc-1)+1:ndof2*(jc)) = hecmat%AU(ndof2*(j-1)+1:ndof2*(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, NDOF, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W)
164  use hecmw_util
165  integer(kind=kint) :: N,NDOF, MJAD,NDOF2
166  integer(kind=kint) :: IAJAD(*), JAJAD(*), JADORD(*)
167  real(kind=kreal) :: ajad(*), x(*), y(*), w(ndof,n)
168  integer(kind=kint) :: I, K, NZ, IXX, idof,jdof
169  ndof2=ndof*ndof
170 
171  w=0.0d0
172 
173  do nz=1,mjad
174  !$OMP PARALLEL PRIVATE(K,IXX,idof,jdof)
175  !$OMP DO
176  do k=iajad(nz),iajad(nz+1)-1
177  ixx = k-iajad(nz)+1
178  do idof = 1, ndof
179  do jdof = 1, ndof
180  w(idof,ixx)=w(idof,ixx)+ajad(ndof2*(k-1)+ndof*(idof-1)+jdof)*x(ndof*(jajad(k)-1)+jdof)
181  end do
182  end do
183  enddo
184  !$OMP END DO
185  !$OMP END PARALLEL
186  enddo
187 
188  !$OMP PARALLEL PRIVATE(I,idof)
189  !$OMP DO
190  do i=1,n
191  do idof = 1, ndof
192  y(ndof*(i-1)+idof)=y(ndof*(i-1)+idof)+w(idof,jadord(i))
193  end do
194  enddo
195  !$OMP END DO
196  !$OMP END PARALLEL
197  end subroutine matjad
198 
199 end module hecmw_jad_type_nn
Jagged Diagonal Matrix storage for vector processors. Original code was provided by JAMSTEC.
subroutine, public hecmw_jad_matvec_nn(hecMESH, hecMAT, X, Y, COMMtime)
subroutine matjad(N, NDOF, MJAD, IAJAD, JAJAD, AJAD, JADORD, X, Y, W)
subroutine, public hecmw_jad_finalize_nn()
subroutine, public hecmw_jad_init_nn(hecMAT)
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)