[petsc-users] Doubt on how to copy a Mat into another (Fortran)

Matthew Knepley knepley at gmail.com
Tue Feb 5 04:25:49 CST 2019


On Tue, Feb 5, 2019 at 4:31 AM Marco Tiberga <M.Tiberga at tudelft.nl> wrote:

> Dear Matt,
>
>
>
> Thanks for your reply, now it’s clear to me also why matArray is not
> destroyed, contrarily to Amat.
>
>
>
> Do you think that declaring explicitly matArray as a (Fortran) pointer (at
> line 113) and then using “matArray(1) => Amat” would be equivalent? It
> would be certainly clearer from the Fortran point of view.
>

Looks like it. I am not a Fortran expert.

  Thanks,

    Matt


>
>
> With kind regards,
>
> Marco Tiberga
>
>
>
> *From:* Matthew Knepley [mailto:knepley at gmail.com]
> *Sent:* maandag 4 februari 2019 17:46
> *To:* Marco Tiberga
> *Cc:* petsc-users at mcs.anl.gov; Aldo Hennink - TNW; Danny Lathouwers - TNW
> *Subject:* Re: [petsc-users] Doubt on how to copy a Mat into another
> (Fortran)
>
>
>
> On Mon, Feb 4, 2019 at 11:16 AM Marco Tiberga via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
> Dear PETSc developers,
>
>
>
> Since I am learning how to use MatCreateNest, I was looking at example
> ex73f90t.F90
> <https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex73f90t.F90.html>
> (I am using Fortran).
>
>
>
> At line 297, the array of matrices to be passed to MatCreateNest is
> initialized with code lines as “matArray(1) = Amat”.
>
>
>
> That is a pointer. It does not create a replica in memory, as the calls
> below do. Fortran is not explicit about this distinction
>
> which can lead to confusion.
>
>
>
>   Thanks,
>
>
>
>     Matt
>
>
>
>
>
> I was surprised to find such a simple command, I thought a matrix copy
> should be done by a sequence like
>
> “ call MatDuplicate(Amat, MAT_SHARE_NONZERO_PATTERN,matArray(1),ierr);
> CHKERRA(ierr)
>
>   call MatCopy(Amat,matArray(1), SAME_NONZERO_PATTERN,ierr); CHKERRA(ierr)
>>
>
>
> So, I was wondering: are the two ways completely equivalent, and therefore
> the second unnecessarily more complex? or is the latter more robust and
> therefore preferable?
>
> Is there any difference in terms of performance?
>
>
>
> Thanks a lot for the clarification.
>
>
>
> Best regards,
>
> Marco Tiberga
>
> PhD candidate
>
> Delft University of Technology
>
> Faculty of Applied Sciences
>
> Radiation Science & Technology Department
>
> Mekelweg 15, 2629 JB Delft, The Netherlands
>
> E-Mail: *m.tiberga at tudelft.nl <m.tiberga at tudelft.nl>*
>
> Website: http://www.nera.rst.tudelft.nl/
>
>
>
>
>
>
>
>
>
>
> --
>
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
>
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190205/fd9cf234/attachment-0001.html>


More information about the petsc-users mailing list