pw90common_wanint_setup Subroutine

public subroutine pw90common_wanint_setup(num_wann, print_output, real_lattice, mp_grid, ws_region, ws_distance, effective_model, wigner_seitz, wannier_data, stdout, seedname, timer, error, comm)

Uses

  • proc~~pw90common_wanint_setup~~UsesGraph proc~pw90common_wanint_setup pw90common_wanint_setup module~w90_comms w90_comms proc~pw90common_wanint_setup->module~w90_comms module~w90_constants w90_constants proc~pw90common_wanint_setup->module~w90_constants module~w90_io w90_io proc~pw90common_wanint_setup->module~w90_io module~w90_postw90_types w90_postw90_types proc~pw90common_wanint_setup->module~w90_postw90_types module~w90_types w90_types proc~pw90common_wanint_setup->module~w90_types module~w90_ws_distance w90_ws_distance proc~pw90common_wanint_setup->module~w90_ws_distance module~w90_comms->module~w90_constants module~w90_error_base w90_error_base module~w90_comms->module~w90_error_base module~w90_io->module~w90_constants module~w90_postw90_types->module~w90_comms module~w90_postw90_types->module~w90_constants module~w90_types->module~w90_constants module~w90_ws_distance->module~w90_constants module~w90_error w90_error module~w90_ws_distance->module~w90_error module~w90_error->module~w90_comms module~w90_error->module~w90_error_base

Setup data ready for interpolation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: num_wann
type(print_output_type), intent(in) :: print_output
real(kind=dp), intent(in) :: real_lattice(3,3)
integer, intent(in) :: mp_grid(3)
type(ws_region_type), intent(in) :: ws_region
type(ws_distance_type), intent(inout) :: ws_distance
logical, intent(in) :: effective_model
type(wigner_seitz_type), intent(inout) :: wigner_seitz
type(wannier_data_type), intent(in) :: wannier_data
integer, intent(in) :: stdout
character(len=50), intent(in) :: seedname
type(timer_list_type), intent(inout) :: timer
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~pw90common_wanint_setup~~CallsGraph proc~pw90common_wanint_setup pw90common_wanint_setup interface~comms_bcast comms_bcast proc~pw90common_wanint_setup->interface~comms_bcast proc~mpirank mpirank proc~pw90common_wanint_setup->proc~mpirank proc~set_error_alloc set_error_alloc proc~pw90common_wanint_setup->proc~set_error_alloc proc~set_error_fatal set_error_fatal proc~pw90common_wanint_setup->proc~set_error_fatal proc~set_error_file set_error_file proc~pw90common_wanint_setup->proc~set_error_file proc~wigner_seitz_opt_setup wigner_seitz_opt_setup proc~pw90common_wanint_setup->proc~wigner_seitz_opt_setup proc~wignerseitz wignerseitz proc~pw90common_wanint_setup->proc~wignerseitz proc~ws_translate_dist ws_translate_dist proc~pw90common_wanint_setup->proc~ws_translate_dist proc~comms_bcast_char comms_bcast_char interface~comms_bcast->proc~comms_bcast_char proc~comms_bcast_cmplx comms_bcast_cmplx interface~comms_bcast->proc~comms_bcast_cmplx proc~comms_bcast_int comms_bcast_int interface~comms_bcast->proc~comms_bcast_int proc~comms_bcast_logical comms_bcast_logical interface~comms_bcast->proc~comms_bcast_logical proc~comms_bcast_real comms_bcast_real interface~comms_bcast->proc~comms_bcast_real 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_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~set_error_file->proc~comms_sync_error proc~set_error_file->proc~set_base_error proc~wigner_seitz_opt_setup->proc~set_error_alloc proc~wigner_seitz_opt_setup->proc~set_error_fatal proc~set_error_dealloc set_error_dealloc proc~wigner_seitz_opt_setup->proc~set_error_dealloc proc~wignerseitz->proc~mpirank proc~wignerseitz->proc~set_error_alloc proc~wignerseitz->proc~set_error_fatal proc~io_stopwatch_start io_stopwatch_start proc~wignerseitz->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~wignerseitz->proc~io_stopwatch_stop proc~wignerseitz->proc~set_error_dealloc proc~utility_metric utility_metric proc~wignerseitz->proc~utility_metric proc~ws_translate_dist->proc~set_error_alloc proc~ws_translate_dist->proc~set_error_fatal proc~clean_ws_translate clean_ws_translate proc~ws_translate_dist->proc~clean_ws_translate proc~r_wz_sc R_wz_sc proc~ws_translate_dist->proc~r_wz_sc proc~utility_frac_to_cart utility_frac_to_cart proc~ws_translate_dist->proc~utility_frac_to_cart proc~utility_inverse_mat utility_inverse_mat proc~ws_translate_dist->proc~utility_inverse_mat proc~clean_ws_translate->proc~set_error_dealloc proc~comms_bcast_char->proc~comms_sync_error proc~comms_no_sync_bcast_char comms_no_sync_bcast_char proc~comms_bcast_char->proc~comms_no_sync_bcast_char proc~comms_bcast_cmplx->proc~comms_sync_error proc~comms_no_sync_bcast_cmplx comms_no_sync_bcast_cmplx proc~comms_bcast_cmplx->proc~comms_no_sync_bcast_cmplx proc~comms_bcast_int->proc~comms_sync_error proc~comms_no_sync_bcast_int comms_no_sync_bcast_int proc~comms_bcast_int->proc~comms_no_sync_bcast_int proc~comms_bcast_logical->proc~comms_sync_error proc~comms_no_sync_bcast_logical comms_no_sync_bcast_logical proc~comms_bcast_logical->proc~comms_no_sync_bcast_logical proc~comms_bcast_real->proc~comms_sync_error proc~comms_no_sync_bcast_real comms_no_sync_bcast_real proc~comms_bcast_real->proc~comms_no_sync_bcast_real proc~r_wz_sc->proc~set_error_fatal proc~r_wz_sc->proc~utility_frac_to_cart proc~utility_cart_to_frac utility_cart_to_frac proc~r_wz_sc->proc~utility_cart_to_frac proc~set_error_dealloc->proc~comms_sync_error proc~set_error_dealloc->proc~set_base_error proc~utility_inv3 utility_inv3 proc~utility_inverse_mat->proc~utility_inv3

