program muting
use sep
implicit none

integer			:: i,k,nd1,nd2,nd3,n1
real       	          :: dd1,dd2,dd3,od1,od2,od3,z,d1,o1
real, allocatable             :: mute(:), data(:,:,:)
call sep_init()
call sep_begin_prog()

 call from_aux("mute","n1",n1); call from_aux("mute","d1",d1); call from_aux("mute","o1",o1);
 call from_aux("data","n1",nd1); call from_aux("data","d1",dd1); call from_aux("data","o1",od1);
 call from_aux("data","n2",nd2); call from_aux("data","d2",dd2); call from_aux("data","o2",od2);
 call from_aux("data","n3",nd3); call from_aux("data","d3",dd3); call from_aux("data","o3",od3);
 if (n1.ne.nd1) call seperr("Porra o mute deve ter o mesmo tamanho do dado")
 allocate(mute(n1), data(nd1,nd2,nd3))
 call sreed("mute", mute, 4*n1)
 call sreed("data", data, 4*nd1*nd2*nd3)

 write(0,*) mute
 do i=1,nd1
    z=0
    k=1
    do while (z < mute(i))
       data(i,:,k)=0
       k=k+1
       z=(k-1)*dd3+od3
    end do
 end do

 call to_history("n1",nd1); call to_history("d1",dd1); call to_history("o1",od1)
 call to_history("n2",nd2); call to_history("d2",dd2); call to_history("o2",od2)
 call to_history("n3",nd3); call to_history("d3",dd3); call to_history("o1",od3)

 call srite("out",data,4*nd1*nd2*nd3)
 deallocate(mute, data)
 call sep_end_prog()
end program
