I've been starting to use Fortran (95) for some numerical code (generating python modules). Here is a simple example:
subroutine bincount (x,c,n,m)
implicit none
integer, intent(in) :: n,m
integer, dimension(0:n-1), intent(in) :: x
integer, dimension(0:m-1), intent(out) :: c
integer :: i
c = 0
do i = 0, n-1
c(x(i)) = ...
The following Fortran code fills a 2D array x with value v
subroutine fill(x,v,m,n)
real*8 x(m,n),v
integer m,n,i
cf2py intent(in) :: x,v,m,n
forall(i=1:m,j=1:n) x(i,j) = v
end
When calling this function from Python:
x = numpy.array([[[0.0]]],order='F')
fill(x[:,:,0],2.0)
assert(x[0,0,0]==2.0) # Assertio...
I am trying to read some smps files with python, and found a fortran implementation, so I thought I would give f2py a shot. The problem is that I have no experience with fortran.
I have successfully installed gfortran and f2py on my Linux box and ran the example on thew f2py page, but I have some trouble compiling and running the large ...
In a project I work on we use a Python C module compiled from Fortran with f2py. I've had no issues building it on Windows 7 32bit (using mingw32) and on the servers it's built on 32bit Linux.
But I've recently installed Ubuntu 10.04 LTS 64bit on my laptop that I use for development, and when I build it I get a lot of warnings (even thou...
I have some routines written in fortran that I'd like to use in my python code. A quick websearch informed me about f2py, and I gave it a try. Using
f2py -c numericalMethods.f -m numericalMethods
it seems to work for a while until a lot of errors are spawn during the conversion. Any idea of why the following bit of code fails to work...