<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 27, 2015 at 12:39 PM, Li, Xinya <span dir="ltr"><<a href="mailto:Xinya.Li@pnnl.gov" target="_blank">Xinya.Li@pnnl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The error messages were still the same.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In original code, I called MatAssemblyBegin and MatAssemblyEnd after I use MatSetValues to evaluate A.</span></p></div></div></blockquote><div><br></div><div>That error message is given when a matrix you give PETSc is not assembled. If the message persists, you have</div><div>called MatAssemblyBegin/End() on the wrong matrix. Maybe it would be easier for you to use the debugger to</div><div>track down which matrix you need to assemble.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:11pt"> </span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Matthew Knepley [mailto:<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, May 27, 2015 10:04 AM<br>
<b>To:</b> Li, Xinya<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] Allocation errors<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Wed, May 27, 2015 at 11:58 AM, Li, Xinya <<a href="mailto:Xinya.Li@pnnl.gov" target="_blank">Xinya.Li@pnnl.gov</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Dear Sir/Madam,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I am trying to assembling a large sparse complex matrix for parallel computing. I need to pre-allocate for this sparse matrix A.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">This is what I included in the code<u></u><u></u></p>
<p class="MsoNormal">***************************************************************************************************<u></u><u></u></p>
<p class="MsoNormal">// Allocate A<u></u><u></u></p>
<p class="MsoNormal"> ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,4*ngen,4*ngen); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> ierr = MatSetFromOptions(A); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> ierr = MatSetUp(A); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> ierr = MatGetOwnershipRange(A, &xstart, &xend); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> if (iteration > 0) {<u></u><u></u></p>
<p class="MsoNormal"> ierr = MatRetrieveValues(A); CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Call MatAssemblyBeginEnd().<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">***************************************************************************************************<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">This is the error message<u></u><u></u></p>
<p class="MsoNormal">***************************************************************************************************<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: Object is in wrong state<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: Not for unassembled matrix<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: See
<a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: Petsc Release Version 3.5.3, unknown<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: ./dynSim on a arch-complex named olympus.local by lixi729 Wed May 27 09:46:05 2015<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran --with-cxx=g++ --with-scalar-type=complex --with-clanguage=C++ --with-fortran-kernels=generic --with-cxx-dialect=C++11
--download-fblaslapack --download-mpich --download-superlu_dist --download-mumps --download-scalapack --download-parmetis --download-metis --download-elemental<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #1 MatGetOrdering() line 189 in /people/lixi729/petsc/src/mat/order/sorder.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #2 PCSetUp_ILU() line 196 in /people/lixi729/petsc/src/ksp/pc/impls/factor/ilu/ilu.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #3 PCSetUp() line 902 in /people/lixi729/petsc/src/ksp/pc/interface/precon.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #4 KSPSetUp() line 306 in /people/lixi729/petsc/src/ksp/ksp/interface/itfunc.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #5 KSPSolve() line 418 in /people/lixi729/petsc/src/ksp/ksp/interface/itfunc.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #6 SNESSolve_NEWTONLS() line 232 in /people/lixi729/petsc/src/snes/impls/ls/ls.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #7 SNESSolve() line 3743 in /people/lixi729/petsc/src/snes/interface/snes.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #8 TSStep_Theta() line 194 in /people/lixi729/petsc/src/ts/impls/implicit/theta/theta.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #9 TSStep() line 2629 in /people/lixi729/petsc/src/ts/interface/ts.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #10 TSSolve() line 2748 in /people/lixi729/petsc/src/ts/interface/ts.c<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #11 simu() line 638 in simulation.C<u></u><u></u></p>
<p class="MsoNormal">[0]PETSC ERROR: #12 runSimulation() line 99 in dynSim.h<u></u><u></u></p>
<p class="MsoNormal">****************************************************************************************************<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thank you very much. I really appreciate your help and time.<u></u><u></u></p>
<p class="MsoNormal">Regards<u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#d47500">__________________________________________________</span>
</b><br>
<b><span style="font-family:"Verdana","sans-serif";color:black">Xinya Li</span></b>
<br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">Scientist</span><br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">EED/Hydrology</span>
<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">Pacific Northwest National Laboratory</span>
<br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">902 Battelle Boulevard</span>
<br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">P.O. Box 999, MSIN K9-33</span><br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">Richland, WA 99352 USA</span>
<br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">Tel:
<a href="tel:509-372-6248" target="_blank">509-372-6248</a></span><br>
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:black">Fax:
<a href="tel:509-372-6089" target="_blank">509-372-6089</a></span> <br>
<u><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:blue"><a href="mailto:Xinya.Li@pnl.gov" target="_blank">Xinya.Li@pnl.gov</a></span></u>
<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<p class="MsoNormal">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<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">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>