C  * * * * * * * * * * * * * * * * * * * *                              
C     SUBROUTINE FOR ENVELOPE FUNCTION                                  
C  * * * * * * * * * * * * * * * * * * * *                              
C                                                                       
C                    CODED BY Y.OHSAKI                                  
C                                                                       
C     PURPOSE                                                           
C       TO GENERATE THE ENVELOPE FUNCTION IN COMPLIANCE WITH THE        
C       MAGNITUDE OF EARTHQUAKE                                         
C                                                                       
C     USAGE                                                             
C       CALL ENVL(EM,TB,TC,TD,N,Z,ND)                                   
C                                                                       
C     DESCRIPTION OF ARGUMENTS                                          
C       EM    - MAGNITUDE OF EARTHQUAKE                                 
C       TB    - TIME AT THE BEGINNING OF PRINCIPAL SHOCK IN SEC         
C       TC    - TIME AT THE END OF PRINCIPAL SHOCK IN SEC               
C       TD    - DURATION OF EARTHQAKE MOTION IN SEC                     
C       N     - TOTAL NUMBER OF POINTS DESCRIBING THE ENVELOPE FUNCTION 
C       Z(ND) - ENVELOPE FUNCTION                                       
C       ND    - DIMENSION OF Z IN CALLING PROGRAM  ND.GE.N              
C                                                                       
C     SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED                     
C       NONE                                                            
C                                                                       
      SUBROUTINE ENVL(EM,TB,TC,TD,N,Z,ND)                               
C                                                                       
      DIMENSION Z(ND)                                                   
C                                                                       
      TD=10.**(0.31*EM-0.774)                                           
      DT=TD/REAL(N-1)                                                   
      TB=(0.12-(EM-7.)*0.04)*TD                                         
      TC=(0.50-(EM-7.)*0.04)*TD                                         
      A=-ALOG(0.1)/(TD-TC)                                              
      DO 130 M=1,N                                                      
      T=REAL(M-1)*DT                                                    
      IF(T.GE.TB) GO TO 110                                             
      Z(M)=(T/TB)**2                                                    
      GO TO 130                                                         
  110 IF(T.GT.TC) GO TO 120                                             
      Z(M)=1.                                                           
      GO TO 130                                                         
  120 Z(M)=EXP(-A*(T-TC))                                               
  130 CONTINUE                                                          
      RETURN                                                            
      END                                                               
                                                                        
