Write the Hamiltonian in the WF basis
subroutine hamiltonian_write_hr()
!============================================!
!! Write the Hamiltonian in the WF basis
!============================================!
use w90_io, only: io_error, io_stopwatch, io_file_unit, &
seedname, io_date
use w90_parameters, only: num_wann, timing_level
integer :: i, j, irpt, file_unit
character(len=33) :: header
character(len=9) :: cdate, ctime
if (hr_written) return
if (timing_level > 1) call io_stopwatch('hamiltonian: write_hr', 1)
! write the whole matrix with all the indices
file_unit = io_file_unit()
open (file_unit, file=trim(seedname)//'_hr.dat', form='formatted', &
status='unknown', err=101)
call io_date(cdate, ctime)
header = 'written on '//cdate//' at '//ctime
write (file_unit, *) header ! Date and time
write (file_unit, *) num_wann
write (file_unit, *) nrpts
write (file_unit, '(15I5)') (ndegen(i), i=1, nrpts)
do irpt = 1, nrpts
do i = 1, num_wann
do j = 1, num_wann
write (file_unit, '(5I5,2F12.6)') irvec(:, irpt), j, i, &
ham_r(j, i, irpt)
end do
end do
end do
close (file_unit)
hr_written = .true.
if (timing_level > 1) call io_stopwatch('hamiltonian: write_hr', 2)
return
101 call io_error('Error: hamiltonian_write_hr: problem opening file '//trim(seedname)//'_hr.dat')
end subroutine hamiltonian_write_hr