V3FIT
vecpc3.f
1  subroutine vecpc3(ict,ivec,xvec,yvec,zvec,ivd,fval,
2  > nx,xpkg,ny,ypkg,nz,zpkg,flin,inf1,inf2,
3  > iwarn,ier)
4 c
5 c vectorized piecewise linear evaluation routine --
6 c 1. call vectorized zone lookup routine
7 c 2. call vectorized piecewise linear evaluation routine
8 c
9 c--------------------------
10 c input:
11  integer ict(10) ! selector:
12 c ict(1)=1 for f (don't evaluate if ict(1)=0)
13 c ict(2)=1 for df/dx (don't evaluate if ict(2)=0)
14 c ict(3)=1 for df/dy (don't evaluate if ict(3)=0)
15 c ict(4)=1 for df/dy (don't evaluate if ict(4)=0)
16 c ict(5)=1 for d2f/dxdy (don't evaluate if ict(5)=0)
17 c ict(6)=1 for d2f/dxdz (don't evaluate if ict(6)=0)
18 c ict(7)=1 for d2f/dydz (don't evaluate if ict(7)=0)
19 c ict(8)=1 for d3f/dxdydz (don't evaluate if ict(8)=0)
20 c
21 c note -- derivatives are *not* continuous!
22 c
23  integer ivec ! vector dimensioning
24 c
25 c ivec-- number of vector pts (piecewise linear values to look up)
26 c
27 c list of (x,y,z) triples:
28 c
29  real xvec(ivec) ! x-locations at which to evaluate
30  real yvec(ivec) ! y-locations at which to evaluate
31  real zvec(ivec) ! z-locations at which to evaluate
32 c
33  integer ivd ! 1st dimension of output array
34 c
35 c ivd -- 1st dimension of fval, .ge.ivec
36 c
37 c output:
38  real fval(ivd,*) ! output array
39 c
40 c fval(1:ivec,1) -- values as per 1st non-zero ict(...) element
41 c fval(1:ivec,2) -- values as per 2nd non-zero ict(...) element
42 c --etc--
43 c
44 c input:
45  integer nx,ny,nz ! dimension of axis grids
46  real xpkg(nx,4) ! x grid "package" (cf genxpkg)
47  real ypkg(ny,4) ! y grid "package" (cf genxpkg)
48  real zpkg(nz,4) ! z grid "package" (cf genxpkg)
49  integer inf1 ! flin 1st array dimension, .ge.nx
50  integer inf2 ! flin 2nd array dimension, .ge.ny
51  real flin(inf1,inf2,nz) ! Piecewise Linear function array
52 c
53 c output:
54 c condition codes, 0 = normal return
55  integer iwarn ! =1 if an x value was out of range
56  integer ier ! =1 if argument error detected
57 c
58 c---------------------------------------------------------------
59 c local arrays
60 c
61  integer, dimension(:), allocatable :: ix,iy,iz
62  real, dimension(:), allocatable :: dxn,dyn,dzn
63  real, dimension(:), allocatable :: hx,hxi,hy,hyi,hz,hzi
64 c
65 c---------------------------------------------------------------
66 c
67 c error checks
68 c
69  ier=0
70 c
71  if(ivec.le.0) then
72  write(6,*) .le.' ?vecpc3: vector dimension 0: ivec = ',
73  > ivec
74  ier=1
75  endif
76 c
77  if(ivd.lt.ivec) then
78  write(6,*)
79  > ' ?vecpc3: output vector dimension less than input ',
80  > 'vector dimension.'
81  write(6,*) ' ivec=',ivec,' ivd=',ivd
82  ier=1
83  endif
84 c
85  if(ier.ne.0) return
86 c
87  allocate(ix(ivec), iy(ivec), iz(ivec),
88  > dxn(ivec), dyn(ivec), dzn(ivec),
89  > hx(ivec), hy(ivec), hz(ivec),
90  > hxi(ivec), hyi(ivec), hzi(ivec), stat=ier)
91 c
92  if(ier.ne.0) then
93  write(6,*)
94  > ' ?vecpc3: memory allocation failure.'
95  ier=99
96  endif
97 c
98  if(ier.ne.0) return
99 c
100 c vectorized lookup
101 c
102  ix=0; iy=0; iz=0
103  call xlookup(ivec,xvec,nx,xpkg,2,ix,dxn,hx,hxi,iwarn1)
104  call xlookup(ivec,yvec,ny,ypkg,2,iy,dyn,hy,hyi,iwarn2)
105  call xlookup(ivec,zvec,nz,zpkg,2,iz,dzn,hz,hzi,iwarn3)
106  iwarn=max(iwarn1,iwarn2,iwarn3)
107 c
108 c vectorized evaluation
109 c
110  call pc3fcn(ict,ivec,ivd,fval,ix,iy,iz,dxn,dyn,dzn,
111  > hx,hxi,hy,hyi,hz,hzi,flin,inf1,inf2,nz)
112 c
113  deallocate(ix,iy,iz,dxn,dyn,dzn,hx,hy,hz,hxi,hyi,hzi)
114 c
115  return
116  end