C
C *** CALCULATION OF VELOCITY AND DISPLACEMENT
C                   ,AND RESPONSES OF ONE-DEGREE OF FREEDOM SYSTEM 
C
      SUBROUTINE RESS(NH,H,ND1,NT,T,ND2,DT,NN,DDY,DY,Y,ND3,RES,EQMAX)
C
C INPUT DATA
C NH      : TOTAL NUMBER OF DAMPING FACTORS
C H(ND1)  : DAMPING FACTORS
C ND1     : DIMENSION OF H IN CALLING PROGRAM
C NT      : TOTAL NUMBER OF NATURAL PERIODS
C T(ND2)  : NATURAL PERIODS (SEC)
C ND2     : DIMENSION OF T IN CALLING PROGRAM
C DT      : TIME INCREMENT IN ACCELROGRAM (SEC)
C NN      : TOTAL NUMBER OF DT
C DDY(ND3): ACCELEROGRAM (GAL)
C ND3     : DIMENSION OF DDY IN CALLING PROGRAM
C OUTPUT DATA
C DY(ND3)       : VELOCITY (KINE)    <== DDY
C Y(ND3)        : DISPLACEMENT (CM)  <== DY 
C RES(ND2,ND1,3): RESPONSES OF ONE-DEGREE FREEDOM SYSTEM
C         =>  1 : ABSOLUTE ACCELERATION RESPONSE (GAL)
C         =>  2 : RELATIVE VELOCITY RESPONSE (KINE)
C         =>  3 : RELATIVE DISPLACEMENT RESPONSE (CM)
C EQMAX(3)      : MAXI.VALUE OF ACC(1), VEL(2) AND DIS(3)
C
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION H(ND1),T(ND2),DDY(ND3),DY(ND3),Y(ND3)
     *         ,RES(ND2,ND1,3),EQMAX(3)
C
C *** DATA CHECK ***
C
      IF(ND3.GT.32800)THEN
      WRITE(*,*)' FROM SUBROUTINE RESS :'
      WRITE(*,*)' ND3 > 32800 !!!!, THEN STOP !!!!'
      STOP
      END IF
C
C *** CALCULATION OF DY AND Y, AND MAX. OF INPUT ***
C
      DY(1)=DDY(1)*DT
      Y(1)=0.D0
      DDYMAX=DABS(DDY(1))
      DYMAX=DABS(DY(1))
      YMAX=0.D0
C
      DO 100 M=2,NN
      Y(M)=Y(M-1)+(DY(M-1)+DDY(M-1)*DT/3.D0+DDY(M)*DT/6.D0)*DT
      DY(M)=DY(M-1)+(DDY(M-1)+DDY(M))*DT/2.D0
      DDYMAX=DMAX1(DDYMAX,DABS(DDY(M)))
      DYMAX=DMAX1(DYMAX,DABS(DY(M)))
      YMAX=DMAX1(YMAX,DABS(Y(M)))
  100 CONTINUE
C
      EQMAX(1)=DDYMAX
      EQMAX(2)=DYMAX
      EQMAX(3)=YMAX
C
C *** CALCULATION OF RESPONSES ***
C
      DO 210 L=1,NH
      DO 200 K=1,NT
      CALL RESP(H(L),T(K),DT,NN,DDY,ND3,DDYMAX,ACCMAX,VELMAX,DISMAX)
      RES(K,L,1)=ACCMAX
      RES(K,L,2)=VELMAX
      RES(K,L,3)=DISMAX
  200 CONTINUE
  210 CONTINUE
C
      RETURN
      END
       