[petsc-users] Problem with "likely location of problem given in stack below"?

Jed Brown jedbrown at mcs.anl.gov
Mon Apr 9 19:16:50 CDT 2012


2012/4/9 Zhenglun (Alan) Wei <zhenglun.wei at gmail.com>

>  Thank you, Dr. Brown, for pointing me out this example. However, I met a
> problem when I was trying to modify it.
>     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:
>
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer!
> [0]PETSC ERROR: Null Object: Parameter # 1!
>
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Development HG revision:
> 85e6055943e0711fccdec2d08caeba48971d3d55  HG Date: Fri Sep 23 14:46:14 2011
> -0700
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: ./ex45 on a arch-linu named l2118a-linux.soecs.ku.edu by
> zlwei Mon Apr  9 17:11:02 2012
>
> [0]PETSC ERROR: Libraries linked from
> /home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib
> [0]PETSC ERROR: Configure run at Fri Sep 23 17:13:32 2011
> [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
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: DMDAVecGetArray() line 51 in src/dm/impls/da/dagetarray.c
>

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

--- ex45.c.old  2012-04-09 19:13:21.438775057 -0500
+++ ex45.c      2012-04-09 19:13:42.661909463 -0500
@@ -60,6 +60,7 @@
   ierr = VecAXPY(r,-1.0,b);CHKERRQ(ierr);
   ierr = VecNorm(r,NORM_2,&norm);CHKERRQ(ierr);
   ierr = PetscPrintf(PETSC_COMM_WORLD,"Residual norm
%G\n",norm);CHKERRQ(ierr);
+  ierr = KSPGetDM(ksp,&da);CHKERRQ(ierr);
   ierr = OutputFunction(da,x);

   ierr = VecDestroy(&r);CHKERRQ(ierr);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120409/8c29cb40/attachment.htm>


More information about the petsc-users mailing list