      program regroumat
      double precision a
      call titre('PROGRAM REGROUMAT#',40)
 1000 format(2i6,f12.8)
 1001 format(2i6,f12.5)
      open(1,file='cds',status='old')
      open(2,file='cdsg',status='unknown')
      open(3,file='cdsg2',status='unknown')
      read(1,1000) i0,j0,a0
      do
         read(1,1000,end=2) i,j,a
         if(i==i0.and.j==j0) then
            a0=a0+a
            cycle
         else
            write(2,1001) i0,j0,a0
            write(3,1000) i0,j0,a0
            i0=i
            j0=j
            a0=a
         endif
      enddo
  2   continue
      write(2,1001) i0,j0,a0
      write(3,1000) i0,j0,a0
      close (1)
      close (2)
      open(1,file='ls',status='old')
      open(2,file='lsg',status='unknown')
      open(3,file='lsg2',status='unknown')
      read(1,1000) i0,j0,a0
      do
         read(1,1000,end=3) i,j,a
         if(i==i0.and.j==j0) then
            a0=a0+a
            cycle
         else
            write(2,1001) i0,j0,a0
            write(3,1000) i0,j0,a0
            i0=i
            j0=j
            a0=a
         endif
      enddo
  3   continue
      write(2,1001) i0,j0,a0
      write(3,1000) i0,j0,a0
      end
         
