<div dir="ltr">You might need to fix this:<div><br></div><div><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">if (i - j < m)</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">to </pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px"><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap">if (i - j < m && i - j >= 0)</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap"><br></pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap">Mark</pre></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 15, 2022 at 12:12 AM Patrick Alken <<a href="mailto:patrick.alken@geomag.info">patrick.alken@geomag.info</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">I am trying to assemble a matrix in parallel in Petsc, and it is working <br>
for 1 processor, but when I try running it with 2 processors I get <br>
errors like the following:<br>
<br>
----<br>
<br>
[1]PETSC ERROR: --------------------- Error Message <br>
--------------------------------------------------------------<br>
[1]PETSC ERROR: Argument out of range<br>
[1]PETSC ERROR: New nonzero at (0,207) caused a malloc<br>
Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn <br>
off this check<br>
[1]PETSC ERROR: See <a href="https://petsc.org/release/faq/" rel="noreferrer" target="_blank">https://petsc.org/release/faq/</a> for trouble shooting.<br>
[1]PETSC ERROR: Petsc Release Version 3.17.4, unknown<br>
[1]PETSC ERROR: #1 MatSetValues_MPIAIJ() at <br>
/data/palken/petsc/src/mat/impls/aij/mpi/mpiaij.c:506<br>
<br>
----<br>
<br>
and then many MatSetValues errors follow.<br>
<br>
I have attached a minimal working example and a Makefile. My code does <br>
depend on the GSL library also. I think there must be a problem in how I <br>
set up the d_nnz and o_nnz arrays for the MatMPIAIJSetPreallocation() <br>
function (lines 211-235 of mwe.c).<br>
<br>
I am building a matrix using radial basis functions with compact <br>
support, so the matrix entries are zero when ||Xi - Xj|| >= c, where c <br>
is the RBF shape parameter. This is accounted for on line 224 and 254 of <br>
the code. As far as I can tell I am consistent in the way I define the <br>
nnz arrays and the way I call MatSetValues, so I don't know why Petsc <br>
would need to malloc additional memory during the assembly process.<br>
<br>
Any pointers would be greatly appreciated.<br>
<br>
Patrick<br>
</blockquote></div>