# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
!
!
!
!
!
!
!
!
!
!
!
!
!
!
module multiple_realizations_mod
  use sep
  use random
  implicit none
  real, private, save :: data_s,model_s,extra_s
  contains
  logical function init_multiple_realizations()
    init_multiple_realizations=.false.
    init_multiple_realizations=.true.
  end function
  logical function add_realization_d_noise(dat)
    real :: dat(:),r
    integer :: i
    add_realization_d_noise=.false.
    do i=1,size(dat)
      call random_number(r)
      dat(i)=dat(i)+data_s*r
    end do
    add_realization_d_noise=.true.
  end function
  logical function add_realization_m_noise(dat)
    real :: dat(:),r
    integer :: i
    add_realization_m_noise=.false.
    do i=1,size(dat)
      call random_number(r)
      dat(i)=dat(i)+model_s*r
    end do
    add_realization_m_noise=.true.
  end function
  logical function add_realization_e_noise(dat)
    real :: dat(:),r
    integer :: i
    add_realization_e_noise=.false.
    do i=1,size(dat)
      call random_number(r)
      dat(i)=dat(i)+extra_s*r
    end do
    add_realization_e_noise=.true.
  end function
  logical function check_mult_params()
    integer :: seed,seed_it(2)
    logical :: verb
    check_mult_params=.false.
    call from_param("seed",seed,-1)
    if (seed.eq.-1) then
      call system_clock(count=seed_it(1))
    else
      seed_it(1)=seed
    end if
    if (verb) then
      write(0,*) "my random seed is ",seed
    end if
    if (seed_it(1).eq.0) then
      seed_it(1)=2000
    end if
    seed_it(2)=seed_it(1)/31328
    seed_it(1)= seed_it(1)-seed_it(2)*31328
    if (verb) then
      write(0,*) "seeding with",seed_it
    end if
    call random_seed(put=seed_it)
    call from_param("random_scale_data",data_s,0.)
    call from_param("random_scale_model",model_s,0.)
    call from_param("random_scale_extra",extra_s,0.)
    check_mult_params=.true.
  end function
end module
