<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>  My understanding of Fortran bounds checking is that before each array access in Fortran it checks to see if the index is valid for the array you are accessing; that is it is from start to end if you had declared the array as <div><br></div><div>  double precision, <span class="pln" style="caret-color: rgb(116, 117, 121); font-family: var(--bs-font-monospace); font-size: 15px; background-color: rgb(238, 238, 238); box-sizing: border-box;">dimension </span><span class="pun" style="caret-color: rgb(116, 117, 121); font-family: var(--bs-font-monospace); font-size: 15px; background-color: rgb(238, 238, 238); box-sizing: border-box; color: rgb(102, 102, 0);">(start:end</span><span class="pun" style="caret-color: rgb(116, 117, 121); font-family: var(--bs-font-monospace); font-size: 15px; background-color: rgb(238, 238, 238); box-sizing: border-box; color: rgb(102, 102, 0);">)</span> :: A</div><div><br></div><div> It should also work if the array is a Fortran allocatable array or if you obtain the array from PETSc with VecGetArrayF90() and all its friends and relations.</div><div><br></div><div> PETSc should not change the behavior above.</div><div><br></div><div>  Now if there is memory corruption (or some other error) somewhere else (like in PETSc or a more subtle problem in your code) then simply array out of bounds then yes you can get more complicated error messages that would usually include the PETSc stack trace. </div><div><br></div><div>  Instead of using valgrind you can also try running the PETSc program with -malloc_debug, this is sort of a poor person's version of valgrind but can sometimes provide more useful information than valgrind.</div><div><br></div><div>  When debugging always make sure PETSc was NOT ./configure with --with-debugging=0 </div><div><br></div><div>  You can send specific error messages that are cryptic to <a href="mailto:petsc-maint@mcs.anl.gov">petsc-maint@mcs.anl.gov</a> and we may be able to help decipher them.</div><div><br></div><div>  Barry</div><div><br></div><div><br></div><div><br></div><div><br><div><br><blockquote type="cite"><div>On Nov 21, 2022, at 2:16 PM, Nicholas Arnold-Medabalimi <narnoldm@umich.edu> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">Hi Petsc users<br><br>I'm working on an integration of Petsc into an existing fortran code. Most of my memory debugging is very primitive and is usually accomplished using the -check bounds option in the compiler. However with Petsc attached the stack trace becomes much more opaque compared to the original code. At least as far as I can tell the error becomes much harder to pin down (just pointing to libpetsc.so). Any assistance in getting more informative error messages or checks would be much appreciated.<br><br>Sincerely<br>Nicholas<br><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font>Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div></div>
</div></blockquote></div><br></div></body></html>