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 AttributesName
real(kind=dp), intent(inout), dimension(:, :):: non_sorted
real(kind=dp), intent(out), dimension(:, :):: sorted

Called by

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

Contents

Source Code


Source Code

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

    use w90_constants, only: dp

    implicit none

    real(dp), intent(inout), dimension(:, :)       :: non_sorted
    real(dp), intent(out), dimension(:, :)         :: 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
    enddo

    return

  endsubroutine sort