!----------------! program averages !--------------------------------------------------------! ! Statistics program to run with input from 'rk.f90'. ! ! Writes average results versus the parameter s to ! ! the file 'r.dat' and final results at the given (read) ! ! velocity to 'f.dat'. ! !--------------------------------------------------------! implicit none integer :: i,j,nt,wf,nr real(8) :: p,e,t,tt,dt real(8), allocatable :: p0(:,:),e0(:,:) open(10,file='read.in',status='old') read(10,*)i read(10,*)tt,dt,wf close(10) nt=int(tt/dt+0.1d0)/wf allocate(e0(2,nt)) allocate(p0(2,nt)) nr=0 p0=0.d0 e0=0.d0 open(10,file='res.dat',status='old') do do i=1,nt read(10,*,end=10)t,p,e p0(1,i)=p0(1,i)+p p0(2,i)=p0(2,i)+p**2 e0(1,i)=e0(1,i)+e e0(2,i)=e0(2,i)+e**2 enddo nr=nr+1 enddo 10 close(10) write(*,*)'Number of bins read: ',nr p0=p0/dble(nr) p0(2,:)=sqrt(abs(p0(2,:)-p0(1,:)**2)/dble(nr)) e0=e0/dble(nr) e0(2,:)=sqrt(abs(e0(2,:)-e0(1,:)**2)/dble(nr)) open(10,file='r.dat') do i=1,nt write(10,'(5f15.8)')dble(i)/dble(nt),p0(:,i),e0(:,i) enddo close(10) open(10,file='f.dat') write(10,'(5f15.8)')1.d0/tt,p0(:,nt),e0(:,nt) close(10) deallocate(p0) deallocate(e0) end program averages !--------------------!