f2py

Compile fortran module with f2py

只愿长相守 提交于 2019-12-06 01:58:28
问题 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 following results: > f2py.py -c -m its --compiler=mingw itimes-s2.f ... Reading fortran codes... Reading file 'itimes-s2.f' (format:fix,strict) crackline: groupcounter=1 groupname={0: '', 1: 'module', 2: 'interface', 3: 'subroutine'} crackline:

Using f2py with windows x64 and Intel Fortran

╄→гoц情女王★ 提交于 2019-12-05 19:55:47
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 Fortran Compiler --fcompiler=gnu GNU Fortran 77 compiler --fcompiler=gnu95 GNU Fortran 95 compiler -

How do I compile a Fortran library for use with Python? (f2py may not be an option)

喜夏-厌秋 提交于 2019-12-05 08:11:52
I'm trying to compile a fortran90 library (specifically this one ) in order to call it from python (3.4.0). Generally in this case I would write a wrapper for f2py and call it a day, but the library itself makes use of derived types, which seems to be making f2py fail. The full stderr is pasted here , but the relevent line is getctype: No C-type found in "{'typename': 'optim_type', 'typespec': 'type'}", assuming void. The other option, based on the numpy documentation is to use ctypes, which also fails Python 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] on linux Type "help", "copyright",

f2py array valued functions

跟風遠走 提交于 2019-12-05 06:50:00
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 = array(xrange(1,10),dtype='float64') print 'x=',x y = func.func(x) print 'func(x)=',y The output from

f2py: some of returned arrays are unchanged/empty

好久不见. 提交于 2019-12-04 21:28:10
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 rank-2 array('d') with bounds (ldu,*) vt : input rank-2 array('d') with bounds (ldvt,*) work : input

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

余生长醉 提交于 2019-12-04 15:06:47
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)) y = temp(:j) end function select A similar StackOverflow post can be found here . Take a look at

Install f2py with python3

£可爱£侵袭症+ 提交于 2019-12-04 05:50:07
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, what alternate solution do you propose to link Fortran libraries with python3 ? As an alternative,

f2py: Exposing parameters from “used” modules

前提是你 提交于 2019-12-03 11:29:34
问题 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 shows a basic example of the problem. I am attempting to compile a module that contains a USE statement pointing to another, more general, module. I would prefer to keep the used module separate so that it can be used in several "packages" as a set of

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

匆匆过客 提交于 2019-12-03 02:34:36
问题 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 this approach, I noticed some confusing behavior when mixing setuptools and numpy.distutils . Is it bad practice to mix the two? As of 2015, it seems preferable to use setuptools as much as possible. However, I would like to build Fortran extensions

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

落花浮王杯 提交于 2019-12-02 16:06:38
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 this approach, I noticed some confusing behavior when mixing setuptools and numpy.distutils . Is it bad practice to mix the two? As of 2015, it seems preferable to use setuptools as much as possible. However, I would like to build Fortran extensions in a way that is compatible with numpy. So I would like to import from numpy.distutils to get