Questions tagged [f2py]

F2PY is a tool that provides an interface between the Python and Fortran programming languages.

F2PY is a tool that provides an interface between the and programming languages. F2PY is part of .

491 questions
9
votes
2 answers

f2py -- prevent array reordering

I have an array which is read from a fortran subroutine as a 1D array via f2py. Then in python, that array gets reshaped: a=np.zeros(nx*ny*nz) read_fortran_array(a) a=a.reshape(nz,ny,nx) #in fortran, the order is a(nx,ny,nz), C/Python it is…
mgilson
  • 300,191
  • 65
  • 633
  • 696
8
votes
2 answers

f2py error with allocatable arrays

I have a Fortran subroutine that I would like to use in Python. subroutine create_hist(a, n, dr, bins, hist) integer, intent(in) :: n real(8), intent(in) :: a(n) real(8), intent(in) :: dr integer, intent(out), allocatable :: hist(:) …
petervanya
  • 306
  • 4
  • 11
8
votes
2 answers

Install f2py with python3

I need to call routines from Fortran modules within Python. I did it with f2py and python2.7. It worked pretty well. Now, I have to use it with python3 but f2py does not seem to be compatible with python3. I see that some people use a version called…
jvtrudel
  • 1,235
  • 3
  • 15
  • 28
8
votes
0 answers

Complicated Cython embedded executable with f2py compiled module

I am trying to cythonize a python project found at https://pypi.python.org/packages/source/p/phaseshifts/phaseshifts-0.1.2-dev.zip with the end goal of creating a standalone executable for the phsh.py module. The core structure of the project I wish…
Liam Deacon
  • 904
  • 1
  • 9
  • 25
8
votes
2 answers

Stop python code in (Fortran) module error using f2py?

I am creating a Python module in Fortran using f2py. I would like produce an error (including error message) in the Python program if an error is encountered in the Fortran module. Consider the following example: Fortran code (test.f): subroutine…
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
8
votes
1 answer

Numpy distutils howto

I spent almost an hour googling for the solution, but the documentation for numpy.distutils is very sparse. I have a f2py-wrapped module. It consists basically of 3 files: a.f90 a.pyf lib.a <- this is a static library that contains most of the…
Ivan Oseledets
  • 2,270
  • 4
  • 23
  • 28
7
votes
1 answer

How do I compile a Fortran library for use with Python? (f2py may not be an option)

I'm trying to compile a fortran90 library (specifically this one) in order to call it from python (3.4.0). Generally in this case I would write a wrapper for f2py and call it a day, but the library itself makes use of derived types, which seems to…
Elliot
  • 2,541
  • 17
  • 27
7
votes
1 answer

Why is my Fortran code wrapped with f2py using so much memory?

I am trying to calculate all the distances between approximately a hundred thousand points. I have the following code written in Fortran and compiled using f2py: C 1 2 3 4 5 6 …
Steven C. Howell
  • 16,902
  • 15
  • 72
  • 97
7
votes
1 answer

Including a compiled module in module that is wrapped with f2py (Minimum working example)?

I have tried, but am failing, to get a minimum working example. As I do not need to expose much of my fortran code to python, I don't need f2py to wrap large parts of it. Also, due to allocatable arrays being passed and derived types being used, I…
GPMueller
  • 2,881
  • 2
  • 27
  • 36
7
votes
3 answers

Fortran extension to Python via f2py: How to profile?

I'm using an extension to Python (2.7.2) written in Fortran (gfortran 4.4.7) compiled via f2py (Ver. 2). I can profile the Python part with cProfile, but the result does not give any information about the Fortran functions. Instead the time is…
NichtJens
  • 1,709
  • 19
  • 27
6
votes
1 answer

Why can I call Fortran subroutine through f2py without having right number of inputs?

I am trying to learn f2py and I have the following Fortran code subroutine fibonacci(a, n) implicit none integer :: i, n double precision :: a(n) do i = 1, n if (i .eq. 1) then a(i) = 0d0 …
zyy
  • 1,271
  • 15
  • 25
6
votes
1 answer

compilation error with f2py and gfortran: undefined reference to `main'

I recently started using f2py and python2.7 for working on some codes related to an ocean model (ROMS) in Fortran. My workstation specifics are Ubuntu 16.04 with python2.7, anaconda2 and gfortran. I have netcdf and hdf5 libraries installed as…
6
votes
1 answer

f2py with OMP: can't import module, undefined symbol GOMP_*

I was hoping to use openmp to speed up my Fortran code that I run through f2py. However, after compiling succesfully, I can't import the module in Python. For a Fortran95 module like this: module test implicit none contains subroutine…
Mark
  • 18,730
  • 7
  • 107
  • 130
6
votes
2 answers

What is f2py used for while building numpy source?

When I list all the Fortran files in NumPy's source tree, I…
osolmaz
  • 1,873
  • 2
  • 24
  • 41
6
votes
2 answers

Porting an old fortran program to work with python+numpy

I am supposed to be doing research with this huge Fortran 77 program (which I recently ported to Fortran 90 superficially). It is a very old piece of software used for modeling using finite element methods. It is a monstrosity. It is roughly…
osolmaz
  • 1,873
  • 2
  • 24
  • 41
1
2
3
32 33