<div dir="ltr"><div><div><div>Dear Matt,<br><br></div>Sorry, I am not able to get you, as if I do not provide i>=j then the matrix mentioned in the earlier mail won't be generated. For the code I mentioned earlier, the output obtained is as follows - <br><b>Mat Object: 1 MPI processes<br>  type: mpiaij<br>row 0: (0, 1)  (1, 1)  (2, 1)  (3, 1)  (4, 0)  (5, 0)  (6, 0)  (7, 0) <br>row 1: (0, 0)  (1, 1)  (2, 1)  (3, 1)  (4, 1)  (5, 0)  (6, 0)  (7, 0) <br>row 2: (0, 0)  (1, 0)  (2, 1)  (3, 1)  (4, 1)  (5, 1)  (6, 0)  (7, 0) <br>row 3: (0, 0)  (1, 0)  (2, 0)  (3, 1)  (4, 1)  (5, 1)  (6, 1)  (7, 0) <br>row 4: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 1)  (5, 1)  (6, 1)  (7, 1)<br><br></b></div>which is satisfactory, but once I use <b>MatMPIAIJSetPreallocation(A,0,d_nnz,0,o_nnz); </b>the code encounters a runtime error. And throws a malloc error as - <br><b>[0]PETSC ERROR: New nonzero at (0,4) caused a malloc<br>Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check<br><br></b></div>Thanks<br><br><div><div><div>----<br>John Albequerque.<br><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 19, 2016 at 4:17 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Fri, Feb 19, 2016 at 4:34 AM, John Albequerque <span dir="ltr"><<a href="mailto:johncfdcfd@gmail.com" target="_blank">johncfdcfd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Currently I have used single processor. And without the Preallocation it works fine. And gives me the correct output as well. I have posted the full code for reference. <br></div><b>Here:</b> <a href="http://pastebin.com/kWUGHqSM" target="_blank">http://pastebin.com/kWUGHqSM</a></div></blockquote><div><br></div></span><div>Look at the last row. Your condition 'j >= i' will produce no off-diagonal rows here, but</div><div>clearly you have them, and this is the error you are getting.</div><div><br></div><div>   Matt</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 19, 2016 at 3:01 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Feb 19, 2016 at 3:27 AM, John Albequerque <span dir="ltr"><<a href="mailto:johncfdcfd@gmail.com" target="_blank">johncfdcfd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>I came up with this could you please have a look at it as I am not getting it. I am getting an error<br><br><b>New nonzero at (0,4) caused a malloc<br><br></b><a href="http://pastebin.com/ZxT7SWtc" target="_blank">http://pastebin.com/ZxT7SWtc</a><br><br></div>Could you please have a look at it.<br></div></div></div></blockquote><div><br></div></span><div>It looks like you are only allocating the upper triangle:</div><div><br></div><div><div><span style="white-space:pre-wrap">                  </span>if((j-i<=3) && (j>=i))</div><div>            <span style="white-space:pre-wrap">   </span>values[(i-low)*nc+j]=1;</div><div><span style="white-space:pre-wrap">                  </span>else</div><div><span style="white-space:pre-wrap">                             </span>values[(i-low)*nc+j]=0;</div></div><div><br></div><div>   Matt</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>---------------<br></div>Thanks,<br></div>John Albequerque<div><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 19, 2016 at 1:25 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Feb 19, 2016 at 1:50 AM, John Albequerque <span dir="ltr"><<a href="mailto:johncfdcfd@gmail.com" target="_blank">johncfdcfd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>Could someone help me setting up this matrix i.e from preallocation to Set Values for an MPIAIJ matrix which has its entries.<br><b><br>1  1  1  1  0  0  0  0<br>0  1  1  1  1  0  0  0<br>0  0  1  1  1  1  0  0<br>0  0  0  1  1  1  1  0<br>0  0  0  0  1  1  1  1</b><br><br>I am trying to do it from 3 days now but not able to figure it out. Could someone please help me do this.</div></div></div></div></blockquote><div><br></div></span><div>It will be enough to say that each row has 3 off-diagonal values, so you can use the simplified preallocation rather</div><div>than giving a value for each row individually.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Thanks.<br><br>----<br></div>John Albequerque.<br><div><br><br></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><span><font color="#888888"><div><br></div>-- <br><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</font></span></font></span></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></span></div><span><font color="#888888"><span><br><br clear="all"><div><br></div>-- <br><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</span></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div></div></div>
</blockquote></div><br></div>