V3FIT
r8vecpc3.f
1  subroutine r8vecpc3(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 !============
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/dxdy (don't evaluate if ict(5)=0)
26 c ict(6)=1 for d2f/dxdz (don't evaluate if ict(6)=0)
27 c ict(7)=1 for d2f/dydz (don't evaluate if ict(7)=0)
28 c ict(8)=1 for d3f/dxdydz (don't evaluate if ict(8)=0)
29 c
30 c note -- derivatives are *not* continuous!
31 c
32  integer ivec ! vector dimensioning
33 c
34 c ivec-- number of vector pts (piecewise linear 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 axis 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 inf1 ! flin 1st array dimension, .ge.nx
59  integer inf2 ! flin 2nd array dimension, .ge.ny
60  real*8 flin(inf1,inf2,nz) ! Piecewise Linear function array
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(ivec.le.0) then
81  write(6,*) .le.' ?vecpc3: vector dimension 0: ivec = ',
82  > ivec
83  ier=1
84  endif
85 c
86  if(ivd.lt.ivec) then
87  write(6,*)
88  > ' ?vecpc3: output vector dimension less than input ',
89  > 'vector dimension.'
90  write(6,*) ' ivec=',ivec,' ivd=',ivd
91  ier=1
92  endif
93 c
94  if(ier.ne.0) return
95 c
96  allocate(ix(ivec), iy(ivec), iz(ivec),
97  > dxn(ivec), dyn(ivec), dzn(ivec),
98  > hx(ivec), hy(ivec), hz(ivec),
99  > hxi(ivec), hyi(ivec), hzi(ivec), stat=ier)
100 c
101  if(ier.ne.0) then
102  write(6,*)
103  > ' ?vecpc3: memory allocation failure.'
104  ier=99
105  endif
106 c
107  if(ier.ne.0) return
108 c
109 c vectorized lookup
110 c
111  ix=0; iy=0; iz=0
112  call r8xlookup(ivec,xvec,nx,xpkg,2,ix,dxn,hx,hxi,iwarn1)
113  call r8xlookup(ivec,yvec,ny,ypkg,2,iy,dyn,hy,hyi,iwarn2)
114  call r8xlookup(ivec,zvec,nz,zpkg,2,iz,dzn,hz,hzi,iwarn3)
115  iwarn=max(iwarn1,iwarn2,iwarn3)
116 c
117 c vectorized evaluation
118 c
119  call r8pc3fcn(ict,ivec,ivd,fval,ix,iy,iz,dxn,dyn,dzn,
120  > hx,hxi,hy,hyi,hz,hzi,flin,inf1,inf2,nz)
121 c
122  deallocate(ix,iy,iz,dxn,dyn,dzn,hx,hy,hz,hxi,hyi,hzi)
123 c
124  return
125  end