<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Thanks, Satish,<BR>
<BR>
The index of the array is modified to i+1:<BR>
!===================<BR> do i=Istart,Iend-1<BR> write(6,*)'check xx_v',i+1,xx_v(i+1),myid<BR> enddo <BR>!===================<BR><BR>
However, only the elements on root process (process 0) and the last process (process 3) are corrent, is there any ohter logical error?<BR>
<BR>
check xx_v 1 3999.9999999999982 0<BR> check xx_v 2 3999.9999999999982 0<BR> check xx_v 3 3999.9999999999982 0<BR> check xx_v 4 3999.9999999999982 0<BR> check xx_v 5 3999.9999999999982 0<BR> check xx_v 6 3000.0000000000005 0<BR> check xx_v 7 3000.0000000000005 0<BR> check xx_v 8 2.61360726650019422E-321 1 <BR>
check xx_v 9 7.90505033345994471E-323 1<BR>
check xx_v 10 1.69759663277221785E-312 1<BR> check xx_v 11 6.16840020108069212E-317 1<BR> check xx_v 12 6.16840316547456717E-317 1<BR> check xx_v 13 6.16832658529946177E-317 1<BR> check xx_v 14 1.99665037664579820E-314 2<BR> check xx_v 15 6.19784009071943448E-317 2<BR> check xx_v 16 6.20249221284067566E-317 2<BR>
check xx_v 17 6.20218737433719161E-317 2<BR> check xx_v 18 6.18236051996958238E-317 2<BR> check xx_v 19 6.16840316547456717E-317 2<BR>
check xx_v 20 6.18107199676522841E-317 3<BR> check xx_v 21 0.0000000000000000 3<BR> check xx_v 22 0.0000000000000000 3<BR> check xx_v 23 0.0000000000000000 3<BR> check xx_v 24 0.0000000000000000 3<BR> check xx_v 25 0.0000000000000000 3<BR><BR><BR> <BR>
> Date: Tue, 4 Jan 2011 22:49:50 -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>> The global index starts at Istart - but the array index starts at 1 [for fortran array]<BR>> <BR>> Satish<BR>> <BR>> On Tue, 4 Jan 2011, Peter Wang wrote:<BR>> <BR>> > <BR>> > In last question, the pointer xx_v is local data. However, if write them to the monitor or assign them to another array, the value is incorrect.<BR>> > <BR>> > The protion of the code to display them on the monitor is like as following: <BR>> > call MatGetOwnershipRange(A,Istart,Iend,ierr)<BR>> > call VecGetArrayF90(x,xx_v,ierr) ! Vector x is matched with Matrix A in the same communicator<BR>> > <BR>> > write(*,*)xx_v,myid ! write the poiner array together<BR>> > <BR>> > do i=Istart,Iend-1<BR>> > write(6,*)'check xx_v',i,xx_v(i),myid !write the element of the array one by one with local range (Istart to Iend-1)<BR>> > enddo <BR>> > <BR>> > <BR>> > =========The result is as following: ( the values of the elements from 7 to 20 are not correct !!)<BR>> > <BR>> > 3999.9999999999982 3999.9999999999982 3999.9999999999982 3999.9999999999982 3999.9999999999982 3000.0000000000005 3000.0000000000005 0<BR>> > <BR>> > 3000.0000000000009 3000.0000000000009 3000.0000000000009 2000.0000000000011 2000.0000000000011 2000.0000000000000 1<BR>> > <BR>> > 2000.0000000000009 2000.0000000000009 1000.0000000000003 1000.0000000000003 1000.0000000000003 999.99999999999989 2<BR>> > <BR>> > 1000.0000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 3<BR>> > <BR>> > <BR>> > check xx_v 0 0.0000000000000000 0.0000000000000000 0<BR>> > check xx_v 1 3999.9999999999982 3999.9999999999982 0<BR>> > check xx_v 2 3999.9999999999982 3999.9999999999982 0<BR>> > check xx_v 3 3999.9999999999982 3999.9999999999982 0<BR>> > check xx_v 4 3999.9999999999982 3999.9999999999982 0<BR>> > check xx_v 5 3999.9999999999982 3999.9999999999982 0<BR>> > check xx_v 6 3000.0000000000005 3000.0000000000005 0<BR>> > check xx_v 7 1.99665037664579820E-314 1.99665037664579820E-314 1<BR>> > check xx_v 8 2.61360726650019422E-321 2.61360726650019422E-321 1<BR>> > check xx_v 9 7.90505033345994471E-323 7.90505033345994471E-323 1<BR>> > check xx_v 10 1.69759663277221785E-312 1.69759663277221785E-312 1<BR>> > check xx_v 11 6.16846344148335980E-317 6.16846344148335980E-317 1<BR>> > check xx_v 12 6.16846640587723485E-317 6.16846640587723485E-317 1<BR>> > check xx_v 13 6.16838982570212945E-317 6.16838982570212945E-317 2<BR>> > check xx_v 14 1.99665037664579820E-314 1.99665037664579820E-314 2<BR>> > check xx_v 15 6.19790333112210216E-317 6.19790333112210216E-317 2<BR>> > check xx_v 16 6.20255545324334334E-317 6.20255545324334334E-317 2<BR>> > check xx_v 17 6.20225061473985929E-317 6.20225061473985929E-317 2<BR>> > check xx_v 18 6.18242376037225006E-317 6.18242376037225006E-317 2<BR>> > check xx_v 19 6.16846640587723485E-317 6.16846640587723485E-317 3<BR>> > check xx_v 20 6.18113523716789609E-317 6.18113523716789609E-317 3<BR>> > check xx_v 21 0.0000000000000000 0.0000000000000000 3<BR>> > check xx_v 22 0.0000000000000000 0.0000000000000000 3<BR>> > check xx_v 23 0.0000000000000000 0.0000000000000000 3<BR>> > check xx_v 24 0.0000000000000000 0.0000000000000000 3<BR>> > <BR>> > ======The vector x is :<BR>> > Process [0]<BR>> > 4000<BR>> > 4000<BR>> > 4000<BR>> > 4000<BR>> > 4000<BR>> > 3000<BR>> > 3000<BR>> > Process [1]<BR>> > 3000<BR>> > 3000<BR>> > 3000<BR>> > 2000<BR>> > 2000<BR>> > 2000<BR>> > Process [2]<BR>> > 2000<BR>> > 2000<BR>> > 1000<BR>> > 1000<BR>> > 1000<BR>> > 1000<BR>> > Process [3]<BR>> > 1000<BR>> > 0<BR>> > 0<BR>> > 0<BR>> > 0<BR>> > 0<BR>> > <BR>> > <BR>> > <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>> > <BR>> <BR>                                            </body>
</html>