f2py

Install f2py with python3

我的未来我决定 提交于 2019-12-09 17:16:40
问题 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 f2py3 , but it is neither available through pip , not through macports (I am using a Mac). Also, python3+numpy+f2py seem to be already integrated in Fedora. Does anyone have managed to use f2py3 (or its equivalent) with python3 on a Mac? If not,

F2PY cannot find intel fortran compiler on windows 7

一笑奈何 提交于 2019-12-09 02:53:34
I am struggling to get F2PY working with Intel Fortran on Windows 7. This appears to be a common issue and I have attempted a number of suggestions found in other posts (described below). A bit of information about my system: Windows 7 64-bit Python 2.7.11 via Enthought Canopy 32-bit (up to date as of June 12, 2016) Intel Fortran 14 (Intel\Composer XE 2013 SP1) (32 and 64-bit) After doing a bit of research see here I found that the issue may be related to the c++ runtime so I installed Microsoft Visual C++ for Python. Still, when I attempt to build a simple test case, I receive the following

malloc error in f2py

邮差的信 提交于 2019-12-08 09:28:54
问题 I am trying to use f2py to run a simple integration problem in 3 dimensions. The python code which calls the fortran code is as follows: #!/Library/Frameworks/EPD64.framework/Versions/Current/bin/python import pymods as modules import pygauleg as gauleg import pyint as integrator import pylab as pl import sys import math import time ############################################ # main routine ############################# ############################################ zero = 0.0 one = 1.0 pi =

Unable to use f2py to link large PETSc/SLEPc Fortran code

心不动则不痛 提交于 2019-12-08 09:23:53
问题 I am attempting to use f2py to create a python module for my Fortran code that uses both PETSc and SLEPc (this question is very closely related to this post, but the discussion there was unable to solve my problem--see comments at bottom of this post). The code is made up of many files and subroutines, but I only need access to the outermost main/driver function in python. The first step I took was to use the SLEPc-provided makefile template to generate all object files (the final linking

f2py: using openMP parallel in fortran fails

血红的双手。 提交于 2019-12-08 06:52:51
问题 I am trying to compile a fortran routine that uses openMP for python using f2py . This is the file bsp.f90 : module OTmod !$ use omp_lib implicit none public :: get_threads contains function get_threads() result(nt) integer :: nt nt = 0 !$ nt = omp_get_max_threads() !$omp parallel num_threads(nt) write( *, * ) 'hello world!' !$omp end parallel end function get_threads end module OTmod If I compile it with f2py -m testmod --fcompiler=gfortran --f90flags='-fopenmp' -lgomp -c bsp.f90 compilation

How can I “catch” a seg fault while importing an F2Py module?

徘徊边缘 提交于 2019-12-08 02:36:22
问题 Some background, the relevance of which may fluctuate: I am currently in possesion of some F2Py libraries - Python modules compiled by F2Py from some Fortran code. For all intents and purposes, you can regard these modules as "third party"; I currently do not have access to the Fortran source code, and I am not in charge of the compilation process. The modules themselves are imported into a program I am helping to develop that has Python scripting support and that runs on multiple platforms.

Embedding Fortran in Python with f2py

£可爱£侵袭症+ 提交于 2019-12-08 01:02:02
问题 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 computations. (I am more comfortable with Fortran and it is a better tool for numerical work) I am trying to use f2py, but I keep getting strange errors. f2py is complaining about my variable declarations, trying to change character(*) to integer and

f2py: using openMP parallel in fortran fails

故事扮演 提交于 2019-12-06 16:08:32
I am trying to compile a fortran routine that uses openMP for python using f2py . This is the file bsp.f90 : module OTmod !$ use omp_lib implicit none public :: get_threads contains function get_threads() result(nt) integer :: nt nt = 0 !$ nt = omp_get_max_threads() !$omp parallel num_threads(nt) write( *, * ) 'hello world!' !$omp end parallel end function get_threads end module OTmod If I compile it with f2py -m testmod --fcompiler=gfortran --f90flags='-fopenmp' -lgomp -c bsp.f90 compilation works, but importing it to python fails with the error ImportError: dlopen(/Users/USER/omp_py/testmod

Embedding Fortran in Python with f2py

房东的猫 提交于 2019-12-06 11:24:49
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 computations. (I am more comfortable with Fortran and it is a better tool for numerical work) I am trying to use f2py, but I keep getting strange errors. f2py is complaining about my variable declarations, trying to change character(*) to integer and appending ! onto my variable names when I have a comment immediately following the variable

callback Python from Fortran

試著忘記壹切 提交于 2019-12-06 04:48:40
问题 Now I am using the f2py to call Python function from Fortran code. I have tried a very easy example but it didn't work. Fortran90 code: subroutine foo(fun,r) external fun integer ( kind = 4 ) i real ( kind = 8 ) r r=0.0D+00 do i= 1,5 r=r+fun(i) enddo end using the commandline: f2py -c -m callback callback.f90 Python code: import callback def f(i): return i * i print callback.foo(f) Error: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: `Required argument 'r'