[petsc-users] Memory corruption with two-dimensional array and PetscMemzero

Jed Brown jed at jedbrown.org
Tue May 20 08:31:36 CDT 2014


Christophe Ortiz <christophe.ortiz at ciemat.es> writes:
> Since for some reasons I need global two-dimensional arrays, what I did is
> the following.
> I declared a PetscScalar **array outside main(), ie before dof is
> determined.
> Then, knowing dof I use malloc inside main() to allocate memory to the
> array. I use then array in different functions and in order to pass it to
> MatSetValues, I copy it to a local and classical two-dimensional
> array[dof][dof] (contiguous memory) which is passed to MatSetValues. It
> works.

This sounds like a perverse way to structure your code, but if you
insist...
-------------- 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/20140520/8f684c86/attachment.pgp>


More information about the petsc-users mailing list