Re: [f2py] external function to subroutines
Pearu Peterson <[email protected]> Thu, 24 Nov 2011 22:17:24 +0200
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <CAPpwKcwSMHvYOVOJRuKfQCS34BQ3RPkCrwMaEhSjPtFpe8S6nw@mail.gmail.com> |
Hi, The problem is that f2py cannot determine the signatures of f0t3 and df0t3 functions. To help f2py in that, add the following lines after the declaration of these functions: !f2py real(DP) x !f2py x = f0t3(x) !f2py x = df0t3(x) HTH, Pearu On Thu, Nov 24, 2011 at 2:26 PM, Davor Horvatic <[email protected]> wrote: > I'm utterly confused ... As I mentioned in previous posts I want to use > several external > functions in subroutines. I.e. something like the attached code. What > I'm I doing wrong. > I.e. can f2py handle this. I'm sorry if I'm nagging you and this turns > out to be trivial > but I'm completely stuck. > > Error is: > > sign2map: Confused: external df0t3 is not in lcb_map['f0t3']. > append_needs: unknown need 'df0t3' > append_needs: unknown need 'df0t3' > > CODE > _______________ > > subroutine gap1pl(r, k, b, t, phi3, m, res) > implicit none > > integer, parameter :: DP = kind(1.0d0) > > !f2py intent (callback) f0t3 > !f2py external f0t3 > real (DP), external:: f0t3 > > !f2py intent (callback) df0t3 > !f2py external df0t3 > real (DP), external:: df0t3 > > real (DP) :: r, k, b, t, phi3, m, res > real (DP) :: rn2,bamp,meas,tmp,tmpgb,ff0t3 > integer :: alpha > > 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.0d0*pi)/(2.0d0*pi)**3)*(r**2) > > tmp=0 > > DO alpha = -1,1,1 > rn2 = r**2 + ((2.0d0*k+1.0d0)*pi*t + alpha*phi3)**2 > ff0t3 = f0t3(rn2) > bamp = m+b*ff0t3 > tmpgb = -4.d0*t*meas*alpha*((2.0d0*k+1.0d0)*pi*t + & > & alpha*phi3)*((1.0d0+2.0d0*b*bamp*df0t3(rn2))/(rn2+bamp**2)-1/(rn2+m**2)) > tmp = tmp+tmpgb > ENDDO > > res=tmp > > end subroutine gap1pl > > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users > _______________________________________________ f2py-users mailing list f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] http://cens.ioc.ee/mailman/listinfo/f2py-users