1 !*** ecsort_shared.h ***
5 #define DATA_TYPE INTEGER(KIND=JPIM) 6 #define SIZEOF_ME sizeof_int4 7 #define KEYSORT_1D INT4_KEYSORT_1D 8 #define KEYSORT_1D_DRHOOKSTR 'ECSORT_MIX:INT4_KEYSORT_1D' 9 #define KEYSORT_2D INT4_KEYSORT_2D 10 #define KEYSORT_2D_DRHOOKSTR 'ECSORT_MIX:INT4_KEYSORT_2D' 11 #define KEYSORT_NUMBER 11 12 #define RSORT_DRHOOKSTR 'ECSORT_MIX:RSORT32_FUNC_11' 14 #define HEAPSORT INT4_HEAPSORT 15 #define HEAPSORT_DRHOOKSTR 'ECSORT_MIX:INT4_HEAPSORT' 16 #define DBGPRINT INT4_DBGPRINT 17 #define DBGFMTNUM 1011 18 #define ECQSORT_DRHOOKSTR 'ECSORT_MIX:INT4_ECQSORT' 19 #define COUNT_DRHOOKSTR 'ECSORT_MIX:INT4_COUNT' 20 #define GNOME_DRHOOKSTR 'ECSORT_MIX:INT4_GNOME' 22 #elif REAL_VERSION == 8 24 #define DATA_TYPE REAL(KIND=JPRD) 25 #define SIZEOF_ME sizeof_real8 26 #define KEYSORT_1D REAL8_KEYSORT_1D 27 #define KEYSORT_1D_DRHOOKSTR 'ECSORT_MIX:REAL8_KEYSORT_1D' 28 #define KEYSORT_2D REAL8_KEYSORT_2D 29 #define KEYSORT_2D_DRHOOKSTR 'ECSORT_MIX:REAL8_KEYSORT_2D' 30 #define KEYSORT_NUMBER 12 31 #define RSORT_DRHOOKSTR 'ECSORT_MIX:RSORT64_12' 33 #define HEAPSORT REAL8_HEAPSORT 34 #define HEAPSORT_DRHOOKSTR 'ECSORT_MIX:REAL8_HEAPSORT' 35 #define DBGPRINT REAL8_DBGPRINT 36 #define DBGFMTNUM 1012 37 #define ECQSORT_DRHOOKSTR 'ECSORT_MIX:REAL8_ECQSORT' 38 #define COUNT_DRHOOKSTR 'ECSORT_MIX:REAL8_COUNT' 39 #define GNOME_DRHOOKSTR 'ECSORT_MIX:REAL8_GNOME' 41 #elif REAL_VERSION == 4 43 #define DATA_TYPE REAL(KIND=JPRM) 44 #define SIZEOF_ME sizeof_real4 45 #define KEYSORT_1D REAL4_KEYSORT_1D 46 #define KEYSORT_1D_DRHOOKSTR 'ECSORT_MIX:REAL4_KEYSORT_1D' 47 #define KEYSORT_2D REAL4_KEYSORT_2D 48 #define KEYSORT_2D_DRHOOKSTR 'ECSORT_MIX:REAL4_KEYSORT_2D' 49 #define KEYSORT_NUMBER 13 50 #define RSORT_DRHOOKSTR 'ECSORT_MIX:RSORT32_FUNC_13' 52 #define HEAPSORT REAL4_HEAPSORT 53 #define HEAPSORT_DRHOOKSTR 'ECSORT_MIX:REAL4_HEAPSORT' 54 #define DBGPRINT REAL4_DBGPRINT 55 #define DBGFMTNUM 1013 56 #define ECQSORT_DRHOOKSTR 'ECSORT_MIX:REAL4_ECQSORT' 57 #define COUNT_DRHOOKSTR 'ECSORT_MIX:REAL4_COUNT' 58 #define GNOME_DRHOOKSTR 'ECSORT_MIX:REAL4_GNOME' 60 #elif INT_VERSION == 8 62 #define DATA_TYPE INTEGER(KIND=JPIB) 63 #define SIZEOF_ME sizeof_int8 64 #define KEYSORT_1D INT8_KEYSORT_1D 65 #define KEYSORT_1D_DRHOOKSTR 'ECSORT_MIX:INT8_KEYSORT_1D' 66 #define KEYSORT_2D INT8_KEYSORT_2D 67 #define KEYSORT_2D_DRHOOKSTR 'ECSORT_MIX:INT8_KEYSORT_2D' 68 #define KEYSORT_NUMBER 14 69 #define RSORT_DRHOOKSTR 'ECSORT_MIX:RSORT64_14' 71 #define HEAPSORT INT8_HEAPSORT 72 #define HEAPSORT_DRHOOKSTR 'ECSORT_MIX:INT8_HEAPSORT' 73 #define DBGPRINT INT8_DBGPRINT 74 #define DBGFMTNUM 1014 75 #define ECQSORT_DRHOOKSTR 'ECSORT_MIX:INT8_ECQSORT' 76 #define COUNT_DRHOOKSTR 'ECSORT_MIX:INT8_COUNT' 77 #define GNOME_DRHOOKSTR 'ECSORT_MIX:INT8_GNOME' 81 ERROR in
programming : No datatype given (should never have ended up here)
85 !----------------------------
86 !-- Public subroutines --
87 !----------------------------
91 !-- Please note that we assume that
a(:) occupies consecutive memory locations
92 INTEGER(KIND=JPIM), intent(out) :: rc
93 DATA_TYPE , intent(inout) ::
a(:)
97 INTEGER(KIND=JPIM), intent(inout), TARGET, OPTIONAL ::
index(:)
98 logical, intent(in), OPTIONAL ::
init 99 ! === END OF INTERFACE BLOCK ===
100 DATA_TYPE , allocatable :: aa(:,:)
102 logical ::
LLfast, LLdescending, LLomp_okay, LLinit
104 REAL(KIND=JPRB) :: ZHOOK_HANDLE
106 IF (LHOOK) CALL DR_HOOK(KEYSORT_1D_DRHOOKSTR,0,ZHOOK_HANDLE)
109 if (
n <= 0 .or.
size(
a) <= 0) goto 99
114 LLdescending = .FALSE.
118 if (LLdescending) irev = 1
120 ITID = OML_MY_THREAD()
130 !-- hasn'
t been implemented
if index is present ;-(
132 & .not.present(
index) .and. &
133 & .not.present(
init))
135 !--
index-presence is ok
140 !- Only Quick-sort & CountingSort covered
143 inumt = OML_MAX_THREADS()
145 LLomp_okay = (LLomp_okay .and. .not. OML_IN_PARALLEL()) ! Prevents nested OpenMP
147 !-- Max 2-way OpenMP parallelism for now ...
149 !$OMP PARALLEL PRIVATE(iret)
152 CALL ecqsortfast(KEYSORT_NUMBER, ichunk,
a(1), irev, iret)
154 CALL ecqsortfast(KEYSORT_NUMBER,
n-ichunk, a(ichunk+1), irev, iret)
157 CALL ecmerge2(KEYSORT_NUMBER, 1, ichunk,
n-ichunk, a(1), &
158 & idummy, 0, 1, irev, idummy, rc)
160 CALL ecqsortfast(KEYSORT_NUMBER,
n, a(1), irev, rc)
166 CALL ec_countingsort(KEYSORT_NUMBER, n, 1, 1, a(1), idummy, 0, 1, irev, rc)
176 CALL ec_countingsort(KEYSORT_NUMBER, n, 1, 1, a(1), index(1),
size(index), index_adj, irev, rc)
186 !-- LLfast == .FALSE. :
190 if (LLdescending) then
196 CALL keysort(rc, aa, n, method=method, index=index,
init=
init)
198 if (LLdescending) then
207 IF (LHOOK) CALL DR_HOOK(KEYSORT_1D_DRHOOKSTR,1,ZHOOK_HANDLE,n)
211 SUBROUTINE KEYSORT_2D(&
213 &key, multikey, method,&
214 &index,
init, transposed)
216 INTEGER(KIND=JPIM), intent(out) :: rc
217 DATA_TYPE , intent(inout) :: a(:,:)
218 INTEGER(KIND=JPIM), intent(in) :: n
219 INTEGER(KIND=JPIM), intent(in), OPTIONAL :: key, method
220 INTEGER(KIND=JPIM), intent(in), OPTIONAL :: multikey(:)
221 logical, intent(in), OPTIONAL :: transposed
222 INTEGER(KIND=JPIM), intent(inout), TARGET, OPTIONAL :: index(:)
223 logical, intent(in), OPTIONAL :: init
224 ! === END OF INTERFACE BLOCK ===
226 INTEGER(KIND=JPIM) ::
ikey, istride, imethod, inumkeys, imethod_1st, imethod_rest
227 INTEGER(KIND=JPIM) ::
lda, iptr,
i, j, sda, idiff, irev,
inumt, jkey, jj, ilastkey
228 INTEGER(KIND=JPIM) :: j1, j2, jmid, inum, imax, iadd, imod, iret, inc, iamax, ibmax
229 DATA_TYPE , allocatable :: data(:)
230 INTEGER(KIND=JPIM), allocatable :: ikeys(:),
ista(:), ichunk(:), irank(:)
231 logical LLinit, LLdescending, LLtrans, LLomp_okay, LLadjusted, LLdebug, LLomp_prefix
233 REAL(KIND=JPRB) :: ZHOOK_HANDLE, ZHOOK_SUBHANDLE
234 REAL(KIND=JPRB) :: ZHOOK_SUBHANDLE0
235 REAL(KIND=JPRB) :: ZHOOK_SUBHANDLE1
236 REAL(KIND=JPRB) :: ZHOOK_SUBHANDLE2
237 REAL(KIND=JPRB) :: ZHOOK_SUBHANDLE3
240 IF (LHOOK) CALL DR_HOOK(KEYSORT_2D_DRHOOKSTR,0,ZHOOK_HANDLE)
245 if (n <= 0 .or. lda <= 0 .or. sda <= 0) goto 99
247 inumt = OML_MAX_THREADS()
248 ITID = OML_MY_THREAD()
250 if (present(method)) then
251 imethod = min(max(min_method,method),
max_method)
253 imethod_1st = imethod
254 imethod_rest = imethod
257 if (present(key)) ikey = key
259 if (present(multikey)) then
260 allocate(ikeys(
size(multikey)))
261 ikeys(:) = multikey(:)
266 inumkeys =
size(ikeys)
268 !-- Only the RADIX-sort & now also QUICK-sort & CountingSort give the result we want with multiple keys
269 if (inumkeys > 1 .and. &
274 imethod_1st = imethod
275 imethod_rest = imethod
277 ! Note: The first sweep may still be e.g. HEAP-sort
282 imethod_rest = imethod
287 if (present(init)) LLinit = init
289 if (present(index)) then
300 if (present(transposed)) LLtrans = transposed
303 else
if (sda >= 2 .and. lda >= 1) then
304 !-- Check for presence of sub-array and adjust lda automatically
305 call addrdiff(a(1,1),a(1,2),idiff)
306 ! lda below: The true leading dimension; overrides sub-arrays one
307 lda = idiff/SIZEOF_ME
312 LLomp_prefix = .FALSE.
313 !$ LLomp_prefix = (istride == 1 .and.
nomp >= inumt .and. n >=
nomp)
314 if (LLomp_prefix) then
315 call get_environment_variable('EC_SORTING_DEBUG',clenv)
316 LLdebug = (clenv == '1' .and. n < 10000)
317 if (LLdebug) write(0,*)'>> EC_SORTING_DEBUG=1'
322 1000 format(1x,a,2i12,:,/,(10i5))
323 1001 format(1x,'[
#',i2,']:',a,(10i5)) 324 1002 format(1x,
'[#',i2,
']:',a,:,/,(10i5))
325 1003 format(1x,
'[#',i2,
']:',a,2i12,:,/,(10i5))
326 1004 format(1x,a,:,(10i5))
327 1005 format(1x,a,i2,1x,a)
329 imethod = imethod_1st
330 KEYLOOP:
do jkey=inumkeys,1,-1
331 !-- Sort by the least significant key first
332 ikey = abs(ikeys(jkey))
333 if (ikey == 0) cycle KEYLOOP
335 if (istride == 1) then
336 iptr = lda * (ikey - 1) + 1
351 LLdescending = (ikeys(jkey) < 0)
353 if (LLdescending) irev = 1
355 !-- Since "irev" is passed into the ecqsort,
no explicit reversing is needed --> savings
359 if (LLdescending) then
360 if (istride == 1) then
361 a(1:n,ikey) = -a(1:n,ikey)
363 a(ikey,1:n) = -a(ikey,1:n)
365 irev = 0 ! prevents use of "reverse" algorithm in ecmerge2 for
radix-sort
368 LLomp_okay = LLomp_prefix .and. (inumt > 1) .and. (&
372 LLomp_okay = LLomp_okay .and. (.not. OML_IN_PARALLEL()) ! Prevents nested OpenMP
374 if (.not.LLomp_okay) then
375 select case (imethod)
377 IF (LHOOK) CALL DR_HOOK(RSORT_DRHOOKSTR,0,ZHOOK_SUBHANDLE0)
379 CALL rsort64(KEYSORT_NUMBER, n, istride, iptr,
a(1,1),
iindex(1), 1, rc)
381 CALL rsort32_func(KEYSORT_NUMBER, n, istride, iptr,
a(1,1),
iindex(1), 1, rc)
383 IF (LHOOK) CALL DR_HOOK(RSORT_DRHOOKSTR,1,ZHOOK_SUBHANDLE0, n)
385 if (istride == 1) then
386 CALL HEAPSORT(KEYSORT_NUMBER, n,
a(1:n, ikey), rc, irev, istride, iindex)
388 CALL HEAPSORT(KEYSORT_NUMBER, n,
a(ikey, 1:n), rc, irev, istride, iindex)
391 IF (LHOOK) CALL DR_HOOK(ECQSORT_DRHOOKSTR,0,ZHOOK_SUBHANDLE0)
392 CALL ecqsort(KEYSORT_NUMBER, n, istride, iptr,
a(1,1),
iindex(1), 1, irev, rc)
393 IF (LHOOK) CALL DR_HOOK(ECQSORT_DRHOOKSTR,1,ZHOOK_SUBHANDLE0,n)
395 IF (LHOOK) CALL DR_HOOK(COUNT_DRHOOKSTR,0,ZHOOK_SUBHANDLE0)
396 CALL ec_countingsort(KEYSORT_NUMBER, n, istride, iptr,
a(1,1),
iindex(1), n, 1, irev, rc)
397 IF (LHOOK) CALL DR_HOOK(COUNT_DRHOOKSTR,1,ZHOOK_SUBHANDLE0,n)
399 IF (LHOOK) CALL DR_HOOK(GNOME_DRHOOKSTR,0,ZHOOK_SUBHANDLE0)
400 CALL ecgnomesort(KEYSORT_NUMBER, n, istride, iptr,
a(1,1),
iindex(1), n, 1, rc)
401 IF (LHOOK) CALL DR_HOOK(GNOME_DRHOOKSTR,1,ZHOOK_SUBHANDLE0,n)
404 else ! i.e. LLomp_okay ;
radix, quick & counting -sorts only
405 if (.not.allocated(ista)) then
410 if (imod == 0) iadd = 0
414 if (iadd > 0 .and. j > imod) iadd = 0
416 ista(inumt+1) = n + 1
423 write(0,1004) '>> ista(1:inumt+1)=',ista(1:inumt+1)
424 write(0,1004) '>> ichunk(1:inumt)=',ichunk(1:inumt)
429 if (LLdebug) write(0,1004) '>>KEYLOOP: jkey,ikey,irev,iptr=',jkey,ikey,irev,iptr
431 if (.not.LLadjusted) then ! only once
432 if (LLdebug) write(0,1000) '<1>iindex(1:n)=',n,
sum(iindex(1:n)),iindex(1:n)
434 if (LLdebug) write(0,1000) '<2>iindex(1:n)=',n,
sum(iindex(1:n))+n,iindex(1:n)
438 if (LLdebug) write(0,*)'>> Sorting inumt-chunks in parallel'
439 !$OMP PARALLEL PRIVATE(j,j1,j2,inum,iret,inc,ITID,ZHOOK_SUBHANDLE1,ZHOOK_SUBHANDLE2)
440 IF (LHOOK) CALL DR_HOOK('ECSORT_MIX:KEYSORT_2D>OMPSORT',0,ZHOOK_SUBHANDLE1)
441 ITID = OML_MY_THREAD()
442 !$OMP DO SCHEDULE(DYNAMIC,1)
448 if (LLdebug) write(0,1001) ITID,'j,j1,j2,inum,inc=',j,j1,j2,inum,inc
449 if (LLdebug) write(0,1002) ITID,'iindex(j1:j2) > ',iindex(j1:j2)
450 select case (imethod)
452 IF (LHOOK) CALL DR_HOOK(RSORT_DRHOOKSTR,0,ZHOOK_SUBHANDLE2)
454 CALL rsort64(KEYSORT_NUMBER, inum, istride, iptr,
a(1,1),
iindex(j1), 0, iret)
456 CALL rsort32_func(KEYSORT_NUMBER, inum, istride, iptr,
a(1,1),
iindex(j1), 0, iret)
458 IF (LHOOK) CALL DR_HOOK(RSORT_DRHOOKSTR,1,ZHOOK_SUBHANDLE2, inum)
460 IF (LHOOK) CALL DR_HOOK(ECQSORT_DRHOOKSTR,0,ZHOOK_SUBHANDLE2)
461 CALL ecqsort(KEYSORT_NUMBER, inum, istride, iptr,
a(1,1),
iindex(j1), 0, irev, iret)
462 IF (LHOOK) CALL DR_HOOK(ECQSORT_DRHOOKSTR,1,ZHOOK_SUBHANDLE2,inum)
464 IF (LHOOK) CALL DR_HOOK(COUNT_DRHOOKSTR,0,ZHOOK_SUBHANDLE2)
465 CALL ec_countingsort(KEYSORT_NUMBER, inum, istride, iptr,
a(1,1),
iindex(j1), inum, 0, irev, iret)
466 IF (LHOOK) CALL DR_HOOK(COUNT_DRHOOKSTR,1,ZHOOK_SUBHANDLE2,inum)
468 if (LLdebug) write(0,1002) ITID,'iindex(j1:j2) < ',iindex(j1:j2)
471 IF (LHOOK) CALL DR_HOOK('ECSORT_MIX:KEYSORT_2D>OMPSORT',1,ZHOOK_SUBHANDLE1)
474 if (LLdebug) write(0,1000) '<after_sort>iindex(1:n)=',n,
sum(iindex(1:n))+n,iindex(1:n)
475 if (LLdebug) CALL
DBGPRINT(0,'<after_sort>',a,iindex,n,ikey,1,n,1)
476 CALL
get_rank(iindex, irank, index_adj=+1)
478 if (LLdebug) write(0,*) '>> Merge neighbouring chunks in parallel as much as possible'
480 imax = (inumt+inc-1)/inc
482 if (LLdebug) write(0,1001) jj,'<before_merge> jj,inc,imax,inumt=',jj,inc,imax,inumt
483 !$OMP PARALLEL PRIVATE(j,j1,j2,inum,iamax,ibmax,jmid,iret,ZHOOK_SUBHANDLE3,ITID)
484 IF (LHOOK) CALL DR_HOOK('ECSORT_MIX:KEYSORT_2D>OMPMERGE',0,ZHOOK_SUBHANDLE3)
485 ITID = OML_MY_THREAD()
486 !$OMP DO SCHEDULE(DYNAMIC,1)
490 jmid = (j1 + j2)/2 + 1
492 jmid = min(jmid,inumt)
493 if (LLdebug) write(0,1001) ITID,'j,j1,j2,jmid=',j,j1,j2,jmid
494 iamax = ista(jmid) - ista(j1)
495 inum =
sum(ichunk(j1:j2))
497 if (LLdebug) write(0,1001) ITID,'j,iamax,ibmax,inum=',j,iamax,ibmax,inum
498 if (iamax == 0 .or. ibmax == 0 .or. inum == 0) cycle
501 if (LLdebug) write(0,1001) ITID,'j,j1,j2,inum=',j,j1,j2,inum
502 if (LLdebug) write(0,1002) ITID,'iindex(j1:j2) > ',iindex(j1:j2)
503 call ecmerge2(KEYSORT_NUMBER, iptr, iamax, ibmax, a(1,1), &
504 & iindex(j1), inum, 0, irev, irank(1), iret)
505 if (LLdebug) write(0,1002) ITID,'iindex(j1:j2) < ',iindex(j1:j2)
506 enddo ! do j=1,inumt,inc
508 IF (LHOOK) CALL DR_HOOK('ECSORT_MIX:KEYSORT_2D>OMPMERGE',1,ZHOOK_SUBHANDLE3)
511 if (LLdebug) write(0,1003) jj,'<after_merge>iindex(1:n)=',n,
sum(iindex(1:n))+n,iindex(1:n)
512 if (LLdebug) CALL DBGPRINT(jj,'<after_merge>',a,iindex,n,ikey,1,n,1)
517 endif !
if (LLomp_okay)
519 if (LLdescending) then
520 if (istride == 1) then
521 a(1:n,ikey) = -a(1:n,ikey)
523 a(ikey,1:n) = -a(ikey,1:n)
527 if (LLadjusted .and. imethod /= imethod_rest) then ! Restore back immediately
528 if (LLdebug) write(0,1000) '<3a>iindex(1:n)=',n,
sum(iindex(1:n))+n,iindex(1:n)
530 if (LLdebug) write(0,1000) '<4a>iindex(1:n)=',n,
sum(iindex(1:n)),iindex(1:n)
534 imethod = imethod_rest
538 if (allocated(ista)) deallocate(ista)
539 if (allocated(ichunk)) deallocate(ichunk)
540 if (allocated(irank)) deallocate(irank)
542 if (LLadjusted) then ! Restore back
543 if (LLdebug) write(0,1000) '<3b>iindex(1:n)=',n,
sum(iindex(1:n))+n,iindex(1:n)
545 if (LLdebug) write(0,1000) '<4b>iindex(1:n)=',n,
sum(iindex(1:n)),iindex(1:n)
549 if (LLdebug) write(0,1000) '<END>iindex(1:n)=',n,
sum(iindex(1:n)),iindex(1:n)
550 if (LLdebug) CALL DBGPRINT(0,'<END>',a,iindex,n,ilastkey,1,n,0)
552 if (.not.present(index)) then
553 LLomp_okay = (
nomp >= inumt .and. n >=
nomp)
554 if (istride == 1) then
555 LLomp_okay = (LLomp_okay .and. sda >= inumt .and. .not. OML_IN_PARALLEL()) ! Prevents nested OpenMP
556 !$OMP PARALLEL PRIVATE(j,data)
IF (LLomp_okay)
558 !$OMP DO SCHEDULE(DYNAMIC,1)
560 data(1:n) = a(iindex(1:n),j)
567 LLomp_okay = (LLomp_okay .and. lda >= inumt .and. .not. OML_IN_PARALLEL()) ! Prevents nested OpenMP
568 !$OMP PARALLEL PRIVATE(i,data)
IF (LLomp_okay)
570 !$OMP DO SCHEDULE(DYNAMIC,1)
572 data(1:n) = a(i,iindex(1:n))
584 IF (LHOOK) CALL DR_HOOK(KEYSORT_2D_DRHOOKSTR,1,ZHOOK_HANDLE,n*inumkeys)
587 !-----------------------------
588 !-- Private subroutines --
589 !-----------------------------
591 SUBROUTINE DBGPRINT(jj, cdstr, a, index, n, key, k1, k2, kadd)
593 INTEGER(KIND=JPIM), intent(in) :: jj, n, key, k1, k2, kadd
594 INTEGER(KIND=JPIM), intent(in) :: index(:)
595 DATA_TYPE, intent(in) :: a(:,:)
597 1000 FORMAT(i3,a,5i5)
598 1011 FORMAT((5i12)) !
integer*4
599 1012 FORMAT(1p,(5g20.12)) !
real*8
600 1013 FORMAT(1p,(5g20.12)) !
real*4
601 1014 FORMAT((5i12)) !
integer*8
602 WRITE(0,1000) jj,cdstr
606 WRITE(0,'(2i6)',advance='
no') j,i-kadd
607 WRITE(0,DBGFMTNUM) a(i,:)
611 SUBROUTINE HEAPSORT(
id, n, a, rc, irev, istride, index)
612 INTEGER(KIND=JPIM), intent(in) ::
id, n, irev, istride
613 DATA_TYPE, intent(in) :: a(:)
614 INTEGER(KIND=JPIM), intent(out) :: rc
615 INTEGER(KIND=JPIM), intent(inout) :: index(:)
616 INTEGER(KIND=JPIM) :: i,j,right,left,idx
618 REAL(KIND=JPRB) :: ZHOOK_HANDLE
619 IF (LHOOK) CALL DR_HOOK(HEAPSORT_DRHOOKSTR,0,ZHOOK_HANDLE)
621 if (n <= 0 .or.
size(a) <= 0) goto 99
630 index(right) = index(1)
640 do while (j <= right)
642 if (a(index(j)) < a(index(j+1))) j = j + 1
644 if (tmp < a(index(j))) then
656 IF (LHOOK) CALL DR_HOOK(HEAPSORT_DRHOOKSTR,1,ZHOOK_HANDLE)
666 #undef KEYSORT_1D_DRHOOKSTR 668 #undef KEYSORT_2D_DRHOOKSTR 669 #undef KEYSORT_NUMBER 670 #undef RSORT_DRHOOKSTR 672 #undef QSORTFAST_DRHOOKSTR 674 #undef HEAPSORT_DRHOOKSTR 677 #undef ECQSORT_DRHOOKSTR 678 #undef COUNT_DRHOOKSTR 679 #undef GNOME_DRHOOKSTR
intent(out) overrides sub arrays one lda
integer(kind=jpim), parameter quicksort_method
intent(out) overrides sub arrays one Sort by the least significant key first< BEGIN > else CALL no reversing is needed savings if(imethod==quicksort_method .or. &imethod==countingsort_method) LLdescending
integer(kind=jpim), parameter gnomesort_method
subroutine, public init_index(INDEX, INDEX_ADJ)
intent(out) overrides sub arrays one Sort by the least significant key first< BEGIN > else CALL DBGPRINT(-jkey,'< BEGIN >', a, iindex, n, ikey, 1, n, 0) endif ilastkey
integer(kind=jpim), parameter min_method
quick &counting sorts only ichunk(inumt)) inc
quick &counting sorts only inumt inumt imethod
quick &counting sorts only inumt inumt inumt
subroutine, public adjust_index(INDEX, INDEX_ADJ)
intent(out) overrides sub arrays one Sort by the least significant key first ikey
integer, dimension(:,:), allocatable no
integer(kind=jpim), parameter heapsort_method
integer(kind=jpim), parameter max_method
static unsigned char * init
intent(out) overrides sub arrays one Sort by the least significant key first< BEGIN > iindex
subroutine, public get_rank(INDEX, RANK, INDEX_ADJ)
INTERFACE SUBROUTINE JPRB IMPLICIT NONE INTEGER(KIND=JPIM)
intent(out) overrides sub arrays one Sort by the least significant key first sum(iindex(1:n))
integer(kind=jpim), parameter radixsort_method
quick &counting sorts only inumt ista(j)
integer(kind=jpim), dimension(nthrds) current_method
quick &counting sorts only inumt inumt nomp
!define ISRCHFLTPV_N !define ISRCHFLTPV_N ISRCHFLTPV_NBITER IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I-1)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+1)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+2)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+3)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+4)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+5)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+6)).LT.ISRCHFLTPV_TARGET) THEN IF(ISRCHFLTPV_ARRAY(1+ISRCHFLTPV_INC *(ISRCHFLTPV_I+7)).LT.ISRCHFLTPV_TARGET) THEN ISRCHFLTPV_RESULT
quick &counting sorts only inumt inumt method_name(imethod) write(0
integer(kind=jpim) default_method
INTERFACE SUBROUTINE FACILO_MT PUNDF USE OPTIONAL ::LDUNDF ! OUT REAL(KIND=JPDBLR)
subroutine t(CDPREF, CDSUFF, KCODPA, LDNIVA, PMULTI)
integer(kind=jpim), parameter countingsort_method