Skip to main content

QuickSort

QuickSort algorithm for sorting.

At present QuickSort generic method contains following interfaces.

CALL QuickSort(vec1, low, high)
CALL QuickSort(vec1, vect2, low, high)
CALL QuickSort(vec1, vect2, vect3, low, high)
CALL QuickSort(vect1, vect2, vect3, vect4, low, high)

Interface 1

  MODULE RECURSIVE PURE SUBROUTINE QuickSort(vect1, low, high)
Int8|Int16|Int32|Int64|Real32|Real64, INTENT(INOUT) :: vect1(:)
INTEGER(I4B), INTENT(IN) :: low, high
END SUBROUTINE QuickSort

In this interface vect1 can be a one dimensional fortran array of

  • Int8, Int16, Int32, Int64
  • Real32, Real64

Interface 2

INTERFACE
MODULE RECURSIVE PURE SUBROUTINE QuickSort(vect1, vect2, low, high)
INTEGER( I4B )| REAL( DFP ) , DIMENSION(:), INTENT(INOUT) :: vect1
INTEGER( I4B )| REAL( DFP ) , DIMENSION(:), INTENT(INOUT) :: vect2
INTEGER(I4B), INTENT(IN) :: low, high
END SUBROUTINE QuickSort
END INTERFACE

In this interface vect1 and vect2 can be a one dimensional fortran array of

  • Int32 or I4B 4 byte integers
  • Real(DFP) default floating point, usually Real64

Interface 3

INTERFACE
MODULE PURE RECURSIVE SUBROUTINE QuickSort(vect1, vect2, vect3, &
& low, high)
INTEGER(I4B) | REAL(DFP), DIMENSION(:), INTENT(INOUT) :: vect3
REAL(DFP) | INTEGER(I4B), DIMENSION(:), INTENT(INOUT) :: vect1, vect2
INTEGER(I4B), INTENT(IN) :: low, high
END SUBROUTINE QuickSort
END INTERFACE

In this interface vect1, vect2, and vect3 can be a one dimensional fortran array of

  • Int32 or I4B 4 byte integers
  • Real(DFP) default floating point, usually Real64

Interface 4

INTERFACE
MODULE PURE RECURSIVE SUBROUTINE QuickSort(vect1, vect2, vect3, &
& vect4, low, high)
INTEGER(I4B)| REAL( DFP ), DIMENSION(:), INTENT(INOUT) :: vect1, vect2, vect3, vect4
INTEGER(I4B), INTENT(IN) :: low, high
END SUBROUTINE QuickSort
END INTERFACE

In this interface vect1, vect2, vect3, and vect4 can be a one dimensional fortran array of

  • Int32 or I4B 4 byte integers
  • Real(DFP) default floating point, usually Real64