w90_readwrite_read_dis_manifold Subroutine

public subroutine w90_readwrite_read_dis_manifold(settings, dis_manifold, error, comm)

Uses

  • proc~~w90_readwrite_read_dis_manifold~~UsesGraph proc~w90_readwrite_read_dis_manifold w90_readwrite_read_dis_manifold module~w90_error w90_error proc~w90_readwrite_read_dis_manifold->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

Reads disentanglement windows "dis_win_min" and "dis_win_max" (both are optional) Reads frozen window "dis_froz_min" and "dis_froz_max" (either neither or both to be supplied)

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
type(dis_manifold_type), intent(inout) :: dis_manifold
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_read_dis_manifold~~CallsGraph proc~w90_readwrite_read_dis_manifold w90_readwrite_read_dis_manifold proc~set_error_input set_error_input proc~w90_readwrite_read_dis_manifold->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_readwrite_read_dis_manifold->proc~w90_readwrite_get_keyword proc~comms_sync_error comms_sync_error proc~set_error_input->proc~comms_sync_error proc~set_base_error set_base_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~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~w90_readwrite_read_dis_manifold~~CalledByGraph proc~w90_readwrite_read_dis_manifold w90_readwrite_read_dis_manifold proc~w90_postw90_readwrite_read w90_postw90_readwrite_read proc~w90_postw90_readwrite_read->proc~w90_readwrite_read_dis_manifold proc~w90_wannier90_readwrite_read w90_wannier90_readwrite_read proc~w90_wannier90_readwrite_read->proc~w90_readwrite_read_dis_manifold 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 program~postw90 postw90 program~postw90->proc~w90_postw90_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_readwrite_read_dis_manifold(settings, dis_manifold, error, comm)
    !! Reads disentanglement windows "dis_win_min" and "dis_win_max" (both are optional)
    !! Reads frozen window "dis_froz_min" and "dis_froz_max" (either neither or both to be supplied)
    use w90_error, only: w90_error_type, set_error_input
    implicit none

    ! arguments
    type(dis_manifold_type), intent(inout) :: dis_manifold
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm
    type(settings_type), intent(inout) :: settings

    ! local
    logical :: found, found2
    logical :: found_proj_min, found_proj_max, found_proj_auto, found_num_classes

    call w90_readwrite_get_keyword(settings, 'dis_win_min', found, error, comm, &
                                   r_value=dis_manifold%win_min)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'dis_win_max', found, error, comm, &
                                   r_value=dis_manifold%win_max)
    if (allocated(error)) return

    if (dis_manifold%win_max .lt. dis_manifold%win_min) then
      call set_error_input(error, &
                           'Error: w90_readwrite_read_dis_manifold: check disentanglement windows (win_max < win_min !)', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'dis_froz_max', found, error, comm, &
                                   r_value=dis_manifold%froz_max)
    if (allocated(error)) return

    if (found) dis_manifold%frozen_states = .true.

    call w90_readwrite_get_keyword(settings, 'dis_froz_min', found2, error, comm, &
                                   r_value=dis_manifold%froz_min)
    if (allocated(error)) return

    if (dis_manifold%froz_max .lt. dis_manifold%froz_min) then
      call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: check disentanglement frozen windows', comm)
      return
    end if
    if (found2 .and. .not. found) then
      call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: found dis_froz_min but not dis_froz_max', comm)
      return
    end if

    ! ndimwin/lwindow are not read

    ! default not using projectability disentanglement, since it works the best
    ! with AMN generated from pseudo-atomic projections.
    ! However, here upon reading AMN we do not know where it comes from.
    ! So we still use energy disentanglement by default.
    dis_manifold%frozen_proj = .false.
    call w90_readwrite_get_keyword(settings, 'dis_froz_proj', found, error, comm, &
                                   l_value=dis_manifold%frozen_proj)
    if (allocated(error)) return

    ! proj_min/proj_max have no defaults: they are set explicitly or determined
    ! automatically (dis_proj_auto, on by default)
    call w90_readwrite_get_keyword(settings, 'dis_proj_min', found_proj_min, error, comm, &
                                   r_value=dis_manifold%proj_min)
    if (allocated(error)) return
    if (found_proj_min) then
      if ((dis_manifold%proj_min < 0.0_dp) .or. (dis_manifold%proj_min > 1.0_dp)) then
        call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: dis_proj_min < 0.0 or > 1.0', comm)
        return
      end if
    end if
    call w90_readwrite_get_keyword(settings, 'dis_proj_max', found_proj_max, error, comm, &
                                   r_value=dis_manifold%proj_max)
    if (allocated(error)) return
    if (found_proj_max) then
      if ((dis_manifold%proj_max < 0.0_dp) .or. (dis_manifold%proj_max > 1.0_dp)) then
        call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: dis_proj_max < 0.0 or > 1.0', comm)
        return
      end if
    end if
    if (found_proj_min .and. found_proj_max) then
      if (dis_manifold%proj_max < dis_manifold%proj_min) then
        call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: dis_proj_max < dis_proj_min', comm)
        return
      end if
    end if
    call w90_readwrite_get_keyword(settings, 'dis_proj_auto', found_proj_auto, error, comm, &
                                   l_value=dis_manifold%proj_auto)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'dis_proj_auto_num_classes', found_num_classes, error, comm, &
                                   i_value=dis_manifold%proj_auto_num_classes)
    if (allocated(error)) return
    if (found_proj_min .or. found_proj_max) then
      ! explicit thresholds take precedence over the defaulted dis_proj_auto,
      ! but contradict an explicit dis_proj_auto = .true.
      if (found_proj_auto .and. dis_manifold%proj_auto) then
        call set_error_input(error, 'Error: dis_proj_auto = .true. is incompatible with '// &
                             'explicit dis_proj_min/dis_proj_max', comm)
        return
      end if
      dis_manifold%proj_auto = .false.
    end if
    if (found_num_classes .and. .not. dis_manifold%proj_auto) then
      call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: '// &
                           'dis_proj_auto_num_classes set but automatic thresholds are disabled', comm)
      return
    end if
    if (dis_manifold%proj_auto) then
      if (dis_manifold%proj_auto_num_classes < 3) then
        call set_error_input(error, 'Error: dis_proj_auto_num_classes must be >= 3', comm)
        return
      end if
      if (dis_manifold%proj_auto_num_classes > 8) then
        ! Exhaustive threshold search enumerates C(nbins-1, classes-1) tuples
        ! (nbins = 64), which explodes past classes = 8 (~5.5e8) -> classes = 9
        ! (~3.9e9); the cap bounds the worst-case cost.
        call set_error_input(error, 'Error: dis_proj_auto_num_classes must be <= 8; '// &
                             'reduce it or set dis_proj_min/max', comm)
        return
      end if
    end if
    if (dis_manifold%frozen_proj) then
      if (found_proj_min .and. .not. found_proj_max) then
        call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: '// &
                             'found dis_proj_min but not dis_proj_max', comm)
        return
      end if
      if (found_proj_max .and. .not. found_proj_min) then
        call set_error_input(error, 'Error: w90_readwrite_read_dis_manifold: '// &
                             'found dis_proj_max but not dis_proj_min', comm)
        return
      end if
      if (.not. dis_manifold%proj_auto .and. .not. found_proj_min) then
        call set_error_input(error, 'Error: dis_froz_proj with dis_proj_auto = .false. '// &
                             'requires explicit dis_proj_min/dis_proj_max', comm)
        return
      end if
    end if
  end subroutine w90_readwrite_read_dis_manifold