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
53
votes
1 answer

Packaging legacy Fortran in Python. Is it OK to use setuptools and numpy.distutils?

I am trying to make a python package distribution for some popular Fortran codes in my field. I want it to use the most standard approach with a setup.py file. The related qustion was helpful for learning how to wrap Fortran extensions. When using…
Will Martin
  • 993
  • 6
  • 18
35
votes
5 answers

WinError 2 The system cannot find the file specified (Python)

I have a Fortran program and want to execute it in python for multiple files. I have 2000 input files but in my Fortran code I am able to run only one file at a time. How should I call the Fortran program in python? My Script: import…
Jone
  • 421
  • 1
  • 5
  • 9
20
votes
2 answers

setup.py for packages that depend on both cython and f2py

I would like to create a setup.py script for a python package with several submodules that depend on both cython and f2py. I have attempted to use setuptools and numpy.distutils, but have so far failed: Using setuptools I am able to compile my…
abergou
  • 441
  • 2
  • 7
17
votes
1 answer

Is it possible to wrap a function from a shared library using F2PY?

I'm developing a package that requires Python bindings for the dgtsv subroutine from the LAPACK Fortran library. At the moment, I'm distributing the Fortran source file, dgtsv.f, alongside my Python code, and using numpy.distutils to automatically…
ali_m
  • 71,714
  • 23
  • 223
  • 298
16
votes
1 answer

f2py: Exposing parameters from "used" modules

I assume that this question has been addressed somewhere, but I have spent an inordinate amount of time looking around for the answer including digging into the source code a bit. I have tried to put the problem in the first paragraph. The rest…
Vorticity
  • 4,582
  • 4
  • 32
  • 49
14
votes
2 answers

Comparing Python accelerators (Cython,Numba,f2py) to Numpy einsum

I'm comparing Python accelerators (Numba, Cython, f2py) to simple For loops and Numpy's einsum for a particular problem (see below). So far Numpy is the fastest for this problem (factor 6x faster), but I wanted some feedback if there are additional…
Michael
  • 486
  • 6
  • 19
14
votes
1 answer

How to document fortran function for f2py?

I would like to use docstring or something similar to document my fortran routines which can be usable with the python help command. The autogenerated docstring made by f2py is very not sufficient and I need to add more details in the same way we do…
Sigmun
  • 1,002
  • 2
  • 12
  • 23
14
votes
1 answer

f2py: Specifying real precision in fortran when interfacing with python?

I am playing around with f2py. I'm a bit confused about numpy intrinsic types vs. fortran 90 types. It seems like I can only use single precision reals in fortran 90, when interacting with python. Let me illustrate with an example: Say I have this…
arne
  • 677
  • 1
  • 6
  • 14
12
votes
3 answers

Building 64-bit Python extensions with f2py on Windows

I'm attempting to build a Python extension from Fortran source using Numpy's f2py.py script. I'm following the steps from http://www.scipy.org/F2PY_Windows (web archive). My system is Windows 7 64-bit, and I primarily use Python 2.7.3 [MSC v.1500 64…
Mike T
  • 41,085
  • 18
  • 152
  • 203
11
votes
3 answers

Compile fortran module with f2py and Python 3.6 on Windows 10

I'm trying (and failing) to compile a fortran module (specifically igrf12.f from the BGS) using f2py and Python 3.6 on Windows 10. Python was installed using Anaconda 4.4.10. My setup: Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15…
dsholes
  • 453
  • 2
  • 4
  • 10
10
votes
2 answers

packaging with numpy and test suite

Introduction Disclaimer: I'm very new to python packaging with distutils. So far I've just stashed everything into modules, and packages manually and developed on top of that. I never wrote a setup.py file before. I have a Fortran module that I want…
Lemming
  • 4,085
  • 3
  • 23
  • 36
9
votes
1 answer

passing c++ double pointer to python

I could pass one-dimension array to python like below. and I wonder if I can pass c++ double pointer array to python by using ctypes, numpy. test.cpp: #include extern "C" void cfun(const void * indatav, int rowcount, int colcount, void *…
wonjun
  • 311
  • 2
  • 10
9
votes
3 answers

Compile Fortran module with f2py

I have a Fortran module which I am trying to compile with f2py (listed below). When I remove the module declaration and leave the subroutine in the file by itself, everything works fine. However, if the module is declared as shown below, I get the…
astay13
  • 6,857
  • 10
  • 41
  • 56
9
votes
1 answer

what's the overhead of passing python callback functions to Fortran subroutines?

I just wrapped a Fortran 90 subroutine to python using F2PY. The subtlety here is that the Fortran subroutine aslo takes a python call-back function as one of its arguments: SUBROUTINE f90foo(pyfunc, a) real(kind=8),intent(in) :: a !f2py…
nye17
  • 12,857
  • 11
  • 58
  • 68
9
votes
2 answers

F2PY - Access module parameter from subroutine

I cannot get f2py to reference a parameter from a module in a separate subroutine where it is used to defined an input array dimension. I.e. the paramter is defeind in a module: ! File: testmod.f90 MODULE testmod INTEGER, PARAMETER :: dimsize =…
ccbunney
  • 2,282
  • 4
  • 26
  • 42
1
2 3
32 33