NADCON5-ng
0.0.2
NADCON5 Next Generation Documentation
About
Manual
Code Documentation
Project Homepage
Project Github
PDF Manual
Index
File List
File Members
iselect2.for
Go to the documentation of this file.
1
c> \ingroup core
2
c> \if MANPAGE
3
c> \page iselect2
4
c> \endif
5
c>
6
c> Function to select an element of a partially filled, but packed multi dimensional array, `integer*2`
7
c>
8
c> Finds the "kth" element of an array, "arr", which
9
c> is dimensioned to be "nmax" values long, but which
10
c> only has data in the first "n" cells.
11
c>
12
c> ## Changelog
13
c>
14
c> ### 1/14/2016:
15
c>
16
c> Like "select2" but modified by D. Smith
17
c> to allow an "nmax" array given, but which only
18
c> has values in elements 1-n, and to have "arr"
19
c> be Integer*2
20
c>
21
FUNCTION
iselect2
(k,n,arr,nmax)
22
23
c - Like "select2" but modified by D. Smith on 1/14/2016
24
c - to allow an "nmax" array given, but which only
25
c - has values in elements 1-n, and to have "arr"
26
c - be Integer*2
27
28
INTEGER
k,n,nmax
29
c REAL*8 select,arr(nmax)
30
integer*2
iselect2,arr(nmax)
31
INTEGER
i,ir,j,l,mid
32
c REAL*8 a,temp
33
integer*2
a,temp
34
l=1
35
ir=n
36
1
if
(ir-l.le.1)
then
37
if
(ir-l.eq.1)
then
38
if
(arr(ir).lt.arr(l))
then
39
temp=arr(l)
40
arr(l)=arr(ir)
41
arr(ir)=temp
42
endif
43
endif
44
iselect2=arr(k)
45
return
46
else
47
mid=(l+ir)/2
48
temp=arr(mid)
49
arr(mid)=arr(l+1)
50
arr(l+1)=temp
51
if
(arr(l+1).gt.arr(ir))
then
52
temp=arr(l+1)
53
arr(l+1)=arr(ir)
54
arr(ir)=temp
55
endif
56
if
(arr(l).gt.arr(ir))
then
57
temp=arr(l)
58
arr(l)=arr(ir)
59
arr(ir)=temp
60
endif
61
if
(arr(l+1).gt.arr(l))
then
62
temp=arr(l+1)
63
arr(l+1)=arr(l)
64
arr(l)=temp
65
endif
66
i=l+1
67
j=ir
68
a=arr(l)
69
3
continue
70
i=i+1
71
if
(arr(i).lt.a)
goto
3
72
4
continue
73
j=j-1
74
if
(arr(j).gt.a)
goto
4
75
if
(j.lt.i)
goto
5
76
temp=arr(i)
77
arr(i)=arr(j)
78
arr(j)=temp
79
goto
3
80
5 arr(l)=arr(j)
81
arr(j)=a
82
if
(j.ge.k)ir=j-1
83
if
(j.le.k)l=i
84
endif
85
goto
1
86
END
iselect2
integer *2 function iselect2(k, n, arr, nmax)
Function to select an element of a partially filled, but packed multi dimensional array...
Definition:
iselect2.for:22
src
Subs
iselect2.for
Generated on Tue Dec 5 2017 18:50:25 for NADCON5-ng by
1.8.11