!---------------------------------------------------------------------
!  mombs_nb -- given flux coords compute local (r,y) and field
!     version for use inside nubeam library
!
subroutine mombs_nb(zxi,zth,zrpos,zypos,zjac,zb,zbp,zbt)
  !
  use nbi_com
  !
  !  this routine calls momry and computes the local field at the
  !  indicated position which is within the indicated transp zone.
  !
  !  input:
  implicit none
  real(fp) :: zxi,zth          ! radial and poloidal angle flux coords
  !
  !  output:
  real(fp) :: zrpos,zypos      ! the spatial position (r,y) (cm)
  real(fp) :: zjac(2,2)        ! 2x2 jacobian (per nbmomry)
  real(fp) :: zb,zbp,zbt       ! the field magnitudes (tot,pol,tor) (t)
  !
  !---------------------------------------
  real(fp) :: zx0,zh
  integer :: ix
  real(fp) :: ziot,zg,zdpsdx,zdet,zgradx
  !
  !---------------------------------------
  !
  !  spline interpolation of r,z and 2x2 jacobian
  !
  if(nfast_map.eq.1) then
     call nbmomry(zxi,zth,1,zrpos,zypos,zjac)  ! use bilinear maps
  else
     call nbmomry_xs(zxi,zth,1,zrpos,zypos,zjac)  !use xplasma spline maps
  end if
  !
  !  spline interpolations of quantities for the field
  !
  ix=int(zxi/dxi(lcentr,2)) + 1
  zx0=real(ix-1,fp)*dxi(lcentr,2)
  zh=zxi-zx0
  !  beam code call
  ziot=spliot(1,ix)+zh*(spliot(2,ix) + zh*( &
       spliot(3,ix)+zh*spliot(4,ix)))
  zg=1.0e-4_fp*(splg(1,ix)+zh*(splg(2,ix) + zh*( &
       splg(3,ix)+zh*splg(4,ix))))
  !
  !  poloidal flux derivative
  !
  zdpsdx=zxi*tflux*ziot/xpi
  !
  zdet=(zjac(1,1)*zjac(2,2)-zjac(1,2)*zjac(2,1))
  zgradx=sqrt(zjac(2,2)**2+zjac(1,2)**2)/zdet
  !
  !  poloidal field -- tesla
  !
  zbp = 1.e4_fp*zdpsdx*zgradx/zrpos
  !
  !  toroidal field -- tesla
  !
  zbt = zg/zrpos
  !
  zb = sqrt(zbp**2 + zbt**2)
  !
  return
end subroutine mombs_nb
! 11sep2004 fgtok
