SORTQQ

Run-Time Subroutine: Sorts a one-dimensional array. The array elements cannot be derived types or record structures.

Module: USE DFLIB

Syntax

CALL SORTQQ (adrarray, count, size)

adrarray
(Input) INTEGER(4). Address of the array (returned by LOC).


count
(Input; output) INTEGER(4). On input, number of elements in the array to be sorted. On output, number of elements actually sorted.


size
(Input) INTEGER(4). Positive constant less than 32,767 that specifies the kind of array to be sorted. The following constants, defined in DFLIB.F90 (in the \DF98\INCLUDE subdirectory), specify type and kind for numeric arrays:


Constant Type of array
SRT$INTEGER1 INTEGER(1)
SRT$INTEGER2 INTEGER(2) or equivalent
SRT$INTEGER4 INTEGER(4) or equivalent
SRT$REAL4 REAL(4) or equivalent
SRT$REAL8 REAL(8) or equivalent

If the value provided in size is not a symbolic constant and is less than 32,767, the array is assumed to be a character array with size characters per element.

To be certain that SORTQQ is successful, compare the value returned in count to the value you provided. If they are the same, then SORTQQ sorted the correct number of elements.


Caution: The location of the array must be passed by address using the LOC function. This defeats Fortran type-checking, so you must make certain that the count and size arguments are correct.

If you pass invalid arguments, SORTQQ attempts to sort random parts of memory. If the memory it attempts to sort is allocated to the current process, that memory is sorted; otherwise, the operating system intervenes, the program is halted, and you get a General Protection Violation message.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: BSEARCHQQ, LOC

Example

 !    Sort a 1-D array
 !
 USE DFLIB
 INTEGER(2) array(10)
 INTEGER(2) i
 DATA ARRAY /143, 99, 612, 61, 712, 9112, 6, 555, 2223, 67/
 !    Sort the array
 Call SORTQQ (LOC(array), 10, SRT$INTEGER2)
 !    Display the sorted array
 DO i = 1, 10
   WRITE (*, 9000) i, array (i)
 9000 FORMAT(1X, ' Array(',I2, '): ', I5)
 END DO
 END