      parameter (nc=14,nmax=2000)
      character *10 nome
      character *5 aval(nc,nmax)
      integer iyear(nmax)
      open (unit=4,file='OKTXLCRN.txt',status='old')
      do j=1,nc
         id1 = j/10
         id2 = j-10*id1
         nome = 'oktx'//
     $        char(48+id1)//
     $        char(48+id2)//'.dat'
         write (6,*) nome
         open (unit=10+j,file=nome,status='unknown')
      end do
c
777   format (i4,14a5)
      do i=1,nmax
         read (4,777,end=99) iyear(i),(aval(j,i),j=1,nc)
         do j=1,nc
            if (aval(j,i).eq.'    .') aval(j,i)=' -999'
         end do
      end do
99    nx = i-1
      write (6,*) 'nx: ',nx
      do j=1,nc
         do i=1,nx
            if (aval(j,i).ne.' -999') then
               istart = i
               goto 33
            endif
         end do
33       do i=nx,1,-1
            if (aval(j,i).ne.' -999') then
               iend = i
               goto 44
            endif
         end do
44       do i=istart,iend
             write (10+j,*) iyear(i),aval(j,i)
         end do
      end do
      close (unit=4)
      do j=1,nc
         close (unit=10+j)
      end do
      stop
      end
