C
C *** grfft.f is a FORTRAN code to obtain seismograms in the time domain,
C     which are computed from grpoint.f and grfault.f
C
      PROGRAM grfftsp
C
      IMPLICIT REAL*8(A-H,O-Z)
      PARAMETER(Msflt=1000)
      dimension slp35(50,Msflt),slp125(50,Msflt)
      dimension a1(5,Msflt),a2(5,Msflt)
c
      NW=22
      NL=43
      OPEN(11,FILE='rateA.dat',STATUS='OLD')
      do 100 n=1,NW*NL
        READ(11,*)a1(1,n),a1(2,n),a1(3,n),a1(4,n),a1(5,n)
        READ(11,*)a2(1,n),a2(2,n),a2(3,n),a2(4,n),a2(5,n),n2
        do i=0,3
          jj=i*10
          READ(11,*)(slp35(j+jj,n),j=1,10)
        end do
        READ(11,*)(slp35(j+40,n),j=1,9)
c
        READ(11,*)
        READ(11,*)
        do i=0,3
          jj=i*10
          READ(11,*)(slp125(j+jj,n),j=1,10)
        end do
        READ(11,*)(slp125(j+40,n),j=1,9)
  100 continue
      CLOSE(11)
C
      write(*,*)
      write(*,*)'Enter Fault Width Num. for Slip Rate Func (1-22)'
      read(*,*)Nout
      OPEN(12,FILE='rateA-out3.csv',STATUS='unknown')
      n=0
      do 200 iW=1,NW
        n=NL*(iW-1)+1
        if(iW.eq.Nout)then
        write(12,1000)(n+i,n+i,i=0,42)
          do 220 it=1,49
            time=dfloat(it-1)*0.5d0
            write(12,1100)time,(slp35(it,n+i),slp125(it,n+i),i=0,42)
  220     continue
        end if
  200 continue
 1000 format('time(s)',43(',SR35:',i3,',SR125:',i3))
 1100 format(f5.1,100(',',f10.5))
      CLOSE(12)
C
      stop
      END

