subroutine timeavp(seq,av,sdv,net,fave,smin,smax) ! ! time average seq over the last fave fraction of the time ! series of length net. ! sdv is the standard deviation. ! use itg_data use diagnostics_arrays implicit none real, dimension(:) :: seq real :: av, sdv, fave, smin, smax integer net real deltm,time1,time2 integer i_first,i_last,i if (net <= 2) return if (fave > 1.) fave=1. i_first=1+(1.-fave)*(net-1) i_last=net i_first=i_first+1 time1=timo(i_first) time2=timo(i_last) deltm=time2-time1 av=0. av=0.5*seq(i_first)*(timo(i_first)-timo(i_first-1)) do i=i_first+1,i_last-1 av=av+seq(i)*(timo(i)-timo(i-1)) enddo av=av+0.5*seq(i_last)*(timo(i_last)-timo(i_last-1)) av=av/deltm sdv=0. sdv=0.5*(seq(i_first)-av)*(seq(i_first)-av)*(timo(i_first)-timo(i_first-1)) do i=i_first+1,i_last-1 sdv=sdv+(seq(i)-av)*(seq(i)-av)*(timo(i)-timo(i-1)) enddo sdv=sdv+0.5*(seq(i_last)-av)*(seq(i_last)-av)*(timo(i_last)-timo(i_last-1)) sdv=sdv/deltm if(sdv > 1.e-10) sdv=sqrt(sdv) smin=seq(i_first) smax=seq(i_first) do i=i_first+1,i_last if (seq(i) > smax) smax=seq(i) if (seq(i) < smin) smin=seq(i) enddo end subroutine timeavp