Intel® Fortran Compiler 16.0 User and Reference Guide

SORTQQ

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

Module

USE IFPORT

CALL SORTQQ (adrarray,count,size)

adrarray

(Input) INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. Address of the array (returned by LOC).

count

(Input; output) INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. On input, number of elements in the array to be sorted. On output, number of elements actually sorted.

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.

size

(Input) INTEGER(4). Positive constant less than 32,767 that specifies the kind of array to be sorted. The following constants, defined in IFPORT.F90, 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$INTEGER8

INTEGER(8) or equivalent

SRT$REAL4

REAL(4) or equivalent

SRT$REAL8

REAL(8) or equivalent

SRT$REAL16

REAL(16) 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.

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.

Example

 !    Sort a 1-D array
 ! USE IFPORT
 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

See Also