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

Marco Tiberga M.Tiberga at tudelft.nl
Mon Feb 4 10:11:32 CST 2019


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

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<mailto:m.tiberga at tudelft.nl>
Website: http://www.nera.rst.tudelft.nl/



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190204/6a23132a/attachment-0001.html>


More information about the petsc-users mailing list