subroutine wann_calc_projection()
!==================================================================!
! !
! Calculates and writes the projection of each Wannier function !
! on the original bands within the outer window. !
! !
!==================================================================!
use w90_parameters, only: num_bands, num_wann, num_kpts, &
u_matrix_opt, eigval, lwindow, timing_level
use w90_io, only: stdout, io_stopwatch
implicit none
integer :: nw, nb, nkp, counter
real(kind=dp) :: summ
if (timing_level > 1 .and. on_root) call io_stopwatch('wann: calc_projection', 1)
if (on_root) then
write (stdout, '(/1x,a78)') repeat('-', 78)
write (stdout, '(1x,9x,a)') &
'Projection of Bands in Outer Window on all Wannier Functions'
write (stdout, '(1x,8x,62a)') repeat('-', 62)
write (stdout, '(1x,16x,a)') ' Kpt Band Eigval |Projection|^2'
write (stdout, '(1x,16x,a47)') repeat('-', 47)
endif
do nkp = 1, num_kpts
counter = 0
do nb = 1, num_bands
if (lwindow(nb, nkp)) then
counter = counter + 1
summ = 0.0_dp
do nw = 1, num_wann
summ = summ + abs(u_matrix_opt(counter, nw, nkp))**2
enddo
if (on_root) write (stdout, '(1x,16x,i5,1x,i5,1x,f14.6,2x,f14.8)') &
nkp, nb, eigval(nb, nkp), summ
endif
enddo
enddo
if (on_root) write (stdout, '(1x,a78/)') repeat('-', 78)
if (timing_level > 1 .and. on_root) call io_stopwatch('wann: calc_projection', 2)
return
end subroutine wann_calc_projection