Helper routine for quicksort, to perform partitioning
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CFG_var_t), | intent(inout) | :: | list(:) | |||
| integer, | intent(out) | :: | marker |
subroutine parition_var_list(list, marker) type(CFG_var_t), intent(inout) :: list(:) integer, intent(out) :: marker integer :: left, right, pivot_ix type(CFG_var_t) :: temp character(len=CFG_name_len) :: pivot_value left = 0 right = size(list) + 1 ! Take the middle element as pivot pivot_ix = size(list) / 2 pivot_value = list(pivot_ix)%var_name do while (left < right) right = right - 1 do while (lgt(list(right)%var_name, pivot_value)) right = right - 1 end do left = left + 1 do while (lgt(pivot_value, list(left)%var_name)) left = left + 1 end do if (left < right) then temp = list(left) list(left) = list(right) list(right) = temp end if end do if (left == right) then marker = left + 1 else marker = left end if end subroutine parition_var_list