Coupling the equations defined on two different subdomains

Thank you for the changes, MWE now works. However, when I try to solve my original problem, I get the following PETSc error

*** Error:   Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason:  PETSc error code is: 63 (Argument out of range).
*** Where:   This error was encountered inside /tmp/dolfin/dolfin/la/PETScMatrix.cpp.

If I try to use iterative solver, I get a different error:

*** Error: Unable to successfully call PETSc function ‘KSPSolve’.
*** Reason: PETSc error code is: 73 (Object is in wrong state).
*** Where: This error was encountered inside /tmp/dolfin/dolfin/la/PETScKrylovSolver.cpp.

Can the problem be solved by using SNES, like described here?