C
C *** SH WAVES BY 2-D SH HASKELL MODEL AND HASKELL,S MATRIX METHOD ***
C
      PROGRAM MLVMLTI
C
C ** MARAMETER **
C MOM   : NOM IN MAIN PROGRAM DIMENSION
C       : IF MOM > 2**13(=8192), CAN NOT USE IN SUBROUTINE !!!
C ** INPUT DATA **
C DOM   : INCREMENT OF CIRCULAR FREQUENCY ( DELTA OMEGA )
C NOM   : TOTAL NUMBER OF CIRCULAR FREQUENCY
C DNS(I): DENSITY OF Ith LAYER ==> SM(I):SHEAR MODULUS => COMMOM SM(35)
C VS (I): VS OF Ith LAYER                              => COMMON VS(35)
C DEP(I): DEPTH ( THICKNESS ) OF Ith LAYER             => COMMON DEP(35)
C NL    : TOTAL NUMBER OF LAYERS                       => COMMON NL
C XF    : FAULT LOCATION ON X-AXIS 
C ZF    : FAULT LOCATION ON Z-AXIS 
C XO    : LOCATION OF OBSERVATION POINT ON X-AXIS 
C ZO    : LOCATION OF OBSERVATION POINT ON Z-AXIS 
C W     : WIDTH OF FAULT
C DA    : DIP ANGLE OF FAULT (DEGREE--->RADIAN IN THIS SUBROUTINE)
C D     : DISPLACEMENT DIFFELENCE OF FAULT
C VRR   : RUPTURE VELOCITY OF FAULT
C RT    : RISE TIME
C ** CALCULATE DATA **
C VDO(I,J): SH BODY AMPLIFIED IN BASIN OF Ith OMEGA AT Jth 
C         : POINT ON BASIN SURFACE
C
      PARAMETER(MOM=100,MOB=8,ML=35)
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION XOB(MOB),DNS(ML),VS(ML),DEP(ML),QF(ML)
      COMPLEX*16 VDO(MOM,MOB),AMP(MOM),VF
      CHARACTER FNAME*15
C
C *** HEAD ***
C
      WRITE(*,*)
      WRITE(*,1000)
 1000 FORMAT(/' From MLVMLTI : Basin edge is located at (0,0)'
     * /' Amlified body SH waves in multi-layered basin by 2-D Haskell'
     * /' Fundamental solusion in semi-infinite medium is used')
C
C *** INPUT OF SOIL DATA ***
C
   10 CALL MLIN(FOM,DOM,NOM,DNS,VS,DEP,QF,NQF,NL,ML,THETA,NSF)
C
C *** CHECK OF INPUT DATA ***
C
      IF(MOM.LT.NOM)THEN
        WRITE(*,*)'FROM MAIN MLVMLTI'
        WRITE(*,*)'MOM < NOM RE-ENTRER !!!'
        WRITE(*,*)'MOM,NOM =',MOM,NOM
        GOTO 10
      END IF
C
C *** INPUT OF OBSERVATION POINTS ON BASIN ***
C
      WRITE(*,*)
      WRITE(*,*)
   20 WRITE(*,1010)
      READ(*,*)NOB
      IF(NOB.GT.MOB)THEN
        WRITE(*,*)'NOB > MOB !!! : Re-Enter NOB : MOB=',MOB
        GOTO 20
      END IF
      IF(NOB.EQ.0)GOTO 20
C
      DO 100 I=1,NOB
        WRITE(*,1020)I
        READ(*,*)XOB(I)
  100 CONTINUE
C
 1010 FORMAT( ' Enter Number of Observation Point : ',\)
 1020 FORMAT( ' Enter X-axis of Observation Point of Num. =',I3,' : ',\)
C
C *** AMPLIFICATION FACTOR ***
C
      CALL SBML(FOM,DOM,NOM,MOM,DNS,VS,DEP,QF,NQF
     *               ,NL,ML,THETA,NSF,AMP)
C
C *** CALCULATION OF BODY SH WAVES ON BASIN ***
C
      CALL H2DIN(XF,ZF,W,DA,D,VRR,RT)
C
      ZO=0.D0
      DO 150 I=1,NL-1
        ZO=ZO+DEP(I)
  150 CONTINUE
C
      VSN=VS(NL)
      DO 200 K=1,NOM
        OM=DOM*DFLOAT(K)
        DO 210 IOB=1,NOB
          XO=XOB(IOB)
          CALL HKSHF1(OM,XF,ZF,XO,ZO,VSN,W,DA,D,VRR,RT,VF)
          VDO(K,IOB)=VF*AMP(K+1)
  210   CONTINUE
  200 CONTINUE
C
C *** OUTPUT OF DATA TO FILE ***
C
      WRITE(*,*)
   30 WRITE(*,1210)
      READ(*,'(A)')FNAME
      IF(FNAME(1:1).EQ.' ')GOTO 30
      WRITE(*,1220)
 1210 FORMAT( ' Enter file name of sediment body wave (PLOTMS) : ',\)
 1220 FORMAT( '  : Data format for PLOTMS 1:OB => 2:VDO roop')
C      
      OPEN(8,FILE=FNAME)
        WRITE(8,1300)DOM,NOM
        WRITE(8,1310)
        DO 300 IOB=1,NOB
          DO 310 K=1,NOM,5
            WRITE(8,1320)(VDO(K+J,IOB),J=0,4)
  310     CONTINUE
  300   CONTINUE
      CLOSE(8)
C
 1300 FORMAT(F15.8,I15)
 1310 FORMAT(///)
 1320 FORMAT(10F8.5)
C
      STOP
      END
