      SUBROUTINE ADAPT (F, XLFT, XRGT, EPSLN, NPIECE, ERREST, XKNOTS,
     * COEFS, IERR, KMAX, NDEG, NSMTH, ANORM, DX, MO, KBREAK, BRAKPT,
     * KDIFF, VALLFT, VALRGT)
C
C        ===============================================================
C
C     TABULATION OF THE INTERNAL AND EXTERNAL NAMES OF THE ARGUMENTS.
C
C
C    INTERNAL   EXTERNAL
C     F          F
C     A          XLFT
C     B          XRGT
C     ACCUR      EPSLN
C     KNOTS      NPIECE
C     ERROR      ERREST
C     XKNOTS     XKNOTS
C     COEFS      COEFS
C     IERR       IERR
C     KMAX       KMAX
C     DEGREE     NDEG
C     SMOOTH     NSMTH
C     NORM       ANORM
C     CHARF      DX
C     EDIST      MO
C     NBREAK     KBREAK
C     XBREAK     BRAKPT
C     DBREAK     KDIFF
C     BLEFT      VALLFT
C     BRIGHT     VALRGT
C
      DOUBLE PRECISION A, ACCUR, B, BLEFT, BRIGHT, CHARF, DDTEMP,
     * DSCTOL, ERROR, ERRORI, FACTOR, FINTRP, FLEFT, FRIGHT, NORM,
     * XBREAK, XDD, XINTRP, XLEFT, XRIGHT, BUFFER
      DIMENSION XBREAK(20), DBREAK(20), BLEFT(20), BRIGHT(20)
      DIMENSION XLEFT(50), XRIGHT(50)
      DIMENSION DDTEMP(20,20), FACTOR(20), FINTRP(18), FLEFT(10),
     * FRIGHT(10), XDD(20), XINTRP(18)
      INTEGER BOTH, BREAK, DBREAK, DEGREE, EDIST, RIGHT, RIGHTX, SMOOTH
      LOGICAL DISCRD
      DOUBLE PRECISION XKNOTS(1), COEFS(KMAX,1)
      DOUBLE PRECISION ANORM, BRAKPT, DX, EPSLN, ERREST, VALLFT,
     * VALRGT, XLFT, XRGT
      DIMENSION BRAKPT(KBREAK), KDIFF(KBREAK), VALLFT(KBREAK),
     * VALRGT(KBREAK)
      DOUBLE PRECISION F
      EXTERNAL F
C
      COMMON /INPUTZ/ A, B, ACCUR, NORM, CHARF, XBREAK, BLEFT, BRIGHT,
     * DBREAK, DEGREE, SMOOTH, LEVEL, EDIST, NBREAK, KNTDIM, NPARDM
      COMMON /RESULZ/ ERROR, KNOTS
      COMMON /KONTRL/ DSCTOL, ERRORI, XLEFT, XRIGHT, BREAK, BOTH,
     * FACTOR, IBREAK, INTERP, LEFT, MAXAUX, MAXKNT, MAXPAR, MAXSTK,
     * NPAR, NSTACK, RIGHT, DISCRD, BUFFER
      COMMON /COMDIF/ DDTEMP, FINTRP, FLEFT, FRIGHT, XDD, XINTRP,
     * LEFTX, NINTRP, RIGHTX
C
C
   10 A = XLFT
      B = XRGT
      ACCUR = EPSLN
      DEGREE = NDEG
      SMOOTH = NSMTH
      NORM = ANORM
      CHARF = DX
      EDIST = MO
      NBREAK = KBREAK
      IF (NBREAK.LE.0 .OR. NBREAK.GE.21) GO TO 30
      DO 20 K=1,NBREAK
        XBREAK(K) = BRAKPT(K)
        DBREAK(K) = KDIFF(K)
        BLEFT(K) = VALLFT(K)
        BRIGHT(K) = VALRGT(K)
   20 CONTINUE
   30 CONTINUE
C
      KDIMEN = KMAX+1
      NDIMEN = NDEG+1
      CALL ADAPT1(F, XKNOTS, COEFS, KDIMEN, KMAX, NDIMEN, IERR)
      NPIECE = KNOTS
      ERREST = ERROR
      RETURN
      END
