[petsc-users] VecAXPY
Dave May
dave.mayhem23 at gmail.com
Fri Aug 16 13:00:55 CDT 2019
On Fri, 16 Aug 2019 at 17:22, José Lorenzo via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Hello,
>
> I am struggling with a strange error when using VecAXPY. I have a ghost
> vector H that needs to be updated as
>
> H = H + eta * dH - eta_old * dH
>
> However, for some reason I obtain different results when using
>
> call VecAXPY(H, eta - eta_old, dH, ierr)
>
> instead of
>
> call VecAXPY(H, - eta_old, dH, ierr)
>
> call VecAXPY(H, eta, dH, ierr)
>
Does the code work if you do the following?
call VecAXPY(H, eta, dH, ierr)
eta_old = -eta_old
call VecAXPY(H, eta_old, dH, ierr)
Fortran pass variables by reference not value, so I don't think it is valid
to pass in -eta_old as the argument.
> where eta and eta_old are PetscScalars.
>
> The first option seems to provide a wrong output, but I do not understand
> what can go wrong in such simple operation.
>
> Thank you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190816/a7ab3635/attachment.html>
More information about the petsc-users
mailing list