Python for Fortran Programmers

S

Stephan Mueller

* Bil Kleb said:
It was neat to see Ruby naturally appear under this
thread recently on news:comp.lang.fortran

I think Ruby is getting quite popular in SC now. Btw: Is there something
like f2py for ruby?

I guess one have to use swig instead to get a binding for a fortran lib.
But there seems to be no english tutorial on the web. Any hints?


Cheers,

Steph.

PS: Bil, sorry for the PM.
 
A

ara.t.howard

I think Ruby is getting quite popular in SC now. Btw: Is there something
like f2py for ruby?

I guess one have to use swig instead to get a binding for a fortran lib.
But there seems to be no english tutorial on the web. Any hints?


Cheers,

Steph.

PS: Bil, sorry for the PM.

better still - ruby/dl can call into fortan libs directory : no binding
required. i think this only works with f77 code though...

check this out

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/100842

regards.

-a
 
S

Stephan Mueller

better still - ruby/dl can call into fortan libs directory : no binding
required. i think this only works with f77 code though...

I guess you are right. Tried it with gfortran and all I get is a
segfault. Setting the -f2c compiler flag does not help either.

Maybe C is still the language of choice when it comes to exending ruby?


Cheers,

Steph.
 
S

Stephan Mueller

* Stephan Mueller said:
I guess you are right. Tried it with gfortran and all I get is a
segfault.

Ooops, this seems to be a problem with the way I pass over parameters
from ruby to the lib. Will have to double check this. Simple functions
without parameters do work.

Sorry for the noise.


Cheers,

- Steph.
 
J

Josef 'Jupp' SCHUGT

Hi!
better still - ruby/dl can call into fortan libs directory : no
binding required. i think this only works with f77 code though...

Many people actually do not need Fortran 90+ support. What they need
is support for huge FORTRAN 77 code bases that consist of millions of
code-lines and are the result of man-millenia of coding and debugging.
Even if one would hire *all* people of adequate numerical mathematics
skills that can program it would most probably take years to re-write
and sufficently test all that code in another language. And quite a
number of these people would not give up their research no matter what
you pay them.

Josef 'Jupp' Schugt
 
D

Dean Wampler

Fortran compilers pass arguments in the opposite order compared to C
and C++. I believe this is a "standard" and if I recall correctly,
it's because C/C++ support variable argument lists ("varargs"), while
Fortran doesn't; C passes the list in reverse order so it's easy to
mark both ends of the lists. ("Layman's" description ;) )

dean
 
J

John W. Kennedy

Dean said:
Fortran compilers pass arguments in the opposite order compared to C
and C++.

Certain Fortran compilers on certain operating systems on certain
architectures do so.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
 
S

Stephan Mueller

Got it working now with Ruby 1.8.4 and gfortran-4.0. Thumbs up and thanks
for the help!


Steph.
 
S

Stephan Mueller

* Bil Kleb said:
Steph, can you post an example somewhere?

Sure. Sorry for the delay. The link from Ara shows all you need. Compile
your fortran file with

gfortran --f2c --free-form -shared -O2 FILE.f -o LIB.so -fPIC

testet on Debian unstable with

ruby 1.8.4 (2005-12-24) [i486-linux]
GNU Fortran 95 (GCC 4.0.3 20060212 (prerelease) (Debian 4.0.2-9))

evil.rb seems to be neccessary only in case you have output parameters
and arrays on the fortran side of life. :)


Cheers,

Steph.
 
R

Ryan Davis

If there are any fortran gurus out here, I've long thought that a
RubyInline::Fortan would be a nice thing to see.

I'm willing to help with this, but I don't know squat about fortran
(and honestly, don't want to). However, getting it working for
RubyInline would be a very cool feat and I can finally get some my
friend at LBLL to maybe start using ruby. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top