Search code examples
pythoninterfacefortransubroutinef2py

f2py. fortran subroutine arguments on multiple lines. "unknown_subroutine"


I am working on a python/fortran interface using f2py. My fortran code has some subroutines whose list of arguments are longer than one line, so I have used the standard fortran rule to break a line, i.e.:

  SUBROUTINE mutation(it,pop,pm,pmg,typem,xmin,xmax,newfx,nbvar,
  $popsize,tip,nouvpop,nbnew)

When I try to build the python module with f2py, using the command :

f2py3 -c forFunct.f -m mga

I get this :

...
Block: unknown_subroutine
...
Constructing wrapper function "unknown_subroutine"...
      unknown_subroutine()

and eventually

error: Command "gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-
prototypes -fPIC -I/tmp/tmp1tw75l/src.linux-x86_64-3.3 
-I/Produits/publics/x86_64.Linux.RH6/python/3.3.3/lib/python3.3/site-
packages/numpy/core/include -
I/Produits/publics/x86_64.Linux.RH6/python/3.3.3/include/python3.3m -c 
/tmp/tmp1tw75l/src.linux-x86_64-3.3/mgamodule.c -o 
/tmp/tmp1tw75l/tmp/tmp1tw75l/src.linux-x86_64-3.3/mgamodule.o" 
failed with exit status 1

Do you know any solution to this problem? I am sure that it comes from the multiple lines arguments, is it supported by f2py?

Thank you

Francesco


Solution

  • How exactly do you break the lines? It is not clear from your snippet, but it looks like it is wrong. If I do it in the real standard way, with positioning any character in the 6th column, it works.

    1234567
          SUBROUTINE mutation(it,pop,pm,pmg,typem,xmin,xmax,newfx,nbvar,
         $    popsize,tip,nouvpop,nbnew)
          END