internal_maxloc Function

private function internal_maxloc(dist)

Uses

  • proc~~internal_maxloc~~UsesGraph proc~internal_maxloc internal_maxloc module~w90_constants w90_constants proc~internal_maxloc->module~w90_constants

A reproducible maxloc function so b-vectors come in the same order each time

Arguments

Type IntentOptional AttributesName
real(kind=dp), intent(in) :: dist((2*nsupcell+1)**3)

Distances from the origin of the unit cells in the supercell.

Return Value integer


Called by

proc~~internal_maxloc~~CalledByGraph proc~internal_maxloc internal_maxloc proc~kmesh_supercell_sort kmesh_supercell_sort proc~kmesh_supercell_sort->proc~internal_maxloc proc~kmesh_get kmesh_get proc~kmesh_get->proc~kmesh_supercell_sort proc~wannier_run wannier_run proc~wannier_run->proc~kmesh_get program~postw90 postw90 program~postw90->proc~kmesh_get

Contents

Source Code


Source Code

  function internal_maxloc(dist)
    !=================================
    !
    !!  A reproducible maxloc function
    !!  so b-vectors come in the same
    !!  order each time
    !=================================

    use w90_constants, only: eps8
    implicit none

    real(kind=dp), intent(in)  :: dist((2*nsupcell + 1)**3)
    !! Distances from the origin of the unit cells in the supercell.
    integer                    :: internal_maxloc

    integer       :: guess(1), loop, counter
    integer       :: list((2*nsupcell + 1)**3)

    list = 0
    counter = 1

    guess = maxloc(dist)
    list(1) = guess(1)
    ! look for any degenerate values
    do loop = 1, (2*nsupcell + 1)**3
      if (loop == guess(1)) cycle
      if (abs(dist(loop) - dist(guess(1))) < eps8) then
        counter = counter + 1
        list(counter) = loop
      endif
    end do
    ! and always return the lowest index
    internal_maxloc = minval(list(1:counter))

  end function internal_maxloc