pw90common_wanint_setup Subroutine

public subroutine pw90common_wanint_setup()

Uses

  • proc~~pw90common_wanint_setup~~UsesGraph proc~pw90common_wanint_setup pw90common_wanint_setup module~w90_constants w90_constants proc~pw90common_wanint_setup->module~w90_constants module~w90_utility w90_utility proc~pw90common_wanint_setup->module~w90_utility module~w90_parameters w90_parameters proc~pw90common_wanint_setup->module~w90_parameters module~w90_io w90_io proc~pw90common_wanint_setup->module~w90_io module~w90_utility->module~w90_constants module~w90_parameters->module~w90_constants module~w90_parameters->module~w90_io module~w90_io->module~w90_constants

Setup data ready for interpolation

Arguments

None

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~wigner_seitz wigner_seitz proc~pw90common_wanint_setup->proc~wigner_seitz proc~io_file_unit io_file_unit proc~pw90common_wanint_setup->proc~io_file_unit 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_real comms_bcast_real interface~comms_bcast->proc~comms_bcast_real proc~comms_bcast_logical comms_bcast_logical interface~comms_bcast->proc~comms_bcast_logical

Called by

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

Contents


Source Code

  subroutine pw90common_wanint_setup
    !! Setup data ready for interpolation
    use w90_constants, only: dp, cmplx_0
    use w90_io, only: io_error, io_file_unit, stdout, seedname
    use w90_utility, only: utility_cart_to_frac
    use w90_parameters, only: real_lattice, effective_model, num_wann

    integer        :: ierr, i, j, k, ikpt, ir, file_unit, num_wann_loc

    ! 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
        file_unit = io_file_unit()
        open (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) &
          call io_error('Inconsistent values of num_wann in ' &
                        //trim(seedname)//'_HH_R.dat and '//trim(seedname)//'.win')
        read (file_unit, *) nrpts
        close (file_unit)
      endif
      call comms_bcast(nrpts, 1)
    else
      call wigner_seitz(count_pts=.true.)
    endif

    ! Now can allocate several arrays
    !
    allocate (irvec(3, nrpts), stat=ierr)
    if (ierr /= 0) call io_error('Error in allocating irvec in pw90common_wanint_setup')
    irvec = 0
    allocate (crvec(3, nrpts), stat=ierr)
    if (ierr /= 0) call io_error('Error in allocating crvec in pw90common_wanint_setup')
    crvec = 0.0_dp
    allocate (ndegen(nrpts), stat=ierr)
    if (ierr /= 0) call io_error('Error in allocating ndegen in pw90common_wanint_setup')
    ndegen = 0
    !
    ! Also rpt_origin, so that when effective_model=.true it is not
    ! passed to get_HH_R without being initialized.
    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 wigner_seitz(count_pts=.false.)
      !
      ! Convert from reduced to Cartesian coordinates
      !
      do ir = 1, nrpts
        ! Note that 'real_lattice' stores the lattice vectors as *rows*
        crvec(:, ir) = matmul(transpose(real_lattice), irvec(:, ir))
      end do
    endif

    return

101 call io_error('Error in pw90common_wanint_setup: problem opening file '// &
                  trim(seedname)//'_HH_R.dat')

  end subroutine pw90common_wanint_setup