      implicit real(8) (a-h,o-z)
      integer(2),dimension(4096),save :: iint,jnt,knt,lnt
      integer(2),dimension(4096),save :: iint1,jnt1,knt1,lnt1
      double precision,save,dimension(3,4096) :: aaloc,aaloc1
      open(10,file='IJCLLOCCAS',status='unknown',form='unformatted')
      kk=0
      open(1,file='ru.ijclloc4',status='old',form='unformatted')
      do
         read(1,end=1) iint,jnt,knt,lnt,aaloc
         do k=1,4096
            if(iint(k)/=39.and.iint(k)/=40.and.iint(k)/=244) cycle
            if(jnt(k)/=39.and.jnt(k)/=40.and.jnt(k)/=244) cycle
            if(knt(k)/=39.and.knt(k)/=40.and.knt(k)/=244) cycle
            if(lnt(k)/=39.and.lnt(k)/=40.and.lnt(k)/=244) cycle
            print'(4i4,3f12.8)',iint(k),jnt(k),knt(k),lnt(k),aaloc(:,k)
            kk=kk+1
            iint1(kk)=iint(k)
            jnt1(kk)=jnt(k)
            knt1(kk)=knt(k)
            lnt1(kk)=lnt(k)
            aaloc1(:,kk)=aaloc(:,k)
         enddo
      enddo
 1    continue
      open(2,file='ru.ijclloc4_1',status='old',form='unformatted')
      do
         read(2,end=2) iint,jnt,knt,lnt,aaloc
         do k=1,4096
            if(iint(k)/=39.and.iint(k)/=40.and.iint(k)/=244) cycle
            if(jnt(k)/=39.and.jnt(k)/=40.and.jnt(k)/=244) cycle
            if(knt(k)/=39.and.knt(k)/=40.and.knt(k)/=244) cycle
            if(lnt(k)/=39.and.lnt(k)/=40.and.lnt(k)/=244) cycle
            print'(4i4,3f12.8)',iint(k),jnt(k),knt(k),lnt(k),aaloc(:,k)
            kk=kk+1
            iint1(kk)=iint(k)
            jnt1(kk)=jnt(k)
            knt1(kk)=knt(k)
            lnt1(kk)=lnt(k)
            aaloc1(:,kk)=aaloc(:,k)
         enddo
      enddo
 2    continue
      open(3,file='ru.ijclloc4',status='old',form='unformatted')
      do
         read(3,end=3) iint,jnt,knt,lnt,aaloc
         do k=1,4096
            if(iint(k)/=39.and.iint(k)/=40.and.iint(k)/=244) cycle
            if(jnt(k)/=39.and.jnt(k)/=40.and.jnt(k)/=244) cycle
            if(knt(k)/=39.and.knt(k)/=40.and.knt(k)/=244) cycle
            if(lnt(k)/=39.and.lnt(k)/=40.and.lnt(k)/=244) cycle
            print'(4i4,3f12.8)',iint(k),jnt(k),knt(k),lnt(k),aaloc(:,k)
            kk=kk+1
            iint1(kk)=iint(k)
            jnt1(kk)=jnt(k)
            knt1(kk)=knt(k)
            lnt1(kk)=lnt(k)
            aaloc1(:,kk)=aaloc(:,k)
         enddo
      enddo
 3    continue
      open(4,file='ru.ijclloc4',status='old',form='unformatted')
      do
         read(4,end=4) iint,jnt,knt,lnt,aaloc
         do k=1,4096
            if(knt(k)==0) exit
            if(iint(k)/=39.and.iint(k)/=40.and.iint(k)/=244) cycle
            if(jnt(k)/=39.and.jnt(k)/=40.and.jnt(k)/=244) cycle
            if(knt(k)/=39.and.knt(k)/=40.and.knt(k)/=244) cycle
            if(lnt(k)/=39.and.lnt(k)/=40.and.lnt(k)/=244) cycle
            print'(4i4,3f12.8)',iint(k),jnt(k),knt(k),lnt(k),aaloc(:,k)
            kk=kk+1
            iint1(kk)=iint(k)
            jnt1(kk)=jnt(k)
            knt1(kk)=knt(k)
            lnt1(kk)=lnt(k)
            aaloc1(:,kk)=aaloc(:,k)
         enddo
      enddo
 4    continue
      kk=kk+1
      knt1(kk)=0
      write(10) iint1,jnt1,knt1,lnt1,aaloc1
      end

            
