w90_wannier90_readwrite_read_wann_plot Subroutine

private subroutine w90_wannier90_readwrite_read_wann_plot(settings, wann_plot, num_wann, wannier_plot, error, comm)

Uses

  • proc~~w90_wannier90_readwrite_read_wann_plot~~UsesGraph proc~w90_wannier90_readwrite_read_wann_plot w90_wannier90_readwrite_read_wann_plot module~w90_error w90_error proc~w90_wannier90_readwrite_read_wann_plot->module~w90_error module~w90_comms w90_comms module~w90_error->module~w90_comms module~w90_error_base w90_error_base module~w90_error->module~w90_error_base module~w90_comms->module~w90_error_base module~w90_constants w90_constants module~w90_comms->module~w90_constants

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
type(wannier_plot_type), intent(inout) :: wann_plot
integer, intent(in) :: num_wann
logical, intent(in) :: wannier_plot
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_wannier90_readwrite_read_wann_plot~~CallsGraph proc~w90_wannier90_readwrite_read_wann_plot w90_wannier90_readwrite_read_wann_plot proc~set_error_alloc set_error_alloc proc~w90_wannier90_readwrite_read_wann_plot->proc~set_error_alloc proc~set_error_dealloc set_error_dealloc proc~w90_wannier90_readwrite_read_wann_plot->proc~set_error_dealloc proc~set_error_input set_error_input proc~w90_wannier90_readwrite_read_wann_plot->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_wannier90_readwrite_read_wann_plot->proc~w90_readwrite_get_keyword proc~w90_readwrite_get_keyword_vector w90_readwrite_get_keyword_vector proc~w90_wannier90_readwrite_read_wann_plot->proc~w90_readwrite_get_keyword_vector proc~w90_readwrite_get_range_vector w90_readwrite_get_range_vector proc~w90_wannier90_readwrite_read_wann_plot->proc~w90_readwrite_get_range_vector proc~w90_readwrite_get_vector_length w90_readwrite_get_vector_length proc~w90_wannier90_readwrite_read_wann_plot->proc~w90_readwrite_get_vector_length proc~comms_sync_error comms_sync_error proc~set_error_alloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_alloc->proc~set_base_error proc~set_error_dealloc->proc~comms_sync_error proc~set_error_dealloc->proc~set_base_error proc~set_error_input->proc~comms_sync_error proc~set_error_input->proc~set_base_error proc~w90_readwrite_get_keyword->proc~set_error_input proc~set_error_fatal set_error_fatal proc~w90_readwrite_get_keyword->proc~set_error_fatal proc~w90_readwrite_get_keyword_vector->proc~set_error_input proc~w90_readwrite_get_keyword_vector->proc~set_error_fatal proc~w90_readwrite_get_range_vector->proc~set_error_input proc~w90_readwrite_get_range_vector->proc~w90_readwrite_get_keyword_vector proc~w90_readwrite_get_range_vector->proc~w90_readwrite_get_vector_length proc~w90_readwrite_get_vector_length->proc~set_error_input proc~w90_readwrite_get_vector_length->proc~set_error_fatal proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~w90_wannier90_readwrite_read_wann_plot~~CalledByGraph proc~w90_wannier90_readwrite_read_wann_plot w90_wannier90_readwrite_read_wann_plot proc~w90_wannier90_readwrite_read w90_wannier90_readwrite_read proc~w90_wannier90_readwrite_read->proc~w90_wannier90_readwrite_read_wann_plot proc~w90_input_reader~2 w90_input_reader proc~w90_input_reader~2->proc~w90_wannier90_readwrite_read proc~w90_input_setopt w90_input_setopt proc~w90_input_setopt->proc~w90_wannier90_readwrite_read proc~w90_input_reader w90_input_reader proc~w90_input_reader->proc~w90_input_reader~2 proc~w90_input_setopt_f w90_input_setopt_f proc~w90_input_setopt_f->proc~w90_input_setopt program~wannier wannier program~wannier->proc~w90_input_reader~2

