      subroutine getgrp
      include 'screen.inc'
      integer*2 maxgrp
      parameter (maxgrp=20)
      real cutpnt(maxgrp),nobjct(maxgrp),temp
      integer*2 ngrps,icolt
      logical yesno
      external yesno
 5    call cls
c
c   get number of groups to read in
c
      irow=5
      icol=10
      line='Begin entry of grouped data.'
      call scrlin
      irow=irow+1
      line='Enter up to 30 characters for a label: '
      call scrlin
      call getbuf(line,nchar,30,iatt)
      write(iout,'(a)') line(1:30)
      irow=irow+1
 10   line='Number of different cut points or groups used is: '
      call scrlin
      call getbuf(line,nchar,10,iatt)
      ngrps=0
      if (nchar.eq.0 .or. line.eq.' ') go to 11
      read(unit=line,fmt='(f10.0)',err=11) temp
      ngrps=int(temp)
 11   if (ngrps.lt.1 .or. ngrps.gt.maxgrp) then
         call scroll(1,0,irow,49,irow,80,7,ierror)
         call putcur(irow+1,icol,ivpage,ierror)
         write(line,'(a,i3,a)') 'Number of groups must be  1 < ngrps <',
     1      maxgrp,'.  Re-enter.'
         call wchars(ivpage,line,70,icolor,ibckgd,0,ierror)
         go to 10
      endif
c
c   put heading at top of table to read in groups
c
      call cls
      icol=1
      irow=1
      write(line,'(a,5x,a,5x,a)') 'Group Number',
     1    'Cut Point Value','Number of Objects Observed'
      call scrlin
      irow=2
      write(line,'(12a1,5x,15a1,5x,26a1)') ('-',i=1,53)
      call scrlin
c   loop to read in a cutpoint and number of objects
      do 20 i=1,ngrps
         iline=i
         irow=irow+1
c   enter line number in table
         call putcur(irow,5,ivpage,ierror)
         write(line,'(i3)') i
         call wchars(ivpage,line,3,icolor,ibckgd,0,ierror)
c   loop to read first line length, then number of objects
 23      do 22 icode=1,2
 21         if (icode.eq.1) then
               write(line,'(a,a,a,i3,a)') 'Enter cut point in ',
     1            disunt(1:ndisut),' for number ',iline,': '
            else
               line='Enter number of objects observed: '
            endif
            icolt=index(line,':')+1
            call putcur(24,5,ivpage,ierror)
            call wchars(ivpage,line,icolt,icolor,ibckgd,0,ierror)
 29         call putcur(24,icolt+5,ivpage,ierror)
            call getbuf(line,nchar,10,iatt)
            temp=0.
            if (nchar.eq.0) go to 28
            read(line,'(f10.0)',err=28) temp
 28         if ((icode.eq.1 .and. temp.le.0.) .or.
     1          (icode.eq.2 .and. temp.lt.0.)) then
               call scroll(1,0,24,icolt+5,24,80,7,ierror)
               call putcur(25,5,ivpage,ierror)
               call wchars(ivpage,'Incorrect input.  Re-enter.',27,
     1            icolor,ibckgd,0,ierror)
               go to 29
            else
               call scroll(1,0,24,1,25,80,7,ierror)
               if (icode.eq.1) then
                  cutpnt(iline)=temp
                  write(line,'(g11.5)') temp
                  call putcur(irow,22,ivpage,ierror)
                  if (pntran) then
                     cutpnt(iline)=cutpnt(iline)**2*pi
                  endif
               else
                  nobjct(iline)=temp
                  write(line,'(i5,6x)') int(temp)
                  call putcur(irow,45,ivpage,ierror)
               endif
               call wchars(ivpage,line,11,icolor,ibckgd,0,ierror)
            endif
 22         continue
c
c   section to request changes in table when 20 entries are in place
c
         if (i.eq.ngrps) then
            call scroll(1,1,23,1,25,80,7,ierror)
            irow=23
            icol=5
            line=
     1      'Everything above OK, and ready to proceed to next page?'
            if (yesno(0)) then
               call scroll(1,0,3,1,25,80,7,ierror)
               irow=2
            else
 26            call scroll(1,0,23,1,25,80,7,ierror)
               call putcur(23,5,ivpage,ierror)
               line='Which group above should be changed: '
               call wchars(ivpage,line,37,icolor,ibckgd,0,ierror)
               call getbuf(line,nchar,3,iatt)
               iline=0
               read(line,'(i3)',err=27) iline
 27            if (iline.gt.i-20 .and. iline.le.i) then
                  irow=mod(iline,20)+2
                  if (irow.eq.2) irow=22
                  go to 23
               else
                 call scroll(1,0,23,29,23,80,7,ierror)
                 call putcur(24,5,ivpage,ierror)
                 call wchars(ivpage,'Improper input. Re-enter.',30,
     1              icolor,ibckgd,0,ierror)
                  go to 26
               endif
            endif
         endif
 20      continue
      write(unit=iout,fmt='(6(g11.5,:1h,),:t80,1h$)')
     1   (cutpnt(i),i=1,ngrps)
      write(unit=iout,fmt='(10(i6,:1h,),:t80,1h$)')
     1   (int(nobjct(i)),i=1,ngrps)
      call scroll(1,1,23,1,25,80,7,ierror)
      irow=23
      icol=5
      line='Do you want to enter another set of grouped data?'
         if (yesno(1)) then
            go to 5
         endif
      end
