Python for Fortran Programmers

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

http://tinyurl.com/c8vtf

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.

On Sat, 18 Feb 2006, Stephan M. wrote:

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

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.

On 2/17/06, [email protected] [email protected] wrote:

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…

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

-pate

Hi!

At Sat, 18 Feb 2006 00:22:56 +0900, [email protected] wrote:

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

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.

Dean W. wrote:

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.

I guess you are right. Tried it with gfortran and all I get is a
segfault.

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

Steph.

Stephan M. wrote:

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

Steph, can you post an example somewhere?

Thanks,

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 :wink: )

dean

On 2/18/06, Stephan M. [email protected] wrote:

Cheers,

  • Steph.


Dean W.
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org

On Feb 17, 2006, at 8:09 AM, pat eyler wrote:

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. :slight_smile:

Stephan M. wrote:

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

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. :slight_smile:

Cheers,

Steph.

On 2/23/06, Ryan D. [email protected] wrote:

On Feb 17, 2006, at 8:09 AM, pat eyler wrote:

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. :slight_smile:

Just to pull things together, I created