[f2py] Calling external functions

Davor Horvatic <[email protected]> Tue, 22 Nov 2011 16:25:55 +0100
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
I have a major issue with calling external functions in subroutine. All 
code is attached in
the end of this mail. Code is used in Sage, and the file is read in and 
then fortran command
called, i.e. f2py wrapper. This code just wont compile to a module and I 
checked
user manual and exhausted all options. Can you see what I'm doing wrong ?

Sage is producing this error:

getctype: No C-type found in "{'intent': ['out', 'out=f0']}", assuming void.
getctype: No C-type found in "{'intent': ['out', 'out=f0']}", assuming void.


CODE
-------------------------------------------------


!f90
module r1potgap
implicit none

integer, parameter :: DP = kind(1.0d0)

real (DP), parameter :: pi=2.D0*ASIN(1.D0)
real (DP), parameter :: nf=2.d0
real (DP), parameter :: nc=3.d0

real (DP), parameter :: l0=0.687d0
real (DP), parameter :: mu=0.0096d0*l0
real (DP), parameter :: dq0=128.d0/l0**2

contains

function f0(r, res)
implicit none

real (DP) :: r, res

intent (in) :: r
intent (out) :: res

!f2py intent (in) r
!f2py intent (out) res

res=exp(-r/l0**2)

end function f0

function df0(r, res)
implicit none

real (DP) :: r, res

intent (in) :: r
intent (out) :: res

! # Pragmas f2py-specific
!f2py intent (in) r
!f2py intent (out) res

res=-exp(-r/l0**2)/l0**2

end function df0

subroutine potqf(r, k, b, t, phi3, m, res)
implicit none

!f2py intent (callback) f0
real (DP), external:: f0

real (DP) :: r, k, b, t, phi3, m, res
real (DP) :: rn2,bamp,meas,tmpgb,tmp
integer :: alpha
!f2py rn2 = f0(rn2)

intent (in) :: r, k, b, t, phi3, m
intent (out) :: res


!f2py intent (in) r, k, b, t, phi3, m
!f2py intent (out) res

meas=((4.d0*pi)/(2.d0*pi)**3)*(r**2)

tmp=0

DO alpha = -1,1,1
     rn2 = r**2 + ((2.d0*k+1.d0)*pi*t + alpha*phi3)**2
     bamp = m+b*f0(rn2)
     tmpgb = -2.d0*t*meas*(log(rn2+bamp**2)-log(rn2+m**2))
     tmp = tmp+tmpgb
ENDDO

res=tmp

end subroutine potqf

end module r1potgap