Visible to Intel only — GUID: GUID-E5616602-E062-466F-BC1F-EA37C75CD213
Visible to Intel only — GUID: GUID-E5616602-E062-466F-BC1F-EA37C75CD213
BSEARCHQQ
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.
Module
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.
Results
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.
Example
The following example shows a way to use BSEARCHQQ:
USE IFPORT
INTEGER(4) array(10)
INTEGER(4) result, target
INTEGER(8) length
length = SIZE(array)
do i = 1,length
array(i) = i
end do
target = 8
write(*,100)length,array,target
100 Format("Array length :: ",i8,/,"Array Elements :: ",10i5,/,"Target number :: ",i5)
result = BSEARCHQQ(LOC(target),LOC(array),length,SRT$INTEGER4)
write(*,101) result
101 Format("Location :: ",i4)
End