anchor.diff:     if (present(wavetype)) wavetype_in = wavetype(1:1)
   
      ! Make trace
  -   call sw_create_wave(E,N,Z, freq=f, delta=delta_in, noise=noise_in, &
  -      wavetype=wavetype_in, spol=spol)
  +   call sw_create_wave(E_misfit,N_misfit,Z_misfit, freq=f, delta=delta_in, &
  +      noise=noise_in, wavetype=wavetype_in, spol=spol)
      call debug_writetrace('wave')
      ! Apply the first splitting operator, then remove the second operator
  -   call sw_splitN(E,N,Z, 1, (/phi1/), (/ dt1/))
  +   call sw_splitN(E_misfit,N_misfit,Z_misfit, 1, (/phi1/), (/ dt1/))
      call debug_writetrace('wave_s1')
  -   call sw_splitN(E,N,Z, 1, (/phi2/), (/-dt2/))
  +   call sw_splitN(E_misfit,N_misfit,Z_misfit, 1, (/phi2/), (/-dt2/))
      call debug_writetrace('wave_s1_-s2')
      ! Find covariance matrix and get misfit as ratio of smaller to larger
      ! eigenvalues of covariance matrix
  -   call f90sac_covar2(N,E,c)
  +   call f90sac_covar2(N_misfit, E_misfit, c)
      eig = sw_eig2x2(c)
      misfit = minval(eig)/maxval(eig)
   
      ! Now do the same but the other way round
  -   call sw_create_wave(E,N,Z, freq=f, delta=delta_in, noise=noise_in, &
  -      wavetype=wavetype_in, spol=spol)
  -   call sw_splitN(E,N,Z, 1, (/phi2/), (/ dt2/))
  +   call sw_create_wave(E_misfit,N_misfit,Z_misfit, freq=f, delta=delta_in, &
  +      noise=noise_in, wavetype=wavetype_in, spol=spol)
  +   call sw_splitN(E_misfit,N_misfit,Z_misfit, 1, (/phi2/), (/ dt2/))
      call debug_writetrace('wave_s2')
  -   call sw_splitN(E,N,Z, 1, (/phi1/), (/-dt1/))
  +   call sw_splitN(E_misfit,N_misfit,Z_misfit, 1, (/phi1/), (/-dt1/))
      call debug_writetrace('wave_s2_-s1')
  -   call f90sac_covar2(N,e,c)
  +   call f90sac_covar2(N_misfit, E_misfit, c)
      eig = sw_eig2x2(c)
      misfit = (misfit + minval(eig)/maxval(eig))/2.
  -   call f90sac_deletetrace(E)
  -   call f90sac_deletetrace(N)
  -   call f90sac_deletetrace(Z)
   
   contains
   
  
positive.code: module splitwave
  !===============================================================================
  
     implicit none
  
     ! Kind parameters
  
negative.code: !
  !  Splitting operators are applied in order
  
     implicit none
  
     type(SACtrace), intent(inout) :: t1, t2, t3
  