c
c *** Program reading COSMOS's PEER-Type Strong Motion Data
c
      program read
c
      dimension X(33000),Y(33000),Z(33000)
      character line1*78,line2*78,line3*78
      character infile1*80,infile2*80,infile3*80
c
      write(*,*)'Program for Reading PEER-Type Strong Motion Data'
      write(*,*)
      write(*,*)'Enter 1st File Name of 3 Components'
      read(*,'(a80)')infile1
      write(*,*)'Enter 2nd File Name of 3 Components'
      read(*,'(a80)')infile2
      write(*,*)'Enter 3rd File Name of 3 Components'
      read(*,'(a80)')infile3
c
c      open(11,file='PAC-UP.AT2.txt',status='old')
      write(*,*)
      write(*,*)'First Component:'
      open(11,file=infile1,status='old')
      read(11,'(a80)')line1
      read(11,'(a80)')line2
      read(11,'(a80)')line3
      write(*,*)line1
      write(*,*)line2
      write(*,*)line3
      read(11,1000)NT,DT
 1000 format(5x,i6,5x,f7.0)
      write(*,*)'Number of Points & Dt (s) =',NT,DT
         do i=1,NT-5,5
         read(11,*)x(i),x(i+1),x(i+2),x(i+3),x(i+4)
         end do
      close(11)
c
      write(*,*)
      write(*,*)'Second Component:'
      open(11,file=infile2,status='old')
      read(11,'(a80)')line1
      read(11,'(a80)')line2
      read(11,'(a80)')line3
      write(*,*)line1
      write(*,*)line2
      write(*,*)line3
      read(11,1000)NT,DT
      write(*,*)'Number of Points & Dt (s) =',NT,DT
         do i=1,NT-5,5
         read(11,*)y(i),y(i+1),y(i+2),y(i+3),y(i+4)
         end do
      close(11)
c
      write(*,*)
      write(*,*)'Third Component:'
      open(11,file=infile3,status='old')
      read(11,'(a80)')line1
      read(11,'(a80)')line2
      read(11,'(a80)')line3
      write(*,*)line1
      write(*,*)line2
      write(*,*)line3
      read(11,1000)NT,DT
      write(*,*)'Number of Points & Dt (s) =',NT,DT
         do i=1,NT-5,5
         read(11,*)z(i),z(i+1),z(i+2),z(i+3),z(i+4)
         end do
      close(11)
c
      write(*,*)
      write(*,*)'Enter Output Acceleration File Name (CSV format)'
      read(*,'(a80)')infile1
      open(11,file=infile1,status='unknown')
        do i=1,nt
          t=dt*(i-1)
          write(11,2000)t,x(i),y(i),z(i)
        end do
      close(11)
 2000 format(f7.3,3(',',f10.3))
c
      stop
      end
