Commit cf975b82 authored by Victor Yu's avatar Victor Yu

Add elsi_set_coo for GENERIC_COO initialization

parent f665dcf0
......@@ -54,6 +54,12 @@ void c_elsi_set_csc(elsi_handle handle_c,
int *row_ind,
int *col_ptr);
void c_elsi_set_coo(elsi_handle handle_c,
int nnz,
int nnz_l,
int *row_ind,
int *col_ind);
void c_elsi_reinit(elsi_handle handle_c);
void c_elsi_finalize(elsi_handle handle_c);
......
......@@ -197,6 +197,25 @@ subroutine elsi_set_csc_c_wrapper(h_c,nnz_g,nnz_l,n_lcol,row_ind,col_ptr)&
end subroutine
subroutine elsi_set_coo_c_wrapper(h_c,nnz_g,nnz_l,row_ind,col_ind)&
bind(C,name="c_elsi_set_coo")
implicit none
type(c_ptr), value, intent(in) :: h_c
integer(kind=c_int), value, intent(in) :: nnz_g
integer(kind=c_int), value, intent(in) :: nnz_l
integer(kind=c_int), intent(in) :: row_ind(nnz_l)
integer(kind=c_int), intent(in) :: col_ind(nnz_l)
type(elsi_handle), pointer :: h_f
call c_f_pointer(h_c,h_f)
call elsi_set_coo(h_f,nnz_g,nnz_l,row_ind,col_ind)
end subroutine
subroutine elsi_reinit_c_wrapper(h_c)&
bind(C,name="c_elsi_reinit")
......
......@@ -34,6 +34,7 @@ module ELSI
public :: elsi_set_kpoint
public :: elsi_set_blacs
public :: elsi_set_csc
public :: elsi_set_coo
public :: elsi_reinit
public :: elsi_finalize
......
......@@ -34,6 +34,7 @@ module ELSI_SETUP
public :: elsi_set_kpoint
public :: elsi_set_blacs
public :: elsi_set_csc
public :: elsi_set_coo
public :: elsi_reinit
public :: elsi_finalize
public :: elsi_cleanup
......@@ -41,9 +42,9 @@ module ELSI_SETUP
contains
!>
!! This routine initializes ELSI with the solver, parallel mode, matrix storage
!! format, number of basis functions (global size of the Hamiltonian matrix),
!! number of electrons, and number of states.
!! This routine initializes ELSI with user's choice of solver, parallel mode,
!! matrix format, number of basis functions (global size of Hamiltonian), number
!! of electrons, and number of states.
!!
subroutine elsi_init(eh,solver,parallel_mode,matrix_format,n_basis,n_electron,&
n_state)
......@@ -94,7 +95,8 @@ subroutine elsi_init(eh,solver,parallel_mode,matrix_format,n_basis,n_electron,&
end subroutine
!>
!! This routine sets the unit MPI communicator.
!! This routine sets the MPI communicator to be used to solve one eigenproblem
!! (i.e., one spin channel, one k-point).
!!
subroutine elsi_set_mpi(eh,comm)
......@@ -121,7 +123,8 @@ subroutine elsi_set_mpi(eh,comm)
end subroutine
!>
!! This routine sets the global MPI communicator.
!! This routine sets the global MPI communicator to be used to exchange
!! information across all spin channels and k-points.
!!
subroutine elsi_set_mpi_global(eh,comm_all)
......@@ -148,7 +151,8 @@ subroutine elsi_set_mpi_global(eh,comm_all)
end subroutine
!>
!! This routine sets the spin information.
!! This routine sets the number of spin channels and the index of the spin
!! channel the calling process is solving.
!!
subroutine elsi_set_spin(eh,n_spin,i_spin)
......@@ -164,7 +168,8 @@ subroutine elsi_set_spin(eh,n_spin,i_spin)
end subroutine
!>
!! This routine sets the k-point information.
!! This routine sets the number of k-points, and the index and weight of the
!! k-point the calling process is solving.
!!
subroutine elsi_set_kpoint(eh,n_kpt,i_kpt,i_wt)
......@@ -182,7 +187,8 @@ subroutine elsi_set_kpoint(eh,n_kpt,i_kpt,i_wt)
end subroutine
!>
!! This routine sets the BLACS context and the block size.
!! This routine sets the BLACS context and block size, necessary for the
!! BLACS_DENSE matrix format.
!!
subroutine elsi_set_blacs(eh,blacs_ctxt,block_size)
......@@ -246,7 +252,11 @@ subroutine elsi_set_blacs(eh,blacs_ctxt,block_size)
end subroutine
!>
!! This routine sets the sparsity pattern.
!! This routine sets the global number of non-zero matrix elements, local number
!! of non-zeros matrix elements, local number of matrix columns, row index
!! array, and column pointer array. These variables are collectively referred to
!! as CSC sparsity pattern, necessary for the PEXSI_CSC and SIESTA_CSC matrix
!! formats.
!!
subroutine elsi_set_csc(eh,nnz_g,nnz_l,n_lcol,row_ind,col_ptr)
......@@ -310,6 +320,48 @@ subroutine elsi_set_csc(eh,nnz_g,nnz_l,n_lcol,row_ind,col_ptr)
end subroutine
!>
!! This routine sets the global number of non-zero matrix elements, local number
!! of non-zeros matrix elements, row index array, and column index array. These
!! variables are collectively referred to as COO sparsity pattern, necessary for
!! the GENERIC_COO matrix format.
!!
subroutine elsi_set_coo(eh,nnz_g,nnz_l,row_ind,col_ind)
implicit none
type(elsi_handle), intent(inout) :: eh !< Handle
integer(kind=i4), intent(in) :: nnz_g !< Global number of nonzeros
integer(kind=i4), intent(in) :: nnz_l !< Local number of nonzeros
integer(kind=i4), intent(in) :: row_ind(nnz_l) !< Row index
integer(kind=i4), intent(in) :: col_ind(nnz_l) !< Column index
character(len=*), parameter :: caller = "elsi_set_coo"
call elsi_check_init(eh%bh,eh%handle_init,caller)
eh%bh%nnz_g = nnz_g
eh%bh%nnz_l_sp = nnz_l
eh%bh%nnz_l_sp3 = nnz_l
if(allocated(eh%row_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%row_ind_sp3,"row_ind_sp3")
end if
if(allocated(eh%col_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%col_ind_sp3,"col_ind_sp3")
end if
call elsi_allocate(eh%bh,eh%row_ind_sp3,nnz_l,"row_ind_sp3",caller)
call elsi_allocate(eh%bh,eh%col_ind_sp3,nnz_l,"col_ind_sp3",caller)
eh%row_ind_sp3 = row_ind
eh%col_ind_sp3 = col_ind
eh%bh%generic_coo_ready = .true.
end subroutine
!>
!! This routine starts a new geometry step, which usually means a new overlap.
!!
......
......@@ -493,7 +493,6 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,ebs)
integer(kind=i4) :: solver
real(kind=r8) :: t0
logical :: unit_ovlp_save
character(len=29) :: dt0
character(len=*), parameter :: caller = "elsi_dm_real"
......@@ -715,7 +714,6 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,ebs)
if(.not. allocated(eh%ph%nt_ovlp_copy%local_data_r)) then
call elsi_init_ntpoly(eh%ph,eh%bh)
unit_ovlp_save = eh%ph%unit_ovlp
eh%ph%unit_ovlp = .true.
eh%ph%first_blacs_to_ntpoly = .true.
......@@ -727,7 +725,7 @@ subroutine elsi_dm_real(eh,ham,ovlp,dm,ebs)
eh%ph%nt_ovlp_copy,eh%ph%nt_ham)
end if
eh%ph%unit_ovlp = unit_ovlp_save
eh%ph%unit_ovlp = .false.
end if
end if
end if
......@@ -752,7 +750,6 @@ subroutine elsi_dm_complex(eh,ham,ovlp,dm,ebs)
integer(kind=i4) :: solver
real(kind=r8) :: t0
logical :: unit_ovlp_save
character(len=29) :: dt0
character(len=*), parameter :: caller = "elsi_dm_complex"
......@@ -909,7 +906,6 @@ subroutine elsi_dm_complex(eh,ham,ovlp,dm,ebs)
if(.not. allocated(eh%ph%nt_ovlp_copy%local_data_c)) then
call elsi_init_ntpoly(eh%ph,eh%bh)
unit_ovlp_save = eh%ph%unit_ovlp
eh%ph%unit_ovlp = .true.
eh%ph%first_blacs_to_ntpoly = .true.
......@@ -921,7 +917,7 @@ subroutine elsi_dm_complex(eh,ham,ovlp,dm,ebs)
eh%ph%nt_ovlp_copy,eh%ph%nt_ham)
end if
eh%ph%unit_ovlp = unit_ovlp_save
eh%ph%unit_ovlp = .false.
end if
end if
end if
......
......@@ -10,7 +10,7 @@
!!
module ELSI_TOOLS
use ELSI_CONSTANTS, only: ELPA_SOLVER,OMM_SOLVER,SIPS_SOLVER,NTPOLY_SOLVER
use ELSI_CONSTANTS, only: ELPA_SOLVER
use ELSI_DATATYPE, only: elsi_handle
use ELSI_ELPA, only: elsi_update_dm_elpa
use ELSI_MALLOC, only: elsi_allocate
......@@ -18,8 +18,7 @@ module ELSI_TOOLS
use ELSI_OCC, only: elsi_mu_and_occ,elsi_entropy
use ELSI_PRECISION, only: i4,r8
use ELSI_REDIST, only: elsi_blacs_to_ntpoly_hs,elsi_ntpoly_to_blacs_dm
use ELSI_UTILS, only: elsi_check_init,elsi_set_full_mat,elsi_build_dm,&
elsi_build_edm,elsi_gram_schmidt
use ELSI_UTILS, only: elsi_check_init,elsi_gram_schmidt
implicit none
......@@ -83,8 +82,6 @@ subroutine elsi_extrapolate_dm_real(eh,ovlp,dm)
real(kind=r8), intent(inout) :: ovlp(eh%bh%n_lrow,eh%bh%n_lcol) !< New overlap
real(kind=r8), intent(inout) :: dm(eh%bh%n_lrow,eh%bh%n_lcol) !< Density matrix
logical :: unit_ovlp_save
character(len=*), parameter :: caller = "elsi_extrapolate_dm_real"
call elsi_check_init(eh%bh,eh%handle_init,caller)
......@@ -96,7 +93,6 @@ subroutine elsi_extrapolate_dm_real(eh,ovlp,dm)
eh%ovlp_real_copy = ovlp
case default
unit_ovlp_save = eh%ph%unit_ovlp
eh%ph%unit_ovlp = .true.
call elsi_blacs_to_ntpoly_hs(eh%ph,eh%bh,dm,ovlp,eh%ph%nt_ham,eh%ph%nt_dm)
......@@ -106,7 +102,7 @@ subroutine elsi_extrapolate_dm_real(eh,ovlp,dm)
call elsi_blacs_to_ntpoly_hs(eh%ph,eh%bh,ovlp,dm,eh%ph%nt_ovlp,&
eh%ph%nt_dm)
eh%ph%unit_ovlp = unit_ovlp_save
eh%ph%unit_ovlp = .false.
call elsi_update_dm_ntpoly(eh%ph,eh%bh,eh%ph%nt_ovlp_copy,eh%ph%nt_ovlp,&
eh%ph%nt_ham,eh%ph%nt_dm)
......@@ -127,8 +123,6 @@ subroutine elsi_extrapolate_dm_complex(eh,ovlp,dm)
complex(kind=r8), intent(inout) :: ovlp(eh%bh%n_lrow,eh%bh%n_lcol) !< New overlap
complex(kind=r8), intent(inout) :: dm(eh%bh%n_lrow,eh%bh%n_lcol) !< Density matrix
logical :: unit_ovlp_save
character(len=*), parameter :: caller = "elsi_extrapolate_dm_complex"
call elsi_check_init(eh%bh,eh%handle_init,caller)
......@@ -140,7 +134,6 @@ subroutine elsi_extrapolate_dm_complex(eh,ovlp,dm)
eh%ovlp_cmplx_copy = ovlp
case default
unit_ovlp_save = eh%ph%unit_ovlp
eh%ph%unit_ovlp = .true.
call elsi_blacs_to_ntpoly_hs(eh%ph,eh%bh,dm,ovlp,eh%ph%nt_ham,eh%ph%nt_dm)
......@@ -150,7 +143,7 @@ subroutine elsi_extrapolate_dm_complex(eh,ovlp,dm)
call elsi_blacs_to_ntpoly_hs(eh%ph,eh%bh,ovlp,dm,eh%ph%nt_ovlp,&
eh%ph%nt_dm)
eh%ph%unit_ovlp = unit_ovlp_save
eh%ph%unit_ovlp = .false.
call elsi_update_dm_ntpoly(eh%ph,eh%bh,eh%ph%nt_ovlp_copy,eh%ph%nt_ovlp,&
eh%ph%nt_ham,eh%ph%nt_dm)
......
......@@ -333,6 +333,10 @@ subroutine elsi_check(ph,bh,caller)
end if
end if
if(ph%unit_ovlp) then
ph%save_ovlp = .false.
end if
! Specific check for each solver
select case(ph%solver)
case(ELPA_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