      program filetest
      
      implicit none
      
      integer,parameter:: LEN2=1553, LEN3=41222
      integer(8) ibuff1(105)
      integer(8) ibuff2a(LEN2),ibuff2b(LEN2)
      integer(8) ibuff3a(LEN3),ibuff3b(LEN3),ibuff3c(LEN3)
      integer(8) ibuff3d(LEN3)
      
      !call writeit
      call readit
      
      contains
      
      subroutine writeit
      integer(8) i1,i2
      integer(8) ibuff2(LEN2),ibuff3(LEN3)
      ibuff1(:) = 0
      ibuff2(:) = 0
      ibuff3(:) = 0
      open(unit=28,file='bintest',status='replace',form='unformatted')
      i1 = LEN2
      i2 = LEN3
      write (28) i1,i2
      write (28) ibuff1
      write (28) ibuff2
      write (28) ibuff2
      write (28) ibuff3
      write (28) ibuff3
      write (28) ibuff3
      write (28) ibuff3
      close(28)
      return
      end subroutine writeit
      
      subroutine readit
      integer(8) i,i3,i4
      open(unit=28,file='bintest',status='old',form='unformatted')
      read (28) i3,i4
      read (28) ibuff1
      read (28) (ibuff2a(i),i=1,i3)
      read (28) (ibuff2b(i),i=1,i3)
      read (28) (ibuff3a(i),i=1,i4)
      read (28) (ibuff3b(i),i=1,i4)
      read (28) (ibuff3c(i),i=1,i4)
      read (28) (ibuff3d(i),i=1,i4)
      close(28)
      return
      end subroutine readit
      
      end program filetest
      
      
      
      
      
      