fortran

How to run a Fortran script with ctypes?

How to run a Fortran script with ctypes? Question: First of all I have no experience coding with fortran. I am trying to run a fortran code with python ctypes. I used the command gfortran -shared -g -o test.so test.f90 to convert my test.f90 file (code below) to test.so. After reading C function called from …

Total answers: 1

How can I improve performance of this Fortran code interfacing with Python?

How can I improve performance of this Fortran code interfacing with Python? Question: I am studying the possibility to interface Fortran code to be used in Python. I know of f2py but, since I did not succeed in using it with external libraries (such as lapack), I reverted to use ctypes. I have everything working, …

Total answers: 1

Fortran argument must be Allocatable in Python F2PY

Fortran argument must be Allocatable in Python F2PY Question: I am currently trying to compile Fortran scripts in the Python command terminal into Python modules using the numpy.f2py function as displayed below: python -m numpy.f2py -c -m matching_pairs Matching_Pairs_V2.F90 –fcompiler=gnu95 –compiler=mingw32 It works fine for two other Fortran scripts and I am able to import …

Total answers: 1

Tell f2py to skip a function

Tell f2py to skip a function Question: I am using f2py to compile a Fortran library such that I can import it in python so that I can easily create unit tests. However, one of the functions in the module uses an allocatable array to read a matrix from a file (the size of the …

Total answers: 2

Independent CDLL Library Instances with Ctypes

Independent CDLL Library Instances with Ctypes Question: I am trying to use ctypes and load the same compiled Fortran library twice, such that I have two independent instances of it, such that any module variables that the library contains are not stored in the same memory locations. The general solution described (for example, here: https://mail.python.org/pipermail/python-list/2010-May/575368.html) …

Total answers: 1

How can numpy be so much faster than my Fortran routine?

How can numpy be so much faster than my Fortran routine? Question: I get a 512^3 array representing a Temperature distribution from a simulation (written in Fortran). The array is stored in a binary file that’s about 1/2G in size. I need to know the minimum, maximum and mean of this array and as I …

Total answers: 2

SciPy build/install Mac Osx

SciPy build/install Mac Osx Question: I successfully built/installed NumPy on my mac os x for python 2.7.3. Now I would like to build/install scipy as well. I downloaded it from git hub. Went into the directory. Ran python setup.py build and it seemed to be working until it came across this error: customize Gnu95FCompiler Could …

Total answers: 10

comparing python with c/fortran

comparing python with c/fortran Question: I wrote the following programs to compare the speed of python with c/fortran. To get the time used by the programs I used the “time” command. All the programs compute the square root of xx+yy+z*z where x,y,z are floats. I used the root square because it is one of the …

Total answers: 8