subroutine gyrotropic_outprint_tensor_w(file_unit, omega, arr33N, arrN, symmetrize)
use w90_parameters, only: nfermi, fermi_energy_list
integer, intent(in) :: file_unit
real(kind=dp), intent(in) :: omega
real(kind=dp), dimension(:, :, :), optional, intent(in) :: arr33N
real(kind=dp), dimension(:), optional, intent(in) :: arrN
! symmetrize= True - get symmetric and assimetric parts
! symmetrize= False - write the asymmetric (in xy) tensor gamma_{xyz}
! symmetrize not present - write as is
logical, optional, intent(in) :: symmetrize
real(kind=dp) :: xx(nfermi), yy(nfermi), zz(nfermi), &
xy(nfermi), xz(nfermi), yz(nfermi), &
x(nfermi), y(nfermi), z(nfermi)
integer :: i
logical lsym
if (present(arr33N)) then
lsym = .false.
if (present(symmetrize)) lsym = symmetrize
if (lsym) then
! Symmetric part
xx = arr33N(1, 1, :)
yy = arr33N(2, 2, :)
zz = arr33N(3, 3, :)
xy = (arr33N(1, 2, :) + arr33N(2, 1, :))/2.0_dp
xz = (arr33N(1, 3, :) + arr33N(3, 1, :))/2.0_dp
yz = (arr33N(2, 3, :) + arr33N(3, 2, :))/2.0_dp
! Antisymmetric part, in polar-vector form
x = (arr33N(2, 3, :) - arr33N(3, 2, :))/2.0_dp
y = (arr33N(3, 1, :) - arr33N(1, 3, :))/2.0_dp
z = (arr33N(1, 2, :) - arr33N(2, 1, :))/2.0_dp
else
xx = arr33N(1, 1, :)
yy = arr33N(2, 2, :)
zz = arr33N(3, 3, :)
xy = arr33N(1, 2, :)
xz = arr33N(1, 3, :)
yz = arr33N(2, 3, :)
x = arr33N(3, 2, :)
y = arr33N(3, 1, :)
z = arr33N(2, 1, :)
endif
if (present(symmetrize)) then
if (symmetrize) then
write (file_unit, '(a1,29x,a1,38x,a14,37x,a2,14x,a15,14x,a1)') '#', "|", "symmetric part", "||", "asymmetric part", "|"
write (file_unit, '(11a15)') '# EFERMI(eV)', "omega(eV)", 'xx', 'yy', 'zz', 'xy', 'xz', 'yz', 'x', 'y', 'z'
else
write (file_unit, '(11a15)') '# EFERMI(eV)', "omega(eV)", 'yzx', 'zxy', 'xyz', 'yzy', 'yzz', 'zxz', 'xyy', 'yzz', 'zxx'
endif
else
write (file_unit, '(11a15)') '# EFERMI(eV)', "omega(eV)", 'xx', 'yy', 'zz', 'xy', 'xz', 'yz', 'zy', 'xz', 'yx'
endif
do i = 1, nfermi
write (file_unit, '(11E15.6)') fermi_energy_list(i), omega, xx(i), yy(i), zz(i), xy(i), xz(i), yz(i), x(i), y(i), z(i)
enddo
endif
if (present(arrN)) then
write (file_unit, '(2a15)') '# EFERMI(eV) '
do i = 1, nfermi
write (file_unit, '(11E15.6)') fermi_energy_list(i), arrN(i)
enddo
endif
write (file_unit, *)
write (file_unit, *)
end subroutine gyrotropic_outprint_tensor_w