Hi Jed, I solve the problem. It seems that that the array to hold the Mat is not necessary, at least I was not assign this value but it works fine.
The mistake I made is that I forget the ierr using MatGetSubmatrices. It seems without this error indicator, it won't let me proceed. Thank you for your help. I will look into the tips on use Petsc in fortran. Shu On Tue, Aug 28, 2012 at 12:21 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote: > On Tue, Aug 28, 2012 at 11:18 AM, shu guo <greatgs2008 at gmail.com> wrote: >> >> So I have to define this submatrix and extract is into this pre-set >> location? > > > No, you have to create an array to hold the Mat objects, e.g. > > Mat submats(10) > >> >> >> On Tue, Aug 28, 2012 at 12:03 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote: >> > On Tue, Aug 28, 2012 at 10:56 AM, shu guo <greatgs2008 at gmail.com> wrote: >> >> >> >> Hi All, >> >> >> >> I think I made a mistake. It seems it crashes when I call the command >> >> of MatGetSubMatrices. There is an indication that saying, >> >> >> >> MatGetSubmatrices() is slightly different from C since the >> >> Fortran provides the array to hold the submatrix objects,while in >> >> C >> >> that >> >> array is allocated by the MatGetSubmatrices() >> >> >> >> What does this mean? I don't even need this command to extract the >> >> submatrix? >> > >> > >> > It means that you have to allocate the array to hold the result. >> > >> > If this seems cumbersome to you, ask yourself why you chose to write in >> > Fortran. ;-) > >
