Intel® Fortran Compiler 16.0 User and Reference Guide
Portability Function: Performs a binary search of a sorted one-dimensional array for a specified element. The array elements cannot be derived types or structures.
USE IFPORT
result = BSEARCHQQ (adrkey,adrarray,length,size)
adrkey |
(Input) INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. Address of the variable containing the element to be found (returned by LOC). |
||||||||||||||||
adrarray |
(Input) INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. Address of the array (returned by LOC). |
||||||||||||||||
length |
(Input) INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. Number of elements in the array. |
||||||||||||||||
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:
|
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.
The result type is INTEGER(4). It is an array index of the matched entry, or 0 if the entry is not found.
The array must be sorted in ascending order before being searched.
The location of the array and the element to be found must both be passed by address using the LOC function. This defeats Fortran type checking, so you must make certain that the length and size arguments are correct, and that size is the same for the element to be found and the array searched.
If you pass invalid arguments, BSEARCHQQ attempts to search random parts of memory. If the memory it attempts to search is not allocated to the current process, the program is halted, and you receive a General Protection Violation message.
USE IFPORT INTEGER(4) array(10), length INTEGER(4) result, target length = SIZE(array) ... result = BSEARCHQQ(LOC(target),LOC(array),length,SRT$INTEGER4)