[petsc-users] VecGetArrayReadF90 with gfortran

Timothée Nicolas timothee.nicolas at gmail.com
Fri Mar 23 09:41:06 CDT 2018


Hello Samuel,

Not an expert on pointers, but I believe that the problem is you are trying
to use the pointer as if it were an array. Maybe? In any case, when I was
using this routine, I would always use a separate routine, using the
pointer as argument, to do the actual business. So with your example it
would be something like:

CALL VecGetArrayReadF90(vecX,vecX_pt,ierr); CHKERRQ(ierr)

CALL DoSomething(vecX_pt)

CALL VecRestoreArrayReadF90(vecX,vecX_pt,ierr); CHKERRQ(ierr)

subroutine DoSomething(X)

  PetscScalar :: X(size)

  ...
  ...

end subroutine DoSomething

In other words, you pass the pointer to a routine and then use the argument
as if it were a normal array within the routine. To be honest, I know
nothing about the internal pointer business, so I hope I am not misleading
you, but at least when I was doing this it was working.

Cheers

Timothee



2018-03-23 15:10 GMT+01:00 Samuel Lanthaler <s.lanthaler at gmail.com>:

> Hi all,
>
> I am having trouble using the function VecGetArrayReadF90 under gfortran.
> I have created a minimal example and put it in the attachment. Basically,
> it appears that the input pointer is empty upon return from
> VecGetArrayReadF90. The code runs fine, when compiled with ifort, so I
> don't know what's going on.
>
> I am attaching the code and makefile that I used, as well as the command
> line output that I can see. Though the errors are just to do with the fact
> that the output pointer is empty, so the command line output is not all
> that helpful...
>
> Thanks in advance for your help!
> Sam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180323/2f834a5a/attachment.html>


More information about the petsc-users mailing list