Nbody6
Main Page
Files
File List
File Members
All
Files
Functions
Variables
hpsort.f
Go to the documentation of this file.
1
SUBROUTINE
hpsort
(N,Array,Indx)
2
*
3
*
4
* Heapsort algorithm (from Press).
5
* --------------------------------
6
*
7
implicit
real*8
(a-h,o-z)
8
* dimension Array(1),Indx(1)
9
REAL*8
array(n)
10
INTEGER
indx(n)
11
*
12
*
13
do
11 j=1,n
14
indx(j)=j
15
11
continue
16
if
(n.lt.2)
RETURN
17
l=n/2+1
18
ir=n
19
10
CONTINUE
20
IF
(l.gt.1)
THEN
21
l=l-1
22
indxt=indx(l)
23
q=array(indxt)
24
ELSE
25
indxt=indx(ir)
26
q=array(indxt)
27
indx(ir)=indx(1)
28
ir=ir-1
29
IF
(ir.eq.1)
THEN
30
indx(1)=indxt
31
RETURN
32
END IF
33
END IF
34
i=l
35
j=l+l
36
20
IF
(j.le.ir)
THEN
37
IF
(j.lt.ir)
THEN
38
IF
(array(indx(j)).lt.array(indx(j+1)))j=j+1
39
END IF
40
IF
(q.lt.array(indx(j)))
THEN
41
indx(i)=indx(j)
42
i=j
43
j=j+j
44
ELSE
45
j=ir+1
46
END IF
47
goto 20
48
END IF
49
indx(i)=indxt
50
go to 10
51
END
Nbody6
Chain
hpsort.f
Generated on Sat Nov 30 2013 19:04:35 for Nbody6 by
1.8.2