program alfill_3D

! Fills in missing traces along either 2, 3 or both the axes

use sep

implicit none

real, dimension(:,:,:), allocatable	:: data, data_fill
integer					:: n1, n2, n3, i2, i3, axis 

call sep_init()

call from_history("n1", n1)
call from_history("n2", n2)
call from_history("n3", n3)
call from_param("axis", axis, 1)

allocate(data(n1,n2,n3))
call sep_read(data)
if(axis==1) then
	 allocate(data_fill(n1,2*n2,n3))
	 data_fill = 0.0
	 do i2=2,2*n2,2 
				data_fill(:,i2,:) = data(:,i2/2,:)
	 end do
	 call to_history("n2", n2*2)
	 call sep_write(data_fill)
end if

if(axis==2) then
	allocate(data_fill(n1,n2,2*n3))
	data_fill = 0.0
	do i3=2,2*n3,2
				data_fill(:,:,i3) = data(:,:,i3/2)
	end do
	call to_history("n3", n3*2)
	call sep_write(data_fill)
end if

	
		

call sep_close()

end program alfill_3D			

