[Numpy-discussion] Please help on compilation fortran module using f2py

Pearu Peterson pearu.peterson@gmail....
Wed Oct 6 02:26:32 CDT 2010


Hi,

On 10/06/2010 04:57 AM, Jing wrote:
>   Hi, everyone:
>
> I am new to the python numpy and f2py. I really need help on compiling
> FORTRAN module using f2py. I have been searched internet without any
> success. Here is my setup: I have a Ubuntu 10.04 LTS with python 2.6,
> numpy 1.3.0 and f2py 2 (installed from ubuntu) and gfortran compiler
> 4.4. I have a simple Fortran subroutine (in CSM_CH01_P1_1a_F.f95 file)
> as shown below:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> !
>
> subroutine sim_model_1(ts, n, a)
>
> !
>
> !f2py integer, intent(in) :: ts, n
>
> !f2py real,dimension(n), intent(inout) :: a
>
> implicit none

The problem is in Fortran code. The ts, n, and a variables need to be 
declared for fortran compiler too. The f2py directives are invisible
to the fortran compiler, they are just comments that are used by f2py.
So, try adding these lines to the Fortran code:

   integer, intent(in) :: ts, n
   real, dimension(n) :: a

HTH,
Pearu


More information about the NumPy-Discussion mailing list