      SUBROUTINE FIT_GFINAL(IUO,IUD,NFIT,X1,X2,A)
C Bernd Berg, September 11 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
