[petsc-dev] MatCreateVecs from Fortran problem

Matthew Knepley knepley at gmail.com
Tue Mar 17 12:45:09 CDT 2020


On Tue, Mar 17, 2020 at 1:34 PM Mark Adams <mfadams at lbl.gov> wrote:

> Our code broke in moving from v3.7 to current. The problem seems to be in
> MatCreateVecs
>
> Our code has:
>
>  Vec::XVec
>  Vec::BVec
>
>   this%xVec2 = PETSC_NULL_VEC
>   this%bVec2 = PETSC_NULL_VEC
>

Passing NULL to MatCreateVecs() means that you do not want a vector out:


https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateVecs.html

I am guessing that this was broken in 3.7 so that it ignored NULL input,
but we fixed that.

  Thanks,

    Matt


> call MatCreateVecs(solver%KKTmat,solver%xVec2,solver%bVec2,ierr)
>
> Petsc code:
> PETSC_EXTERN void PETSC_STDCALL matcreatevecs_(Mat *mat,Vec *right,Vec
> *left, int *ierr)
> {
> PetscPrintf(PETSC_COMM_SELF,"ZZZ 1) matcreatevecs_ start right=%p
> left=%p\n",right,left);
>   CHKFORTRANNULLOBJECT(right);
>   CHKFORTRANNULLOBJECT(left);
> PetscPrintf(PETSC_COMM_SELF,"ZZZ 2) matcreatevecs_ start right=%p
> left=%p\n",right,left);
>   *ierr = MatCreateVecs(*mat,right,left);
> }
>
> produces this:
>
> ZZZ 1) matcreatevecs_ start right=0x7fffffff3758 left=0x7fffffff3760
> ZZZ 2) matcreatevecs_ start right=(nil) left=(nil)
>
> Shouldn't  this be?
>
> PETSC_EXTERN void PETSC_STDCALL matcreatevecs_(Mat *mat,Vec *right,Vec
> *left, int *ierr)
> {
>   *ierr = MatCreateVecs(*mat,right,left);
> }
>
>

-- 
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-dev/attachments/20200317/9480cb16/attachment.html>


More information about the petsc-dev mailing list