      PROGRAM RAW

C     Convert time series file to raw integer format

      INTEGER RAWFIL
      PARAMETER ( RAWFIL = 10, MAXNRD = 1, MAXNT = 1000000 )

      INTEGER*2 IR( MAXNT )
      REAL RD( MAXNRD ), TOUT( MAXNT ), R( MAXNT )
      CHARACTER TITLE*80


      READ( *, * ) TITLE
      READ( *, * ) NRD, ( RD( IRD ), IRD = 1, NRD )

      RMAX = 0.0
      NT = 0

      DO IT = 1, MAXNT
         READ( *, *, END = 1000 ) TOUT( IT ), R( IT )
         RMAX = MAX( RMAX, ABS( R( IT ) ) )
         NT = IT
      END DO

C     *** Write it out ***

 1000 OPEN( FILE = 'RAWFIL', UNIT = RAWFIL,
     &      FORM = 'UNFORMATTED', STATUS = 'UNKNOWN' )

      DO IT = 1, NT
         IR( IT ) = 32000 * R( IT ) / RMAX
      END DO

      WRITE( RAWFIL ) ( IR( IT ), IT = 1, NT )

      STOP
      END

