f2py

Segmentation faults using f2py

心不动则不痛 提交于 2019-12-26 04:02:34
问题 This is a follow up to a question I asked here... How do I allocate input arrays with f2py? I've reworked the question in response to comments. The original question was unclear and too lengthy. See comment 1 below. I am trying to use f2py to wrap various fortran subroutines/functions for reading the data output from a variety of atomic physics codes written in fortran 77. I am using the Anaconda python distribution (python 3.4 64 bit) on Ubuntu 14.04 (64 bit) with the gnu compiler suite (gcc

Segmentation fault after removing debug printing

无人久伴 提交于 2019-12-25 16:36:15
问题 I have a (for me) very weird segmentation error. At first, I thought it was interference between my 4 cores due to openmp, but removing openmp from the equation is not what I want. It turns out that when I do, the segfault still occurs. What's weird is that if I add a print or write anywhere within the inner-do, it works. subroutine histogrambins(rMatrix, N, L, dr, maxBins, bins) implicit none; double precision, dimension(N,3), intent(in):: rMatrix; integer, intent(in) :: maxBins, N; double

f2py-f90wrap error `undefined symbol: __test_mod_MOD_p`

时光总嘲笑我的痴心妄想 提交于 2019-12-25 01:19:32
问题 I am trying to wrap some Fortran using f90wrap, which is built on f2py. (I can use f2py, but I want to extend some code to use derived types). Here is a simple .f90 test code that I have tried to wrap: module test_mod integer::p end module I have compiled and wrapped with the following commands: gfortran -fPIC -c test.f90 f90wrap -m test test.f90 f2py-f90wrap -c -m _test f90wrap_*.f90 When I run: python test.py on this test.py file which is produced: import _test import f90wrap.runtime import

Fortran program fails depending on a write statement before subroutine call

牧云@^-^@ 提交于 2019-12-24 14:33:16
问题 It's been a number of years since I've worked with Fortran, so maybe I'm missing a fundamental issue, but here it goes. I'm not even sure how to properly describe this issue, so I apologize in advance for a lack of descriptive information. I'm writing some Fortran modules to supplement a Python program using f2py. Everything seems to be working fine, but I am encountering some strange errors in one subroutine. I couldn't replicate the issue in a small sample program, so I stripped out the

creating distributable windows python module with f2py

守給你的承諾、 提交于 2019-12-24 08:13:56
问题 I have written some code with python and f2py, mostly using linux. This all works fine, but now I would like to share this with windows users, so I am trying to make a module that is distributable to users who don't necessarily have gfortran or gcc. I've got access to a windows xp box, am using mingw with gfortran. I can compile and use the module on that machine, but on other machines the pyd created seems to require the dll's libgcc and libgfortran. Here is an example from http://www.scipy

How to return a value from a Python callback in Fortran using F2Py

爱⌒轻易说出口 提交于 2019-12-24 00:49:47
问题 Consider the following Fortran subroutine, defined in test.f: subroutine test(py_func) use iso_fortran_env, only stdout => output_unit external py_func integer :: a integer :: b a = 12 write(stdout, *) a b = py_func(a) write(stdout, *) b end subroutine Also the following Python code, defined in call_test.py: import test def func(x): return x * 2 test.test(func) Compiled with the following (Intel compiler): python f2py.py -c test.f --fcompiler=intelvem -m test I expect this as output when I

f2py function release GIL

巧了我就是萌 提交于 2019-12-23 12:01:39
问题 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 this question would either help me to know where in the numpy source to look for a Py_BEGIN_ALLOW_THREADS or it would simply let me know if the GIL is released (preferably with some evidence). 回答1: No, f2py defaults to leaving the GIL in place.

f2py: some of returned arrays are unchanged/empty

断了今生、忘了曾经 提交于 2019-12-22 01:37:50
问题 Hi I'm using f2py to wrap the lapack routine dgesvd, by compiling the dgesvd.f file and linking it against llapack, as explained here according to the docstring, the dgesvd module has the signature: dgesvd - Function signature: dgesvd(jobu,jobvt,m,n,a,s,u,vt,work,lwork,info,[lda,ldu,ldvt]) Required arguments: jobu : input string(len=1) jobvt : input string(len=1) m : input int n : input int a : input rank-2 array('d') with bounds (lda,*) s : input rank-1 array('d') with bounds (*) u : input

How do I allocate input arrays with f2py?

╄→гoц情女王★ 提交于 2019-12-21 23:03:27
问题 Warning..... I am a relative python noob, and completely new to using f2py. I have tried to exercise due diligence and search for the answer to my questions here and elsewhere on the interweb, but I've had little luck. This is very likely due to my own ignorance on this subject. My problem: I have a legacy fortran (f77) subroutine along with several functions that are used by the subroutine to read in various arrays from a data file. This data file is itself the result of one of several f77

Building 64-bit Python extensions with f2py on Windows

萝らか妹 提交于 2019-12-20 10:37:18
问题 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 bit (AMD64)]. I have Numpy-MKL 1.7.1, from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy Here is what I've tried: Choose a Fortran compiler. Since I'm using 64-bit Python, a 64-bit Fortran compiler is required. From MinGW-w64, I've tried a few