PCShellSetContext fortran interface
Barry Smith
bsmith at mcs.anl.gov
Thu Jun 7 16:22:49 CDT 2007
Stephan,
Even from Fortran the context is treated as a memory address, not
an integer value. You could use a common block (yuck) or some array that
is alloacated higher in the stack as the context, but as you note you
cannot use a local variable.
Barry
You could argue that we should have implemented the way you suggest as
only allow an integer value, but I would respond that in Fortran 90 one
can pass in address of derived types, allocated arrays etc so I prefer our
current design.
On Thu, 7 Jun 2007, Stephan Kramer wrote:
> Hi,
>
> I don't know if this is the expected behaviour but calling PCShellSetContext
> from fortran, the thing that is stored is not the integer value of context,
> but the pointer to this integer. Thus problems arise when supplying an
> integer variable that goes out of scope (e.g. on the stack) inbetween
> PCShellSetContext and the call to the 'apply shell preconditioner' routine. I
> know this makes sense from the C point of view, where you are merely
> supplying a void pointer, but this is not what you expect in Fortran were the
> only use of context could be as a reference/index itself to another object,
> and you thus expect the value of context to be stored.
>
> Cheers
> Stephan Kramer
>
>
More information about the petsc-users
mailing list