Commit c4b4757e authored by Victor Yu's avatar Victor Yu

Support DM extrapolation with libOMM

parent 0f64d353
......@@ -154,6 +154,7 @@ subroutine elsi_to_original_ev_sp_real(ph,bh,ovlp,evec)
if(ph%ill_ovlp) then
call elsi_allocate(bh,tmp,bh%n_lrow,bh%n_lcol,"tmp",caller)
tmp = evec
call dgemm("N","N",ph%n_basis,ph%n_states_solve,ph%n_good,1.0_r8,ovlp,&
......@@ -485,6 +486,7 @@ subroutine elsi_to_original_ev_sp_cmplx(ph,bh,ovlp,evec)
if(ph%ill_ovlp) then
call elsi_allocate(bh,tmp,bh%n_lrow,bh%n_lcol,"tmp",caller)
tmp = evec
call zgemm("N","N",ph%n_basis,ph%n_states_solve,ph%n_good,&
......
......@@ -400,6 +400,14 @@ subroutine elsi_reinit(eh)
if(allocated(eh%col_ptr_sp2)) then
call elsi_deallocate(eh%bh,eh%col_ptr_sp2,"col_ptr_sp2")
end if
if(allocated(eh%ovlp_real_copy)) then
call elsi_deallocate(eh%bh,eh%ovlp_real_copy,"ovlp_real_copy")
end if
if(allocated(eh%ovlp_cmplx_copy)) then
call elsi_deallocate(eh%bh,eh%ovlp_cmplx_copy,"ovlp_cmplx_copy")
end if
end if
end subroutine
......
......@@ -186,6 +186,7 @@ subroutine elsi_ev_real(eh,ham,ovlp,eval,evec)
if(.not. allocated(eh%ovlp_real_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,eh%bh%n_lcol,&
"ovlp_real_copy",caller)
eh%ovlp_real_copy = ovlp
end if
end if
......@@ -205,6 +206,7 @@ subroutine elsi_ev_real(eh,ham,ovlp,eval,evec)
if(allocated(eh%ovlp_real_copy)) then
! Restore overlap
ovlp = eh%ovlp_real_copy
call elsi_deallocate(eh%bh,eh%ovlp_real_copy,"ovlp_real_copy")
end if
......@@ -516,6 +518,7 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,energy)
if(.not. allocated(eh%ovlp_real_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,eh%bh%n_lcol,&
"ovlp_real_copy",caller)
eh%ovlp_real_copy = ovlp
end if
end if
......@@ -529,6 +532,7 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,energy)
if(.not. allocated(eh%ovlp_real_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_real_copy",caller)
eh%ovlp_real_copy = ovlp
end if
end if
......@@ -565,6 +569,7 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,energy)
if(allocated(eh%ovlp_real_copy)) then
! Retrieve overlap matrix that has been destroyed by Cholesky
ovlp = eh%ovlp_real_copy
call elsi_deallocate(eh%bh,eh%ovlp_real_copy,"ovlp_real_copy")
end if
......@@ -640,6 +645,7 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,energy)
if(allocated(eh%ovlp_real_copy)) then
! Restore overlap
ovlp = eh%ovlp_real_copy
call elsi_deallocate(eh%bh,eh%ovlp_real_copy,"ovlp_real_copy")
call elsi_deallocate(eh%bh,eh%evec_real,"evec_real")
end if
......@@ -752,6 +758,7 @@ subroutine elsi_dm_complex(eh,ham,ovlp,dm,energy)
if(.not. allocated(eh%ovlp_cmplx_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_cmplx_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_cmplx_copy",caller)
eh%ovlp_cmplx_copy = ovlp
end if
end if
......@@ -788,6 +795,7 @@ subroutine elsi_dm_complex(eh,ham,ovlp,dm,energy)
if(allocated(eh%ovlp_cmplx_copy)) then
! Restore overlap
ovlp = eh%ovlp_cmplx_copy
call elsi_deallocate(eh%bh,eh%ovlp_cmplx_copy,"ovlp_cmplx_copy")
end if
......@@ -971,6 +979,7 @@ subroutine elsi_dm_real_sparse(eh,ham,ovlp,dm,energy)
! Overlap will be destroyed by Cholesky
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_real_copy",caller)
eh%ovlp_real_copy = eh%ovlp_real_den
end if
end if
......@@ -1058,6 +1067,7 @@ subroutine elsi_dm_real_sparse(eh,ham,ovlp,dm,energy)
if(allocated(eh%ovlp_real_copy)) then
! Restore overlap
eh%ovlp_real_den = eh%ovlp_real_copy
call elsi_deallocate(eh%bh,eh%ovlp_real_copy,"ovlp_real_copy")
end if
......@@ -1334,6 +1344,7 @@ subroutine elsi_dm_complex_sparse(eh,ham,ovlp,dm,energy)
! Overlap will be destroyed by Cholesky
call elsi_allocate(eh%bh,eh%ovlp_cmplx_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_cmplx_copy",caller)
eh%ovlp_cmplx_copy = eh%ovlp_cmplx_den
end if
end if
......@@ -1422,6 +1433,7 @@ subroutine elsi_dm_complex_sparse(eh,ham,ovlp,dm,energy)
if(allocated(eh%ovlp_cmplx_copy)) then
! Restore overlap
eh%ovlp_cmplx_den = eh%ovlp_cmplx_copy
call elsi_deallocate(eh%bh,eh%ovlp_cmplx_copy,"ovlp_cmplx_copy")
end if
......
......@@ -102,11 +102,29 @@ subroutine elsi_extrapolate_dm_real(eh,ovlp0,ovlp1,dm)
if(eh%ph%solver == SIPS_SOLVER .and. eh%ph%sips_n_elpa > 0) then
solver_save = SIPS_SOLVER
eh%ph%solver = ELPA_SOLVER
! Overlap will be destroyed by Cholesky
if(.not. allocated(eh%ovlp_real_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,eh%bh%n_lcol,&
"ovlp_real_copy",caller)
eh%ovlp_real_copy = ovlp1
end if
end if
if(eh%ph%solver == OMM_SOLVER .and. eh%ph%omm_n_elpa > 0) then
solver_save = OMM_SOLVER
eh%ph%solver = ELPA_SOLVER
if(eh%ph%omm_flavor == 0) then
! Overlap will be destroyed by Cholesky
if(.not. allocated(eh%ovlp_real_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_real_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_real_copy",caller)
eh%ovlp_real_copy = ovlp1
end if
end if
end if
select case(eh%ph%solver)
......@@ -164,6 +182,16 @@ subroutine elsi_extrapolate_dm_complex(eh,ovlp0,ovlp1,dm)
if(eh%ph%solver == OMM_SOLVER .and. eh%ph%omm_n_elpa > 0) then
solver_save = OMM_SOLVER
eh%ph%solver = ELPA_SOLVER
if(eh%ph%omm_flavor == 0) then
! Overlap will be destroyed by Cholesky
if(.not. allocated(eh%ovlp_cmplx_copy)) then
call elsi_allocate(eh%bh,eh%ovlp_cmplx_copy,eh%bh%n_lrow,&
eh%bh%n_lcol,"ovlp_cmplx_copy",caller)
eh%ovlp_cmplx_copy = ovlp1
end if
end if
end if
select case(eh%ph%solver)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment