[petsc-users] Vec is locked read only
Matthew Knepley
knepley at gmail.com
Sat Apr 2 06:59:04 CDT 2016
On Sat, Apr 2, 2016 at 6:49 AM, Rongliang Chen <rl.chen at siat.ac.cn> wrote:
> Hi Dave,
>
> I did not call any VecGetArrary and VecGetArraryRead in function
> FormMassTimeStepFunction().
>
It looks like you have a function FormMassTimeStep() inside your
FormFunction() method. This
has an argument X, the solution guess, which is read-only. However, you are
calling DMLocalToGlobal()
using that X, which is illegal, since its read-only. Is this right?
Matt
> Best regards,
> Rongliang
>
> On 04/02/2016 06:20 PM, Dave May wrote:
>
>
>
> On 2 April 2016 at 11:18, Rongliang Chen <rl.chen at siat.ac.cn> wrote:
>
>> Hi Shri,
>>
>> Thanks for your reply.
>>
>> 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()?
>>
>
> No - you should change it in your function FormMassTimeStepFunction().
> The input vector x passed into SNESComputeFunction() is read only.
>
>
>
>> I tried it and I got a warning when I make the petsc:
>>
>> /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c: In function
>> ‘DMLocalToGlobalBegin’:
>> /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]
>> In file included from
>> /home/rlchen/soft/petsc-3.6.3/include/petscmat.h:6:0,
>> from /home/rlchen/soft/petsc-3.6.3/include/petscdm.h:6,
>> from /home/rlchen/soft/petsc-3.6.3/include/petsc/private/dmimpl.h:6,
>> from /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c:1:
>> /home/rlchen/soft/petsc-3.6.3/include/petscvec.h:420:29: note: expected
>> ‘const PetscScalar **’ but argument is of type ‘PetscScalar **’
>>
>> Best regards,
>> Rongliang
>>
>> ---------------------
>> Rongliang Chen, PhD
>> Associate Professor
>>
>> Laboratory for Engineering and Scientific Computing
>> Shenzhen Institutes of Advanced Technology
>> Chinese Academy of Sciences
>> Address: 1068 Xueyuan Avenue, Shenzhen University Town, Shenzhen,
>> Guangdong (518055), P. R. China
>> E-mail: rl.chen at siat.ac.cn
>> Phone: +86-755-86392312
>>
>>
>> On 04/02/2016 05:03 PM, Abhyankar, Shrirang G. wrote:
>>
>>> Use VecGetArrayRead instead of VecGetArray
>>>
>>>
>>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetArray
>>> Read.html
>>>
>>>
>>> Shri
>>>
>>> -----Original Message-----
>>> From: Rongliang Chen <rl.chen at siat.ac.cn>
>>> Date: Saturday, April 2, 2016 at 3:51 AM
>>> To: PETSc users list <petsc-users at mcs.anl.gov>, "
>>> rongliang.chan at gmail.com"
>>> <rongliang.chan at gmail.com>
>>> Subject: [petsc-users] Vec is locked read only
>>>
>>> Dear All,
>>>>
>>>> My code got the following error messages, but the code works well for
>>>> the petsc optimized version (--with-debugging=0). Anyone can tell me how
>>>> to fix this problem?
>>>>
>>>> Best regards,
>>>> Rongliang
>>>>
>>>>
>>>> [0]PETSC ERROR: --------------------- Error Message
>>>> --------------------------------------------------------------
>>>> [0]PETSC ERROR: Object is in wrong state
>>>> [0]PETSC ERROR: Vec is locked read only, argument # 1
>>>> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
>>>> for trouble shooting.
>>>> [0]PETSC ERROR: Petsc Release Version 3.6.3, Dec, 03, 2015
>>>> [0]PETSC ERROR: ./Nwtun on a 64bit-debug named rlchen by rlchen Sat Apr
>>>> 2 15:40:32 2016
>>>> [0]PETSC ERROR: Configure options --download-blacs --download-scalapack
>>>> --download-metis --download-parmetis --download-exodusii
>>>> --download-netcdf --download-hdf5
>>>> --with-mpi-dir=/home/rlchen/soft/Program/mpich2-shared
>>>> --with-debugging=1 --download-fblaslapack --download-chaco
>>>> [0]PETSC ERROR: #1 VecGetArray() line 1646 in
>>>> /home/rlchen/soft/petsc-3.6.3/src/vec/vec/interface/rvector.c
>>>> [0]PETSC ERROR: #2 DMLocalToGlobalBegin() line 1913 in
>>>> /home/rlchen/soft/petsc-3.6.3/src/dm/interface/dm.c
>>>> [0]PETSC ERROR: #3 FormMassTimeStepFunction() line 191 in
>>>>
>>>> /home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF
>>>> unctions.c
>>>> [0]PETSC ERROR: #4 FormFunction() line 46 in
>>>>
>>>> /home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/SetupF
>>>> unctions.c
>>>> [0]PETSC ERROR: #5 SNESComputeFunction() line 2067 in
>>>> /home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c
>>>> [0]PETSC ERROR: #6 SNESSolve_NEWTONLS() line 184 in
>>>> /home/rlchen/soft/petsc-3.6.3/src/snes/impls/ls/ls.c
>>>> [0]PETSC ERROR: #7 SNESSolve() line 3906 in
>>>> /home/rlchen/soft/petsc-3.6.3/src/snes/interface/snes.c
>>>> [0]PETSC ERROR: #8 SolveTimeDependent() line 843 in
>>>>
>>>> /home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.
>>>> c
>>>> [0]PETSC ERROR: #9 main() line 452 in
>>>>
>>>> /home/rlchen/soft/3D_fluid/FiniteVolumeMethod/PETScCodes/codefor3.6/Nwtun.
>>>> c
>>>>
>>>>
>>>>
>>>
>>
>>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160402/f82766de/attachment.html>
More information about the petsc-users
mailing list