subroutine w90_wannier90_readwrite_read_pw90spin(settings, spin_moment, spin_decomp, pw90_spin, &
num_elec_per_state, error, comm)
!================================================!
use w90_error, only: w90_error_type
use w90_comms, only: w90_comm_type
implicit none
logical, intent(inout) :: spin_moment ! from pw90_calculation
logical, intent(inout) :: spin_decomp ! from pw90_common
type(pw90_spin_mod_type), intent(inout) :: pw90_spin
integer, intent(in) :: num_elec_per_state
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
logical :: found
call w90_readwrite_get_keyword(settings, 'spin_moment', found, error, comm, l_value=spin_moment)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'spin_axis_polar', found, error, comm, &
r_value=pw90_spin%axis_polar)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'spin_axis_azimuth', found, error, comm, &
r_value=pw90_spin%axis_azimuth)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'spin_decomp', found, error, comm, l_value=spin_decomp)
if (allocated(error)) return
if (spin_decomp .and. (num_elec_per_state .ne. 1)) then
call set_error_input(error, 'spin_decomp can be true only if num_elec_per_state is 1', comm)
return
end if
end subroutine w90_wannier90_readwrite_read_pw90spin