f2py

Python Import error for f2py modules compiled with OpenMP

时光总嘲笑我的痴心妄想 提交于 2020-01-06 23:19:49
问题 I'm currently experiencing an issue in wrapping some Fortran subroutines for use in a python3 script. This issue has only come up since I have attempted to use OpenMP in the subroutines. For example, if I compile a module 'test.pyd' using f2py -c -m --fcompiler=gfortran --compiler=mingw32 --f90flags='-fopenmp' test test.f90 -lgomp , in which 'test.f90' is a Fortran subroutine which contains a parallelized loop, upon attempting to import this module into my script, I encounter ImportError: DLL

How to expose Python callbacks to Fortran using modules

萝らか妹 提交于 2020-01-03 14:14:44
问题 This scipy documentation page about F2Py states: [Callback functions] may also be explicitly set in the module. Then it is not necessary to pass the function in the argument list to the Fortran function. This may be desired if the Fortran function calling the python callback function is itself called by another Fortran function. However, I can't seem to find an example of how this would be done. Consider the following Fortran / Python combination: test.f : subroutine test(py_func) use iso

Using f2py with windows x64 and Intel Fortran

房东的猫 提交于 2020-01-02 07:05:53
问题 I'm trying to achieve in using f2py on windows 8, x64, with Intel Fortran Compiler. I've tried two things : 1) install via windows 64x installer. http://www.lfd.uci.edu/~gohlke/pythonlibs/ NumPy is correctly installed, but no compiler found when executing f2py -c --help-fcompiler I got : Fortran compilers found: Compilers available for this platform, but not found: --fcompiler=absoft Absoft Corp Fortran Compiler --fcompiler=compaqv DIGITAL or Compaq Visual Fortran Compil --fcompiler=g95 G95

Using f2py with windows x64 and Intel Fortran

家住魔仙堡 提交于 2020-01-02 07:05:04
问题 I'm trying to achieve in using f2py on windows 8, x64, with Intel Fortran Compiler. I've tried two things : 1) install via windows 64x installer. http://www.lfd.uci.edu/~gohlke/pythonlibs/ NumPy is correctly installed, but no compiler found when executing f2py -c --help-fcompiler I got : Fortran compilers found: Compilers available for this platform, but not found: --fcompiler=absoft Absoft Corp Fortran Compiler --fcompiler=compaqv DIGITAL or Compaq Visual Fortran Compil --fcompiler=g95 G95

f2py array valued functions

我只是一个虾纸丫 提交于 2020-01-02 03:44:06
问题 Do recent versions of f2py support wrapping array-valued fortran functions? In some ancient documentation this wasn't supported. How about it now? Let's for example save the following function as func.f95. function func(x) implicit none double precision :: x(:),func(size(x)) integer :: i do i=1,size(x) func(i) = i*x(i) end do end function I compile this with f2py --fcompiler=gnu95 -c -m func func.f95 Then let the following python code be test_func.py import func from numpy import array x =

F2Py: Working with allocatable arrays in Fortran being invoked through Python

拜拜、爱过 提交于 2020-01-01 19:12:32
问题 Using F2Py to compile Fortran routines being suitable to be used within Python , the following piece of code is successfully compiled configured gfortran as the compiler while using F2Py , however, at the time of invoking in Python it raises a runtime error! Any comments and solutions? function select(x) result(y) implicit none integer,intent(in):: x(:) integer:: i,j,temp(size(x)) integer,allocatable:: y(:) j = 0 do i=1,size(x) if (x(i)/=0) then j = j+1 temp(j) = x(i) endif enddo allocate(y(j

Translate F2PY compile steps into setup.py

ⅰ亾dé卋堺 提交于 2020-01-01 10:49:12
问题 I've inherited a Fortran 77 code which implements several subroutines which are run through a program block which requires a significant amount of user-input via an interactive command prompt every time the program is run. Since I'd like to automate running the code, I moved all the subroutines into a module and wrote a wrapper code through F2PY. Everything works fine after a 2-step compilation: gfortran -c my_module.f90 -o my_module.o -ffixed-form f2py -c my_module.o -m my_wrapper my_wrapper

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

末鹿安然 提交于 2019-12-28 12:09:22
问题 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 specifically want f2py to only wrap the interface module I created (in the following example 'main.f90'). But I am having problems to get the other modules which I compile separately to link to my main module. The Code: Note all source files are in

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

邮差的信 提交于 2019-12-28 12:09:14
问题 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 specifically want f2py to only wrap the interface module I created (in the following example 'main.f90'). But I am having problems to get the other modules which I compile separately to link to my main module. The Code: Note all source files are in

Segmentation faults using f2py

随声附和 提交于 2019-12-26 04:04:20
问题 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