<div class="gmail_quote">2012/4/9 Zhenglun (Alan) Wei <span dir="ltr"><<a href="mailto:zhenglun.wei@gmail.com">zhenglun.wei@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Thank you, Dr. Brown, for pointing me out this example. However, I
met a problem when I was trying to modify it. <br>
I added a 'OutputFunction' subroutine to access the solution
data by using DMDAGetVecArray. I tried it with single process, it
keeps giving me this error:<div class="im"><br>
[0]PETSC ERROR: --------------------- Error Message
------------------------------------<br></div>
[0]PETSC ERROR: Null argument, when expecting valid pointer!<br>
[0]PETSC ERROR: Null Object: Parameter # 1!<div class="im"><br>
[0]PETSC ERROR:
------------------------------------------------------------------------<br>
[0]PETSC ERROR: Petsc Development HG revision:
85e6055943e0711fccdec2d08caeba48971d3d55 HG Date: Fri Sep 23
14:46:14 2011 -0700<br>
[0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>
[0]PETSC ERROR: See docs/index.html for manual pages.<br>
[0]PETSC ERROR:
------------------------------------------------------------------------<br></div>
[0]PETSC ERROR: ./ex45 on a arch-linu named
<a href="http://l2118a-linux.soecs.ku.edu" target="_blank">l2118a-linux.soecs.ku.edu</a> by zlwei Mon Apr 9 17:11:02 2012<div class="im"><br>
[0]PETSC ERROR: Libraries linked from
/home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib<br>
[0]PETSC ERROR: Configure run at Fri Sep 23 17:13:32 2011<br>
[0]PETSC ERROR: Configure options --download-f-blas-lapack=1
--download-mpich=1 --with-cc=gcc --with-fc=gfortran
PETSC_ARCH=arch-linux2-c-debug<br>
[0]PETSC ERROR:
------------------------------------------------------------------------<br></div>
[0]PETSC ERROR: DMDAVecGetArray() line 51 in
src/dm/impls/da/dagetarray.c<br></div></blockquote><div><br></div><div>I suggest using the CHKERRQ macros so that the rest of the stack would be shown here. In any case, the problem is that you gave up your reference to the DM earlier. You can either move the DMDestroy() to the end of the function or get access to the KSP's reference using</div>
<div><br></div><div><div><font face="'courier new', monospace">--- ex45.c.old 2012-04-09 19:13:21.438775057 -0500</font></div><div><font face="'courier new', monospace">+++ ex45.c 2012-04-09 19:13:42.661909463 -0500</font></div>
<div><font face="'courier new', monospace">@@ -60,6 +60,7 @@</font></div><div><font face="'courier new', monospace"> ierr = VecAXPY(r,-1.0,b);CHKERRQ(ierr);</font></div><div><font face="'courier new', monospace"> ierr = VecNorm(r,NORM_2,&norm);CHKERRQ(ierr);</font></div>
<div><font face="'courier new', monospace"> ierr = PetscPrintf(PETSC_COMM_WORLD,"Residual norm %G\n",norm);CHKERRQ(ierr); </font></div><div><font face="'courier new', monospace">+ ierr = KSPGetDM(ksp,&da);CHKERRQ(ierr);</font></div>
<div><font face="'courier new', monospace"> ierr = OutputFunction(da,x);</font></div><div><font face="'courier new', monospace"> </font></div><div><font face="'courier new', monospace"> ierr = VecDestroy(&r);CHKERRQ(ierr);</font></div>
</div><div><br></div></div>