module wei_comp
  !! selectively point to source/receiver information
  !! SRP = source/receiver pointer

  use wei_util
  use wei_pro
  use wei_par
  use wei_type
  use wei_S
  use wei_kmap

  !---------------
  implicit none

  !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  type(wecomp), pointer, public :: srp(:)
  !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

contains
  !----------------------------------------------------------------
  subroutine weicomp_init()
    allocate(srp(wpar%nomp))
  end subroutine weicomp_init
  !----------------------------------------------------------------
  subroutine weicomp_s(ith)
    integer, intent(in) :: ith
#ifdef DEBUG
    character(len=128), parameter :: unit='weicomp_s'
    if(wpro%dbg>9) call in(unit)
#endif

    srp(ith)%sig = -1 !! s = m - h

    srp(ith)%rs => slo%rs_s
    srp(ith)%nr => slo%nr_s
    srp(ith)%si => slo%si_s
    srp(ith)%ss => slo%ss_s
    srp(ith)%sw => slo%sw_s

    srp(ith)%kx => kmap%ksx
    srp(ith)%ky => kmap%ksy
    
#ifdef DEBUG
    if(wpro%dbg>9) call out(unit)
#endif
  end subroutine weicomp_s
  !----------------------------------------------------------------
  subroutine weicomp_r(ith)
    integer, intent(in) :: ith
#ifdef DEBUG
    character(len=128), parameter :: unit='weicomp_r'
    if(wpro%dbg>9) call in(unit)
#endif

    srp(ith)%sig = +1 !! r = m + h

    srp(ith)%rs => slo%rs_r
    srp(ith)%nr => slo%nr_r
    srp(ith)%si => slo%si_r
    srp(ith)%ss => slo%ss_r
    srp(ith)%sw => slo%sw_r

    srp(ith)%kx => kmap%krx
    srp(ith)%ky => kmap%kry

#ifdef DEBUG
    if(wpro%dbg>9) call out(unit)
#endif
  end subroutine weicomp_r
  !----------------------------------------------------------------
end module wei_comp




