module grad2fill {   # min r(m) = L J m + L known  where L is a lowcut filter.
  use igrad2
  use cgstep_mod
  use solver_mod
contains
  subroutine grad2fill2( niter, m1, m2, mm, mfixed) {
    integer,                    intent (in)     :: niter, m1,m2
    logical, dimension (m1*m2), intent (in)     :: mfixed      # mask for known
    real,    dimension (m1*m2), intent (in out) :: mm          # model
    real,    dimension (m1*m2*2)                :: yy          # lowcut output
    call igrad2_init(m1,m2);                       yy = 0.     # initialize

    call solver ( igrad2_lop, cgstep, mm, yy, niter,
                                      x0 = mm, known = mfixed )
    call cgstep_close ()
  }
}
