Due to the lapse in federal government funding, NASA is not updating this website. We sincerely regret this inconvenience.
NASA Logo
Ocean Color Science Software

ocssw V2022
select.f
Go to the documentation of this file.
1  FUNCTION select(k,n,arr)
2  INTEGER*4 k,n
3  real*8 select,arr(n)
4  INTEGER*4 i,ir,j,l,mid
5  real*8 a,temp
6  l=1
7  ir=n
8 1 if(ir-l.le.1)then
9  if(ir-l.eq.1)then
10  if(arr(ir).lt.arr(l))then
11  temp=arr(l)
12  arr(l)=arr(ir)
13  arr(ir)=temp
14  endif
15  endif
16  select=arr(k)
17  return
18  else
19  mid=(l+ir)/2
20  temp=arr(mid)
21  arr(mid)=arr(l+1)
22  arr(l+1)=temp
23  if(arr(l+1).gt.arr(ir))then
24  temp=arr(l+1)
25  arr(l+1)=arr(ir)
26  arr(ir)=temp
27  endif
28  if(arr(l).gt.arr(ir))then
29  temp=arr(l)
30  arr(l)=arr(ir)
31  arr(ir)=temp
32  endif
33  if(arr(l+1).gt.arr(l))then
34  temp=arr(l+1)
35  arr(l+1)=arr(l)
36  arr(l)=temp
37  endif
38  i=l+1
39  j=ir
40  a=arr(l)
41 3 continue
42  i=i+1
43  if(arr(i).lt.a)goto 3
44 4 continue
45  j=j-1
46  if(arr(j).gt.a)goto 4
47  if(j.lt.i)goto 5
48  temp=arr(i)
49  arr(i)=arr(j)
50  arr(j)=temp
51  goto 3
52 5 arr(l)=arr(j)
53  arr(j)=a
54  if(j.ge.k)ir=j-1
55  if(j.le.k)l=i
56  endif
57  goto 1
58  END
59 
#define real
Definition: DbAlgOcean.cpp:26
real *8 function select(k, n, arr)
Definition: select.f:2