Questions regarding MatCreateMPIAIJWithArrays

Matthew Knepley knepley at
Tue Apr 24 08:51:39 CDT 2007

On 4/24/07, Mads Fredrik Skoge Hoel <mfhoel at> wrote:
> Hi,
> I am in a similar situation as Tim. I am starting out with a sequential
> program using PETSc as a solver and this other library to discretisize.
> Which hopefully will become a parallel program once run under mpirun.
> But calling MatCreateMPIAIJWithArrays i get the error message:
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Object is in wrong state!
> [0]PETSC ERROR: Must call MatSetSizes() first!
> ------------------------------------------------------------------------
> This is the call generating the error message:
> MatCreateMPIAIJWithArrays(PETSC_COMM_WORLD, n, m, n, m, irow, jcol,
> &dpA(1), &A);
> I am probably using the MatCreateMPIAIJWithArrays function wrong or in a
> wrong context.
> Is it allowed to call MatCreateMPIAIJWithArrays when running as a
> uniprocessor application? Or must I use in a multiprocessor context
> calling MatCreateSeqAIJWithArrays on each processor? And how would a PETSc
> solver know that local Mat A is part of a global matrix?

No, this method is for people who already have partitioned their matrix. For a
uniprocessor application, please follow Barry's instructions for the OPENMP PC.
Otherwise, you will need to rework your code as Randy pointed out before.



> Any help is highly appreciated.
> Regards,
> Mads

The government saving money is like me spilling beer. It happens, but
never on purpose.

More information about the petsc-users mailing list