subroutine sitesym_read()
!==================================================================!
use w90_parameters, only: num_bands, num_wann, num_kpts
use w90_io, only: io_file_unit, io_error, seedname
implicit none
integer :: iu, ibnum, iknum, ierr
iu = io_file_unit()
open (unit=iu, file=trim(seedname)//".dmn", form='formatted', status='old', action='read')
read (iu, *)
read (iu, *) ibnum, nsymmetry, nkptirr, iknum
if (ibnum .ne. num_bands) call io_error("Error: Number of bands is not correct (sitesym_read)")
if (iknum .ne. num_kpts) call io_error("Error: Number of k-points is not correct (sitesym_read)")
allocate (ik2ir(num_kpts), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating ik2ir in sitesym_read')
allocate (ir2ik(nkptirr), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating ir2ik in sitesym_read')
allocate (kptsym(nsymmetry, nkptirr), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating kptsym in sitesym_read')
allocate (d_matrix_band(num_bands, num_bands, nsymmetry, nkptirr), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating d_matrix_band in sitesym_read')
allocate (d_matrix_wann(num_wann, num_wann, nsymmetry, nkptirr), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating d_matrix_wann in sitesym_read')
read (iu, *) ik2ir
read (iu, *) ir2ik
read (iu, *) kptsym
read (iu, *) d_matrix_wann
read (iu, *) d_matrix_band
close (iu)
return
end subroutine sitesym_read