C
C *** WAVE READ, FOURIER TRANS., ADD 0 OMEGA AND WAVE PLOT
C
      PROGRAM MWVA
C
C ** PARAMETER **
C MWV : WAVE NUMBER
C ** INPUT DATA **
C TITL  : TITLE OF EACH CHANNEL
C WV    : WAVE AMPLITUDE DATA
C NWV   : WAVE DATA NUMBER
C DT    : DELTA TIME ( SEC )
C ** CALCURATED DATA **
C FOUR(I)  : FOURIER COEFFICIENTS OR SPECTRUM
C          : FOURIER SPECTRUM = FOURIER COEFFICIENTS * DURATION/2.0
C
      PARAMETER(MWV=9000)
      IMPLICIT REAL*8(A-H,O-Z)
      CHARACTER TITL*50,FNAME*30
      DIMENSION WV(MWV)
      COMPLEX*16 FOUR(MWV)
C
C *** HEAD ***
C
      WRITE(*,1000)
      WRITE(*,1010)MWV
 1000 FORMAT(/' From MWVA (main): multiple wave data1 and data2'
     *    /'    Delta time of data1 must be shorter than that of data2')
 1010 FORMAT( ' MWV =',I5)  
C
C *** WAVE DATA INPUT ***
C
      CALL WVIN(WV,NWV,MWV,DT)
C
C *** FOURIER TRANS. ***
C
      CALL WVFR(WV,NWV,MWV,FOUR,NFAST,DT)
C
      DUR=DFLOAT(NFAST)*DT
      FOM=0.0D0
      DOM=6.2831853070D0/DUR
      NOM=NFAST/2+1
C
C *** ADD OMEGA ***
C
   10 WRITE(*,1100)DT,NFAST
      WRITE(*,1110)
      READ(*,*)IYES
      IF(IYES.NE.0)GOTO 20
 1100 FORMAT(/' From MWVA : DT, NFAST =',F8.4,I5)
 1110 FORMAT(/' Add more omega (yes=0)? : ',\)
C
      DO 100 I=NFAST/2+2,NFAST
        FOUR(I)=(0.D0,0.D0)
  100 CONTINUE
C
      NFAST=NFAST*2
      DT=DT/2.D0
      NOM=NFAST/2+1
C
      GOTO 10
C
C *** OUTPUT OF SPEC DATA TO FILE FOR LAZER SHOT ***
C
   20 WRITE(*,*)
   11 WRITE(*,1001)
      READ(*,'(A)')FNAME
      IF(FNAME(1:1).EQ.' ')GOTO 11
 1001 FORMAT( ' From MLVWV : '
     *       /' Enter spec file name for Lazer Shot : ',\)
C      
      OPEN(8,FILE=FNAME)
        WRITE(8,1101)DOM,NOM-1
        WRITE(8,1111)
        DO 101 K=2,NOM,5
          WRITE(8,1121)(FOUR(K+J)*DUR,J=0,4)
  101   CONTINUE
      CLOSE(8)
C
 1101 FORMAT(F15.8,I15)
 1111 FORMAT(///)
 1121 FORMAT(10F8.2)
C
C *** TRANS. FROM FOURIER COEFF. TO AMPLITUDE SPECTRUM ***
C
      DO 150 I=1,NOM
        WV(I)=CDABS(FOUR(I))*DUR
  150 CONTINUE
C
C *** SPECTRUM DATA PLOT ***
C
      CALL SPPT(FOM,DOM,NOM,MWV,WV)
C
C *** INVERSE FOURIER TRANSFORM ***
C
      DO 200 I=2,NFAST/2
        FOUR(NFAST+2-I)=DCMPLX(DREAL(FOUR(I)),-DIMAG(FOUR(I)))
  200 CONTINUE
C           
      CALL WVFT(NFAST,FOUR,MWV,1)
C
      DO 300 I=1,NFAST
        WV(I)=DREAL(FOUR(I))
  300 CONTINUE
C
C *** WAVE DATA PLOT ***
C
      CALL WVOT(WV,NFAST,MWV,DT)
      CALL WVPT(TITL,WV,NFAST,MWV,DT)
C
      STOP
      END
