wann_write_r2mn Subroutine

private subroutine wann_write_r2mn()

Uses

  • proc~~wann_write_r2mn~~UsesGraph proc~wann_write_r2mn wann_write_r2mn module~w90_constants w90_constants proc~wann_write_r2mn->module~w90_constants module~w90_parameters w90_parameters proc~wann_write_r2mn->module~w90_parameters module~w90_io w90_io proc~wann_write_r2mn->module~w90_io module~w90_parameters->module~w90_constants module~w90_parameters->module~w90_io module~w90_io->module~w90_constants

Arguments

None

Calls

proc~~wann_write_r2mn~~CallsGraph proc~wann_write_r2mn wann_write_r2mn proc~io_file_unit io_file_unit proc~wann_write_r2mn->proc~io_file_unit

Contents

Source Code


Source Code

  subroutine wann_write_r2mn()
    !========================================!
    !                                        !
    ! Write seedname.r2mn file               !
    !                                        !
    !========================================!

    use w90_constants, only: dp
    use w90_io, only: seedname, io_file_unit, io_error
    use w90_parameters, only: num_kpts, num_wann, nntot, wb, &
      m_matrix

    implicit none

    integer :: r2mnunit, nw1, nw2, nkp, nn
    real(kind=dp) :: r2ave_mn, delta

    ! note that here I use formulas analogue to Eq. 23, and not to the
    ! shift-invariant Eq. 32 .
    r2mnunit = io_file_unit()
    open (r2mnunit, file=trim(seedname)//'.r2mn', form='formatted', err=158)
    do nw1 = 1, num_wann
      do nw2 = 1, num_wann
        r2ave_mn = 0.0_dp
        delta = 0.0_dp
        if (nw1 .eq. nw2) delta = 1.0_dp
        do nkp = 1, num_kpts
          do nn = 1, nntot
            r2ave_mn = r2ave_mn + wb(nn)* &
                       ! [GP-begin, Apr13, 2012: corrected sign inside "real"]
                       (2.0_dp*delta - real(m_matrix(nw1, nw2, nn, nkp) + &
                                            conjg(m_matrix(nw2, nw1, nn, nkp)), kind=dp))
            ! [GP-end]
          enddo
        enddo
        r2ave_mn = r2ave_mn/real(num_kpts, dp)
        write (r2mnunit, '(2i6,f20.12)') nw1, nw2, r2ave_mn
      enddo
    enddo
    close (r2mnunit)

    return

158 call io_error('Error opening file '//trim(seedname)//'.r2mn in wann_write_r2mn')

  end subroutine wann_write_r2mn