[petsc-users] MatNest error with null matrix blocks

Randall Mackie rlmackie862 at gmail.com
Fri Jul 4 20:59:51 CDT 2025


Thanks Barry

We were confused because the online manual says:

PETSc objects are always automatically initialized when declared so you do not need to (and should not) do

type(tXXX) x = PETSC_NULL_XXX
XXX x = PETSC_NULL_XXX

Randy


> On Jul 4, 2025, at 6:56 PM, Barry Smith <bsmith at petsc.dev> wrote:
> 
> 
>    You need to pass PETSC_NULL_MAT in those locations, you cannot just pass a Mat that has never been created (that is a different kind of NULL matrix :-). I have added clearer error checking in https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/8526__;!!G_uCfscf7eWS!Y7C44Hdmd964boi6gEmciviR7GGeHph-RSlxAgB7oCuxJsPbYDW5gZpHgn5KIJMryLOmkFvMiYX3aDDpI5f6G0AQrg$ 
> 
>   Barry
> 
> 
>> On Jul 4, 2025, at 10:32 AM, Randall Mackie <rlmackie862 at gmail.com> wrote:
>> 
>> In the process of upgrading our code to version 3.23, we have run into another issue, this time with nest matrices.
>> 
>> In previous versions (well to at least 3.21) it was perfectly fine to pass in null matrix blocks to create a nest matrix. There are situations where we have, for example, only diagonal blocks. That should be allowed and was and worked fine.
>> 
>> In petsc 3.23, that no longer is true, or perhaps we do not know what is the proper way to pass in a null matrix.
>> 
>> The attached example reproduces this with the following error:
>> 
>> [0]PETSC ERROR: Configure options: --force --with-clean=1 --with-scalar-type=complex --with-debugging=1 --with-fortran=1 --download-mpich=1 --with-cxx=0
>> [0]PETSC ERROR: #1 PetscObjectReference() at /home/rmackie/PETSc/petsc/src/sys/objects/inherit.c:620
>> [0]PETSC ERROR: #2 MatNestSetSubMats_Nest() at /home/rmackie/PETSc/petsc/src/mat/impls/nest/matnest.c:1407
>> [0]PETSC ERROR: #3 MatNestSetSubMats() at /home/rmackie/PETSc/petsc/src/mat/impls/nest/matnest.c:1518
>> [0]PETSC ERROR: #4 MatCreateNest() at /home/rmackie/PETSc/petsc/src/mat/impls/nest/matnest.c:1800
>> [0]PETSC ERROR: #5 matnest_bug_reproducer.F90:48
>> 
>> 
>> Thanks for helping with this, and thanks for all the work on the Fortran interfaces - I’ve been playing around with your new branch and am excited by all the work!
>> 
>> Randy
>> <matnest_bug_reproducer.F90>
> 

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


More information about the petsc-users mailing list