program OW_vrms

use sep

implicit none
real			:: o1,o2,d1,d2
integer			:: i1,i2,n1,n2
real,allocatable		:: velin(:,:),velout(:,:)

call sep_init()
call sep_begin_prog()

call from_history("n1",n2); call from_history("d1",d2); call from_history("o1",o2)
call from_history("n3",n1); call from_history("d3",d1); call from_history("o3",o1)
call to_history("n1",n2); call to_history("d1",d2); call to_history("o1",o2)
call to_history("n2",1); call to_history("d2",1.); call to_history("o2",0.)
call to_history("n3",n1); call to_history("d3",d1); call to_history("o3",o1)
call to_history("n4",1); call to_history("d4",1.); call to_history("o4",0.)
call to_history("eout",4);call to_history("label3","")

allocate(velin(n2,n1));velin=0;
allocate(velout(n2,n1));velout=0;
call sreed("in",velin,4*n1*n2)

do i1=1,n1
do i2=1,n2
   velout(i2,i1)=sum(velin(i2,1:i1))/i1
end do
end do

call srite("out",velout,4*n1*n2)
deallocate(velin,velout)
call sep_end_prog()
end program
