      program FigVGR ! BB June 012017.
c Gravitational units G=c=1. Mass unit: Central mass = 1.
c Parameter: Specific angular momentum in units of the central mass.
      implicit real*8 (a-h,o-z)
      logical ltest
      character ch*6
      parameter(iuo=6,iud=8,ngnu=5000)
      parameter(h=100.0d00) ! Specific angular momentum.
c     parameter(r0=2.d00,r1=1.d05) ! N Distance plott range.
      parameter(r0=1.d00,r1=1.d02) ! S Distance plott range.
      ltest=.false.
      if(ltest) stop "FigVGR: ltest."
      ltest=.true.
      write(iuo,'(/," r0,   r1   =  ",2g12.4)') r0,r1
      h2=h**2
      hsqrt=sqrt(h2*abs(h2/4.d00-3.d00))
      if(h2.gt.12) then
        rmax=h2/2.d00-hsqrt 
        rmin=h2/2.d00+hsqrt 
        write(iuo,'(" rmax, rmin =  ",2g12.4,/)') rmax,rmin
      else
        write(iuo,'(" Re,   Im   =  ",2g12.4,
     &  " (rmin, rmax complex)",/)') h2/2,hsqrt
      endif
      tmr=2.d00*r1
      write(iuo,'(" h, tmr   =",2g12.4,/)') h,tmr
c
      dr=(r1-r0)/ngnu
      ih=nint(10.d00*h)
      write(ch,'(i6.6)') ih
      open(iud,file="VGR"//ch//"S.d",form='formatted',status='unknown')
      do i=0,ngnu
        r=r0+i*dr
        xn1=2/r        ! 1. Newton contribution.
        xn2=(h/r)**2      ! 2. Newton contribution.
        vn=xn2-xn1        ! Newton effective potential.
        tmr=2*r
        vnn=(h2-tmr)/r**2 ! vnn=vn tested.
c xn1 and gr have the same sign (negative contributions)
        gr=2*h**2/r**3 ! Schwarzschild gravity contribution.
        vg=vn-gr       ! Gravity effective potential.
        dv=vg-vn
        write(iud,'(i9,4g16.7)') i,r,vn,vg,dv
      enddo
      close(iud)
      stop "FigVGR: all done."
      end
