subroutine xs_rzget1_r8(zphi,zth,zrho,zscale,zr,zz,iwarn)
 
  ! perform (phi,rho,theta)->([phi],R,Z) fast map for a single point
 
  use xstraln_mod
  implicit NONE
 
  REAL*8, intent(in) :: zphi,zth,zrho   ! input coordinates
  REAL*8, intent(in) :: zscale          ! scale factor for output
                                      ! 1.0 -> m, 100.0 -> cm
 
  REAL*8, intent(out) :: zr,zz          ! (R,Z) output (scaled)
  integer, intent(out) :: iwarn       ! warning set if (zrho) out of range
 
  !-------------------------------------------
  !  local variables:
 
  integer irho1,ith1,iphi1
  REAL*8 zfrho,zfth,zfphi
 
  REAL*8, parameter :: one = 1
  !-------------------------------------------
 
  call fxgrid1_r8(zphi,zth,zrho, &
       iphi1,zfphi, ith1,zfth, irho1,zfrho, iwarn)
 
  if(nphi.eq.1) then
 
     zr = zscale*( &
            (one-zfrho) * &
              ((one-zfth)*ffx_r8%r(1,ith1,irho1) + &
                     zfth*ffx_r8%r(1,ith1+1,irho1)) + &
             zfrho * &
              ((one-zfth)*ffx_r8%r(1,ith1,irho1+1) + &
                     zfth*ffx_r8%r(1,ith1+1,irho1+1)) )
 
     zz = zscale*( &
            (one-zfrho) * &
              ((one-zfth)*ffx_r8%z(1,ith1,irho1) + &
                     zfth*ffx_r8%z(1,ith1+1,irho1)) + &
             zfrho * &
              ((one-zfth)*ffx_r8%z(1,ith1,irho1+1) + &
                     zfth*ffx_r8%z(1,ith1+1,irho1+1)) )
  else
 
     zr = zscale*( &
         (one-zfrho) * &
            ((one-zfth) * &
              ((one-zfphi)*ffx_r8%r(iphi1,ith1,irho1) + &
                     zfphi*ffx_r8%r(iphi1+1,ith1,irho1)) + &
             zfth * &
              ((one-zfphi)*ffx_r8%r(iphi1,ith1+1,irho1) + &
                     zfphi*ffx_r8%r(iphi1+1,ith1+1,irho1)) ) + &
          zfrho * &
            ((one-zfth) * &
              ((one-zfphi)*ffx_r8%r(iphi1,ith1,irho1+1) + &
                     zfphi*ffx_r8%r(iphi1+1,ith1,irho1+1)) + &
             zfth * &
              ((one-zfphi)*ffx_r8%r(iphi1,ith1+1,irho1+1) + &
                     zfphi*ffx_r8%r(iphi1+1,ith1+1,irho1+1)) ) )
 
     zz = zscale*( &
         (one-zfrho) * &
            ((one-zfth) * &
              ((one-zfphi)*ffx_r8%z(iphi1,ith1,irho1) + &
                     zfphi*ffx_r8%z(iphi1+1,ith1,irho1)) + &
             zfth * &
              ((one-zfphi)*ffx_r8%z(iphi1,ith1+1,irho1) + &
                     zfphi*ffx_r8%z(iphi1+1,ith1+1,irho1)) ) + &
          zfrho * &
            ((one-zfth) * &
              ((one-zfphi)*ffx_r8%z(iphi1,ith1,irho1+1) + &
                     zfphi*ffx_r8%z(iphi1+1,ith1,irho1+1)) + &
             zfth * &
              ((one-zfphi)*ffx_r8%z(iphi1,ith1+1,irho1+1) + &
                     zfphi*ffx_r8%z(iphi1+1,ith1+1,irho1+1)) ) )
 
  endif
 
end subroutine xs_rzget1_r8
 
