[f2py] pointers supported in f90 modules?

Pearu Peterson pearu@cens.ioc.ee
Wed, 29 Aug 2001 11:49:46 +0200 (EET)

On Tue, 28 Aug 2001, Ben Cornett wrote:

> Hi,
> When I try to wrap this code:
> -----------------------------
> module bar
>   integer, pointer:: data(:)
> contains
>   function s()
>     integer s
>     s = 4
>   end function s
> end module bar
> -----------------------------
> I get an immediate segfault while importing the module from python.  I'm using
> Python 2.1 and Numeric 20.1.0 on irix 6.5.

What f2py version do you use? Only latest f2py can be used in connection
with Numeric 20.x.

> Is this sort of thing supported by f2py?  

No, Fortran 90 pointers are not supported. The reason is that they are not
like C pointers and currently I don't have information how to treat them
from the C side. This is probably also very compiler dependent matter.

> Maybe I don't even need them, I just picked up a f90 book a couple of days ago
> and I'm not very good at using it yet.  So please pardon me while I solicit
> some f90 advice ;-)  What I'm trying to do is wrap a couple of subroutines
> which call a NAG optimization routine.  The NAG routine needs to be passed an
> objective function, so I thought I would just set up something like this:
> ----------------------------------------
> module mymod
> 	contains
> 	subroutine s1(...)
> 		call nag routine (..., objectivefunction, ...)
> 	end subroutine s1
> 	subroutine objectivefunction(...)
> 		.
> 		.
> 	end subroutine objectivefunction
> end module mymod
> ----------------------------------------
> but I also need share some of the data that gets passed to s1 with
> the objective function.

You can use module data for that. I think, you could do that also without
using pointers. Note that f2py supports also allocatable arrays.
May be some one else, who uses f90 more often than me, in this list could
provide more constructive help?