471,348 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Fortran to Python

I got someone who asked me to make changes in an old Fortran program she is
using for some calculations.
The calculations are pretty standard aside from 2 calls to DLINCG (an IMSL
numerical_libraries function to calculate an inverse matrix).

What I wonder about, does anybody have a Fortran to Python conversion page
somewhere to map some of the basic types to Python equivalents?
What kind of speed difference should I expect?

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org/ asmodai
イェルーン ラウフ*ック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
One often hears the most when everyone is silent...
Jan 4 '08 #1
5 5043


Jeroen Ruigrok van der Werven wrote:
I got someone who asked me to make changes in an old Fortran program she is
using for some calculations.
Why convert? Modern Fortran is an object oriented, structured language
with the singular advantage that it can run old Fortran programs.
Jan 5 '08 #2
-On [20080105 11:21], Ma************@gmail.com (Ma************@gmail.com) wrote:
>Why convert? Modern Fortran is an object oriented, structured language
with the singular advantage that it can run old Fortran programs.
With all due respect to Fortran but I find the syntax to be utterly
horrendous. :)

Furthermore, the code is not really heavy number crunching in that it seems to
warrant explicit use in Fortran. At most it takes about 2 seconds on a current
day PC to calculate some of these values.

Furthermore it currently has a dependency on the Visual Numerics IMSL library.
For just some calculations to warrant the cost of both this library and a
Fortran compiler seems a bit excessive.

Given we use Matlab in-house, next to C# (and perhaps F# in the future), and
some Python it makes more sense to stick to your domain-specific knowledge
rather than maintaining some relic from the past.

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org/ asmodai
イェルーン ラウフ*ック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
For ever, brother, hail and farewell...
Jan 5 '08 #3
-On [20080104 19:21], Dennis Lee Bieber (wl*****@ix.netcom.com) wrote:
> If the FORTRAN is using single precision reals, I'd expect a
slow-down in Python just on that alone, as Python uses doubles as the
only float type. There is also the overhead of object access for each.
In this case it uses complex*16 and real*8. Is a real*8 a single precision
real?

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org/ asmodai
イェルーン ラウフ*ック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Everything has beauty, but not everyone sees it. - Confucius
Jan 5 '08 #4
Jeroen Ruigrok van der Werven wrote:
-On [20080104 19:21], Dennis Lee Bieber (wl*****@ix.netcom.com) wrote:
> If the FORTRAN is using single precision reals, I'd expect a
slow-down in Python just on that alone, as Python uses doubles as the
only float type. There is also the overhead of object access for each.

In this case it uses complex*16 and real*8. Is a real*8 a single precision
real?
Double precision. These map to the Python complex and float types exactly.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jan 5 '08 #5
On Jan 4, 2:21*pm, Jeroen Ruigrok van der Werven <asmo...@in-
nomine.orgwrote:
I got someone who asked me to make changes in an old Fortran program she is
using for some calculations.
The calculations are pretty standard aside from 2 calls to DLINCG (an IMSL
numerical_libraries function to calculate an inverse matrix).

What I wonder about, does anybody have a Fortran to Python conversion page
somewhere to map some of the basic types to Python equivalents?
What kind of speed difference should I expect?
When it comes to matrices the difference can be quite big. You can
find the comparison of NumPy, Fortran 77, C, and C++ for matrix
multiplication with and without optimized BLAS at

http://matrixprogramming.com/MatrixMultiply/

NumPy interfaces optimized BLAS, and you can find a LAPACK interface
in SciPy, so it is a good choice.

Evgenii
Jan 5 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Markus Faust | last post: by
7 posts views Thread by byte biscuit | last post: by
1 post views Thread by Kumbale, Murali T. | last post: by
3 posts views Thread by unexpected | last post: by
3 posts views Thread by sam | last post: by
10 posts views Thread by Tyler | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.