PROGRESS  master
prg_nonortho_mod.F90
Go to the documentation of this file.
1 
9 !
11 
12  use bml
14 
15  implicit none
16 
17  private
18 
19  integer, parameter :: dp = kind(1.0d0)
20 
22 
23 contains
24 
35  subroutine prg_orthogonalize(A_bml,zmat_bml,orthoA_bml,threshold,bml_type,verbose)
36  implicit none
37  integer :: hdim, mdim
38  integer, intent(in) :: verbose
39  real(dp), intent(in) :: threshold
40  type(bml_matrix_t), intent(inout) :: a_bml
41  type(bml_matrix_t), intent(inout) :: zmat_bml
42  type(bml_matrix_t) :: aux_bml
43  type(bml_matrix_t), intent(inout) :: orthoa_bml
44  character(len=*), intent(in) :: bml_type
45 
46  if(verbose.eq.1) write(*,*)"In prg_orthogonalize ..."
47 
48  hdim= bml_get_n(a_bml)
49  mdim= bml_get_m(a_bml)
50 
51  !Allocate bml's
52  if(bml_get_n(orthoa_bml) .le. 0)then
53  call bml_zero_matrix(bml_type,bml_element_real,dp,hdim ,mdim,orthoa_bml, &
54  bml_get_distribution_mode(a_bml))
55  endif
56 
57  !Do the operations in bml
58  call bml_transpose_new(zmat_bml, aux_bml)
59 
60  call bml_multiply(aux_bml, a_bml, orthoa_bml, 1.0_dp, 0.0_dp,threshold) !Z^t*A
61 
62  call bml_multiply(orthoa_bml, zmat_bml, aux_bml, 1.0_dp, 0.0_dp,threshold) !Z^t*A * Z
63 
64  call bml_copy_new(aux_bml, orthoa_bml)
65 
66  call bml_deallocate(aux_bml)
67 
68  end subroutine prg_orthogonalize
69 
70 
81  subroutine prg_deorthogonalize(orthoA_bml,zmat_bml,a_bml,threshold,bml_type,verbose)
82  use, intrinsic :: iso_c_binding
83  implicit none
84  integer :: hdim,verbose
85  real(dp) :: threshold
86  type(bml_matrix_t), intent(inout) :: a_bml
87  type(bml_matrix_t), intent(in) :: zmat_bml
88  type(bml_matrix_t) :: aux_bml
89  type(bml_matrix_t), intent(in) :: orthoa_bml
90  character(len=*) :: bml_type
91 
92  if(verbose.eq.1) write(*,*)"In prg_deorthogonalize ..."
93 
94  hdim = bml_get_n(orthoa_bml)
95 
96  !Allocate bml's
97  if(bml_get_n(a_bml).le.0) then
98  call bml_zero_matrix(bml_type,bml_element_real,dp,hdim,hdim,a_bml, &
99  bml_get_distribution_mode(orthoa_bml))
100  endif
101 
102  call bml_transpose_new(zmat_bml, aux_bml)
103 
104  call bml_multiply(orthoa_bml, aux_bml, a_bml, 1.0_dp, 0.0_dp, threshold) !orthoA*Z^t
105 
106  ! Required when running distributed
107 #ifdef DO_MPI
108  if (getnranks() > 1 .and. &
109  bml_get_distribution_mode(orthoa_bml) == bml_dmode_distributed) then
110  call prg_allgatherparallel(a_bml)
111  endif
112 #endif
113 
114  call bml_multiply(zmat_bml, a_bml, aux_bml, 1.0_dp, 0.0_dp, threshold) !Z*orthoA * Z^t
115 
116  ! call bml_copy(aux_bml, a_bml)
117  !call bml_copy(aux_bml, a_bml)
118  call bml_deallocate(a_bml)
119  a_bml%ptr = aux_bml%ptr
120  aux_bml%ptr = c_null_ptr
121 
122  call bml_deallocate(aux_bml)
123 
124  end subroutine prg_deorthogonalize
125 
126 end module prg_nonortho_mod
Module to prg_orthogonalize and prg_deorthogonalize any operator.
subroutine, public prg_deorthogonalize(orthoA_bml, zmat_bml, a_bml, threshold, bml_type, verbose)
This routine performs: .
subroutine, public prg_orthogonalize(A_bml, zmat_bml, orthoA_bml, threshold, bml_type, verbose)
This routine performs: .
integer, parameter dp
The parallel module.
subroutine, public prg_allgatherparallel(a)
integer function, public getnranks()