V3FIT
LIBSTELL
Sources
Pspline
zonfind.f
1
subroutine
zonfind(x,nx,zxget,i)
2
c
3
real
x(nx),zxget
4
integer
i
5
c
6
c find index i such that x(i).le.zxget.le.x(i+1)
7
c
8
c x(1...nx) is strict increasing and x(1).le.zxget.le.x(nx)
9
c (this is assumed to already have been checked -- no check here!)
10
c
11
nxm=nx-1
12
if
((i.lt.1).or.(i.gt.nxm))
then
13
i1=1
14
i2=nx-1
15
go to
10
16
endif
17
c
18
if
(x(i).gt.zxget)
then
19
c look down
20
dx=x(i+1)-x(i)
21
if
((x(i)-zxget).gt.4*dx)
then
22
i1=1
23
i2=i-1
24
go to
10
25
else
26
i2=i-1
27
do
ij=i2,1,-1
28
if
((x(ij).le.zxget).and.(zxget.le.x(ij+1)))
then
29
i=ij
30
return
31
endif
32
enddo
33
i=1
34
return
35
endif
36
else
if
(x(i+1).lt.zxget)
then
37
c look up
38
dx=x(i+1)-x(i)
39
if
((zxget-x(i+1)).gt.4*dx)
then
40
i1=i+1
41
i2=nxm
42
go to
10
43
else
44
i2=i+1
45
do
ij=i2,nxm
46
if
((x(ij).le.zxget).and.(zxget.le.x(ij+1)))
then
47
i=ij
48
return
49
endif
50
enddo
51
ij=nxm
52
return
53
endif
54
else
55
c already there...
56
return
57
endif
58
c
59
c---------------------------
60
c binary search
61
c
62
10
continue
63
c
64
if
(i1.eq.i2)
then
65
c found by proc. of elimination
66
i=i1
67
return
68
endif
69
c
70
ii=(i1+i2)/2
71
c
72
if
(zxget.lt.x(ii))
then
73
i2=ii-1
74
else
if
(zxget.gt.x(ii+1))
then
75
i1=ii+1
76
else
77
c found
78
i=ii
79
return
80
endif
81
c
82
go to
10
83
c
84
end
85
Generated on Thu Mar 5 2020 15:49:25 for V3FIT by
1.8.17