       program coostats
         character*80 fname
         integer*4 ict(10)

         write(*,*) 'enter coo file name:'
         read(*,'(a80)') fname
         open(11, file=fname, status='old')

         do isc = 1, 10
            ict(isc) = 0
         end do

         nap = 0
         read(11,*,iostat=ios) i, x, s, z, ze, r, scl
         do while (ios .eq. 0)
            nap = nap + 1

            if (nap .ne. i) then
               write(*,*) 'error: i .ne. nap: ', i, nap
               stop
            end if

            if (scl .eq. 0.) then
               ict(10) = ict(10) + 1
            else if (scl .ge. 1. .and. scl .le. 6.) then
               ict(int(scl)) = ict(int(scl)) + 1
            else if (scl .eq. 88.) then
               ict(8) = ict(8) + 1  
            else if (scl .eq. 77.) then
               ict(7) = ict(7) + 1  
            else if (scl .eq. -1.) then
               ict(9) = ict(9) + 1
            else
               write(*,*)
     $           'error: scl unknown: i, z, ze, scl, r = ',
     $                   i, z, ze, scl, r
            end if

            read(11,*,iostat=ios) i, x, s, z, ze, r, scl            
         end do

         close(11)

         write(*,*) 'nap = ', nap
         nok = 0
         do i = 1, 5
            nok = nok + ict(i)
         end do
         write(*,*) 'nok = ', nok
         do i = 1, 6
            write(*,*) '  scl ', i, ' : ', ict(i), 
     $        real(ict(i))/real(nok)*100., ' %'
         end do
         write(*,*) 
         write(*,*) 'scl 0 : ', ict(10)
         write(*,*) 'scl 88 : ', ict(8)
         write(*,*) 'scl 77 (star) : ', ict(7)
         write(*,*) 'scl -1 : ', ict(9)
         write(*,*) 
         ntry = nap - ict(9) - ict(7)
         write(*,*) 'ntry = ', ntry
         write(*,*) 'nok/ntry = ', real(nok)/real(ntry)      
         
         call exit(0)
       end 
