[petsc-dev] XXXGetContext() in Fortran

Blaise Bourdin bourdin at lsu.edu
Tue Nov 8 22:15:58 CST 2011


On Nov 8, 2011, at 8:57 PM, Jed Brown wrote:

> We have bindings for this, but I can't find a way to make it work. I can pass a context into a function, but I can't get one back out with a subroutine call. F90 pointers are grotesque creatures that don't seem to be up to this task either, at least not with any chance of portability.
> 
> Is there anything we can do to avoid common blocks without losing all hope of portability? How does anyone use this sorry excuse for a language?
If you were to do this in fortran 90 alone, you'd need to use the transfer function. Drew Mc Cormack had a short tutorial on this topic a long time ago. http://www.macresearch.org/advanced_fortran_90_callbacks_with_the_transfer_function
I would expect that there'd be a way to get it to play nice with C using the C_interop module. not sure about the bindings we use.

fortran90, 2003 and 2008 are a bit richer than FORTRAN 77...

Blaise

> 
> Note that having the context passed in as an argument isn't feasible for PCShell and MatShell, so it's nigh impossible to use these objects with multigrid (or any other case where you have multiple instances of shell objects, breaking the common blocks.)

-- 
Department of Mathematics and Center for Computation & Technology
Louisiana State University, Baton Rouge, LA 70803, USA
Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin










More information about the petsc-dev mailing list