!******************** start file jintrp.for ; group jintrp ******************
subroutine jintrp
  !
  !       dmc oct 2001 -- *rewritten* -- used spline routine
  !
  !       --------
  !       comments
  !       --------
  !
  !
  !        this routine does the 2-d interpolation to compute the jacobian
  !    terms for a set of beam ions.  this is parallel to bintrp in style
  !    and function.  the primary use is in routines orbg, orbgxy, comprsg.
  !
  !
  !       -------------------
  !       global declarations
  !       -------------------
  !
  use nbi_com
  use logmod
  !
  !
  !       ---------------
  !       input variables
  !       ---------------
  !
  !
  !***
  !
  !
  !       ----------------
  !       output variables
  !       ----------------
  !
  !
  !***
  !
  !
  !       ------------------
  !       local declarations
  !       ------------------
  !
  !
  !============
  implicit none
  integer :: ion,j
  !============
  real(fp) :: zminxi,zximin,zximax
  !============
  parameter	(ion=1)	!vec	needed to force compiler opt.
  !
  !       ---------------
  !       data statements
  !       ---------------
  !
  !
  data	zminxi	/1.0e-5_fp/	!minimum xi allowed
  !
  !
  !       -------------------
  !       statement functions
  !       -------------------
  !
  !=========================================
  !
  !
  !vec  do 70000 ion = 1, nbi  ! if this is ever used, some rearrangement
  !                            ! of the eq_getjac call will be required
  !
  zximin = zminxi                    !min xi allowed
  zximax = xbmbnd + 0.5_fp*dxizc(ledge) !max xi allowed for splines
  !
  ! ---------- moments ------------
  bixi(ion) = max(zximin,min(zximax,bixi(ion)))
  !
  !       -------------------------------------------------------------
  !       2.0     compute j and it's derivatives w.r.t. xi & theta-star
  !       -------------------------------------------------------------
  !
  !		----------------------
  !		j(theta,xi)
  !		d(j)/d(theta)
  !		d(j)/d(xi)
  !		----------------------
  !
  call nbsplj(bixi(ion),bithst(ion),bijac(ion), &
       bijdts(ion),bijdxi(ion))

  if ( bijac(ion) .le. 0._fp)  then
     call errorlog(' jintrp: -- jacobian <0 and =',bijac(ion))
     call errorlog(' jintrp: -- bixi(ion) =',bixi(ion))
     call errorlog(' jintrp: -- bithst(ion) =',bithst(ion))
     do j=lcentr,lep1
        call errorlog(' jintrp: -- qgeo =',qgeo(j))
     end do
     call bad_exit
  end if
  return
end subroutine jintrp
!******************** end file jintrp.for ; group jintrp ******************
