[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Fortran to Python

Jeroen Ruigrok van der Werven

1/4/2008 1:21:00 PM

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-n... | http://www.ra...
One often hears the most when everyone is silent...
6 Answers

Dennis Lee Bieber

1/4/2008 6:15:00 PM

0

On Fri, 4 Jan 2008 14:21:19 +0100, Jeroen Ruigrok van der Werven
<asmodai@in-nomine.org> declaimed the following in comp.lang.python:

> 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?

integer => integer
real/double => float
complex/double-complex => complex

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.

There is a reason FORTRAN hasn't died... namely a LOT of highly
optimized number crunching!
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

Martin Rinehart

1/5/2008 10:15:00 AM

0



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.

Jeroen Ruigrok van der Werven

1/5/2008 10:35:00 AM

0

-On [20080105 11:21], MartinRinehart@gmail.com (MartinRinehart@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-n... | http://www.ra...
For ever, brother, hail and farewell...

Jeroen Ruigrok van der Werven

1/5/2008 10:37:00 AM

0

-On [20080104 19:21], Dennis Lee Bieber (wlfraed@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-n... | http://www.ra...
Everything has beauty, but not everyone sees it. - Confucius

Robert Kern

1/5/2008 11:06:00 AM

0

Jeroen Ruigrok van der Werven wrote:
> -On [20080104 19:21], Dennis Lee Bieber (wlfraed@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

Evgenii Rudnyi

1/5/2008 4:13:00 PM

0

On Jan 4, 2:21 pm, Jeroen Ruigrok van der Werven <asmo...@in-
nomine.org> wrote:
> 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/Matri...

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

Evgenii