program thinhr ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c average files with time in dechr in first column c c input: ifile c ofile c dt, n c c dt: averaging interval (hr) c n: number of data after thr c c rf aug 2005 c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc implicit real*8 (a-h,o-z) dimension dat(10),datsum(10) character*36 ifile,ofile c write(*,*) 'input: ifile ' write(*,*) ' ofile ' write(*,*) ' dt(hr), n ' c read(*,'(a)') ifile read(*,'(a)') ofile read(*,*) dt,n if (n.gt.10) stop '*** n too large' c open(10,file=ifile) open(20,file=ofile,status='unknown') c ii = 0 jj = 0 nd = 0 thrsum = 0 do i = 1,n datsum(i) = 0 enddo thrp = -999 c c reading loop c 10 ii = ii+1 read(10,*,end=20) thr,(dat(i),i=1,n) if (abs(thr-thrp).gt.dt) then if (nd.gt.0) then jj = jj+1 write(20,15) thrsum/nd,(datsum(i)/nd,i=1,n) 15 format(' ',3f12.6,8f8.2) endif nd = 1 thrsum = thr thrp = thr do i = 1,n datsum(i) = dat(i) enddo else nd = nd+1 thrsum = thrsum+thr do i = 1,n datsum(i) = datsum(i)+dat(i) enddo endif goto 10 c 20 write(20,15) thrsum/nd,(datsum(i)/nd,i=1,n) write(*,*) 'total lines input ',ii write(*,*) 'total lines output ',jj+1 end