<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Thanks a million. Yes, you are right, it works after included "finclude/petscvec.h90". The previouse code just with petscvec.h, but without petscvec.h90. Therefore, there is not a compiling error, but the runtime error. Thanks again. I had been stuck with this trouble the whole day. No, it is over !! :)<BR> <BR>
> Date: Tue, 4 Jan 2011 17:50:11 -0600<BR>> From: balay@mcs.anl.gov<BR>> To: petsc-users@mcs.anl.gov<BR>> Subject: Re: [petsc-users] error in calling VecGetArrayf90()<BR>> <BR>> Did you included "finclude/petscvec.h90" in your code - as the example did?<BR>> <BR>> satish<BR>> <BR>> On Tue, 4 Jan 2011, Peter Wang wrote:<BR>> <BR>> > <BR>> > I am trying to obtain the value of each element of a solution Vector by KSPsolve(). <BR>> > <BR>> > The variables are defined according the example of ex4f90.F in \petsc-3.1-p5\src\snes\examples\tutorials\ as following,<BR>> > <BR>> > PetscScalar, pointer :: xx_v(:)<BR>> > <BR>> > ...<BR>> > call KSPSolve(ksp,b,x,ierr)<BR>> > call VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)<BR>> > <BR>> > call VecGetArrayF90(x,xx_v,ierr)<BR>> > call VecRestoreArrayF90(x,xx_v,ierr)<BR>> > <BR>> > ...<BR>> > <BR>> > But, the error keeps coming out when call VecGetArrayF90(x,xx_v,ierr) and call VecRestoreArrayF90(x,xx_v,ierr) are not commented off.<BR>> > <BR>> > <BR>> > The error information shows:<BR>> > Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range<BR>> > <BR>> > [0]PETSC ERROR: --------------------- Stack Frames ------------------------------------<BR>> > [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,<BR>> > [0]PETSC ERROR: INSTEAD the line number of the start of the function<BR>> > [0]PETSC ERROR: is given.<BR>> > [0]PETSC ERROR: [0] F90Array1dCreate line 52 src/sys/f90-src/f90_cwrap.c<BR>> > [0]PETSC ERROR: --------------------- Error Message ------------------------------------<BR>> > <BR>> > I checked the code according the example, but cannot see any difference to that. Just don't know why the pointer array xx_v doesn't work here? Thanks.<BR>> > <BR>> > <BR>> <BR>                                            </body>
</html>