module OW_slantIO

use sep 
  use OW_type
  use OW_sltpar
use sep3d_struct_mod

implicit none

contains 

subroutine owslant_io(GG,ixs)

real, allocatable				:: disk(:)
real					:: GG(:)
integer					:: ixs
type(sep3d)				:: axsog

allocate(disk(sog%xm%n,sog%sh%n,sog%z%n)); disk=0.

if (ixs.eq.1) then
   call init_sep3d(axsog, "OUTPUT","FLOAT", "REGULAR", ctag="out")
   call axis_allocate(axsog,5)
   axsog%o(1)=sog%xm%o;	axsog%n(1)=sog%xm%n;	axsog%d(1)=sog%xm%d
   axsog%o(2)=sog%sh%o;	axsog%n(2)=sog%sh%n;	axsog%d(2)=sog%sh%d
   axsog%o(3)=sog%z%o;	axsog%n(3)=sog%z%n;		axsog%d(3)=sog%z%d
   axsog%o(4)=sog%sh%o;	axsog%n(4)=sog%sh%n;	axsog%d(4)=sog%sh%d
   axsog%o(5)=sog%z%o;	axsog%n(5)=sog%z%n;		axsog%d(5)=sog%z%d
   call sep3d_set_sep3d(axsog)
   call sep3d_write_description("image",axsog)
   disk=GG
   call srite("image",disk,4*sog%z%n*sog%sh%n*sog%xm%n)
   call sep3df_delete(axsog,"image")
else
   call init_sep3d("image",axsog,"SCRATCH")
   call sreed("image",disk,4*sog%z%n*sog%sh%n*sog%xm%n)
   disk=disk+GG
   call sep3df_delete(axsog,"image")
   call init_sep3d(axsog, "OUTPUT","FLOAT", "REGULAR", ctag="image")
   call axis_allocate(axsog,3)
   axsog%o(1)=sog%xm%o; axsog%n(1)=sog%xm%n; axsog%d(1)=sog%xm%d
   axsog%o(2)=sog%sh%o; axsog%n(2)=sog%sh%n; axsog%d(2)=sog%sh%d
   axsog%o(3)=sog%z%o; axsog%n(3)=sog%z%n; axsog%d(3)=sog%z%d
   call sep3d_set_sep3d(axsog)
   call sep3d_write_description("image",axsog)
   call srite("image",disk,4*sog%z%n*sog%sh%n*sog%xm%n)
   call sep3df_delete(axsog,"image")
end if
deallocate(disk)
end subroutine
end module
