C
C *** CALCULATION OF MAXIMUM RESPONSES OF ONE-DEGREE OF FREEDOM SYSTEM 
C
      SUBROUTINE RESP(H,T,DT,NN,DDY,ND,DDYMAX,ACCMAX,
     *                VELMAX,DISMAX)
C
C INPUT DATA
C H      : DAMPING FACTOR
C T      : NATURAL PERIOD (SEC)
C DT     : TIME INCREMENT (SEC)
C NN     : TOTAL NUMBER OF DT
C DDY    : ACCELEROGRAM (GAL)
C ND     : DIMENSION OF DDY IN CALLING PROGRAM
C DDYMAX : MAXIMUM VALUE OF DDY (GAL)
C OUTPUT DATA
C ACCMAX : MAX VALUE OF ACCELERATION RESPONSE (GAL)
C VELMAX : MAX VALUE OF VELOCITY RESPONSE (KINE)
C DISMAX : MAX VALUE OF DISPLACEMENT RESPONSE (CM)
C
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION DDY(ND)
C
C *** DATA CHECK ***
C
      IF(ND.GT.32800)THEN
      WRITE(*,*)' FROM SUBROUTINE RESP :'
      WRITE(*,*)' ND > 32800 !!!!, THEN STOP !!!!'
      STOP
      END IF
C
C *** INITIALIZATION ***
C
      IF(T.EQ.0.D0)THEN
      ACCMAX=DDYMAX
      VELMAX=0.D0
      DISMAX=0.D0
      RETURN
      END IF
C
      W=6.283185307D0/T
      R=1.D0+H*W*DT+W*W*DT*DT/6.D0
      DDX=(2.D0*H*W*DT-1.D0)*DDY(1)
      DX=-DDY(1)*DT
      X=0.D0
      ACCMAX=DABS(DDX+DDY(1))
      VELMAX=DABS(DX)
      DISMAX=0.D0
C
C *** RESPONSE COMPUTATIONS ***
C
      DO 100 M=2,NN
      E=DX+DDX*DT/2.D0
      F=X+DX*DT+DDX*DT*DT/3.D0
      DDX=-(DDY(M)+2.D0*H*W*E+W*W*F)/R
      DX=E+DDX*DT/2.D0
      X=F+DDX*DT*DT/6.D0
      ACCMAX=DMAX1(ACCMAX,DABS(DDX+DDY(M)))
      VELMAX=DMAX1(VELMAX,DABS(DX))
      DISMAX=DMAX1(DISMAX,DABS(X))
  100 CONTINUE
C
      RETURN
      END
       