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(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  implicit none
83  integer :: hdim,verbose
84  real(dp) :: threshold
85  type(bml_matrix_t), intent(inout) :: a_bml
86  type(bml_matrix_t), intent(in) :: zmat_bml
87  type(bml_matrix_t) :: aux_bml
88  type(bml_matrix_t), intent(in) :: orthoa_bml
89  character(len=*) :: bml_type
90 
91  if(verbose.eq.1) write(*,*)"In prg_deorthogonalize ..."
92 
93  hdim = bml_get_n(orthoa_bml)
94 
95  !Allocate bml's
96  if(bml_get_n(a_bml).le.0) then
97  call bml_zero_matrix(bml_type,bml_element_real,dp,hdim,hdim,a_bml, &
98  bml_get_distribution_mode(orthoa_bml))
99  endif
100 
101  call bml_transpose(zmat_bml, aux_bml)
102 
103  call bml_multiply(orthoa_bml, aux_bml, a_bml, 1.0_dp, 0.0_dp, threshold) !orthoA*Z^t
104 
105  ! Required when running distributed
106 #ifdef DO_MPI
107  if (getnranks() > 1 .and. &
108  bml_get_distribution_mode(orthoa_bml) == bml_dmode_distributed) then
109  call prg_allgatherparallel(a_bml)
110  endif
111 #endif
112 
113  call bml_multiply(zmat_bml, a_bml, aux_bml, 1.0_dp, 0.0_dp, threshold) !Z*orthoA * Z^t
114 
115  ! call bml_copy(aux_bml, a_bml)
116  call bml_copy_new(aux_bml, a_bml)
117 
118  call bml_deallocate(aux_bml)
119 
120  end subroutine prg_deorthogonalize
121 
122 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()