C
C *** WAVE READ, FOURIER TRANS., MULTIPLE REFLECTION METHOD, 
C     SPECTRUM PLOT, INVERSE FOURIER TRANS., AND WAVE PLOT
C
      PROGRAM MWVSHML
C
C PARAMETER
C *** MWV    : WAVE AMPLITUDE DATA IN MAIN PROGRAM DIMENSION
C            : IF MWV > 2**13(=8192), CAN NOT USE IN SUBROUTINE !!!
C READ DATA FROM FILE
C *** TITL   : TITLE OF EACH CHANNEL
C *** WV     : WAVE AMPLITUDE DATA
C *** NWV    : WAVE DATA NUMBER
C *** DT     : DELTA TIME ( SEC )
C DATA FOT PLOTTER
C *** FOUR(I): FOURIER COEFFICIENTS OR SPECTRUM
C            : FOURIER SPECTRUM = FOURIER COEFFICIENTS * DURATION/2.0
C
      PARAMETER(ML=30,MWV=32800)
      CHARACTER TITL*50
      DIMENSION DNS(ML),DEP(ML),VS(ML),QF(ML),WV(MWV)
      COMPLEX*8 FOUR(MWV)
C
C *** WAVE DATA READ AND FOURIER COEFF. TRANS. ***
C
      CALL WVREAD(TITL,WV,NWV,MWV,DT)
      CALL SOILIN(FOM,DOM,NOM,DNS,VS,DEP,QF,NQF,NL,ML,THETA,NSF)
      CALL WVFOUR(WV,NWV,MWV,FOUR,NFAST)
C
      DUR=FLOAT(NFAST)*DT
      FOM=0.0
      DOM=6.2831853070/DUR
      NOM=NFAST/2+1
      CALL WVSHML(FOM,DOM,NOM,MWV,DNS,VS,DEP,QF,NQF
     *           ,NL,ML,THETA,NSF,FOUR)
      CALL SPCOUT(FOM,DOM,NOM,MWV,FOUR)
C
C *** TRANS. FROM FOURIER COEFF. TO AMPLITUDE SPECTRUM ***
C
      DO 100 I=1,NOM
      WV(I)=CABS(FOUR(I))*DUR/2.0
  100 CONTINUE
C
C *** SPECTRUM PLOTTER DATA OUTPUT ***
C
      CALL SPAPLT(FOM,DOM,NOM,MWV,WV)
C
C *** INVERSE FOURIER TRANSFORM ***
C
      DO 200 I=2,NFAST/2
      FOUR(NFAST+2-I)=CMPLX(REAL(FOUR(I)),-IMAG(FOUR(I)))
  200 CONTINUE
C
      CALL WVFAST(NFAST,FOUR,MWV,1)
C
      DO 300 I=1,NFAST
      WV(I)=REAL(FOUR(I))
  300 CONTINUE
C
      CALL WVPLOT(TITL,WV,NWV,MWV,DT)
C
      STOP
      END
         