Source Code

  subroutine w90_wannier90_readwrite_read_wann_plot(settings, wann_plot, num_wann, wannier_plot, &
                                                    error, comm)
    !================================================!
    ! Plotting
    !================================================!
    use w90_error, only: w90_error_type
    implicit none

    integer, intent(in) :: num_wann
    logical, intent(in) :: wannier_plot
    type(settings_type), intent(inout) :: settings
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error
    type(wannier_plot_type), intent(inout) :: wann_plot

    integer :: i, loop, ierr, wann_plot_num
    logical :: found

    found = .false.

    call w90_readwrite_get_vector_length(settings, 'wannier_plot_supercell', found, i, error, comm)
    if (allocated(error)) return

    if (found) then
      if (i .eq. 1) then
        call w90_readwrite_get_keyword_vector(settings, 'wannier_plot_supercell', found, 1, error, comm, &
                                              i_value=wann_plot%supercell)
        if (allocated(error)) return

        wann_plot%supercell(2) = wann_plot%supercell(1)
        wann_plot%supercell(3) = wann_plot%supercell(1)
      elseif (i .eq. 3) then
        call w90_readwrite_get_keyword_vector(settings, 'wannier_plot_supercell', found, 3, error, comm, &
                                              i_value=wann_plot%supercell)
        if (allocated(error)) return

      else
        call set_error_input(error, 'Error: wannier_plot_supercell must be provided as either' &
                             //'one integer or a vector of three integers', comm)
        return
      end if
      if (any(wann_plot%supercell <= 0)) then
        call set_error_input(error, 'Error: wannier_plot_supercell elements must be greater than zero', comm)
        return
      end if
    end if

    call w90_readwrite_get_keyword(settings, 'wannier_plot_format', found, error, comm, c_value=wann_plot%format)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'wannier_plot_mode', found, error, comm, c_value=wann_plot%mode)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'wannier_plot_spinor_mode', found, error, comm, &
                                   c_value=wann_plot%spinor_mode)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'wannier_plot_spinor_phase', found, error, comm, &
                                   l_value=wann_plot%spinor_phase)
    if (allocated(error)) return

    wann_plot_num = 0
    call w90_readwrite_get_range_vector(settings, 'wannier_plot_list', found, wann_plot_num, .true., error, comm)
    if (allocated(error)) return
    if (found) then
      if (wann_plot_num < 1) then
        call set_error_input(error, 'Error: problem reading wannier_plot_list', comm)
        return
      end if
      if (allocated(wann_plot%list)) then
        deallocate (wann_plot%list, stat=ierr)
        if (ierr /= 0) then
          call set_error_dealloc(error, 'Error deallocating wannier_plot%list in w90_wannier90_readwrite_read', comm)
          return
        end if
      end if
      allocate (wann_plot%list(wann_plot_num), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating wannier_plot%list in w90_wannier90_readwrite_read', comm)
        return
      end if
      call w90_readwrite_get_range_vector(settings, 'wannier_plot_list', found, wann_plot_num, .false., &
                                          error, comm, wann_plot%list)
      if (allocated(error)) return
      if (any(wann_plot%list < 1) .or. any(wann_plot%list > num_wann)) then
        call set_error_input(error, 'Error: wannier_plot_list asks for a non-valid wannier function to be plotted', comm)
        return
      end if
    else
      ! we plot all wannier functions
      wann_plot_num = num_wann
      if (allocated(wann_plot%list)) then
        deallocate (wann_plot%list, stat=ierr)
        if (ierr /= 0) then
          call set_error_dealloc(error, 'Error deallocating wannier_plot%list &
          & in w90_wannier90_readwrite_read_wann_plot', comm)
          return
        end if
      end if
      allocate (wann_plot%list(wann_plot_num), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating wannier_plot%list in w90_wannier90_readwrite_read_wann_plot', comm)
        return
      end if
      do loop = 1, num_wann
        wann_plot%list(loop) = loop
      end do
    end if

    call w90_readwrite_get_keyword(settings, 'wannier_plot_radius', found, error, comm, r_value=wann_plot%radius)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'wannier_plot_scale', found, error, comm, r_value=wann_plot%scale)
    if (allocated(error)) return

    ! checks
    if (wannier_plot) then
      if ((index(wann_plot%format, 'xcrys') .eq. 0) .and. (index(wann_plot%format, 'cub') .eq. 0)) then
        call set_error_input(error, 'Error: wannier_plot_format not recognised', comm)
        return
      end if
      if ((index(wann_plot%mode, 'crys') .eq. 0) .and. (index(wann_plot%mode, 'mol') .eq. 0)) then
        call set_error_input(error, 'Error: wannier_plot_mode not recognised', comm)
        return
      end if
      if ((index(wann_plot%spinor_mode, 'total') .eq. 0) &
          .and. (index(wann_plot%spinor_mode, 'up') .eq. 0) &
          .and. (index(wann_plot%spinor_mode, 'down') .eq. 0)) then
        call set_error_input(error, 'Error: wannier_plot_spinor_mode not recognised', comm)
        return
      end if
      if (wann_plot%radius < 0.0_dp) then
        call set_error_input(error, 'Error: wannier_plot_radius must be positive', comm)
        return
      end if
      if (wann_plot%scale < 0.0_dp) then
        call set_error_input(error, 'Error: wannier_plot_scale must be positive', comm)
        return
      end if
    end if

  end subroutine w90_wannier90_readwrite_read_wann_plot