V3FIT
mkspl3zb.f
1  subroutine mkspl3zb(fun,x,nx,th,nth,ph,nph,fspl,nf2,nf3,
2  > ibcxmin,bcxmin,ibcxmax,bcxmax,nb1,
3  > wk,inwk,ilinx,ilinth,ilinph,ier)
4 C
5 C create a tricubic biperiodic spline with knots at grid points and
6 C function values from the callable function `fun' passed.
7 C
8 C use tpsplinb to setup the spline coefficients
9 C
10 C periodic boundary condition for theta & phi grids.
11 C boundary condition data may be specified at x(1) and x(nx) for each
12 C theta & phi:
13 C ibcxmin=0 ==> "not a knot" boundary condition, cf cubspl.for
14 C ibcxmin=1 ==> match slope, bcxmin(ith,iph) gives df/dx at
15 C x(1),th(ith),ph(iph)
16 C ibcxmin=2 ==> match 2nd derivative, given at x(1),th(ith),ph(iph)
17 C by bcxmin(ith,iph)
18 C
19 C ibcxmax,bcxmax have analogous interpretation -- at x(nx).
20 C
21  external fun ! passed real function(x,th)
22  real x(nx) ! x coordinate array
23  real th(nth) ! th coordinate array
24  real ph(nph) ! ph coordinate array
25 C
26  real fspl(8,nf2,nf3,nph) ! function data / spline coeff array
27  real wk(inwk) ! workspace for bpsplinb
28 C
29  integer ibcxmin ! boundary condition indicator
30  real bcxmin(nb1,nph) ! boundary condition data
31  integer ibcxmax ! boundary condition indicator
32  real bcxmax(nb1,nph) ! boundary condition data
33 C
34  integer ilinx ! output =1 if x(...) evenly spaced
35  integer ilinth ! output =1 if th(...) evenly spaced
36  integer ilinph ! output =1 if ph(...) evenly spaced
37 C
38  integer ier ! completion code from bpspline
39 C
40 C----------------------------
41 C
42  ier=0
43  if(nf2.lt.nx) then
44  write(6,'('.lt.' ?mkspl3pb -- array dim error, nf2 nx'')')
45  ier=1
46  endif
47  if(nf3.lt.nth) then
48  write(6,'('.lt.' ?mkspl3pb -- array dim error, nf3 nth'')')
49  ier=2
50  endif
51  if(nb1.lt.nth) then
52  write(6,'('.lt.' ?mkspl3pb -- array dim error, nb1 nth'')')
53  ier=3
54  endif
55 
56  if(ier.ne.0) return
57 C
58  do iph=1,nph
59  do ith=1,nth
60  do ix=1,nx
61  fspl(1,ix,ith,iph)=fun(x(ix),th(ith),ph(iph))
62  enddo
63  enddo
64  enddo
65 C
66  call mktricubw(x,nx,th,nth,ph,nph,fspl,nf2,nf3,
67  > ibcxmin,bcxmin,ibcxmax,bcxmax,nb1,
68  > -1,zdummy,-1,zdummy,max(nx,nth,nph),
69  > -1,zdummy,-1,zdummy,max(nx,nth,nph),
70  > wk,inwk,ilinx,ilinth,ilinph,ier)
71 C
72  return
73  end