Only used when interfaced to the CP code Not sure why this is done here and not in CP
| Type | Intent | Optional | 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 |
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