473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 5102


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lamar_air | last post by:
I have a fortran executable which when run from cmd it asks for a series of parameters which you enter then hit enter. From my python cgi script i want to be able to run the executable. Enter the...
2
by: Markus Faust | last post by:
Hi, I'm trying to link Fortran files generated with “Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)” under “Enthought Edition build 1028, Python 2.3 (#46, Aug 11 2003,...
44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
7
by: byte biscuit | last post by:
Hi there everybody! The problem is the following: we have a DLL (H2O.dll) - compiled in Visual Fortran - depending in turn on another DLL. H2O.dll contains only one (1) function, with a known...
1
by: Kumbale, Murali T. | last post by:
I am new to Python and redirection etc. I created a simple COM object in Visual FORTRAN called "disp.disp" that writes to the WINDOWS console. I wrote a Python script which looks like the...
15
by: Nick Coghlan | last post by:
Thought some folks here might find this one interesting. No great revelations, just a fairly sensible piece on writing readable code :) The whole article:...
3
by: unexpected | last post by:
Hi all, I'm currently working on a large, legacy Fortran application. I would like to start new development in Python (as it is mainly I/O related). In order to do so, however, the whole project...
3
by: sam | last post by:
hello all, i am currently in the process of planning a piece of software to model polymerisation kinetics, and intend to use python for all the high-level stuff. the number-crunching is...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.