CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
qsorti.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine qsorti (n, list, key)
 

Function/Subroutine Documentation

◆ qsorti()

subroutine qsorti ( integer  n,
integer, dimension(*)  list,
integer, dimension(*)  key 
)
24 !
25  implicit none
26 !
27  integer list(*),key(*),n,ll,lr,lm,nl,nr,ltemp,stktop,maxstk,guess
28 !
29  parameter(maxstk=32)
30 !
31  integer lstack(maxstk),rstack(maxstk)
32 !
33  ll= 1
34  lr=n
35  stktop=0
36  10 if(ll.lt.lr) then
37  nl=ll
38  nr=lr
39  lm=(ll+lr)/2
40  guess=key(list(lm))
41  20 if (key(list(nl)).lt.guess) then
42  nl=nl+1
43  goto 20
44  end if
45  30 if (guess.lt.key(list(nr))) then
46  nr=nr-1
47  goto 30
48  end if
49  if(nl.lt.(nr-1)) then
50  ltemp=list(nl)
51  list(nl)=list(nr)
52  list(nr)=ltemp
53  nl=nl+1
54  nr=nr-1
55  goto 20
56  end if
57  if(nl.le.nr) then
58  if(nl.lt.nr) then
59  ltemp=list(nl)
60  list(nl)=list(nr)
61  list(nr)=ltemp
62  end if
63  nl=nl+1
64  nr=nr-1
65  end if
66  stktop=stktop+1
67  if(nr.lt.lm) then
68  lstack(stktop)=nl
69  rstack(stktop)=lr
70  lr=nr
71  else
72  lstack(stktop)=ll
73  rstack(stktop)=nr
74  ll=nl
75  end if
76  goto 10
77  end if
78  if (stktop.ne.0) then
79  ll=lstack(stktop)
80  lr=rstack(stktop)
81  stktop=stktop-1
82  goto 10
83  end if
Hosted by OpenAircraft.com, (Michigan UAV, LLC)