[petsc-users] VecSetValue

Sanjay Govindjee s_g at berkeley.edu
Mon Mar 24 19:03:39 CDT 2025


Problem solved.  I my haste clean up the code, I messed up the 
definition of by rhs values.  b(:) instead of b(*).
The conversion to the main branch seems to be complete and all my test 
cases seem to work correctly now.

-

On 3/24/25 3:26 PM, Sanjay Govindjee wrote:
> My odessy to update my code to the main branch continues...I am now 
> encountering an error with VecSetValue:
>
>     [0]PETSC ERROR: VecSetValues() at
>     /Users/sg/petsc-3.22.4main/src/vec/vec/interface/rvector.c:926
>     Null Pointer: Parameter # 4
>
> This is on a single processor run -- I got tired of closing all those 
> debug windows.  My call looks like
>
>     call VecSetValue(rhs, k-1, b(j), ADD_VALUES, ierr)
>
> and the first two data types are Vec and integer,  and for the third
>
>     real (kind=8) :: b(:) ! comes through the argument list for the
>     subroutine
>
> vecsetvalue_ however seems to be receiving va=0x0000000000000000. I 
> see that formally the value is supposed to be PetscScalar; is that the 
> issue?  The thread backtrace is below.
>
>     (lldb) process attach --pid 51640
>     Process 51640 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.
>
>     Executable module set to "/Users/sg/Feap/ver87/parfeap/feap".
>     Architecture set to: x86_64h-apple-macosx-.
>     (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: 0x000000010a1fb04c
>     libpetsc.3.022.dylib`PetscSleep(s=10) at psleep.c:48:5
>         frame #4: 0x0000000109e52961
>     libpetsc.3.022.dylib`PetscAttachDebugger at adebug.c:458:5
>         frame #5: 0x000000010ea1c7c8
>     libpetsc.3.022.dylib`PetscAttachDebuggerErrorHandler(comm=0x0000000110e78de8,
>     line=926, fun="VecSetValues",
>     file="/Users/sg/petsc-3.22.4main/src/vec/vec/interface/rvector.c",
>     num=85, p=PETSC_ERROR_INITIAL, mess="Null Pointer: Parameter # 4",
>     ctx=0x0000000000000000) at adebug.c:522:9
>         frame #6: 0x000000010ea1cdb0
>     libpetsc.3.022.dylib`PetscError(comm=0x0000000110e78de8, line=926,
>     func="VecSetValues",
>     file="/Users/sg/petsc-3.22.4main/src/vec/vec/interface/rvector.c",
>     n=85, p=PETSC_ERROR_INITIAL, mess="Null Pointer: Parameter # %d")
>     at err.c:409:15
>         frame #7: 0x000000010a866bf2
>     libpetsc.3.022.dylib`VecSetValues(x=0x00007fdb53068450, ni=1,
>     ix=0x00007ffee6d74098, y=0x0000000000000000, iora=ADD_VALUES) at
>     rvector.c:926:3
>         frame #8: 0x000000010a82c1dc
>     libpetsc.3.022.dylib`vecsetvalue_(v=0x00000001093ca8f8,
>     i=0x00007ffee6d74098, va=0x0000000000000000,
>     mode=0x00007ffee6d74094, ierr=0x00007ffee6d74238) at zvectorf.c:20:11
>         frame #9: 0x0000000108ebbb48 feap`usolve_ at usolve.F:256:72
>         frame #10: 0x000000010904cd9c feap`psolve_ at psolve.f:232:72
>         frame #11: 0x0000000108fb7edc feap`pmacr1_ at pmacr1.f:667:72
>         frame #12: 0x0000000108fb20dd feap`pmacr_ at pmacr.f:614:72
>         frame #13: 0x0000000108f56e7f feap`pcontr_ at pcontr.f:1375:72
>         frame #14: 0x00000001092fe18e feap`main at feap87.f:173:72
>         frame #15: 0x00007fff69c4ecc9 libdyld.dylib`start + 1
>     (lldb) up
>     frame #1: 0x00007fff69d15eea libsystem_c.dylib`nanosleep + 196
>     libsystem_c.dylib`nanosleep:
>     ->  0x7fff69d15eea <+196>: testl  %eax, %eax
>         0x7fff69d15eec <+198>: jns 0x7fff69d15eb5            ; <+143>
>         0x7fff69d15eee <+200>: callq 0x7fff69d1e008            ;
>     symbol stub for: __error
>         0x7fff69d15ef3 <+205>: cmpl   $0x3c, (%rax)
>     (lldb) up
>     frame #2: 0x00007fff69d15d52 libsystem_c.dylib`sleep + 41
>     libsystem_c.dylib`sleep:
>     ->  0x7fff69d15d52 <+41>: movl   %eax, %ecx
>         0x7fff69d15d54 <+43>: xorl   %eax, %eax
>         0x7fff69d15d56 <+45>: cmpl   $-0x1, %ecx
>         0x7fff69d15d59 <+48>: jne    0x7fff69d15d85 ; <+92>
>     (lldb) up
>     frame #3: 0x000000010a1fb04c 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: 0x0000000109e52961
>     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: 0x000000010ea1c7c8
>     libpetsc.3.022.dylib`PetscAttachDebuggerErrorHandler(comm=0x0000000110e78de8,
>     line=926, fun="VecSetValues",
>     file="/Users/sg/petsc-3.22.4main/src/vec/vec/interface/rvector.c",
>     num=85, p=PETSC_ERROR_INITIAL, mess="Null Pointer: Parameter # 4",
>     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: 0x000000010ea1cdb0
>     libpetsc.3.022.dylib`PetscError(comm=0x0000000110e78de8, line=926,
>     func="VecSetValues",
>     file="/Users/sg/petsc-3.22.4main/src/vec/vec/interface/rvector.c",
>     n=85, p=PETSC_ERROR_INITIAL, mess="Null Pointer: Parameter # %d")
>     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: 0x000000010a866bf2
>     libpetsc.3.022.dylib`VecSetValues(x=0x00007fdb53068450, ni=1,
>     ix=0x00007ffee6d74098, y=0x0000000000000000, iora=ADD_VALUES) at
>     rvector.c:926:3
>        923       PetscValidHeaderSpecific(x, VEC_CLASSID, 1);
>        924       if (!ni) PetscFunctionReturn(PETSC_SUCCESS);
>        925       PetscAssertPointer(ix, 3);
>     -> 926       PetscAssertPointer(y, 4);
>        927       PetscValidType(x, 1);
>        928
>        929       PetscCall(PetscLogEventBegin(VEC_SetValues, x, 0, 0, 0));
>     (lldb) up
>     frame #8: 0x000000010a82c1dc
>     libpetsc.3.022.dylib`vecsetvalue_(v=0x00000001093ca8f8,
>     i=0x00007ffee6d74098, va=0x0000000000000000,
>     mode=0x00007ffee6d74094, ierr=0x00007ffee6d74238) at zvectorf.c:20:11
>        17      PETSC_EXTERN void vecsetvalue_(Vec *v, PetscInt *i,
>     PetscScalar *va, InsertMode *mode, PetscErrorCode *ierr)
>        18      {
>        19        /* cannot use VecSetValue() here since that uses
>     PetscCall() which has a return in it */
>     -> 20        *ierr = VecSetValues(*v, 1, i, va, *mode);
>        21      }
>        22
>        23      PETSC_EXTERN void vecsetvaluelocal_(Vec *v, PetscInt
>     *i, PetscScalar *va, InsertMode *mode, PetscErrorCode *ierr)
>     (lldb) up
>     frame #9: 0x0000000108ebbb48 feap`usolve_ at usolve.F:256:72
>        253                 if( k .gt. 0 ) then
>        254                   j = j + 1
>        255     !              write(*,*) 'rank: ',rank,' k,j,b(j)
>     ',k,j,b(j)
>     -> 256                   call VecSetValue(rhs, k-1, b(j),
>     ADD_VALUES, ierr)
>        257                 endif
>        258               end do
>
> -- 
> -------------------------------------------------------------------
> 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!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqVNP5YBrA$ 
> -------------------------------------------------------------------
>
> 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!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqUXpj3hgw$ 
>
> Continuum Mechanics of Solids
> https://urldefense.us/v3/__https://global.oup.com/academic/product/continuum-mechanics-of-solids-9780198864721__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqWpCx2KBg$ 
>
> Example Problems for Continuum Mechanics of Solids
> https://urldefense.us/v3/__https://www.amazon.com/dp/1083047361/__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqX_UomMAA$ 
>
> Engineering Mechanics of Deformable Solids
> https://urldefense.us/v3/__https://www.amazon.com/dp/0199651647__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqVCtbC14A$ 
>
> Engineering Mechanics 3 (Dynamics) 2nd Edition
> https://urldefense.us/v3/__http://www.amazon.com/dp/3642537111__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqW9ylWWbg$ 
>
> Engineering Mechanics 3, Supplementary Problems: Dynamics
> https://urldefense.us/v3/__http://www.amzn.com/B00SOXN8JU__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqWpqNSfAg$ 
>
> -------------------------------------------------------------------
> NSF NHERI SimCenter
> https://urldefense.us/v3/__https://simcenter.designsafe-ci.org/__;!!G_uCfscf7eWS!dYf1SlS-8ja3_n6peHkUMIB5DdSGjm-UvoWPR-vhJMl2ouqSLJD-L1T_ejTPQkZsSeGKD6bYHN6ZfqVEqpkvTg$ 
> -------------------------------------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250324/e8ebeb2c/attachment-0001.html>


More information about the petsc-users mailing list