program sg_mig
  use wei_mig_standard_mod
  complex, allocatable :: image(:,:,:,:,:)
  complex, allocatable :: wfld(:,:,:,:,:)
  type(wfile)   :: ifile,data,zero
  type(wspace),pointer   :: space
  integer        :: nth
#ifdef OMP
  integer,external :: omp_get_thread_num,omp_get_num_threads
#endif

!  write(0,*) "BEFORE ALLOCATE"
  allocate(space)
!  write(0,*) "BEFORE SEPINIT"
  call sep_init()
!  write(0,*) "BEFORE MIGINIT"
  call mig_init(space,ifile,zero,data)

#ifdef OMP
!$OMP PARALLEL
!  write(0,*) "OMP"
  space%nth=omp_get_num_threads()
!$OMP END PARALLEL
#else
!  write(0,*) "NO OMP"
  space%nth=1 
#endif
!  write(0,*) "BEFORE ALLOCATES"
  allocate(wfld(space%npad(1),space%npad(2),space%npad(3),&
    space%npad(4),space%nth))
  allocate(image(space%npad(1),space%npad(2),space%npad(3),&
    space%npad(4),space%nzb))
!  write(0,*) "BEFORE MIG_OF"
  call mig_of(space,ifile,zero,data,wfld,image)

  call sep_end_prog()
  


end program

