summaryrefslogtreecommitdiff
path: root/lib/averms.f90
blob: 904004c81d1c7285fe2c2466d8a57c357c1cc665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
subroutine averms(x,n,nskip,ave,rms)
  real x(n)
  integer ipk(1)

  ns=0
  s=0.
  sq=0.
  ipk=maxloc(x)
  do i=1,n
     if(abs(i-ipk(1)).gt.nskip) then
        s=s + x(i)
        sq=sq + x(i)**2
        ns=ns+1
     endif
  enddo
  ave=s/ns
  rms=sqrt(sq/ns - ave*ave)
 
  return
end subroutine averms