      real*8 rso(2880,6),pre(2880,6),diff(2880,6),d(2880,2)
      integer y,doy
      character sy*2,sdoy*3,dum*1
      
      write(*,*) 'Input year and day of year (2007 1)'
      read(*,*) y,doy
      y=y-2000
      write(sy,'(i2.2)') y
      write(sdoy,'(i3.3)') doy

      open(1,file='CHAM'//sy//sdoy//'.dat')
      do i=1,2880
         read(1,'(5x,3f14.3,3f14.7)') rso(i,1:6)
      enddo
      close(1)
      open(1,file='CHA'//sy//sdoy//'.PRE')
      do i=1,2880
         read(1,'(20x,3f13.3,3f13.6)') pre(i,1:6)
         if(i .lt. 2880) then
            do j=1,29 
               read(1,'(a1)') dum
            enddo
         endif
      enddo
      write(*,*) rso(1,1:6)
      write(*,*) pre(1,1:6)
      close(1)      
      diff(1:2880,1:6)=rso(1:2880,1:6)-pre(1:2880,1:6)
      d(1:2880,1)=sqrt(diff(1:2880,1)**2+diff(1:2880,2)**2+
     *	diff(1:2880,3)**2)
      d(1:2880,2)=sqrt(diff(1:2880,4)**2+diff(1:2880,5)**2+
     *	diff(1:2880,6)**2)
      p1=0
      p2=0
      v1=0
      v2=0
      do i=1,2880
         p1=p1+d(i,1)**2
         if(d(i,1) .gt. p2) p2=d(i,1)
         v1=v1+d(i,2)**2
         if(d(i,2) .gt. v2) v2=d(i,2)
      enddo
      p1=sqrt(p1/2880)
      v1=sqrt(v1/2880)
      write(*,*) 'Result of Modtest for ',y+2000,doy
      write(*,*) 'RMS deviation for POS (m)  ',p1
      write(*,*) 'Abs deviation for POS (m)  ',p2
      write(*,*) 'RMS deviation for VEL (m/s)',v1
      write(*,*) 'Abs deviation for VEL (m/s)',v2
      end
