<div dir="ltr">When I do not explicitly set the type in petsc-dev I get errors:<div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Object is in wrong state!</div>

<div>[0]PETSC ERROR: Mat object&#39;s type is not set: Argument # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Development HG revision: 5c943f0d8cbf252873fd4abeffa38c8d3c15987e  HG Date: Mon Apr 09 22:04:11 2012 -0500</div>

<div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>

[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: ./petsc on a arch-linu named mohammad-laptop by mohammad Tue Apr 24 22:49:38 2012</div><div>[0]PETSC ERROR: Libraries linked from /home/mohammad/soft/petsc-dev/arch-linux2-cxx-debug/lib</div>

<div>[0]PETSC ERROR: Configure run at Mon Apr  9 23:17:27 2012</div><div>[0]PETSC ERROR: Configure options --with-clanguage=cxx --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich=1 --download-f-blas-lapack=1 --download-hypre=1 --download-superlu_dist=1 --download-metis=1 --download-parmetis=1</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: MatMPIAIJSetPreallocation() line 3883 in /home/mohammad/soft/petsc-dev/src/mat/impls/aij/mpi/mpiaij.c</div>

<div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Object is in wrong state!</div><div>[0]PETSC ERROR: Must call MatXXXSetPreallocation() or MatSetUp() on argument 1 &quot;mat&quot; before MatGetOwnershipRange()!</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Development HG revision: 5c943f0d8cbf252873fd4abeffa38c8d3c15987e  HG Date: Mon Apr 09 22:04:11 2012 -0500</div>

<div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>

[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: ./petsc on a arch-linu named mohammad-laptop by mohammad Tue Apr 24 22:49:38 2012</div><div>[0]PETSC ERROR: Libraries linked from /home/mohammad/soft/petsc-dev/arch-linux2-cxx-debug/lib</div>

<div>[0]PETSC ERROR: Configure run at Mon Apr  9 23:17:27 2012</div><div>[0]PETSC ERROR: Configure options --with-clanguage=cxx --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich=1 --download-f-blas-lapack=1 --download-hypre=1 --download-superlu_dist=1 --download-metis=1 --download-parmetis=1</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: MatGetOwnershipRange() line 6106 in /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div><div>

[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Object is in wrong state!</div><div>[0]PETSC ERROR: Must call MatXXXSetPreallocation() or MatSetUp() on argument 1 &quot;mat&quot; before MatAssemblyBegin()!</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Development HG revision: 5c943f0d8cbf252873fd4abeffa38c8d3c15987e  HG Date: Mon Apr 09 22:04:11 2012 -0500</div>

<div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>

[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: ./petsc on a arch-linu named mohammad-laptop by mohammad Tue Apr 24 22:49:38 2012</div><div>[0]PETSC ERROR: Libraries linked from /home/mohammad/soft/petsc-dev/arch-linux2-cxx-debug/lib</div>

<div>[0]PETSC ERROR: Configure run at Mon Apr  9 23:17:27 2012</div><div>[0]PETSC ERROR: Configure options --with-clanguage=cxx --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich=1 --download-f-blas-lapack=1 --download-hypre=1 --download-superlu_dist=1 --download-metis=1 --download-parmetis=1</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: MatAssemblyBegin() line 4810 in /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div>

<div>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</div><div>[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger</div><div>[0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC</a> ERROR: or try <a href="http://valgrind.org">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors</div>

<div>[0]PETSC ERROR: likely location of problem given in stack below</div><div>[0]PETSC ERROR: ---------------------  Stack Frames ------------------------------------</div><div>[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,</div>

<div>[0]PETSC ERROR:       INSTEAD the line number of the start of the function</div><div>[0]PETSC ERROR:       is given.</div><div>[0]PETSC ERROR: [0] MatAssemblyEnd_SeqAIJ line 800 /home/mohammad/soft/petsc-dev/src/mat/impls/aij/seq/aij.c</div>

<div>[0]PETSC ERROR: [0] MatAssemblyEnd line 4984 /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: [0] MatAssemblyBegin line 4807 /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div>

<div>[0]PETSC ERROR: [0] MatGetOwnershipRange line 6101 /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: [0] MatMPIAIJSetPreallocation line 3881 /home/mohammad/soft/petsc-dev/src/mat/impls/aij/mpi/mpiaij.c</div>

<div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Signal received!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div>

<div>[0]PETSC ERROR: Petsc Development HG revision: 5c943f0d8cbf252873fd4abeffa38c8d3c15987e  HG Date: Mon Apr 09 22:04:11 2012 -0500</div><div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div>

<div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: ./petsc on a arch-linu named mohammad-laptop by mohammad Tue Apr 24 22:49:38 2012</div>

<div>[0]PETSC ERROR: Libraries linked from /home/mohammad/soft/petsc-dev/arch-linux2-cxx-debug/lib</div><div>[0]PETSC ERROR: Configure run at Mon Apr  9 23:17:27 2012</div><div>[0]PETSC ERROR: Configure options --with-clanguage=cxx --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich=1 --download-f-blas-lapack=1 --download-hypre=1 --download-superlu_dist=1 --download-metis=1 --download-parmetis=1</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file</div><div>application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0</div>

<div>[unset]: aborting job:</div><div>application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0</div><div><br></div><div>Even more than that, I get lots of errors apparently complaining that I have not preallocated the matrix:</div>

<div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Argument out of range!</div><div>[0]PETSC ERROR: New nonzero at (6,209) caused a malloc!</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Development HG revision: 5c943f0d8cbf252873fd4abeffa38c8d3c15987e  HG Date: Mon Apr 09 22:04:11 2012 -0500</div>

<div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>

[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: ./petsc on a arch-linu named mohammad-laptop by mohammad Tue Apr 24 22:44:09 2012</div><div>[0]PETSC ERROR: Libraries linked from /home/mohammad/soft/petsc-dev/arch-linux2-cxx-debug/lib</div>

<div>[0]PETSC ERROR: Configure run at Mon Apr  9 23:17:27 2012</div><div>[0]PETSC ERROR: Configure options --with-clanguage=cxx --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich=1 --download-f-blas-lapack=1 --download-hypre=1 --download-superlu_dist=1 --download-metis=1 --download-parmetis=1</div>

<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: MatSetValues_MPIAIJ() line 507 in /home/mohammad/soft/petsc-dev/src/mat/impls/aij/mpi/mpiaij.c</div>
<div>
[0]PETSC ERROR: MatSetValues() line 1148 in /home/mohammad/soft/petsc-dev/src/mat/interface/matrix.c</div></div><div><br></div><div><br></div><div>I do not see these with 3.2-p6. Does 3.2-p6 has any mechanism for such alerts?</div>

<br><div class="gmail_quote">On Tue, Apr 24, 2012 at 5:58 PM, Hong Zhang <span dir="ltr">&lt;<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_extra">Mohammad :<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Is this also true with MatSetType()? petsc-dev seems to need it (3.2-p6 does not) but it&#39;s not listed in the changes link ...</div>


</div></blockquote></div><div>There is no change on  MatSetType(). The default type is aij. </div><div>You can check petsc examples, e.g. petsc-dev/src/ksp/ksp/examples/tutorials/ex2.c</div><span class="HOEnZb"><font color="#888888"><div>

<br></div><div>Hong</div></font></span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><br><br><div class="gmail_quote">On Tue, Apr 24, 2012 at 4:27 PM, Mohammad Mirzadeh <span dir="ltr">&lt;<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@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 dir="ltr">Thanks Hong.<div><div><br><br><div class="gmail_quote">On Tue, Apr 24, 2012 at 4:25 PM, Hong Zhang <span dir="ltr">&lt;<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra"><span style="font-family:Times;font-size:medium">See </span></div><div class="gmail_extra"><span style="font-family:Times;font-size:medium"><a href="http://www.mcs.anl.gov/petsc/documentation/changes/dev.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/changes/dev.html</a>:</span></div>






<div class="gmail_extra"><span style="font-family:Times;font-size:medium"><br></span></div><div class="gmail_extra"><span style="font-family:Times;font-size:medium">You MUST now call MatXXXSetPreallocation() or MatSetUp() on any matrix you create directly (not using DMCreateMatrix()) before calling MatSetValues(), MatSetValuesBlocked() etc.</span></div>






<div class="gmail_extra"><font face="Times" size="3"><br></font><br><div class="gmail_quote"><div>On Tue, Apr 24, 2012 at 6:01 PM, Mohammad Mirzadeh <span dir="ltr">&lt;<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>&gt;</span> wrote:<br>






</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<div><br></div><div>While trying to figure out a problem, I came across the following situation. Consider the following code:</div>






<div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#808bed">int</span><span style="color:#646482"> </span>main<span style="color:#646482"> </span><span style="color:#409040">(</span><span style="color:#808bed">int</span><span style="color:#646482"> </span>argc<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#808bed">char</span><span style="color:#646482"> </span><span style="color:#409040">**</span>argv<span style="color:#409040">){</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>PetscInitialize<span style="color:#409040">(&amp;</span>argc<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#409040">&amp;</span>argv<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#409040">(</span><span style="color:#808bed">char</span><span style="color:#409040">*)</span><span style="color:#506bbd">0</span><span style="color:#409040">,</span><span style="color:#646482"> </span>help<span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><br></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span><span style="color:#ff8bff">Mat</span><span style="color:#646482"> </span>m<span style="color:#409040">;</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatCreate<span style="color:#409040">(</span>PETSC_COMM_WORLD<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#409040">&amp;</span>m<span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatSetSizes<span style="color:#409040">(</span>m<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#506bbd">10</span><span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#506bbd">10</span><span style="color:#409040">,</span><span style="color:#646482"> </span>PETSC_DECIDE<span style="color:#409040">,</span><span style="color:#646482"> </span>PETSC_DECIDE<span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatSetFromOptions<span style="color:#409040">(</span>m<span style="color:#409040">);</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatAssemblyBegin<span style="color:#409040">(</span>m<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#cb6ecb">MAT_FINAL_ASSEMBLY</span><span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatAssemblyEnd<span style="color:#409040">(</span>m<span style="color:#409040">,</span><span style="color:#646482"> </span><span style="color:#cb6ecb">MAT_FINAL_ASSEMBLY</span><span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatView<span style="color:#409040">(</span>m<span style="color:#409040">,</span><span style="color:#646482"> </span>PETSC_VIEWER_STDOUT_WORLD<span style="color:#409040">);</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>MatDestroy<span style="color:#409040">(&amp;</span>m<span style="color:#409040">);</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><br></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span>PetscFinalize<span style="color:#409040">();</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font size="4"><span style="color:#646482">    </span><span style="color:#808bed">return</span><span style="color:#646482"> </span><span style="color:#506bbd">0</span><span style="color:#409040">;</span></font></pre>









<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#409040"><font size="4">}</font></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:#409040"><br></span></pre>This runs without any problem under 3.2-p6 but fails with petsc-dev:</div>








<div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Object is in wrong state!</div><div>[0]PETSC ERROR: Must call MatXXXSetPreallocation() or MatSetUp() on argument 1 &quot;mat&quot; before MatAssemblyBegin()!</div>








<div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div><br></div></div></div><div><div>Eventually I could fix this by adding MatSetUp(m) after setting the options. Why do I need this in petsc-dev? Does this somehow preallocate the matrix?</div>






</div></div></blockquote><div>Yes.</div><div><br></div><div>Hong </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<div><br></div><div>Thanks,</div><div>Mohammad</div></div>
</blockquote></div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div></div>