subroutine xs_rzget_r8(ivec,zphi,zth,zrho,zscale,zr,zz,iwarn)
 
  ! perform (phi,rho,theta)->([phi],R,Z) fast map for a vector of points
 
  use xstraln_mod
  implicit NONE
 
  integer, intent(in) :: ivec         ! vector dimension
  REAL*8, intent(in) :: zphi(ivec),zth(ivec),zrho(ivec) ! input coordinates
  REAL*8, intent(in) :: zscale          ! scale factor for output
                                      ! 1.0 -> m, 100.0 -> cm
 
  REAL*8, intent(out) :: zr(ivec),zz(ivec) ! (R,Z) output (scaled)
  integer, intent(out) :: iwarn(ivec) ! warning set if (zrho) out of range
 
  !-------------------------------------------
  !  local variables:
 
  integer irho1(ivec),ith1(ivec),iphi1(ivec)
  REAL*8 zfrho(ivec),zfth(ivec),zfphi(ivec)
 
  integer i,iphi,ith,irho
 
  REAL*8, parameter :: one = 1
 
  !-------------------------------------------
 
  call fxgrid_r8(ivec,zphi,zth,zrho, &
       iphi1,zfphi, ith1,zfth, irho1,zfrho, iwarn)
 
  if(nphi.eq.1) then
 
     do i=1,ivec
 
        ith=ith1(i)
        irho=irho1(i)
 
        zr(i) = zscale*( &
               (one-zfrho(i)) * &
                    ((one-zfth(i))*ffx_r8%r(1,ith,irho) + &
                           zfth(i)*ffx_r8%r(1,ith+1,irho)) + &
                zfrho(i) * &
                    ((one-zfth(i))*ffx_r8%r(1,ith,irho+1) + &
                           zfth(i)*ffx_r8%r(1,ith+1,irho+1)) )
 
        zz(i) = zscale*( &
               (one-zfrho(i)) * &
                    ((one-zfth(i))*ffx_r8%z(1,ith,irho) + &
                           zfth(i)*ffx_r8%z(1,ith+1,irho)) + &
                zfrho(i) * &
                    ((one-zfth(i))*ffx_r8%z(1,ith,irho+1) + &
                           zfth(i)*ffx_r8%z(1,ith+1,irho+1)) )
 
     enddo
 
  else
 
     do i=1,ivec
 
        ith=ith1(i)
        irho=irho1(i)
        iphi=iphi1(i)
 
        zr(i) = zscale*( &
             (one-zfrho(i)) * &
               ((one-zfth(i)) * &
                 ((one-zfphi(i))*ffx_r8%r(iphi,ith,irho) + &
                        zfphi(i)*ffx_r8%r(iphi+1,ith,irho)) + &
                zfth(i) * &
                 ((one-zfphi(i))*ffx_r8%r(iphi,ith+1,irho) + &
                        zfphi(i)*ffx_r8%r(iphi+1,ith+1,irho)) ) + &
             zfrho(i) * &
               ((one-zfth(i)) * &
                 ((one-zfphi(i))*ffx_r8%r(iphi,ith,irho+1) + &
                        zfphi(i)*ffx_r8%r(iphi+1,ith,irho+1)) + &
                zfth(i) * &
                 ((one-zfphi(i))*ffx_r8%r(iphi,ith+1,irho+1) + &
                        zfphi(i)*ffx_r8%r(iphi+1,ith+1,irho+1)) ) )
 
        zz(i) = zscale*( &
             (one-zfrho(i)) * &
               ((one-zfth(i)) * &
                 ((one-zfphi(i))*ffx_r8%z(iphi,ith,irho) + &
                        zfphi(i)*ffx_r8%z(iphi+1,ith,irho)) + &
                zfth(i) * &
                 ((one-zfphi(i))*ffx_r8%z(iphi,ith+1,irho) + &
                        zfphi(i)*ffx_r8%z(iphi+1,ith+1,irho)) ) + &
             zfrho(i) * &
               ((one-zfth(i)) * &
                 ((one-zfphi(i))*ffx_r8%z(iphi,ith,irho+1) + &
                        zfphi(i)*ffx_r8%z(iphi+1,ith,irho+1)) + &
                zfth(i) * &
                 ((one-zfphi(i))*ffx_r8%z(iphi,ith+1,irho+1) + &
                        zfphi(i)*ffx_r8%z(iphi+1,ith+1,irho+1)) ) )
 
     enddo
 
  endif
 
 
end subroutine xs_rzget_r8
