V3FIT
tcspvec.f
1  subroutine tcspvec(ict,ivec,xvec,yvec,zvec,ivd,fval,
2  > nx,xpkg,ny,ypkg,nz,zpkg,fspl,inf4,inf5,
3  > iwarn,ier)
4 c
5 c vectorized spline evaluation routine -- 3d spline
6 c 1. call vectorized zone lookup routine
7 c 2. call vectorized spline 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/dx2 (don't evaluate if ict(5)=0)
17 c ict(6)=1 for d2f/dy2 (don't evaluate if ict(6)=0)
18 c ict(7)=1 for d2f/dz2 (don't evaluate if ict(7)=0)
19 c ict(8)=1 for d2f/dxdy (don't evaluate if ict(8)=0)
20 c ict(9)=1 for d2f/dxdz (don't evaluate if ict(9)=0)
21 c ict(10)=1 for d2f/dydz (don't evaluate if ict(10)=0)
22 c
23  integer ivec ! vector dimensioning
24 c
25 c ivec-- number of vector pts (spline 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 spline 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 inf4 ! fspl 4th array dimension, .ge.nx
50  integer inf5 ! fspl 5th array dimension, .ge.ny
51  real fspl(4,4,4,inf4,inf5,nz) ! (non-compact) spline coefficients
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 :: dxv,dyv,dzv
63 c
64 c---------------------------------------------------------------
65 c
66 c error checks
67 c
68  ier=0
69 c
70  if(nx.lt.2) then
71  write(6,*) .lt.' ?tcspvec: nx2: nx = ',nx
72  ier=1
73  endif
74 c
75  if(ny.lt.2) then
76  write(6,*) .lt.' ?tcspvec: ny2: ny = ',ny
77  ier=1
78  endif
79 c
80  if(nz.lt.2) then
81  write(6,*) .lt.' ?tcspvec: nz2: nz = ',nz
82  ier=1
83  endif
84 c
85  if(ivec.le.0) then
86  write(6,*) .le.' ?tcspvec: vector dimension 0: ivec = ',
87  > ivec
88  ier=1
89  endif
90 c
91  if(ivd.lt.ivec) then
92  write(6,*)
93  > ' ?tcspvec: output vector dimension less than input ',
94  > 'vector dimension.'
95  write(6,*) ' ivec=',ivec,' ivd=',ivd
96  ier=1
97  endif
98 c
99  if(ier.ne.0) return
100 c
101  allocate(ix(ivec), iy(ivec), iz(ivec),
102  > dxv(ivec), dyv(ivec), dzv(ivec), stat=ier)
103 c
104  if(ier.ne.0) then
105  write(6,*)
106  > ' ?tcspvec: memory allocation failure.'
107  ier=99
108  endif
109 c
110  if(ier.ne.0) return
111 c
112 c vectorized lookups
113 c
114  ix=0; iy=0; iz=0
115  call xlookup(ivec,xvec,nx,xpkg,1,ix,dxv,dxv,dxv,iwarn1)
116  call xlookup(ivec,yvec,ny,ypkg,1,iy,dyv,dyv,dyv,iwarn2)
117  call xlookup(ivec,zvec,nz,zpkg,1,iz,dzv,dzv,dzv,iwarn3)
118  iwarn=max(iwarn1,iwarn2,iwarn3)
119 c
120 c vectorized evaluation
121 c
122  call tcspevfn(ict,ivec,ivd,fval,ix,iy,iz,dxv,dyv,dzv,
123  > fspl,inf4,inf5,nz)
124 c
125  deallocate(ix,iy,iz,dxv,dyv,dzv)
126 c
127  return
128  end