[f2py] wrapping a fortran library with f2py
Paul Anton Letnes <[email protected]> Thu, 5 May 2011 13:03:15 -0700
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
> Hi all! > > I am attempting to wrap the SHTOOLS [0] library using this [1] approach. I started out with a fairly simple routine, the PlmBar routine (attached). > > I first generated a "first draft" of the interface, then made a few additions - notably dimension-ing the variable p explicitly, using depend(). > python module shtools ! in > interface ! in :shtools > subroutine plmbar(p, lmax, z, csphase, cnorm) ! in :shtools:PlmBar.f95 > use shtools, only: csphase_default > integer, intent(in) :: lmax > real*8, intent(out), dimension((lmax + 1) * (lmax + 2) / 2), depend(lmax) :: p > real*8, intent(in) :: z > integer, optional, intent(in) :: csphase > integer, optional, intent(in) :: cnorm > end subroutine plmbar > end interface > end python module shtools > > I compile with (gfortran 4.4 and): > f2py -c shtools.pyf PlmBar.f95 SHTOOLS.f95 > Everything looks nice and dandy, except a lot of: > Warning: Nonconforming tab character at (1) > > Now, the compiled .so seems not to do what I would like it to: > % python -c 'import shtools; shtools.plmbar(10, 0.3)' > Error --- PlmBar > P must be dimensioned as (LMAX+1)*(LMAX+2)/2 where LMAX is 10 > Input array is dimensioned 1 > So my dimensioning is off, somehow. What's going on? > > Oh, and there is a "use shtools" so you need to generate the .mod file from SHTOOLS.f95 first. > > Cheers, > Paul. > > > [0] http://www.ipgp.fr/~wieczor/SHTOOLS/SHTOOLS.html > [1] http://cens.ioc.ee/projects/f2py2e/usersguide/index.html#the-smart-way _______________________________________________ f2py-users mailing list f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] http://cens.ioc.ee/mailman/listinfo/f2py-users
PlmBar.f95
(application/octet-stream, 7.4 KB) - not displayed
SHTOOLS.f95
(application/octet-stream, 26 KB) - not displayed