Skip to content

f2py: --no-lower does not work in one-step compilation (Trac #1954) #2547

@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/1954 on 2011-09-26 by trac user azrael, assigned to @pearu.

In order to impliment exception handling for Fortran errors into a f2py wrapped function, I followed this advice:

[http://mail.scipy.org/pipermail/numpy-discussion/2009-January/039672.html]

I wanted this to work without editing the .pyf file, and got that by adding the following to the Fortran code:

!f2py callstatement (*f2py_func)( ... ); if (ierr == 1) PyErr_SetString(PyExc_ValueError, "msg")
!f2py callprotoargument ...

(The ... is just a replacement for actual code)

When I tried to compile this with

f2py -c -m m src.f

I got several warnings/errors like this

warning: implicit declaration of function ‘pyerr_setstring’

Obviously the case-lowering acted on this line. As far as I understand the User Guide this should not happen, since I didn't call f2py with '-h' or '--lower'. Nevertheless I added the '--no-lower', but still got the same warnings/errors.

Then I tried whether the added line will show up in the .pyf correctly, which it did, when I used '--no-lower' like this:

f2py --no-lower -m m -h m.pyf src.f

After generating the .pyf I can compile the module - without further editing in the .pyf!

f2py -c m.pyf src.f

  1. Is this intended behaviour? Should it make a difference whether I generate the .pyf first and then compile or use the one-step way?
  2. Is there a way to circumvent using "callprotoargument"? I'd much rather have f2py do it's magic to guess the first line in callstatement and the callprotoargument, and then just add my piece of extra code. Can this be done? Something like a 'addtocallstatement' directive comes to mind ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions