subroutine tran_write_xyz(atom_data, transport, wannier_centres_translated, tran_sorted_idx, &
num_wann, seedname, stdout)
!================================================!
!
! Write xyz file with Wannier centres
! and atomic positions
!
!================================================!
use w90_io, only: io_date
use w90_types, only: atom_data_type
use w90_wannier90_types, only: transport_type
implicit none
! arguments
type(transport_type), intent(inout) :: transport
type(atom_data_type), intent(in) :: atom_data
integer, intent(in) :: tran_sorted_idx(:)
integer, intent(in) :: num_wann
integer, intent(in) :: stdout
real(kind=dp), intent(in) :: wannier_centres_translated(:, :)
character(len=50), intent(in) :: seedname
! local variables
integer :: iw, ind, xyz_unit, nat, nsp
character(len=9) :: cdate, ctime
real(kind=dp) :: wc(3, num_wann)
if (index(transport%mode, 'bulk') > 0) wc = wannier_centres_translated
if (index(transport%mode, 'lcr') > 0) then
do iw = 1, num_wann
wc(:, iw) = wannier_centres_translated(:, tran_sorted_idx(iw))
end do
end if
open (newunit=xyz_unit, file=trim(seedname)//'_centres.xyz', form='formatted')
write (xyz_unit, '(i6)') num_wann + atom_data%num_atoms
call io_date(cdate, ctime)
write (xyz_unit, '(a84)') 'Wannier centres and atomic positions, written by Wannier90 on '//cdate//' at '//ctime
do iw = 1, num_wann
write (xyz_unit, '("X",6x,3(f14.8,3x))') (wc(ind, iw), ind=1, 3)
end do
do nsp = 1, atom_data%num_species
do nat = 1, atom_data%species_num(nsp)
write (xyz_unit, '(a2,5x,3(f14.8,3x))') atom_data%symbol(nsp), atom_data%pos_cart(:, nat, nsp)
end do
end do
write (stdout, *) ' Wannier centres written to file '//trim(seedname)//'_centres.xyz'
return
end subroutine tran_write_xyz