V3FIT
r8vectricub.f
1  subroutine r8vectricub(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 *compact* 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 !============
12 ! idecl: explicitize implicit INTEGER declarations:
13  IMPLICIT NONE
14  INTEGER, PARAMETER :: R8=selected_real_kind(12,100)
15  INTEGER iwarn1,iwarn2,iwarn3
16 !============
17 ! idecl: explicitize implicit REAL declarations:
18  real*8 stat
19 !============
20  integer ict(10) ! selector:
21 c ict(1)=1 for f (don't evaluate if ict(1)=0)
22 c ict(2)=1 for df/dx (don't evaluate if ict(2)=0)
23 c ict(3)=1 for df/dy (don't evaluate if ict(3)=0)
24 c ict(4)=1 for df/dy (don't evaluate if ict(4)=0)
25 c ict(5)=1 for d2f/dx2 (don't evaluate if ict(5)=0)
26 c ict(6)=1 for d2f/dy2 (don't evaluate if ict(6)=0)
27 c ict(7)=1 for d2f/dz2 (don't evaluate if ict(7)=0)
28 c ict(8)=1 for d2f/dxdy (don't evaluate if ict(8)=0)
29 c ict(9)=1 for d2f/dxdz (don't evaluate if ict(9)=0)
30 c ict(10)=1 for d2f/dydz (don't evaluate if ict(10)=0)
31 c
32  integer ivec ! vector dimensioning
33 c
34 c ivec-- number of vector pts (spline values to look up)
35 c
36 c list of (x,y,z) triples:
37 c
38  real*8 xvec(ivec) ! x-locations at which to evaluate
39  real*8 yvec(ivec) ! y-locations at which to evaluate
40  real*8 zvec(ivec) ! z-locations at which to evaluate
41 c
42  integer ivd ! 1st dimension of output array
43 c
44 c ivd -- 1st dimension of fval, .ge.ivec
45 c
46 c output:
47  real*8 fval(ivd,*) ! output array
48 c
49 c fval(1:ivec,1) -- values as per 1st non-zero ict(...) element
50 c fval(1:ivec,2) -- values as per 2nd non-zero ict(...) element
51 c --etc--
52 c
53 c input:
54  integer nx,ny,nz ! dimension of spline grids
55  REAL*8 xpkg(nx,4) ! x grid "package" (cf genxpkg)
56  real*8 ypkg(ny,4) ! y grid "package" (cf genxpkg)
57  real*8 zpkg(nz,4) ! z grid "package" (cf genxpkg)
58  integer inf4 ! fspl 4th array dimension, .ge.nx
59  integer inf5 ! fspl 5th array dimension, .ge.ny
60  real*8 fspl(8,inf4,inf5,nz) ! (compact) spline coefficients
61 c
62 c output:
63 c condition codes, 0 = normal return
64  integer iwarn ! =1 if an x value was out of range
65  integer ier ! =1 if argument error detected
66 c
67 c---------------------------------------------------------------
68 c local arrays
69 c
70  integer, dimension(:), allocatable :: ix,iy,iz
71  REAL*8, dimension(:), allocatable :: dxn,dyn,dzn
72  real*8, dimension(:), allocatable :: hx,hxi,hy,hyi,hz,hzi
73 c
74 c---------------------------------------------------------------
75 c
76 c error checks
77 c
78  ier=0
79 c
80  if(nx.lt.2) then
81  write(6,*) .lt.' ?vectricub: nx2: nx = ',nx
82  ier=1
83  endif
84 c
85  if(ny.lt.2) then
86  write(6,*) .lt.' ?vectricub: ny2: ny = ',ny
87  ier=1
88  endif
89 c
90  if(nz.lt.2) then
91  write(6,*) .lt.' ?vectricub: nz2: nz = ',nz
92  ier=1
93  endif
94 c
95  if(ivec.le.0) then
96  write(6,*) .le.' ?vectricub: vector dimension 0: ivec = ',
97  > ivec
98  ier=1
99  endif
100 c
101  if(ivd.lt.ivec) then
102  write(6,*)
103  > ' ?vectricub: output vector dimension less than input ',
104  > 'vector dimension.'
105  write(6,*) ' ivec=',ivec,' ivd=',ivd
106  ier=1
107  endif
108 c
109  if(ier.ne.0) return
110 c
111  allocate(ix(ivec), iy(ivec), iz(ivec),
112  > dxn(ivec), dyn(ivec), dzn(ivec),
113  > hx(ivec), hy(ivec), hz(ivec),
114  > hxi(ivec), hyi(ivec), hzi(ivec), stat=ier)
115 c
116  if(ier.ne.0) then
117  write(6,*)
118  > ' ?vectricub: memory allocation failure.'
119  ier=99
120  endif
121 c
122  if(ier.ne.0) return
123 c
124 c vectorized lookup
125 c
126  ix=0; iy=0; iz=0
127  call r8xlookup(ivec,xvec,nx,xpkg,2,ix,dxn,hx,hxi,iwarn1)
128  call r8xlookup(ivec,yvec,ny,ypkg,2,iy,dyn,hy,hyi,iwarn2)
129  call r8xlookup(ivec,zvec,nz,zpkg,2,iz,dzn,hz,hzi,iwarn3)
130  iwarn=max(iwarn1,iwarn2,iwarn3)
131 c
132 c vectorized evaluation
133 c
134  call r8fvtricub(ict,ivec,ivd,fval,ix,iy,iz,dxn,dyn,dzn,
135  > hx,hxi,hy,hyi,hz,hzi,fspl,inf4,inf5,nz)
136 c
137  deallocate(ix,iy,iz,dxn,dyn,dzn,hx,hy,hz,hxi,hyi,hzi)
138 c
139  return
140  end