COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kpolintp2S.f
Go to the documentation of this file.
1 ! test kpolintp2Stest kpolintp2S
2 ! single precision version of kpolintp2
3 ! implicit none
4 ! integer m, n, adj
5 ! parameter (m = 20, n=20, adj=m+5)
6 ! real*4 xa(m), ya(n), za(adj, n), x, y, z, error
7 ! integer i, j, ma, na
8 ! ma = 4
9 ! na = 4
10 ! do i =1, m
11 ! xa(i) = i/5.
12 ! enddo
13 !
14 ! do j=1, n
15 ! ya(j) = j/3.
16 ! enddo
17 ! do i = 1, m
18 ! do j = 1, n
19 ! za(i, j) = exp(xa(i))* sin(ya(j))
20 ! enddo
21 ! enddo
22 !
23 ! do i=1, m
24 ! x= xa(i)+.23
25 ! do j=1, n
26 ! y = ya(j) +.2
27 ! call kpolintp2S(xa, 1, 1/5., ya, 1, 1/3.,
28 ! * za, adj, m, n, ma, na, x, y, z, error)
29 !c write(*, *) x, y, exp(x)*sin(y), z, error
30 ! write(*, *) x, y,
31 ! * abs(z-exp(x)*sin(y))/exp(x)*sin(y)
32 ! enddo
33 ! write(*,*)
34 ! enddo
35 ! end
36 
37 ! two dimensional interpolation, using kpolintpS
38 !
39  subroutine kpolintp2s(xa, xstep, dx, ya, ystep, dy,
40  * za, adj, m, n, ma, na, x, y, z, error)
41 ! ********************************************************
42 ! real*4 xa(xstep, m). input.
43 ! real*4 ya(ystep, n). input.
44 ! real*4 dx. input. if non zero, xa is assumed to be
45 ! equistepd with dx.
46 ! real*4 dy. input. the same as dx for y.
47 ! integer adj. input. adjustable dim. fo z >= m
48 ! real*4 za(adj, n). input. function values at (xa, ya)
49 ! real*4 x. input.
50 ! real*4 y. input.
51 ! real*4 z. output. estimated func. value at (x, y).
52 !
53 ! integer ma. input. a max of ma points around x is used
54 ! integer na. input. a max of na points around y is used.
55 ! ma, na <= maxp(=10)
56 !
57  implicit none
58  integer xstep, ystep, n, m, na, ma, adj
59  real*4 xa(xstep, m), ya(ystep, n), za(adj, n)
60  real*4 x, y, z, error, dx, dy
61 
62  integer lx, ly, kx, ky, i, maxp
63  parameter(maxp = 10) ! max # of points.
64  real*4 ztmp(maxp)
65 !
66  if(ma .gt. maxp .or. na .gt. maxp) then
67  write(*, *) "kpolintp2S: too large number of points"
68  stop
69  endif
70  if(dx .eq. 0.) then
71  call kwhereis(x, m, xa, xstep, lx)
72  else
73  lx = (x - xa(1,1))/dx+1
74  endif
75 
76  if(dy .eq. 0.) then
77  call kwhereis(y, n, ya, ystep, ly)
78  else
79  ly = (y-ya(1,1))/dy +1
80  endif
81  kx = min(max(lx - (ma -1)/2,1), m+1-ma) ! max of ma points from kx
82  ky = min(max(ly - (na -1)/2,1), n+1-na) ! max of na points from ky
83 
84 ! make ztmp: scan along x direction
85  do i = kx, min(m, kx + ma-1)
86  if(dy .eq. 0.) then
87  call kpolintps(ya(1, ky), ystep, za(i, ky), adj,
88  * min(na, n- ky +1), y, ztmp(i-kx+1), error)
89  else
90  call kpolintpseqs( (ya(1, 1)+(ky-1)*dy), dy, za(i, ky), adj,
91  * min(na, n- ky +1), y, ztmp(i-kx+1), error)
92  endif
93  enddo
94  if(dx .eq. 0.) then
95  call kpolintps(xa(1, kx), xstep, ztmp, 1,
96  * min(ma, m-kx +1), x, z, error)
97  else
98  call kpolintpseqs( (xa(1, 1)+(kx-1)*dx), dx, ztmp, 1,
99  * min(ma, m-kx +1), x, z, error)
100  endif
101  end
102 
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine kpolintpseqs(x0, dx, ya, ystep, n, x, y, error)
Definition: kpolintpS.f:229
subroutine kpolintps(xa, xstep, ya, ystep, n, x, y, error)
Definition: kpolintpS.f:164
subroutine kwhereis(x, in, a, step, loc)
Definition: kdwhereis.f:63
subroutine kpolintp2s(xa, xstep, dx, ya, ystep, dy, za, adj, m, n, ma, na, x, y, z, error)
Definition: kpolintp2S.f:41