      PROGRAM write_bigendian
      INTEGER i, ks, last
      REAL t_red(225), f_red(1300,225), w(1300)
      CHARACTER infile*80, outfile*80

      WRITE(*,*) 'Input ASCII file'
      WRITE(*,*) '(without extension .ascii_sed)'
      READ(*,'(a)') infile
      WRITE(*,*) 'Output binary file'
      WRITE(*,*) '(without extension, will be .ised)'
      READ(*,'(a)') outfile
      last=INDEX(infile,' ')-1
      infile=infile(1:last)//'.ascii_sed'
      last=INDEX(outfile,' ')-1
      outfile=outfile(1:last)//'.ised'
      OPEN (10,FILE=infile,STATUS='old')
      READ (10,*) KS,(T_red(ii),ii=1,KS) 
      READ (10,*) IW,(W(ii),ii=1,IW) 
      DO j=1,KS
         READ (10,*) IW,(F_red(ii,j),ii=1,IW)
      ENDDO
      CLOSE(10)
      OPEN(11,FILE=outfile,STATUS='new',FORM='unformatted')
      WRITE(11) KS,(T_red(ii),ii=1,KS) 
      WRITE(11) IW,(W(ii),ii=1,IW) 
      DO j=1,KS
         WRITE(11) IW,(F_red(ii,j),ii=1,IW)
      END DO
      CLOSE(11)
      END

