subroutine w90_wannier90_readwrite_read_dos(settings, pw90_calculation, pw90_dos, &
found_fermi_energy, num_wann, pw90_smearing, &
dos_plot, error, comm)
!================================================!
use w90_error, only: w90_error_type
use w90_comms, only: w90_comm_type
implicit none
type(pw90_calculation_type), intent(in) :: pw90_calculation
type(pw90_dos_mod_type), intent(inout) :: pw90_dos
type(pw90_smearing_type), intent(in) :: pw90_smearing
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
integer, intent(in) :: num_wann
logical, intent(out) :: dos_plot
logical, intent(in) :: found_fermi_energy
integer :: i, ierr
logical :: found
character(len=maxlen) :: ctmp
if (pw90_calculation%dos) then
dos_plot = .true.
else
dos_plot = .false.
end if
call w90_readwrite_get_keyword(settings, 'dos_task', found, error, comm, c_value=pw90_dos%task)
if (allocated(error)) return
if (pw90_calculation%dos) then
if (index(pw90_dos%task, 'dos_plot') == 0 .and. &
index(pw90_dos%task, 'find_fermi_energy') == 0) then
call set_error_input(error, 'Error: value of dos_task not recognised in w90_wannier90_readwrite_read', comm)
return
end if
if (index(pw90_dos%task, 'dos_plot') > 0) dos_plot = .true.
if (index(pw90_dos%task, 'find_fermi_energy') > 0 .and. found_fermi_energy) then
call set_error_input(error, 'Error: Cannot set "dos_task = find_fermi_energy" and give a value to "fermi_energy"', comm)
return
end if
end if
! sigma_abc_onlyorb=.false.
! call w90_readwrite_get_keyword(settings, 'sigma_abc_onlyorb',found,l_value=sigma_abc_onlyorb)
! -------------------------------------------------------------------
!IVO_END
call w90_readwrite_get_keyword(settings, 'dos_energy_step', found, error, comm, &
r_value=pw90_dos%energy_step)
if (allocated(error)) return
pw90_dos%smearing%use_adaptive = pw90_smearing%use_adaptive
call w90_readwrite_get_keyword(settings, 'dos_adpt_smr', found, error, comm, &
l_value=pw90_dos%smearing%use_adaptive)
if (allocated(error)) return
pw90_dos%smearing%adaptive_prefactor = pw90_smearing%adaptive_prefactor
call w90_readwrite_get_keyword(settings, 'dos_adpt_smr_fac', found, error, comm, &
r_value=pw90_dos%smearing%adaptive_prefactor)
if (allocated(error)) return
if (found .and. (pw90_dos%smearing%adaptive_prefactor <= 0._dp)) then
call set_error_input(error, 'Error: dos_adpt_smr_fac must be greater than zero', comm)
return
end if
pw90_dos%smearing%adaptive_max_width = pw90_smearing%adaptive_max_width
call w90_readwrite_get_keyword(settings, 'dos_adpt_smr_max', found, error, comm, &
r_value=pw90_dos%smearing%adaptive_max_width)
if (allocated(error)) return
if (pw90_dos%smearing%adaptive_max_width <= 0._dp) then
call set_error_input(error, 'Error: dos_adpt_smr_max must be greater than zero', comm)
return
end if
pw90_dos%smearing%fixed_width = pw90_smearing%fixed_width
call w90_readwrite_get_keyword(settings, 'dos_smr_fixed_en_width', found, error, comm, &
r_value=pw90_dos%smearing%fixed_width)
if (allocated(error)) return
if (found .and. (pw90_dos%smearing%fixed_width < 0._dp)) then
call set_error_input(error, 'Error: dos_smr_fixed_en_width must be greater than or equal to zero', comm)
return
end if
! dos_gaussian_width = 0.1_dp
! call w90_readwrite_get_keyword(settings, 'dos_gaussian_width',found,r_value=dos_gaussian_width)
! dos_plot_format = 'gnuplot'
! call w90_readwrite_get_keyword(settings, 'dos_plot_format',found,c_value=dos_plot_format)
call w90_readwrite_get_range_vector(settings, 'dos_project', found, pw90_dos%num_project, &
.true., error, comm)
if (allocated(error)) return
if (found) then
if (pw90_dos%num_project < 1) then
call set_error_input(error, 'Error: problem reading dos_project', comm)
return
end if
if (allocated(pw90_dos%project)) deallocate (pw90_dos%project)
allocate (pw90_dos%project(pw90_dos%num_project), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating dos_project in w90_wannier90_readwrite_read', comm)
return
end if
call w90_readwrite_get_range_vector(settings, 'dos_project', found, pw90_dos%num_project, &
.false., error, comm, pw90_dos%project)
if (allocated(error)) return
if (any(pw90_dos%project < 1) .or. &
any(pw90_dos%project > num_wann)) then
call set_error_input(error, 'Error: dos_project asks for out-of-range Wannier functions', comm)
return
end if
else
! by default plot all
pw90_dos%num_project = num_wann
if (allocated(pw90_dos%project)) deallocate (pw90_dos%project)
allocate (pw90_dos%project(pw90_dos%num_project), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating dos_project in w90_wannier90_readwrite_read', comm)
return
end if
do i = 1, pw90_dos%num_project
pw90_dos%project(i) = i
end do
end if
! By default: use the "global" smearing index
pw90_dos%smearing%type_index = pw90_smearing%type_index
call w90_readwrite_get_keyword(settings, 'dos_smr_type', found, error, comm, c_value=ctmp)
if (allocated(error)) return
if (found) then
pw90_dos%smearing%type_index = w90_readwrite_get_smearing_index(ctmp, 'dos_smr_type', &
error, comm)
if (allocated(error)) return
end if
end subroutine w90_wannier90_readwrite_read_dos