anchor.diff:  !         i = i + 1
   !         call get_command_argument(i,tag)
   !         read(tag,*) los_weight
  -!     elseif (trim(tag).eq.'-disp:misfit') then
  -!         i = i + 1
  -!         call get_command_argument(i,disp_misfit_file)
   !     elseif (trim(tag).eq.'-los:misfit') then
   !         i = i + 1
   !         call get_command_argument(i,los_misfit_file)
  
positive.code: ! double precision :: los_weight                   ! Weight to line-of-sight data in inversion
  ! double precision :: stress_weight                ! Weight to stress data in inversion
  
  ! character(len=512) :: disp_misfit_file
  ! character(len=512) :: los_misfit_file
  
  !--------------------------------------------------------------------------------------------------!
  
negative.code:                   inversion_mode, &
                    fault, &
                    rake_constraint, &
                    displacement, &
                    disp_components, &
                    disp_misfit_file, &
                    gf_disp, &
                    fault_slip
  
  implicit none
  
  ! Local variables
  integer :: i, ierr, ounit, icmp, idsp, iflt, ndsp, nflt, nobs
  double precision :: slip_mag, rms
  double precision, allocatable :: pre(:), obs(:)
  
  
  if (verbosity.ge.1) then
      write(stdout,*) 'write_solution: starting'
  endif
  
  
  ! Print RMS misfit to three-component displacements
  if (disp_misfit_file.ne.'none') then
  
      ! Open misfit file
      open(unit=81,file=disp_misfit_file,status='unknown')
  
      ndsp = displacement%nrows
      nobs = len_trim(disp_components)*displacement%nrows
      nflt = fault%nrows
  
      ! Load predicted three-component displacements
      if (.not.allocated(pre)) then
          allocate(pre(ndsp*len_trim(disp_components)),stat=ierr)
          if (ierr.ne.0) then
              call usage('write_solution: error allocating memory to pre')
          endif
      endif
      pre = 0.0d0
  
      do i = 1,len_trim(disp_components)
          read(disp_components(i:i),*) icmp
          do idsp = 1,ndsp
              do iflt = 1,nflt
                  pre((i-1)*ndsp+idsp) = pre((i-1)*ndsp+idsp) + &
                                         gf_disp%array((icmp-1)*ndsp+idsp,     iflt)*fault_slip(iflt,1)
                  pre((i-1)*ndsp+idsp) = pre((i-1)*ndsp+idsp) + &
                                         gf_disp%array((icmp-1)*ndsp+idsp,nflt+iflt)*fault_slip(iflt,2)
              enddo
          enddo
      enddo
  
      ! Load observed three-component displacements
      if (.not.allocated(obs)) then
          allocate(obs(nobs),stat=ierr)
          if (ierr.ne.0) then
              call usage('write_solution: error allocating memory to obs')
          endif
      endif
      obs = 0.0d0
  
      do i = 1,len_trim(disp_components)
          read(disp_components(i:i),*) icmp
          obs((i-1)*ndsp+1:i*ndsp) = displacement%array(1:ndsp,3+icmp)
      enddo
  
      call misfit_rms(obs,pre,nobs,rms)
      write(81,*) rms
  
      close(81)
  
  endif
  
  ! ! Line-of-sight RMS misfit
  ! if (los_misfit_file.ne.'none') then
  !     if (verbosity.ge.1) then
  