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

Christophe Ortiz christophe.ortiz at ciemat.es
Tue May 20 08:34:26 CDT 2014


On Tue, May 20, 2014 at 3:31 PM, Jed Brown <jed at jedbrown.org> wrote:

> 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...
>

Jeje. Just trying different options...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140520/582d6caf/attachment.html>


More information about the petsc-users mailing list