c
c
c************************************************************************
c
      subroutine CH ( icode, mmax, m, kg, iv, t, y, weight, alf )
c
c-----------------------------------------------------------------------
c
c   change the value of data points, weights, nonlinear
c   parameters or numerical derivative increments 
c   (depending on the command code entered).
c
      PARAMETER ( maxp=200 ) 
c
      dimension  t(mmax,iv), y(m), weight(m), alf(kg) 
c
      real  ndi(maxp)
c
      logical  ip
c
      character*1 ians
      character*4 icode
c
      common /blkndi/ ndi
      common /blokip/ ip
c
c---------------------------------------------------------------------
c
10    format (a1)
c
      if (icode.eq.'ct') go to 20
c
      if (icode.eq.'cw') go to 80
c
      if (icode.eq.'calf') go to 120
c
      if (icode.eq.'cndi') go to 160
c
c---------------- change one or more data points ----------------------
c
20    continue
      print 30
30    format (' which data point is to be changed ?  ')
      print 40
40    format (' (type its index no. as it appears in the',' list)  ') 
      read (5,*) il 
      if (il.lt.1.or.il.gt.m) goto 20
      print 50, il
50    format (' type new indep & dep variables for data point ',
     2        i3,':  ')
      read (5,*) (t(il,j),j=1,iv),y(il) 
      if (ip) write (10,60) il,(t(il,j),j=1,iv),y(il)
60    format (' '/' ','new indep & dependent variables for point ',i3,
     2        ':  '/1p4e15.6/15x,1p3e15.6)
      print 70
70    format (' do you want to change any others ?  ')
      read 10, ians 
      if (ians.eq.'y') go to 20
      go to 200
c
c--------------- change one or more weights ----------------------
c
80    continue
      print 79
79    format (' are weights to be changed using subroutine wt ?  ')
      read 10,ians
      if ( ians .ne. 'y' ) go to 84
c
c    --------------------------
      call WT ( m, weight, y )
c    --------------------------
c
      goto 200
84    print 81
81    format (' are all weights to be changed to the same value ?  ')
      read 10,ians
      if (ians .ne. 'y') goto 85
      print 82
82    format (' enter the value:   ')
      read (5,*) wtval
      do 83 i=1,m
         weight(i) = wtval
83    continue
      if (ip) write (10,101) wtval
101   format (' '/' ','new weight value for all data points:  ',1pe15.6)
      goto 200
85    print 90
90    format (' which weight is to be changed ?  ')
      print 40
      read (5,*) il 
      if (il.lt.1.or.il.gt.m) goto 85
      print 100, il 
100   format (' enter new weight for data point',i4,': ')
      read (5,*) weight(il)
      if (ip) write (10,110) il,weight(il)
110   format (' '/' ','new weight for data point',i4,': ',1pe15.6)
      print 70
      read 10, ians 
      if (ians.eq.'y') go to 80
      go to 200
c
c------------ change one or more nonlinear parameters ---------------
c
120   continue
      print 130
130   format (' which nonlinear parameter is to be',' changed ?  ')
      print 40
      read (5,*) il 
      if (il.lt.1.or.il.gt.kg) goto 120 
      print 140, il 
140   format (' enter new value for parameter',i4,': ')
      read (5,*) alf(il)
      if (ip) write (10,150) il,alf(il) 
150   format (' '/
     1        ' ','new value for nonlinear parameter',i4,': ',1pe15.6)
      print 70
      read 10, ians 
      if (ians.eq.'y') go to 120
      go to 200
c
c---------- change one or more numer deriv increments ------------
c
160   continue
      print 170
170   format (' which numer. deriv. increment is to be',' changed ?  ')
      print 40
      read (5,*) il 
      if (il.lt.1.or.il.gt.maxp) goto 160
      print 180, il 
180   format (' new increment for derivate',i4,': ')
      read (5,*) ndi(il)
      if (ip) write (10,190) il,ndi(il) 
190   format (' '/' ','new increment for derivative',i4,': ',1pe15.6) 
      print 70
      read 10, ians 
      if (ians.eq.'y') go to 160
c
200   return
c
      end 
