NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
indexxd.for
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page indexxd
4 c> \endif
5 c>
6 c> Subroutine to perform ?? indexing on floating point data (double precision)
7 c>
8 c> \param[in] n number of iterations (rows?)
9 c> \param[in] nd array and index dimensions
10 c> \param[in] arr input data array
11 c> \param[out] indx index out
12 c>
13 c> ## Changelog
14 c>
15 c> ### 1/8/2004:
16 c> Modified to allow `indx` and `arr` to
17 c> be DIMENSIONED differently than the number of good
18 c> values they contain
19 c>
20 c> ### 11/7/2003
21 c> Modified to REAL*8 by D. Smith,
22 c>
23  SUBROUTINE indexxd(n,nd,arr,indx)
24 c - Modified to REAL*8 by D. Smith, 11/7/2003
25 c - Further modified 1/8/2004 to allow indx and arr to
26 c - be DIMENSIONED differently than the number of good
27 c - values they contain
28 
29  integer nd
30  INTEGER n,indx(nd),M,NSTACK
31  REAL*8 arr(nd)
32  parameter(m=7,nstack=50)
33  INTEGER i,indxt,ir,itemp,j,jstack,k,l,istack(nstack)
34  REAL*8 a
35  do 11 j=1,n
36  indx(j)=j
37 11 continue
38  jstack=0
39  l=1
40  ir=n
41 1 if(ir-l.lt.m)then
42  do 13 j=l+1,ir
43  indxt=indx(j)
44  a=arr(indxt)
45  do 12 i=j-1,1,-1
46  if(arr(indx(i)).le.a)goto 2
47  indx(i+1)=indx(i)
48 12 continue
49  i=0
50 2 indx(i+1)=indxt
51 13 continue
52  if(jstack.eq.0)return
53  ir=istack(jstack)
54  l=istack(jstack-1)
55  jstack=jstack-2
56  else
57  k=(l+ir)/2
58  itemp=indx(k)
59  indx(k)=indx(l+1)
60  indx(l+1)=itemp
61  if(arr(indx(l+1)).gt.arr(indx(ir)))then
62  itemp=indx(l+1)
63  indx(l+1)=indx(ir)
64  indx(ir)=itemp
65  endif
66  if(arr(indx(l)).gt.arr(indx(ir)))then
67  itemp=indx(l)
68  indx(l)=indx(ir)
69  indx(ir)=itemp
70  endif
71  if(arr(indx(l+1)).gt.arr(indx(l)))then
72  itemp=indx(l+1)
73  indx(l+1)=indx(l)
74  indx(l)=itemp
75  endif
76  i=l+1
77  j=ir
78  indxt=indx(l)
79  a=arr(indxt)
80 3 continue
81  i=i+1
82  if(arr(indx(i)).lt.a)goto 3
83 4 continue
84  j=j-1
85  if(arr(indx(j)).gt.a)goto 4
86  if(j.lt.i)goto 5
87  itemp=indx(i)
88  indx(i)=indx(j)
89  indx(j)=itemp
90  goto 3
91 5 indx(l)=indx(j)
92  indx(j)=indxt
93  jstack=jstack+2
94  if(jstack.gt.nstack)pause 'NSTACK too small in indexx'
95  if(ir-i+1.ge.j-l)then
96  istack(jstack)=ir
97  istack(jstack-1)=i
98  ir=j-1
99  else
100  istack(jstack)=j-1
101  istack(jstack-1)=l
102  l=i
103  endif
104  endif
105  goto 1
106  END
subroutine indexxd(n, nd, arr, indx)
Subroutine to perform ?? indexing on floating point data (double precision)
Definition: indexxd.for:24