      real*8 function rfgbinv(ztheta)
c
c returns B(zrho,ztheta)-zBrequ -- in GAUSS --
c This is called by a routine which finds the zero of RFGBINV, thereby
c finding the ztheta which gives the requested B value.
c
c *internal use only*
c
C============
C idecl:  explicitize implicit REAL declarations:
      IMPLICIT NONE
      REAL*8 ztheta,zr,zy,zjac(2,2),zb
C============
      REAL*8 zBrequ ! requested B field value.
      REAL*8 zxi    ! on this flux surface (normalized rho/rho_lim)
      REAL*8 zRB    ! R*Bt for rfgbcom
      common /rfgbcom/ zxi,zBrequ, zRB
 
      call rfmomry1(zxi,ztheta,0,zR,zY,zJac)
      zB=zRB/zR
      rfgbinv=zB-zBrequ
      return
      end