Called by

proc~~pw90common_wanint_setup~~CalledByGraph proc~pw90common_wanint_setup pw90common_wanint_setup program~postw90 postw90 program~postw90->proc~pw90common_wanint_setup

Source Code

  subroutine pw90common_wanint_setup(num_wann, print_output, real_lattice, mp_grid, ws_region, &
                                     ws_distance, effective_model, wigner_seitz, wannier_data, &
                                     stdout, seedname, timer, error, comm)
    !================================================!
    !
    !! Setup data ready for interpolation
    !
    !================================================!

    use w90_constants, only: dp
    use w90_io, only: io_stopwatch_start, io_stopwatch_stop
    use w90_types, only: ws_region_type, ws_distance_type, wannier_data_type, &
                         print_output_type, timer_list_type
    use w90_comms, only: mpirank, w90_comm_type, comms_bcast
    use w90_postw90_types, only: wigner_seitz_type
    use w90_ws_distance, only: ws_translate_dist

    type(print_output_type), intent(in) :: print_output
    type(wigner_seitz_type), intent(inout) :: wigner_seitz
    type(ws_distance_type), intent(inout) :: ws_distance
    type(ws_region_type), intent(in) :: ws_region
    type(wannier_data_type), intent(in) :: wannier_data
    type(timer_list_type), intent(inout) :: timer
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error

    real(kind=dp), intent(in) :: real_lattice(3, 3)
    integer, intent(in) :: num_wann
    integer, intent(in) :: stdout
    integer, intent(in) :: mp_grid(3)
    logical, intent(in) :: effective_model
    character(len=50), intent(in)  :: seedname

    integer :: ierr, ir, file_unit, num_wann_loc
    logical :: on_root = .false.

    if (mpirank(comm) == 0) on_root = .true.

    ! Find nrpts, the number of points in the Wigner-Seitz cell
    if (effective_model) then
      if (on_root) then
        ! nrpts is read from file, together with num_wann
        open (newunit=file_unit, file=trim(seedname)//'_HH_R.dat', form='formatted', &
              status='old', err=101)
        read (file_unit, *) !header
        read (file_unit, *) num_wann_loc
        if (num_wann_loc /= num_wann) then
          call set_error_fatal(error, 'Inconsistent values of num_wann in '//trim(seedname) &
                               //'_HH_R.dat and '//trim(seedname)//'.win', comm)
          return
        end if
        read (file_unit, *) wigner_seitz%nrpts
        close (file_unit)
      end if
      call comms_bcast(wigner_seitz%nrpts, 1, error, comm)
      if (allocated(error)) return
    else
      call wignerseitz(print_output, real_lattice, mp_grid, ws_region, wigner_seitz, stdout, &
                       .true., timer, error, comm)
      if (allocated(error)) return
    end if

    ! Now can allocate several arrays
    allocate (wigner_seitz%irvec(3, wigner_seitz%nrpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating irvec in pw90common_wanint_setup', comm)
      return
    end if
    wigner_seitz%irvec = 0
    allocate (wigner_seitz%crvec(3, wigner_seitz%nrpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating crvec in pw90common_wanint_setup', comm)
      return
    end if
    wigner_seitz%crvec = 0.0_dp
    allocate (wigner_seitz%ndegen(wigner_seitz%nrpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating ndegen in pw90common_wanint_setup', comm)
      return
    end if
    wigner_seitz%ndegen = 0

    ! Also rpt_origin, so that when effective_model=.true it is not
    ! passed to get_HH_R without being initialized.
    wigner_seitz%rpt_origin = 0

    ! If effective_model, this is done in get_HH_R
    if (.not. effective_model) then
      ! Set up the lattice vectors on the Wigner-Seitz supercell
      ! where the Wannier functions live

      call wignerseitz(print_output, real_lattice, mp_grid, ws_region, wigner_seitz, stdout, &
                       .false., timer, error, comm)
      if (allocated(error)) return

      ! Convert from reduced to Cartesian coordinates

      do ir = 1, wigner_seitz%nrpts
        ! Note that 'real_lattice' stores the lattice vectors as *rows*
        wigner_seitz%crvec(:, ir) = matmul(transpose(real_lattice), wigner_seitz%irvec(:, ir))
      end do

      if (ws_region%use_ws_distance) then
        call ws_translate_dist(ws_distance, ws_region, num_wann, wannier_data%centres, real_lattice, &
                               mp_grid, wigner_seitz%nrpts, wigner_seitz%irvec, error, comm)
        if (allocated(error)) return
      end if

      call wigner_seitz_opt_setup(ws_distance, ws_region, wigner_seitz, num_wann, real_lattice, &
                                  wigner_seitz%nrpts, error, comm)

    end if

    return

101 call set_error_file(error, 'Error in pw90common_wanint_setup: problem opening file '// &
                        trim(seedname)//'_HH_R.dat', comm)
    return

  end subroutine pw90common_wanint_setup