Setup data ready for interpolation
subroutine pw90common_wanint_setup
!! Setup data ready for interpolation
use w90_constants, only: dp, cmplx_0
use w90_io, only: io_error, io_file_unit, stdout, seedname
use w90_utility, only: utility_cart_to_frac
use w90_parameters, only: real_lattice, effective_model, num_wann
integer :: ierr, i, j, k, ikpt, ir, file_unit, num_wann_loc
! Find nrpts, the number of points in the Wigner-Seitz cell
!
if (effective_model) then
if (on_root) then
! nrpts is read from file, together with num_wann
file_unit = io_file_unit()
open (file_unit, file=trim(seedname)//'_HH_R.dat', form='formatted', &
status='old', err=101)
read (file_unit, *) !header
read (file_unit, *) num_wann_loc
if (num_wann_loc /= num_wann) &
call io_error('Inconsistent values of num_wann in ' &
//trim(seedname)//'_HH_R.dat and '//trim(seedname)//'.win')
read (file_unit, *) nrpts
close (file_unit)
endif
call comms_bcast(nrpts, 1)
else
call wigner_seitz(count_pts=.true.)
endif
! Now can allocate several arrays
!
allocate (irvec(3, nrpts), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating irvec in pw90common_wanint_setup')
irvec = 0
allocate (crvec(3, nrpts), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating crvec in pw90common_wanint_setup')
crvec = 0.0_dp
allocate (ndegen(nrpts), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating ndegen in pw90common_wanint_setup')
ndegen = 0
!
! Also rpt_origin, so that when effective_model=.true it is not
! passed to get_HH_R without being initialized.
rpt_origin = 0
! If effective_model, this is done in get_HH_R
if (.not. effective_model) then
!
! Set up the lattice vectors on the Wigner-Seitz supercell
! where the Wannier functions live
!
call wigner_seitz(count_pts=.false.)
!
! Convert from reduced to Cartesian coordinates
!
do ir = 1, nrpts
! Note that 'real_lattice' stores the lattice vectors as *rows*
crvec(:, ir) = matmul(transpose(real_lattice), irvec(:, ir))
end do
endif
return
101 call io_error('Error in pw90common_wanint_setup: problem opening file '// &
trim(seedname)//'_HH_R.dat')
end subroutine pw90common_wanint_setup