      subroutine fit_gfinal(iuo,iud,nfit,x1,x2,a)
c bernd berg, september 12, 2006.
c overwrites gfit.d file with extended fit.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      parameter(nplot=200,mmax=20)
      dimension a(nfit),dyda(mmax)
      if(nfit.gt.mmax) stop "fit_gfinal: mmax too small."
      write(iuo,'(/," fit_gfinal: overwrites gfit.d x1,x2 =",2g14.5,/)')
     &                                              x1,x2
      open(iud,file='gfit.d',form='formatted',status='unknown')
      delx=(x2-x1)/nplot
      do i=0,nplot
        xx=x1+i*delx
        call subg(xx,a,yy,dyda,nfit)
        write(iud,'(2g16.7)') xx,yy
      end do
      close(iud)
      return
      end
