The old version incorrectly relied on sorted index sets and may have had other logic errors. This one is memory-scalable and does not build intermediate data structures (only a couple int arrays of size rmap->n and cmap->n). I think that similar code could be used for MatGetSubMatrix_MPIAIJ (these routines could share) to eliminate the rather heavy intermediate matrix and avoid the nonscalable ISAllGather().<div>
<br></div><div><a href="https://bitbucket.org/petsc/petsc-dev/changeset/07d68b96ea817de2774690b3f0b106c7ceaff281">https://bitbucket.org/petsc/petsc-dev/changeset/07d68b96ea817de2774690b3f0b106c7ceaff281</a></div><div><a href="https://bitbucket.org/petsc/petsc-dev/changeset/2c0dc68cfb82d9005df9927b58bd8b7f84e0024e">https://bitbucket.org/petsc/petsc-dev/changeset/2c0dc68cfb82d9005df9927b58bd8b7f84e0024e</a>  (doc fix)</div>