Portability Subroutine: Performs a quick sort on an array of rank one.
Module: USE DFPORT
Syntax
INTEGER(2) FUNCTION compar(arg1, arg2)
where arg1 and arg2 have the same type as array. Once you have created an ordering scheme, implement your sorting function so that it returns the following:
Dummy argument compar must be declared as external.
If you use QSORT with different data types, your program must have a USE DFPORT statement in order for all the calls to work correctly. In addition, if you wish to use QSORT with a derived type or a type that is not in the predefined interfaces, you must include an overload for the generic subroutine QSORT. Examples of how to do this are in the portability module's source file, DFPORT.F90, located in your \DF98\INCLUDE subdirectory.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
Example
PROGRAM SORTQ
USE DFPORT
integer(2), external :: cmp_function
integer(2) insort(26), i
integer (4) array_len, array_size
array_len = 26
array_size = 2
do i=90,65,-1
insort(i-64)=91 - i
end do
print *, "Before: "
print *,insort
CALL qsort(insort,array_len,array_size,cmp_function)
print *, 'After: '
print *, insort
END
!
integer(2) function cmp_function(a1, a2)
integer(2) a1, a2
cmp_function=a1-a2
end function