gibuu is hosted by Hepforge, IPPP Durham
GiBUU

TABLE OF CONTENTS


/sorting [ Modules ]

[ Top ] [ Modules ]

NAME

module sorting

PURPOSE

This module defines some routines for sorting purposes


sorting/indexx [ Subroutines ]

[ Top ] [ sorting ] [ Subroutines ]

NAME

SUBROUTINE indexx(arr,index)

PURPOSE

Indexes an array arr, i.e., outputs the array index of length N such that arr(index(j)) is in ascending order for j = 1, 2, . . . ,N. The input quantity arr is not changed.

(Uses SORTTF from CernLib; cf. SORTZV)

INPUTS

  • real, dimension(:) :: arr

OUTPUT

  • integer, dimension(:) :: index

NOTES

the integer array "index" has to be provided as input. The size may not be smaller than the size of "arr"

USAGE

Assume you have to arrays A and B and you want to access the information first in an unsorted way and secondly sorted according the values of array A.

Example:

    do i=1,n
      write(*,*) A(i),B(i)         ! unsorted
    enddo
    call indexx(A,ii)
    do i=1,n
      write(*,*) A(ii(i)),B(ii(i)) ! sorted according A
    enddo