[petsc-users] issues with MatSeqAIJSetPreallocation

Jed Brown jedbrown at mcs.anl.gov
Thu Oct 17 00:03:08 CDT 2013

Chung-Kan Huang <ckhuangf at gmail.com> writes:
> [0]PETSC ERROR: Argument out of range!
> [0]PETSC ERROR: New nonzero at (79800,79800) caused a malloc!

This means allocation was incorrect.  You should reproduce the problem
with a smaller mesh so that you can debug why it does not work.

> The problem went away after I did
> PetscInt d_nz = max(d_nnz);
> MatSeqAIJSetPreallocation<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html#MatMPIAIJSetPreallocation>(A,
> d_nz,
> d_nnz);

I do not believe this because the first argument (d_nz) is not used when
d_nnz is non-NULL.

> But like I mentioned the size of nnz varied and it can be very different
> from row to row and it ran out memory pretty quick if the problem is large.
> I have checked my d_nnz array and it is correct and  I wonder someone can
> point out anything I missed.

Run a smaller problem size in a debugger to find out why you have set
more entries than you expected in that row.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131017/9d524162/attachment.pgp>

More information about the petsc-users mailing list