PCShellSetContext fortran interface
Stephan Kramer
stephan.kramer at imperial.ac.uk
Thu Jun 7 17:03:37 CDT 2007
Hi Barry,
Thanks, just wanted some clarification. Might I suggest in the documentation
as well? I don't understand what you mean by:
in Fortran 90 one can pass in address of derived types, allocated arrays etc
Do you mean to rely on the fact that, without an explicit interface, fortran
will (in practice) pass in the derived type by reference, which granted you
do for the integer as well? This is quite in contradiction what it says in
the documentation, and has nothing to do with any Fortran 90 standard. Also
you would have to rely on the fact that this is gonna work for the supplied
apply routine as well.
As I said, I am merely being curious here. Thanks for any clarification. BTW
is there a fortran interface for PCShellSetDestroy coming any soon?
Thanks
Stephan
On Thursday 07 June 2007 22:22:49 Barry Smith wrote:
> 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