<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 2 April 2016 at 11:18, Rongliang Chen <span dir="ltr"><<a href="mailto:rl.chen@siat.ac.cn" target="_blank">rl.chen@siat.ac.cn</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Shri,<br>
<br>
Thanks for your reply.<br>
<br>
Do you mean that I need to change the VecGetArrary() in /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c to VecGetArrayRead()?<br></blockquote><div><br></div><div>No - you should change it in your function FormMassTimeStepFunction().<br></div><div>The input vector x passed into SNESComputeFunction() is read only.<br></div><div> <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I tried it and I got a warning when I make the petsc:<br>
<br>
/home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c: In function ‘DMLocalToGlobalBegin’:<br>
/home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:1913:5: warning: passing argument 2 of ‘VecGetArrayRead’ from incompatible pointer type [enabled by default]<br>
In file included from /home/rlchen/soft/petsc-3.6.3/include/petscmat.h:6:0,<br>
from /home/rlchen/soft/petsc-3.6.3/include/petscdm.h:6,<br>
from /home/rlchen/soft/petsc-3.6.3/include/petsc/private/dmimpl.h:6,<br>
from /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:1:<br>
/home/rlchen/soft/petsc-3.6.3/include/petscvec.h:420:29: note: expected ‘const PetscScalar **’ but argument is of type ‘PetscScalar **’<br>
<br>
Best regards,<br>
Rongliang<br>
<br>
---------------------<br>
Rongliang Chen, PhD<br>
Associate Professor<br>
<br>
Laboratory for Engineering and Scientific Computing<br>
Shenzhen Institutes of Advanced Technology<br>
Chinese Academy of Sciences<br>
Address: 1068 Xueyuan Avenue, Shenzhen University Town, Shenzhen, Guangdong (518055), P. R. China<br>
E-mail: <a href="mailto:rl.chen@siat.ac.cn" target="_blank">rl.chen@siat.ac.cn</a><br>
Phone: <a href="tel:%2B86-755-86392312" value="+8675586392312" target="_blank">+86-755-86392312</a><div class=""><div class="h5"><br>
<br>
On 04/02/2016 05:03 PM, Abhyankar, Shrirang G. wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Use VecGetArrayRead instead of VecGetArray<br>
<br>
<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetArray" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetArray</a><br>
Read.html<br>
<br>
<br>
Shri<br>
<br>
-----Original Message-----<br>
From: Rongliang Chen <<a href="mailto:rl.chen@siat.ac.cn" target="_blank">rl.chen@siat.ac.cn</a>><br>
Date: Saturday, April 2, 2016 at 3:51 AM<br>
To: PETSc users list <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>>, "<a href="mailto:rongliang.chan@gmail.com" target="_blank">rongliang.chan@gmail.com</a>"<br>
<<a href="mailto:rongliang.chan@gmail.com" target="_blank">rongliang.chan@gmail.com</a>><br>
Subject: [petsc-users] Vec is locked read only<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Dear All,<br>
<br>
My code got the following error messages, but the code works well for<br>
the petsc optimized version (--with-debugging=0). Anyone can tell me how<br>
to fix this problem?<br>
<br>
Best regards,<br>
Rongliang<br>
<br>
<br>
[0]PETSC ERROR: --------------------- Error Message<br>
--------------------------------------------------------------<br>
[0]PETSC ERROR: Object is in wrong state<br>
[0]PETSC ERROR: Vec is locked read only, argument # 1<br>
[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a><br>
for trouble shooting.<br>
[0]PETSC ERROR: Petsc Release Version 3.6.3, Dec, 03, 2015<br>
[0]PETSC ERROR: ./Nwtun on a 64bit-debug named rlchen by rlchen Sat Apr<br>
2 15:40:32 2016<br>
[0]PETSC ERROR: Configure options --download-blacs --download-scalapack<br>
--download-metis --download-parmetis --download-exodusii<br>
--download-netcdf --download-hdf5<br>
--with-mpi-dir=/home/rlchen/soft/Program/mpich2-shared<br>
--with-debugging=1 --download-fblaslapack --download-chaco<br>
[0]PETSC ERROR: #1 VecGetArray() line 1646 in<br>
/home/rlchen/soft/petsc-3.6.3/src/vec/vec/interface/rvector.c<br>
[0]PETSC ERROR: #2 DMLocalToGlobalBegin() line 1913 in<br>
/home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c<br>
[0]PETSC ERROR: #3 FormMassTimeStepFunction() line 191 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF<br>
unctions.c<br>
[0]PETSC ERROR: #4 FormFunction() line 46 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF<br>
unctions.c<br>
[0]PETSC ERROR: #5 SNESComputeFunction() line 2067 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c<br>
[0]PETSC ERROR: #6 SNESSolve_NEWTONLS() line 184 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/impls/ls/ls.c<br>
[0]PETSC ERROR: #7 SNESSolve() line 3906 in<br>
/home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c<br>
[0]PETSC ERROR: #8 SolveTimeDependent() line 843 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.<br>
c<br>
[0]PETSC ERROR: #9 main() line 452 in<br>
/home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.<br>
c<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br></div></div>