!---------------------------------------------------------------------------
! This code was developed at Tech-X (www.txcorp.com). It is free for any one
! to use but comes with no warranty whatsoever. Use at your own risk. 
! Thanks for reporting bugs to pletzer@txcorp.com. 
!---------------------------------------------------------------------------
! Compute spline coefficients

#include "cpp/czspline_handle_size.h"

#define _S czspline_setup1
#define _O czspline1
  subroutine _S(handle, n1, f, ier)
    use iso_c_binding, only: fp => c_double
    use ezspline_obj
    use ezspline
    use czspline_pointer_types
    implicit none
    integer, intent(inout) :: handle(_ARRSZ)
    integer, intent(in) :: n1
    real(fp), intent(in) :: f(n1)
    integer, intent(out) :: ier
    type(_O) :: self
    self = transfer(handle, self)
    call ezspline_setup(self % ptr, f, ier)
  end subroutine _S
#undef _S
#undef _O

#define _S czspline_setup2
#define _O czspline2
  subroutine _S(handle, n1, n2, f, ier)
    use iso_c_binding, only: fp => c_double
    use ezspline_obj
    use ezspline
    use czspline_pointer_types
    implicit none
    integer, intent(inout) :: handle(_ARRSZ)
    integer, intent(in) :: n1, n2
    real(fp), intent(in) :: f(n1, n2)
    integer, intent(out) :: ier
    type(_O) :: self
    self = transfer(handle, self)
    call ezspline_setup(self % ptr, f, ier)
  end subroutine _S
#undef _S
#undef _O

#define _S czspline_setup3
#define _O czspline3
  subroutine _S(handle, n1, n2, n3, f, ier)
    use ezspline_obj
    use ezspline
    use czspline_pointer_types
    implicit none
    integer, intent(inout) :: handle(_ARRSZ)
    integer, intent(in) :: n1, n2, n3
    real(fp), intent(in) :: f(n1, n2, n3)
    integer, intent(out) :: ier
    type(_O) :: self
    self = transfer(handle, self)
    call ezspline_setup(self % ptr, f, ier)
  end subroutine _S
#undef _S
#undef _O
