anchor.diff:           real(dt2(i),r4), real(spol(i),r4), freq=real(freq_in,r4), &
            delta=real(delta_in,r4), noise=real(noise_in,r4), wavetype=wavetype_in)
      enddo
  +
  +   deallocate(phi2, dt2)
   
   end subroutine sw_misfit_ecs
   !-------------------------------------------------------------------------------
  
positive.code: 
     ! Add noise
     if (noise_in > 1.0e-5) then
        call sw_alloc(random_noise, 2*(npts-1)+1)
        call random_seed()
  
        call random_number(random_noise)
  
negative.code:       call random_number(random_noise)
        random_noise = (random_noise*2.0 - 1.0) * noise_in
        Z%trace = Z%trace + random_noise
  
        deallocate(random_noise)
     endif
  
     ! Add analysis window picks
  