      subroutine rfmomry1(xi,theta,ijac,R,Z,jac2)
c
c  single point vsn
c
      real*8, intent(in) :: xi,theta
      integer, intent(in) :: ijac

      real*8, intent(out) :: R,Z
      real*8, intent(out) :: jac2(2,2)
c
c----------------------------------------
c
      real*8 :: xiv(1),thv(1)
      real*8 :: rv(1),zv(1)
      real*8 :: jac2v(2,2,1)
c
c----------------------------------------
c
      xiv(1)=xi
      thv(1)=theta
c
      call rfmomry(1,xiv,thv,ijac,rv,zv,jac2v)

      R=rv(1)
      Z=zv(1)
      if(ijac.gt.0) then
         jac2(1:2,1:2) = jac2v(1:2,1:2,1)
      endif

      return
      end

c----------------------------------------

      subroutine rfmomry(ivec,xi,theta,ijac,R,Z,jac2)
c
c  fppmod/xplasma momry replacement routine -- args in cm as in the
c  old TRANSP routine, for now.
c  ** internal use only **
c
      IMPLICIT NONE
c  input:
      integer ivec                      ! vector size
      REAL*8 xi(ivec)                     ! radial coordinate
      REAL*8 theta(ivec)                  ! poloidal coordinate
c
      integer ijac                      ! if .gt.0 -- compute jacobian
c
c  output:
      REAL*8 R(ivec),Z(ivec)              ! (R,Z) position (cm)
 
      REAL*8 jac2(2,2,ivec)               ! 2x2 Jacobian (cm/...)
c
c------------------------------------------------------
c
      REAL*8 zphi(ivec),czero,c100
c
      REAL*8 zjtens(3,3,ivec),zdetj(ivec)
c
      integer iregion(ivec)
      integer ierr,irzmode,i
c
c------------------------------------------------------
c
      czero=0
      c100 =100
      zphi=czero
c
      if(ijac.gt.0) then
         irzmode=2
         call eq_getjac(ivec,xi,theta,zphi,irzmode,zjtens,zdetj,ierr)
c
         if(ierr.ne.0) then
            call errmsg_exit(' ?rfmomry -- ierr.ne.0 after eq_getjac!')
         else if(minval(zdetj)*maxval(zdetj).le.czero) then
            call errmsg_exit(' ?rfmomry -- singular Jacobian!')
         endif
c
         do i=1,ivec
            R(i)=zjtens(3,3,i)*c100
            Z(i)=zjtens(1,3,i)*c100  ! irzmode=2 gives this
c
c  note off diag index swap needed
c
            jac2(1,1,i)=zjtens(1,1,i)*c100
            jac2(1,2,i)=zjtens(2,1,i)*c100
            jac2(2,1,i)=zjtens(1,2,i)*c100
            jac2(2,2,i)=zjtens(2,2,i)*c100
         enddo
c
      else
c
         call eq_rzget(ivec,xi,theta,zphi,R,Z,iregion,ierr)
         if(ierr.ne.0) then
            call errmsg_exit(' ?rfmomry -- ierr.ne.0 after eq_rzget!')
         endif
c
         R=c100*R
         Z=c100*Z
c
      endif
c
      return
      end
