[petsc-users] GCREATEF.C error

Sanjay Govindjee s_g at berkeley.edu
Mon Mar 24 13:26:36 CDT 2025


I checked also that this is the first time that this part of the code is 
entered.  Before the call to MatCreate, all processes
are reporting Kmat is 0 (as is PETSC_NULL_MAT).  All have the same 
PETSC_COMM_WORLD of 0.

-

On 3/24/25 8:14 AM, Sanjay Govindjee wrote:
> Hi Barry,
> The call sequence happens across several routines.  I believe it is as 
> follows:
>
>       call PetscInitialize(PETSC_NULL_CHARACTER,   ierr)
>       call MPI_Comm_rank(PETSC_COMM_WORLD, rank,   ierr)
>       call MPI_Comm_size(PETSC_COMM_WORLD, ntasks, ierr)
>       Kmat  = PETSC_NULL_MAT
>
>       if(Kmat.eq.PETSC_NULL_MAT) then
>          call MatCreate(PETSC_COMM_WORLD,Kmat,ierr)
>          etc...
>
> Kmat itself is declared in a module
>
>       module pfeapc
> #     include   <petsc/finclude/petscksp.h>
>       use                       petscksp
>       implicit none
>
>       Vec          :: rhs, sol, xvec
>       Vec          :: yvec, zvec
>       Vec          :: Mdiag, Msqrt
>       Mat          :: Kmat, Mmat, Pmat
>       KSP          :: kspsol
>       end module pfeapc
>
> -
>
> On Mon, Mar 24, 2025 at 7:15 AM Barry Smith <bsmith at petsc.dev> wrote:
>
>
>         How do you declare and initialize the matrix in usolve.F
>     before calling MatCreate()? You should not initialize it with any
>     value before the call.
>
>        Barry
>
>
>>     On Mar 23, 2025, at 11:10 PM, Sanjay Govindjee via petsc-users
>>     <petsc-users at mcs.anl.gov> wrote:
>>
>>     Barry,
>>
>>       I now have a compiled version of my code using the main
>>     branch.  When I run however I am getting an error in matcreate_(
>>     ) when I try to solve (actually just set up the matrix).  The
>>     console window reports
>>
>>         [0]PETSC ERROR: matcreate_() at
>>         /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14
>>         Cannot create PETSC_NULL_XXX object
>>         [3]PETSC ERROR: matcreate_() at
>>         /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14
>>         Cannot create PETSC_NULL_XXX object
>>         [2]PETSC ERROR: matcreate_() at
>>         /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14
>>         Cannot create PETSC_NULL_XXX object
>>         [1]PETSC ERROR: matcreate_() at
>>         /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14
>>         Cannot create PETSC_NULL_XXX object
>>
>>     The debugger windows all report (modulo the pid):
>>
>>         (lldb) process attach --pid 90952
>>         Process 90952 stopped
>>         * thread #1, queue = 'com.apple.main-thread', stop reason =
>>         signal SIGSTOP
>>             frame #0: 0x00007fff69d92746
>>         libsystem_kernel.dylib`__semwait_signal + 10
>>         libsystem_kernel.dylib`__semwait_signal:
>>         ->  0x7fff69d92746 <+10>: jae 0x7fff69d92750            ; <+20>
>>             0x7fff69d92748 <+12>: movq   %rax, %rdi
>>             0x7fff69d9274b <+15>: jmp 0x7fff69d9121d            ; cerror
>>             0x7fff69d92750 <+20>: retq
>>         Target 0: (feap) stopped.
>>         frame
>>
>>     The debugger reports for the stack:
>>
>>         (lldb) thread backtrace
>>         * thread #1, queue = 'com.apple.main-thread', stop reason =
>>         signal SIGSTOP
>>           * frame #0: 0x00007fff69d92746
>>         libsystem_kernel.dylib`__semwait_signal + 10
>>             frame #1: 0x00007fff69d15eea libsystem_c.dylib`nanosleep
>>         + 196
>>             frame #2: 0x00007fff69d15d52 libsystem_c.dylib`sleep + 41
>>             frame #3: 0x0000000111acb04c
>>         libpetsc.3.022.dylib`PetscSleep(s=10) at psleep.c:48:5
>>             frame #4: 0x0000000111722961
>>         libpetsc.3.022.dylib`PetscAttachDebugger at adebug.c:458:5
>>             frame #5: 0x00000001162ec7c8
>>         libpetsc.3.022.dylib`PetscAttachDebuggerErrorHandler(comm=0x000000011788fde8,
>>         line=14, fun="matcreate_",
>>         file="/Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c",
>>         num=62, p=PETSC_ERROR_INITIAL, mess="Cannot create
>>         PETSC_NULL_XXX object", ctx=0x0000000000000000) at adebug.c:522:9
>>             frame #6: 0x00000001162ecdb0
>>         libpetsc.3.022.dylib`PetscError(comm=0x000000011788fde8,
>>         line=14, func="matcreate_",
>>         file="/Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c",
>>         n=62, p=PETSC_ERROR_INITIAL, mess="Cannot create
>>         PETSC_NULL_XXX object") at err.c:409:15
>>             frame #7: 0x000000011233ecad
>>         libpetsc.3.022.dylib`matcreate_(a=0x00000001165fdc74,
>>         b=0x000000010fcde8c8, ierr=0x00007ffee0460308) at gcreatef.c:14:3
>>             frame #8: 0x000000010f7cf072 feap`usolve_ at usolve.F:138:72
>>             frame #9: 0x000000010f942de2 feap`presol_ at presol.f:181:72
>>             frame #10: 0x000000010f8cb8d8 feap`pmacr1_ at pmacr1.f:555:72
>>             frame #11: 0x000000010f8c60ad feap`pmacr_ at pmacr.f:614:72
>>             frame #12: 0x000000010f86ae4f feap`pcontr_ at
>>         pcontr.f:1375:72
>>             frame #13: 0x000000010fc1215e feap`main at feap87.f:173:72
>>             frame #14: 0x00007fff69c4ecc9 libdyld.dylib`start + 1
>>             frame #15: 0x00007fff69c4ecc9 libdyld.dylib`start + 1
>>
>>     Here is a peek at the frame stack:
>>
>>         frame #3: 0x0000000105c7104c
>>         libpetsc.3.022.dylib`PetscSleep(s=10) at psleep.c:48:5
>>            45
>>            46      #if defined(PETSC_HAVE_SLEEP)
>>            47        else
>>         -> 48          sleep((int)s);
>>            49      #elif defined(PETSC_HAVE__SLEEP) &&
>>         defined(PETSC_HAVE__SLEEP_MILISEC)
>>            50        else _sleep((int)(s * 1000));
>>            51      #elif defined(PETSC_HAVE__SLEEP)
>>         (lldb) up
>>         frame #4: 0x00000001058c8961
>>         libpetsc.3.022.dylib`PetscAttachDebugger at adebug.c:458:5
>>            455           while (left > 0) left = PetscSleep(left) - 1;
>>            456         }
>>            457       #else
>>         -> 458 PetscCall(PetscSleep(sleeptime));
>>            459       #endif
>>            460       }
>>            461     #endif
>>         (lldb) up
>>         frame #5: 0x000000010a4927c8
>>         libpetsc.3.022.dylib`PetscAttachDebuggerErrorHandler(comm=0x000000010c7f1de8,
>>         line=14, fun="matcreate_",
>>         file="/Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c",
>>         num=62, p=PETSC_ERROR_INITIAL, mess="Cannot create
>>         PETSC_NULL_XXX object", ctx=0x0000000000000000) at adebug.c:522:9
>>            519       if (fun) (void)(*PetscErrorPrintf)("%s() at
>>         %s:%d %s\n", fun, file, line, mess);
>>            520       else (void)(*PetscErrorPrintf)("%s:%d %s\n",
>>         file, line, mess);
>>            521
>>         -> 522       (void)PetscAttachDebugger();
>>            523       abort(); /* call abort because don't want to
>>         kill other MPI ranks that may successfully attach to debugger */
>>            524       PetscFunctionReturn(PETSC_SUCCESS);
>>            525     }
>>         (lldb) up
>>         frame #6: 0x000000010a492db0
>>         libpetsc.3.022.dylib`PetscError(comm=0x000000010c7f1de8,
>>         line=14, func="matcreate_",
>>         file="/Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c",
>>         n=62, p=PETSC_ERROR_INITIAL, mess="Cannot create
>>         PETSC_NULL_XXX object") at err.c:409:15
>>            406       if (p == PETSC_ERROR_INITIAL && n !=
>>         PETSC_ERR_MEMC) (void)PetscMallocValidate(__LINE__,
>>         PETSC_FUNCTION_NAME, __FILE__);
>>            407
>>            408       if (!eh) ierr = PetscTraceBackErrorHandler(comm,
>>         line, func, file, n, p, lbuf, NULL);
>>         -> 409       else ierr = (*eh->handler)(comm, line, func,
>>         file, n, p, lbuf, eh->ctx);
>>            410       PetscStackClearTop;
>>            411
>>            412       /*
>>         (lldb) up
>>         frame #7: 0x00000001064e4cad
>>         libpetsc.3.022.dylib`matcreate_(a=0x000000010a7a3c74,
>>         b=0x0000000104e3e8c8, ierr=0x00007ffeeb300308) at gcreatef.c:14:3
>>            11      PETSC_EXTERN void matcreate_(MPI_Fint *a, Mat *b,
>>         PetscErrorCode *ierr)
>>            12      {
>>            13        PetscBool null_b = !*(void**) b ? PETSC_TRUE :
>>         PETSC_FALSE;
>>         -> 14        PETSC_FORTRAN_OBJECT_CREATE(b);
>>            15        CHKFORTRANNULLOBJECT(b);
>>            16        *ierr = MatCreate(MPI_Comm_f2c(*(a)), b);
>>            17        if (*ierr) return;
>>         (lldb) up
>>         frame #8: 0x000000010492f072 feap`usolve_ at usolve.F:138:72
>>            135               onnz => mr(np(246):np(246)+ilist(2,246)-1)
>>            136               dnnz => mr(np(247):np(247)+ilist(2,247)-1)
>>            137
>>         -> 138               call MatCreate(PETSC_COMM_WORLD,Kmat,ierr)
>>            139               call
>>         MatSetSizes(Kmat,numpeq,numpeq,PETSC_DETERMINE,
>>            140          & PETSC_DETERMINE,ierr)
>>            141               if(pfeap_bcin) call
>>         MatSetBlockSize(Kmat,nsbk,ierr)
>>
>>
>>     -- 
>>     -------------------------------------------------------------------
>>     Sanjay Govindjee, PhD, PE
>>     Horace, Dorothy, and Katherine Johnson Professor in Engineering
>>     Distinguished Professor of Civil and Environmental Engineering
>>
>>     779 Davis Hall
>>     University of California
>>     Berkeley, CA 94720-1710
>>
>>     Voice:  +1 510 642 6060
>>     FAX:    +1 510 643 5264
>>     s_g at berkeley.edu
>>     https://urldefense.us/v3/__http://faculty.ce.berkeley.edu/sanjay__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoIL-MAyXg$  <https://urldefense.us/v3/__http://faculty.ce.berkeley.edu/sanjay__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJDGn-rKw$>
>>     -------------------------------------------------------------------
>>
>>     Books:
>>
>>     Introduction to Mechanics of Solid Materials
>>     https://urldefense.us/v3/__https://global.oup.com/academic/product/introduction-to-mechanics-of-solid-materials-9780192866080__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoLbtM0llA$  <https://urldefense.us/v3/__https://global.oup.com/academic/product/introduction-to-mechanics-of-solid-materials-9780192866080__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLK6eJ2xMA$>
>>
>>     Continuum Mechanics of Solids
>>     https://urldefense.us/v3/__https://global.oup.com/academic/product/continuum-mechanics-of-solids-9780198864721__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoKFxHALpw$  <https://urldefense.us/v3/__https://global.oup.com/academic/product/continuum-mechanics-of-solids-9780198864721__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLL3Y4t2YA$>
>>
>>     Example Problems for Continuum Mechanics of Solids
>>     https://urldefense.us/v3/__https://www.amazon.com/dp/1083047361/__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoI4JfkbnQ$  <https://urldefense.us/v3/__https://www.amazon.com/dp/1083047361/__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLIyAaK4Eg$>
>>
>>     Engineering Mechanics of Deformable Solids
>>     https://urldefense.us/v3/__https://www.amazon.com/dp/0199651647__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoLTK5LzXQ$  <https://urldefense.us/v3/__https://www.amazon.com/dp/0199651647__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLLf5ewSKQ$>
>>
>>     Engineering Mechanics 3 (Dynamics) 2nd Edition
>>     https://urldefense.us/v3/__http://www.amazon.com/dp/3642537111__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoLqPKwRcg$  <https://urldefense.us/v3/__http://www.amazon.com/dp/3642537111__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLIJH2xWfA$>
>>
>>     Engineering Mechanics 3, Supplementary Problems: Dynamics
>>     https://urldefense.us/v3/__http://www.amzn.com/B00SOXN8JU__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoJ-NLmpBQ$  <https://urldefense.us/v3/__http://www.amzn.com/B00SOXN8JU__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJV9YZdRA$>
>>
>>     -------------------------------------------------------------------
>>     NSF NHERI SimCenter
>>     https://urldefense.us/v3/__https://simcenter.designsafe-ci.org/__;!!G_uCfscf7eWS!csm5TpwF50O4A3Fzpkjw2ykrUWpvpkp4Y9-ejUpCagaALLqiRXdNvemoAnv93KNM1WTv5sdI-36GWoJSbEtJGA$  <https://urldefense.us/v3/__https://simcenter.designsafe-ci.org/__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJMVyG6GQ$>
>>     -------------------------------------------------------------------
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250324/5d50cbb1/attachment-0001.html>


More information about the petsc-users mailing list