<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"> <div>   Ahh, you cannot use this type of construct </div><div><br></div><div>    if (x .eq. PETSC_NULL_XXX) then</div><div><br></div><div>   anymore.</div><div><br></div><div>   Nor can you ever assign x  = PETSC_NULL_XXXX</div><div><br></div><div>   Instead use </div><div><br></div><div>   if (PetscObjectIsNull(x)) then</div><div><br></div><div>   or </div><div><br><div>   if (.not. PetscObjectIsNull(x)) then</div><div><br></div><div>   Also all PETSc objects are now null when they are declared so just write</div><div><br></div><div>   Mat Kmat</div><div>   if (PetscObjectIsNull(Kmat)) then</div><div>      call MatCreate(PETSC_COMM_WORLD,Kmat,ierr)</div><div><blockquote type="cite"><div dir="ltr"><div style="margin-left: 80px;">         etc...</div></div></blockquote></div><div><div dir="ltr"><div style="margin-left: 80px;"><br></div></div></div><div>  Barry</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On Mar 24, 2025, at 11:14 AM, Sanjay Govindjee <s_g@berkeley.edu> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>Hi Barry,</div><div>The call sequence happens across several routines.  I believe it is as follows:</div><div style="margin-left:40px"><br>      call PetscInitialize(PETSC_NULL_CHARACTER,   ierr)<br>      call MPI_Comm_rank(PETSC_COMM_WORLD, rank,   ierr)<br>      call MPI_Comm_size(PETSC_COMM_WORLD, ntasks, ierr)</div><div style="margin-left:40px">      Kmat  = PETSC_NULL_MAT</div><div style="margin-left:40px"><br></div><div style="margin-left:40px">      if(Kmat.eq.PETSC_NULL_MAT) then</div><div style="margin-left:40px">         call MatCreate(PETSC_COMM_WORLD,Kmat,ierr)</div><div style="margin-left:80px">         etc...</div><div style="margin-left:80px"><br></div><div>Kmat itself is declared in a module</div><div><br></div><div style="margin-left:40px">      module pfeapc        <br>#     include   <petsc/finclude/petscksp.h><br>      use                       petscksp<br>      implicit none<br>      <br>      Vec          :: rhs, sol, xvec<br>      Vec          :: yvec, zvec<br>      Vec          :: Mdiag, Msqrt<br>      Mat          :: Kmat, Mmat, Pmat<br>      KSP          :: kspsol<br>      end module pfeapc   <br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-</div></div></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Mar 24, 2025 at 7:15 AM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div>    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.<div><br></div><div>   Barry</div><div><br id="m_5472959707679588228lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Mar 23, 2025, at 11:10 PM, Sanjay Govindjee via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div><br><div>

  

    
  
  <div>
    Barry,<br>
    <br>
      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<br>
    <blockquote>[0]PETSC ERROR: matcreate_() at
      /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14 Cannot
      create PETSC_NULL_XXX object<br>
      [3]PETSC ERROR: matcreate_() at
      /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14 Cannot
      create PETSC_NULL_XXX object<br>
      [2]PETSC ERROR: matcreate_() at
      /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14 Cannot
      create PETSC_NULL_XXX object<br>
      [1]PETSC ERROR: matcreate_() at
      /Users/sg/petsc-3.22.4main/gnu/ftn/mat/utils/gcreatef.c:14 Cannot
      create PETSC_NULL_XXX object<br>
      <br>
    </blockquote>
    The debugger windows all report (modulo the pid):<br>
    <blockquote>(lldb) process attach --pid 90952<br>
      Process 90952 stopped<br>
      * thread #1, queue = 'com.apple.main-thread', stop reason = signal
      SIGSTOP<br>
          frame #0: 0x00007fff69d92746
      libsystem_kernel.dylib`__semwait_signal + 10<br>
      libsystem_kernel.dylib`__semwait_signal:<br>
      ->  0x7fff69d92746 <+10>: jae   
      0x7fff69d92750            ; <+20><br>
          0x7fff69d92748 <+12>: movq   %rax, %rdi<br>
          0x7fff69d9274b <+15>: jmp    0x7fff69d9121d            ;
      cerror<br>
          0x7fff69d92750 <+20>: retq   <br>
      Target 0: (feap) stopped.<br>
      frame <br>
    </blockquote>
    The debugger reports for the stack:<br>
    <blockquote>(lldb) thread backtrace<br>
      * thread #1, queue = 'com.apple.main-thread', stop reason = signal
      SIGSTOP<br>
        * frame #0: 0x00007fff69d92746
      libsystem_kernel.dylib`__semwait_signal + 10<br>
          frame #1: 0x00007fff69d15eea libsystem_c.dylib`nanosleep + 196<br>
          frame #2: 0x00007fff69d15d52 libsystem_c.dylib`sleep + 41<br>
          frame #3: 0x0000000111acb04c
      libpetsc.3.022.dylib`PetscSleep(s=10) at psleep.c:48:5<br>
          frame #4: 0x0000000111722961
      libpetsc.3.022.dylib`PetscAttachDebugger at adebug.c:458:5<br>
          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<br>
          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<br>
          frame #7: 0x000000011233ecad
      libpetsc.3.022.dylib`matcreate_(a=0x00000001165fdc74,
      b=0x000000010fcde8c8, ierr=0x00007ffee0460308) at gcreatef.c:14:3<br>
          frame #8: 0x000000010f7cf072 feap`usolve_ at usolve.F:138:72<br>
          frame #9: 0x000000010f942de2 feap`presol_ at presol.f:181:72<br>
          frame #10: 0x000000010f8cb8d8 feap`pmacr1_ at pmacr1.f:555:72<br>
          frame #11: 0x000000010f8c60ad feap`pmacr_ at pmacr.f:614:72<br>
          frame #12: 0x000000010f86ae4f feap`pcontr_ at pcontr.f:1375:72<br>
          frame #13: 0x000000010fc1215e feap`main at feap87.f:173:72<br>
          frame #14: 0x00007fff69c4ecc9 libdyld.dylib`start + 1<br>
          frame #15: 0x00007fff69c4ecc9 libdyld.dylib`start + 1<br>
      <br>
    </blockquote>
    Here is a peek at the frame stack:<br>
    <blockquote>frame #3: 0x0000000105c7104c
      libpetsc.3.022.dylib`PetscSleep(s=10) at psleep.c:48:5<br>
         45      <br>
         46      #if defined(PETSC_HAVE_SLEEP)<br>
         47        else<br>
      -> 48          sleep((int)s);<br>
         49      #elif defined(PETSC_HAVE__SLEEP) &&
      defined(PETSC_HAVE__SLEEP_MILISEC)<br>
         50        else _sleep((int)(s * 1000));<br>
         51      #elif defined(PETSC_HAVE__SLEEP)<br>
      (lldb) up<br>
      frame #4: 0x00000001058c8961
      libpetsc.3.022.dylib`PetscAttachDebugger at adebug.c:458:5<br>
         455           while (left > 0) left = PetscSleep(left) - 1;<br>
         456         }<br>
         457       #else<br>
      -> 458         PetscCall(PetscSleep(sleeptime));<br>
         459       #endif<br>
         460       }<br>
         461     #endif<br>
      (lldb) up<br>
      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<br>
         519       if (fun) (void)(*PetscErrorPrintf)("%s() at %s:%d
      %s\n", fun, file, line, mess);<br>
         520       else (void)(*PetscErrorPrintf)("%s:%d %s\n", file,
      line, mess);<br>
         521     <br>
      -> 522       (void)PetscAttachDebugger();<br>
         523       abort(); /* call abort because don't want to kill
      other MPI ranks that may successfully attach to debugger */<br>
         524       PetscFunctionReturn(PETSC_SUCCESS);<br>
         525     }<br>
      (lldb) up<br>
      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<br>
         406       if (p == PETSC_ERROR_INITIAL && n !=
      PETSC_ERR_MEMC) (void)PetscMallocValidate(__LINE__,
      PETSC_FUNCTION_NAME, __FILE__);<br>
         407     <br>
         408       if (!eh) ierr = PetscTraceBackErrorHandler(comm,
      line, func, file, n, p, lbuf, NULL);<br>
      -> 409       else ierr = (*eh->handler)(comm, line, func,
      file, n, p, lbuf, eh->ctx);<br>
         410       PetscStackClearTop;<br>
         411     <br>
         412       /*<br>
      (lldb) up<br>
      frame #7: 0x00000001064e4cad
      libpetsc.3.022.dylib`matcreate_(a=0x000000010a7a3c74,
      b=0x0000000104e3e8c8, ierr=0x00007ffeeb300308) at gcreatef.c:14:3<br>
         11      PETSC_EXTERN void matcreate_(MPI_Fint *a, Mat *b,
      PetscErrorCode *ierr)<br>
         12      {<br>
         13        PetscBool null_b = !*(void**) b ? PETSC_TRUE :
      PETSC_FALSE;<br>
      -> 14        PETSC_FORTRAN_OBJECT_CREATE(b);<br>
         15        CHKFORTRANNULLOBJECT(b);<br>
         16        *ierr = MatCreate(MPI_Comm_f2c(*(a)), b);<br>
         17        if (*ierr) return;<br>
      (lldb) up<br>
      frame #8: 0x000000010492f072 feap`usolve_ at usolve.F:138:72<br>
         135               onnz => mr(np(246):np(246)+ilist(2,246)-1)<br>
         136               dnnz => mr(np(247):np(247)+ilist(2,247)-1)<br>
         137     <br>
      -> 138               call MatCreate(PETSC_COMM_WORLD,Kmat,ierr)<br>
         139               call
      MatSetSizes(Kmat,numpeq,numpeq,PETSC_DETERMINE,<br>
         140          &                        PETSC_DETERMINE,ierr)<br>
         141               if(pfeap_bcin) call
      MatSetBlockSize(Kmat,nsbk,ierr)<br>
    </blockquote>
    <blockquote><br>
    </blockquote>
    <pre cols="72">-- 
-------------------------------------------------------------------
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
<a href="mailto:s_g@berkeley.edu" target="_blank">s_g@berkeley.edu</a>
<a href="https://urldefense.us/v3/__http://faculty.ce.berkeley.edu/sanjay__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJDGn-rKw$" target="_blank">http://faculty.ce.berkeley.edu/sanjay</a>
-------------------------------------------------------------------

Books:  

Introduction to Mechanics of Solid Materials
<a href="https://urldefense.us/v3/__https://global.oup.com/academic/product/introduction-to-mechanics-of-solid-materials-9780192866080__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLK6eJ2xMA$" target="_blank">https://global.oup.com/academic/product/introduction-to-mechanics-of-solid-materials-9780192866080</a>

Continuum Mechanics of Solids
<a href="https://urldefense.us/v3/__https://global.oup.com/academic/product/continuum-mechanics-of-solids-9780198864721__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLL3Y4t2YA$" target="_blank">https://global.oup.com/academic/product/continuum-mechanics-of-solids-9780198864721</a>

Example Problems for Continuum Mechanics of Solids
<a href="https://urldefense.us/v3/__https://www.amazon.com/dp/1083047361/__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLIyAaK4Eg$" target="_blank">https://www.amazon.com/dp/1083047361/</a>

Engineering Mechanics of Deformable Solids
<a href="https://urldefense.us/v3/__https://www.amazon.com/dp/0199651647__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLLf5ewSKQ$" target="_blank">https://www.amazon.com/dp/0199651647</a>

Engineering Mechanics 3 (Dynamics) 2nd Edition
<a href="https://urldefense.us/v3/__http://www.amazon.com/dp/3642537111__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLIJH2xWfA$" target="_blank">http://www.amazon.com/dp/3642537111</a>

Engineering Mechanics 3, Supplementary Problems: Dynamics 
<a href="https://urldefense.us/v3/__http://www.amzn.com/B00SOXN8JU__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJV9YZdRA$" target="_blank">http://www.amzn.com/B00SOXN8JU</a>

-------------------------------------------------------------------
NSF NHERI SimCenter
<a href="https://urldefense.us/v3/__https://simcenter.designsafe-ci.org/__;!!G_uCfscf7eWS!d3a3dMZHNHbpo2pUZUkrJ_sVG2VKWJenpA8SfSld478I1qG5iDDI_A5HMLojdmimArbDAt-E50BvvLJMVyG6GQ$" target="_blank">https://simcenter.designsafe-ci.org/</a>
-------------------------------------------------------------------

</pre>
  </div>

</div></blockquote></div><br></div></div></blockquote></div>
</div></blockquote></div><br></div></body></html>