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
4
votes
0 answers

Using F2py for creating python module in windows

I am trying to create python module in windows 7 using f2py command This is my test FORTRAN code : subroutine foo(a) integer a print*,"Hello from Fortan foo" print*,"a=",a call goo(a) end subroutine goo(b) integer b integer c c=b+10 …
PUJA
  • 639
  • 1
  • 8
  • 18
4
votes
1 answer

Using f2py with LAPACK called from inside a module

I am trying to wrap FORTRAN90 code using f2py by writing the following commands gfortran -c nrt.f90 gfortran -c lu.f90 gfortran -c sqn.f90 gfortran -c csm.f90 -llapack -lblas gfortran -c pa.f90 f2py -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m…
4
votes
3 answers

Linking Libraries using f2py

I have a fortran program that uses some library files. I am trying to link them along with the module file being created. The library file I am trying to link is called ulib.a and is located in the directory /home/replace/lib/ The command I am using…
RagHaven
  • 4,156
  • 21
  • 72
  • 113
4
votes
1 answer

Determining the origin of compiler flags

When compiling, how can you determine what compiler flags are set? I'm dealing with a weird issue where, if I don't have any environmental variables set: $ env | grep FLAG $ then gfortran uses all these flags: -Wall -arch i686 -arch x86_64 -Wall…
keflavich
  • 18,278
  • 20
  • 86
  • 118
4
votes
1 answer

when using f2py, function scope within fortran module different than when compiled for fortran program?

My problem is that when compiling with f2py, some module variables are not recognized by functions defined within the module. The errors are raised where variable types of arguments passed to the function are declared (such as a variable describing…
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
4
votes
1 answer

Returning a text string from fortran subroutine to python using f2py

I got this simple module in Fortran: test.f90: module test implicit none contains subroutine foo(chid) implicit none character(len=*),intent(out):: chid ! char. identifier chid = "foo" end subroutine foo end…
Paul
  • 4,239
  • 6
  • 28
  • 29
4
votes
1 answer

f2py function release GIL

Does the Global Interpretter Lock (GIL) get released when I call an f2py wrapped function? (I'm happy to try to discover on my own, but I'm not familiar enough with the numpy source to know where to start looking)... To clarify, a good answer to…
mgilson
  • 300,191
  • 65
  • 633
  • 696
4
votes
1 answer

How to deal with global variables when calling fortran code in python (e.g. with f2py)?

I want to run some fortran codes with python and am using f2py -c -m for it. However, it seems that only the FUNCTIONs are packed into the .so file, but not the PROGRAM. How can I deal with global variables then? For example, a variable c is put in…
user1342516
  • 447
  • 2
  • 5
  • 10
4
votes
0 answers

import f2py extension as 'import mymod.foo'

I've created a Python module from Fortran files with: f2py -c -m mymod file1.f90 file2.f90 file3.f90 file1.f90 contains Fortran modules: foo, bar, bar. Module foo contains functions: f,g,h. f2py automatically write docstring for function…
user744629
  • 1,961
  • 1
  • 18
  • 27
4
votes
1 answer

f2py: Wrapping fortran module which makes use of subrouines distributed in different files?

For reasons I described earlier, I need to use LAPACKs dgesvd and zgesvd methods in Python instead of the ones wrapped in numpy. Someone pointed out, that I could use f2py, to create my own python package. The trouble is, that, dgesdd in lapack…
Mischa Obrecht
  • 2,737
  • 6
  • 21
  • 31
3
votes
1 answer

Embedding Fortran in Python with f2py

I need a script to recurse across a directory structure, extract numbers from files in the directories, then perform calculations on those numbers. I am using Python as the main language for the script, but wanted to use Fortran for the numerical…
astay13
  • 6,857
  • 10
  • 41
  • 56
3
votes
1 answer

Fortran subroutine returning None in python c.f. working in R

Im trying to implement some probability work that utilises the bivariate normal cdf. In R I can use the pbivnorm package (line 90 specifically), e.g. (with some made up numbers) library(pbivnorm) .Fortran("PBIVNORM", as.double(0), c(0,0),…
Robert Hickman
  • 869
  • 1
  • 6
  • 22
3
votes
1 answer

How to make external function work with f2py?

I am trying to compile a piece of old Fortran code with f2py so that it can be called within Python. However, the part with external function wouldn’t work. Here is an MWE, first I have the test.f: function f(x) implicit double precision…
zyy
  • 1,271
  • 15
  • 25
3
votes
1 answer

f2py gives error when subroutine contains internal procedures (but compiles successfully with gfortran)

Following program compiles(in f2py) when the subroutine doesn't contain any internal procedures but fails to compile in f2py (compiles with gfortran) when it contains any internal procedure Fortran code: subroutine example(array) implicit none …
Shriraj Hegde
  • 829
  • 5
  • 18
3
votes
0 answers

Intel Fortran: How to get traceback on floating-point exception in f2py-wrapped code

I have a trivial test program that implements one function, INV, which just computes 1/x. Passing 0 for the argument x triggers a zero-division error. When I compile it with ifort (version 2021.3.0), using the flags /fpe-all:0…
Some Guy
  • 31
  • 2