c*************************************************************
c     This program is named WIN. Its purpose is to produce
c     a window for data sets which are NOT tapered with 
c     cosine bell taper.  It takes
c     a data file with no number of points.
c*************************************************************
      implicit double precision (a-h,o-z)
      character*20 infile, outfile
      dimension time(25000),y(25000),per(40),amp(40),tmax(40)
c  pi2 is pi/2.0
      pi2=dacos(-1.0d0)/2.0d0
c  pit2 is twopi
      pit2=4.0d0*pi2
c
c     name input file from tty
c
      write(*,1) 
1     format(1x,' input file is (N<25000): ',$)
      read(*,2) infile
2     format(a20)
      open(9,file=infile,status='old')
      write(*,120)
120   format(1x,' output file is: ',$)
      read(*,2) outfile
      open(11, file=outfile, status='new')
      nper=1
      write(*,2001) 
      read(*,*) per(i),amp(i),tmax(i)
      write(*,*) per(i),amp(i),tmax(i)
2001  format(1x,'enter period, amplitude, tmax ',$)

c     compute artificial sine curve for window using the input times
c     from the raw data to preserve the temporal stucture
c with norm=1
      do 50 i=1,25000
      read (9,*,end=50) time(i),ydumb
c  set y equal to zero before loop for each sine   
      y(i)=1.0d0
c  loop for each sine curve
      freq=pit2/per(ii)
      ft=freq*(time(i)-tmax(ii))+pi2
      z=dmod(ft,pit2)
      y(i)=y(i)+amp(ii)*dsin(z)
	ndata=i
   50 continue
	close(9)
	write(*,*)ndata
c  write out each chunck file
      do 11 i=1,ndata
      write (11,5) time(i),y(i)
5     format(f14.1,2x,1pe12.5)
   11 continue
	close(11)

      stop
      end      

