qsort_(array, len, isize, compar)

Purpose

The qsort_ subroutine performs a parallel quicksort on a one-dimensional array ARRAY whose length LEN is the number of elements in the array with each element having a size of ISIZE, and a user-defined sorting order function COMPAR to sort the elements of the array.

Class

Subroutine

Argument Type and Attributes

array
The array to be sorted. It can be of any type.

len
The number of elements in the array. The argument is of type INTEGER(4).

isize
The size of a single element of the array. The argument is of type INTEGER(4).

compar
A user-defined comparison function used to sort the array.

Examples

INTEGER(4) FUNCTION COMPAR_UP(C1, C2)
INTEGER(4) C1, C2
IF (C1.LT.C2) COMPAR_UP = -1
IF (C1.EQ.C2) COMPAR_UP =  0
IF (C1.GT.C2) COMPAR_UP =  1
RETURN
END
 
SUBROUTINE FOO()
  INTEGER(4) COMPAR_UP
  EXTERNAL COMPAR_UP
  INTEGER(4) ARRAY(8), LEN, ISIZE
  DATA ARRAY/0, 3, 1, 2, 9, 5, 7, 4/
  LEN = 6
  ISIZE = 4
  CALL qsort_(ARRAY(3:8), LEN, ISIZE, COMPAR_UP)! sorting ARRAY(3:8)
  PRINT *, ARRAY                                ! result value is [0, 3, 1, 2, 4, 5, 7, 9]
  RETURN
END
IBM Copyright 2003