overlap_rotate Subroutine

private subroutine overlap_rotate(a_matrix, m_matrix_orig, nntot, num_bands, timing_level, timer, error, comm)

Uses

  • proc~~overlap_rotate~~UsesGraph proc~overlap_rotate overlap_rotate module~w90_error w90_error proc~overlap_rotate->module~w90_error module~w90_io w90_io proc~overlap_rotate->module~w90_io module~w90_types w90_types proc~overlap_rotate->module~w90_types 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_constants w90_constants module~w90_io->module~w90_constants module~w90_types->module~w90_constants module~w90_comms->module~w90_constants module~w90_comms->module~w90_error_base

Only used when interfaced to the CP code Not sure why this is done here and not in CP

Arguments

Type IntentOptional Attributes Name
complex(kind=dp), intent(inout) :: a_matrix(:,:,:)
complex(kind=dp), intent(inout) :: m_matrix_orig(:,:,:,:)
integer, intent(in) :: nntot
integer, intent(in) :: num_bands
integer, intent(in) :: timing_level
type(timer_list_type), intent(inout) :: timer
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~overlap_rotate~~CallsGraph proc~overlap_rotate overlap_rotate dspev dspev proc~overlap_rotate->dspev proc~io_stopwatch_start io_stopwatch_start proc~overlap_rotate->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~overlap_rotate->proc~io_stopwatch_stop proc~set_error_fatal set_error_fatal proc~overlap_rotate->proc~set_error_fatal proc~comms_sync_error comms_sync_error proc~set_error_fatal->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~overlap_rotate~~CalledByGraph proc~overlap_rotate overlap_rotate proc~overlap_read overlap_read proc~overlap_read->proc~overlap_rotate proc~overlaps overlaps proc~overlaps->proc~overlap_read program~wannier wannier program~wannier->proc~overlaps

Source Code

  subroutine overlap_rotate(a_matrix, m_matrix_orig, nntot, num_bands, timing_level, timer, error, &
                            comm)
    !================================================!
    !
    !! Only used when interfaced to the CP code
    !! Not sure why this is done here and not in CP
    !
    !================================================!

    use w90_io, only: io_stopwatch_start, io_stopwatch_stop
    use w90_error, only: w90_error_type, set_error_fatal
    use w90_types, only: timer_list_type

    implicit none

    ! arguments
    type(timer_list_type), intent(inout) :: timer
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(in) :: nntot
    integer, intent(in) :: num_bands
    integer, intent(in) :: timing_level

    complex(kind=dp), intent(inout) :: m_matrix_orig(:, :, :, :)
    complex(kind=dp), intent(inout) :: a_matrix(:, :, :)

    ! local variables
    integer       :: lam_unit, info, inn, i, j
    real(kind=dp) :: lambda(num_bands, num_bands)
    real(kind=dp) :: AP(num_bands*(num_bands + 1)/2)
    real(kind=dp) :: eig(num_bands), work(3*num_bands)

    if (timing_level > 1) call io_stopwatch_start('overlap: rotate', timer)

    open (newunit=lam_unit, file='lambda.dat', &
          form='unformatted', status='old', action='read')
    read (lam_unit) lambda
    close (lam_unit)

    do j = 1, num_bands
      do i = 1, j
        AP(i + (j - 1)*j/2) = 0.5_dp*(lambda(i, j) + lambda(j, i))
      end do
    end do

    CALL DSPEV('V', 'U', num_bands, AP, eig, lambda, num_bands, work, info)
    if (info .ne. 0) then
      call set_error_fatal(error, 'Diagonalization of lambda in overlap_rotate failed', comm)
      return
    end if

    ! For debugging
!~    write(stdout,*) 'EIGENVALUES - CHECK WITH CP OUTPUT'
!~    do i=1,num_bands
!~       write(stdout,*) 13.6058*eig(i)
!~    end do

    ! Rotate M_mn
    do inn = 1, nntot
      m_matrix_orig(:, :, inn, 1) = &
        matmul(transpose(lambda), matmul(m_matrix_orig(:, :, inn, 1), lambda))
    end do

    ! Rotate A_mn
    a_matrix(:, :, 1) = matmul(transpose(lambda), a_matrix(:, :, 1))

    ! For debugging
!~    ! Write rotated A and M
!~    do i=1,num_bands
!~       do j=1,num_wann
!~          write(12,'(2i5,a,2f18.12)') i,j,'   1',a_matrix(i,j,1)
!~       enddo
!~    enddo
!~    do inn=1,nntot
!~       do i=1,num_bands
!~          do j=1,num_wann
!~             write(11,'(2i5,2a)') i,j,'    1','    1'
!~             write(11,'(2f18.12)') m_matrix_orig(i,j,inn,1)
!~          enddo
!~       enddo
!~    enddo
!~    stop

    if (timing_level > 1) call io_stopwatch_stop('overlap: rotate', timer)

    return

  end subroutine overlap_rotate