FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_solver_direct_MUMPS.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  use hecmw_util
13 
14  private
15  public :: hecmw_solve_direct_mumps
16 
17  logical, save :: INITIALIZED = .false.
18  type (sparse_matrix), save :: spMAT
19 
20 contains
21 
22  subroutine hecmw_solve_direct_mumps(hecMESH,hecMAT)
23  implicit none
24  type (hecmwst_local_mesh), intent(in) :: hecmesh
25  type (hecmwst_matrix ), intent(inout) :: hecmat
26  integer(kind=kint) :: spmat_type
27  integer(kind=kint) :: spmat_symtype
28  integer(kind=kint) :: mumps_job
29  integer(kind=kint) :: istat,myrank
30  real(kind=kreal) :: t1,t2,t3
31 
32  call hecmw_mat_dump(hecmat, hecmesh)
33 
34  t1=hecmw_wtime()
36 
37  if (initialized .and. hecmat%Iarray(98) .eq. 1) then
38  mumps_job=-2
39  call hecmw_mumps_wrapper(spmat, mumps_job, istat)
40  if (istat < 0) then
41  write(*,*) 'ERROR: MUMPS returned with error', istat
42  stop
43  endif
44  call sparse_matrix_finalize(spmat)
45  initialized = .false.
46  endif
47 
48  if (.not. initialized) then
49  spmat_type = sparse_matrix_type_coo
50  if (hecmat%symmetric) then
51  spmat_symtype = sparse_matrix_symtype_spd
52  else
53  spmat_symtype = sparse_matrix_symtype_asym
54  end if
55  call sparse_matrix_set_type(spmat, spmat_type, spmat_symtype)
56  mumps_job = -1
57  call hecmw_mumps_wrapper(spmat, mumps_job, istat)
58  if (istat < 0) then
59  write(*,*) 'ERROR: MUMPS returned with error', istat
60  stop
61  endif
62  initialized = .true.
63  hecmat%Iarray(98) = 1
64  endif
65 
66  !* Flag to activate symbolic factorization: 1(yes) 0(no) hecMESH%Iarray(98)
67  !* Flag to activate numeric factorization: 1(yes) 0(no) hecMESH%Iarray(97)
68 
69  if (hecmat%Iarray(98) .eq. 1) then
70  ! ANALYSIS and FACTORIZATION
71  call sparse_matrix_hec_init_prof(spmat, hecmat, hecmesh)
72  call sparse_matrix_hec_set_vals(spmat, hecmat)
73  !call sparse_matrix_dump(spMAT)
74  mumps_job=4
75  call hecmw_mumps_wrapper(spmat, mumps_job, istat)
76  if (istat < 0) then
77  write(*,*) 'ERROR: MUMPS returned with error', istat
78  stop
79  endif
80  if (myrank==0 .and. (spmat%iterlog > 0 .or. spmat%timelog > 0)) &
81  write(*,*) ' [MUMPS]: Analysis and Factorization completed.'
82  hecmat%Iarray(98) = 0
83  hecmat%Iarray(97) = 0
84  endif
85  if (hecmat%Iarray(97) .eq. 1) then
86  ! FACTORIZATION
87  call sparse_matrix_hec_set_vals(spmat, hecmat)
88  !call sparse_matrix_dump(spMAT)
89  mumps_job=2
90  call hecmw_mumps_wrapper(spmat, mumps_job, istat)
91  if (istat < 0) then
92  write(*,*) 'ERROR: MUMPS returned with error', istat
93  stop
94  endif
95  if (myrank==0 .and. (spmat%iterlog > 0 .or. spmat%timelog > 0)) &
96  write(*,*) ' [MUMPS]: Factorization completed.'
97  hecmat%Iarray(97) = 0
98  endif
99 
100  t2=hecmw_wtime()
101 
102  ! SOLUTION
103  call sparse_matrix_hec_set_rhs(spmat, hecmat)
104  mumps_job=3
105  call hecmw_mumps_wrapper(spmat, mumps_job, istat)
106  if (istat < 0) then
107  write(*,*) 'ERROR: MUMPS returned with error', istat
108  stop
109  endif
110  call sparse_matrix_hec_get_rhs(spmat, hecmat)
111  if (myrank==0 .and. (spmat%iterlog > 0 .or. spmat%timelog > 0)) &
112  write(*,*) ' [MUMPS]: Solution completed.'
113 
114  t3=hecmw_wtime()
115  if (myrank==0 .and. spmat%timelog > 0) then
116  write(*,*) 'setup time : ',t2-t1
117  write(*,*) 'solve time : ',t3-t2
118  endif
119 
120  call hecmw_mat_dump_solution(hecmat)
121 
122  !call sparse_matrix_finalize(spMAT)
123  end subroutine hecmw_solve_direct_mumps
124 
125 end module hecmw_solver_direct_mumps
hecmw_matrix_dump::hecmw_mat_dump_solution
subroutine, public hecmw_mat_dump_solution(hecMAT)
Definition: hecmw_matrix_dump.f90:340
m_sparse_matrix::sparse_matrix_set_type
subroutine, public sparse_matrix_set_type(spMAT, type, symtype)
Definition: sparse_matrix.f90:59
hecmw_util::hecmw_wtime
real(kind=kreal) function hecmw_wtime()
Definition: hecmw_util_f.F90:549
m_sparse_matrix_hec
This module provides conversion routines between HEC data structure and DOF based sparse matrix struc...
Definition: sparse_matrix_hec.f90:7
m_sparse_matrix_hec::sparse_matrix_hec_set_rhs
subroutine, public sparse_matrix_hec_set_rhs(spMAT, hecMAT)
Definition: sparse_matrix_hec.f90:230
m_fstr::myrank
integer(kind=kint) myrank
PARALLEL EXECUTION.
Definition: m_fstr.f90:96
m_sparse_matrix::sparse_matrix_finalize
subroutine, public sparse_matrix_finalize(spMAT)
Definition: sparse_matrix.f90:94
m_sparse_matrix::sparse_matrix_symtype_spd
integer(kind=kint), parameter, public sparse_matrix_symtype_spd
Definition: sparse_matrix.f90:33
hecmw_util
I/O and Utility.
Definition: hecmw_util_f.F90:7
hecmw_util::hecmwst_local_mesh
Definition: hecmw_util_f.F90:234
hecmw_solver_direct_mumps
This module provides linear equation solver interface for MUMPS.
Definition: hecmw_solver_direct_MUMPS.f90:6
hecmw_util::kreal
integer(kind=4), parameter kreal
Definition: hecmw_util_f.F90:16
m_sparse_matrix_hec::sparse_matrix_hec_init_prof
subroutine, public sparse_matrix_hec_init_prof(spMAT, hecMAT, hecMESH)
Definition: sparse_matrix_hec.f90:27
m_sparse_matrix_hec::sparse_matrix_hec_set_vals
subroutine, public sparse_matrix_hec_set_vals(spMAT, hecMAT)
Definition: sparse_matrix_hec.f90:149
hecmw_matrix_ass
Definition: hecmw_mat_ass.f90:6
m_hecmw_mumps_wrapper::hecmw_mumps_wrapper
subroutine, public hecmw_mumps_wrapper(spMAT, job, istat)
Definition: hecmw_MUMPS_wrapper.F90:25
m_hecmw_mumps_wrapper
This module provides wrapper for parallel sparse direct solver MUMPS.
Definition: hecmw_MUMPS_wrapper.F90:6
m_sparse_matrix::sparse_matrix_symtype_asym
integer(kind=kint), parameter, public sparse_matrix_symtype_asym
Definition: sparse_matrix.f90:32
m_sparse_matrix::sparse_matrix_type_coo
integer(kind=kint), parameter, public sparse_matrix_type_coo
Definition: sparse_matrix.f90:30
hecmw_matrix_dump
Definition: hecmw_matrix_dump.f90:6
m_sparse_matrix
This module provides DOF based sparse matrix data structure (CSR and COO)
Definition: sparse_matrix.f90:6
hecmw_solver_direct_mumps::hecmw_solve_direct_mumps
subroutine, public hecmw_solve_direct_mumps(hecMESH, hecMAT)
Definition: hecmw_solver_direct_MUMPS.f90:23
hecmw_matrix_dump::hecmw_mat_dump
subroutine, public hecmw_mat_dump(hecMAT, hecMESH)
Definition: hecmw_matrix_dump.f90:32
m_sparse_matrix_hec::sparse_matrix_hec_get_rhs
subroutine, public sparse_matrix_hec_get_rhs(spMAT, hecMAT)
Definition: sparse_matrix_hec.f90:245
hecmw_util::hecmw_comm_get_rank
integer(kind=kint) function hecmw_comm_get_rank()
Definition: hecmw_util_f.F90:582
hecmw_util::hecmwst_matrix
Definition: hecmw_util_f.F90:444