sort Subroutine

private subroutine sort(non_sorted, sorted)

Uses

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

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: non_sorted(:,:)
real(kind=dp), intent(out) :: sorted(:,:)

Called by

proc~~sort~~CalledByGraph proc~sort sort proc~master_sort_and_group master_sort_and_group proc~master_sort_and_group->proc~sort proc~tran_lcr_2c2_sort tran_lcr_2c2_sort proc~tran_lcr_2c2_sort->proc~sort proc~tran_lcr_2c2_sort->proc~master_sort_and_group proc~tran_main tran_main proc~tran_main->proc~tran_lcr_2c2_sort proc~w90_transport w90_transport proc~w90_transport->proc~tran_main program~wannier wannier program~wannier->proc~w90_transport

Source Code

  subroutine sort(non_sorted, sorted)
    !================================================!

    use w90_constants, only: dp

    implicit none

    real(kind=dp), intent(inout) :: non_sorted(:, :)
    real(kind=dp), intent(out) :: sorted(:, :)

    integer, dimension(1) :: min_loc
    integer :: num_col, i

    num_col = size(non_sorted, 2)

    do i = 1, num_col

      !look for the location of the minimum value of the coordinates in non_sorted

      min_loc = minloc(non_sorted(2, :))

      !now the index in the first row of sorted is the index non_sorted(1,min_loc)

      sorted(1, i) = non_sorted(1, min_loc(1))

      !here is the corresponding coordinate

      sorted(2, i) = non_sorted(2, min_loc(1))

      !here one replaces the minimum coordinate with 10**10 such that this value
      !will not be picked-up again by minloc

      non_sorted(2, min_loc(1)) = 10.0**10
    end do

    return

  end subroutine sort