473,378 Members | 1,495 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,378 software developers and data experts.

accessing fortran modules from python

sam
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 something i would prefer to
do in fortran (which i have never used, but will learn), but i have no
experience of accessing non-python code from python. i am also fairly
new to programming period, and am therefore tackling a fairly serious
issue reletive to my experience.

how easy is it to get fortran modules running from python? if c is
easier to use in this respect, i could go in that direction instead.

i realize there is a lot of material on this subject already available,
but i am finding it difficult to make sense of, it's like trying to
take a drink from a fire hose.

any advice would be gratefully received. i will almost certainly be
coding this on windows, for what it's worth.

thank you,

sam

PS if numpy is adequate for this, i would be quite happy to use it. i
got the impression it was more for matrix algebra. i will be
programming a monte carlo simulation, which will need to perform a lot
(a lot!) of simple operations over and over...

Nov 16 '06 #1
3 2091

sam wrote:
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 something i would prefer to
do in fortran (which i have never used, but will learn), but i have no
experience of accessing non-python code from python.
I strongly recommend learning Fortran 95, rather than Fortran 77
i am also fairly new to programming period, and am therefore tackling a fairly serious
issue reletive to my experience.

how easy is it to get fortran modules running from python?
G95 is a good, free Fortran 95 compiler -- I use it heavily, on
Windows. A discussion of "How to interface with Python programs" using
numpy is at http://www.g95.org/howto.html#python .

There is a numpy group http://groups.google.com/group/Numpy-discussion
with a recent thread "accessing FORTRAN from Python". There is also a
g95 group http://groups.google.com/group/gg95 .
if c is easier to use in this respect, i could go in that direction instead.
easier to interface with Python, but not easier for writing numerical
code IMO, especially if you need multidimensional arrays.

<snip>
PS if numpy is adequate for this, i would be quite happy to use it. i
got the impression it was more for matrix algebra. i will be
programming a monte carlo simulation, which will need to perform a lot
(a lot!) of simple operations over and over...
Fortran 95 has some of the advantages of numpy -- you perform
operations on whole arrays and array sections. It would probably be
considerably faster for code with loops.

Nov 16 '06 #2
sam wrote:
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 something i would prefer to
do in fortran (which i have never used, but will learn), but i have no
experience of accessing non-python code from python. i am also fairly
new to programming period, and am therefore tackling a fairly serious
issue reletive to my experience.

how easy is it to get fortran modules running from python? if c is
easier to use in this respect, i could go in that direction instead.

i realize there is a lot of material on this subject already available,
but i am finding it difficult to make sense of, it's like trying to
take a drink from a fire hose.

any advice would be gratefully received. i will almost certainly be
coding this on windows, for what it's worth.

thank you,

sam

PS if numpy is adequate for this, i would be quite happy to use it. i
got the impression it was more for matrix algebra. i will be
programming a monte carlo simulation, which will need to perform a lot
(a lot!) of simple operations over and over...
numpy isn't for matrix algebra, specifically. It is primarily designed for
operations on arrays. If your simple operations can be "vectorized," then numpy
will benefit you. If you can describe your needs in more detail, we'll be happy
to give you suggestions on the numpy-discussion list.

http://www.scipy.org/Mailing_Lists

Of course, since the major player in wrapping Fortran libraries for Python is
f2py, a component of numpy, you're probably going to end up installing numpy
anyways.

http://numpy.scipy.org

All of the f2py documentation is currently in the source, so start here:

http://projects.scipy.org/scipy/nump...ocs/README.txt

Using f2py to wrap Fortran subroutines is actually a fair bit simpler than
wrapping C code, mostly because typical Fortran uses a limited set of simple types.

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

Nov 16 '06 #3
sam
thanks guys,

i'll follow this up more in a couple of weeks when i know what i need
to do better.

sam

Nov 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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,...
5
by: Carl | last post by:
I have experimented with f2c and swig-generated wrappers to create python modules from Fortran files. I think I'm missing something when I'm building the Python module, because when I import the...
3
by: Paul Phillips | last post by:
Here is what I am trying to do. I have an application that is written in VB 6 and in this application it is accessing a custom dll file that was created using Microsoft Fortran Professional 4.0....
7
by: Anonymous | last post by:
I have a mixed-language pgm (Fortran and C++) which needs to pass a few hundred values from C++ to Fortran. One way to do this is to have a Fortran module and a C++ structure (or class) with an...
1
by: Santosh | last post by:
Hello, I am trying to do some interfacing between c++ and fortran, so my fortran code (say function foo )makes use of the data defined in the modules. Now, I call foo (fortran function) from my...
26
by: sam | last post by:
Hi, Can anyone help me find a software that can convert a code in 'C' to 'Fortran77/90' automatically? Thanks in advance. Sam.
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...
13
by: Mangabasi | last post by:
Howdy, I have been trying to call the following Fortran function from Python (using Windows XP, Compaq Fortran and Python 2.4). I tried F2Py, Pyfort and calldll with no success. I think I...
0
by: Gabriel Genellina | last post by:
En Wed, 19 Nov 2008 20:06:37 -0200, Yann Vonder <yann.vonderscher@gmail.comescribió: If you put tmod in both libraries, you'll have two copies of it, and two copies of the data. Can't you join...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.