<div class="gmail_quote">On Thu, Sep 22, 2011 at 17:05, Milan Mitrovic <span dir="ltr">&lt;<a href="mailto:milan.v.mitrovic@gmail.com">milan.v.mitrovic@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":7r">The J is not initialized when I call SNESSetJacobian...<br>
<br>
I will try that, but I dont know nmax at that point... can I set it later?</div></blockquote></div><br><div>Yes, create the matrix and set the sizes outside, but skip preallocation. Then, inside the jacobian routine (only on the first time unless it changes), call MatMPIAIJSetPreallocation() and MatSeqAIJSetPreallocation(). You can also arrange to do this in a setup stage before calling SNESSolve(), but there is no problem calling it from your Jacobian evaluation.</div>