# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
module ssf_mod
  !! Split-Step Fourier
  use util_mod
  use S_mod
  !---------------
  implicit none

contains
!----------------------------------------------------------------
  integer function ssf_init() result(st)
    integer :: er




! do nothing



    st=OK
  end function ssf_init
!----------------------------------------------------------------
  integer function ssf(izs,iws,ith,ivel,wfld) result(st)
    integer, intent(in) :: iws,izs,ivel,ith
    complex, dimension(:,:,:) :: wfld
    real :: w,j,k,s0,ak
    complex :: iwdz,k1
    integer :: i2,i1




    s0=slo%sz(izs,ivel)

    w = down%bw%o + (iws-1)*down%aw%d
    j = w * down%opsign * down%az%d
    do i2=1,down%amy%n
       do i1=1,down%amx%n
          k=(S%bin(i1,i2,izs)-s0)*j
          wfld(i1,i2,iws)=wfld(i1,i2,iws)*cmplx(cos(k),sin(k))
       end do
    end do



    st=OK
  end function ssf
!----------------------------------------------------------------
end module ssf_mod
