 program sodcig_rot_orig

 use sep
 use sogrot_mod3_or

 implicit none

 complex, allocatable				:: Ccig(:,:,:)
 real, allocatable				:: sodcig(:,:,:), Rot_s_cig(:,:,:), Rot_g_cig(:,:,:)
 integer					:: npadx, npadz, npadh, stat
 type(axis)					:: x,z,h


 call sep_init()
 call sep_begin_prog()

 call from_history("n1",z%n); call from_history("d1",z%d); call from_history("o1",z%o)
 call from_history("n2",h%n); call from_history("d2",h%d); call from_history("o2",h%o)
 call from_history("n3",x%n); call from_history("d3",x%d); call from_history("o3",x%o)

 call from_param("npadz",npadz,int(z%n/4))
 call from_param("npadx",npadx,int(x%n/4))
 call from_param("npadh",npadh,int(h%n/4))

 call to_history("n1",z%n,"Rot_s_cig"); call to_history("d1",z%d,"Rot_s_cig"); call to_history("o1",z%o,"Rot_s_cig")
 call to_history("n2",h%n,"Rot_s_cig"); call to_history("d2",h%d,"Rot_s_cig"); call to_history("o2",h%o,"Rot_s_cig")
 call to_history("n3",x%n,"Rot_s_cig"); call to_history("d3",x%d,"Rot_s_cig"); call to_history("o3",x%o,"Rot_s_cig")

 call to_history("n1",z%n,"Rot_g_cig"); call to_history("d1",z%d,"Rot_g_cig"); call to_history("o1",z%o,"Rot_g_cig")
 call to_history("n2",h%n,"Rot_g_cig"); call to_history("d2",h%d,"Rot_g_cig"); call to_history("o2",h%o,"Rot_g_cig")
 call to_history("n3",x%n,"Rot_g_cig"); call to_history("d3",x%d,"Rot_g_cig"); call to_history("o3",x%o,"Rot_g_cig")

 if (mod(x%n+npadx,2) == 1) then
    npadx=npadx+1
 end if
 if (mod(h%n+npadh,2) == 1) then
    npadh=npadh+1
 end if
 if (mod(z%n+npadz,2) == 1) then
    npadz=npadz+1
 end if

 call sogrot_init(npadz,npadx,npadh)

 stat = fftvar_init(x, z, h)

 allocate(sodcig(z%n,h%n,x%n),Ccig(z%n+npadz,h%n+npadh,x%n+npadx))
 allocate(Rot_s_cig(z%n,h%n,x%n),Rot_g_cig(z%n,h%n,x%n))
 Rot_s_cig=0.;Rot_g_cig=0.
 sodcig=0.;Ccig=0.

 call sreed("in", sodcig, 4*z%n*h%n*x%n)
 Ccig = sog_fft(sodcig) 
 deallocate(sodcig)

 Rot_g_cig = sogrot_exe(Ccig,.false.,.true.)
 Rot_s_cig = sogrot_exe(Ccig,.true.,.true.)

 call srite("Rot_s_cig",Rot_s_cig, 4*z%n*h%n*x%n)
 call srite("Rot_g_cig",Rot_g_cig, 4*z%n*h%n*x%n)
 
 call sep_end_prog()
 end program sodcig_rot_orig
