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