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

···

--
Bil
http://fun3d.larc.nasa.gov

* Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:

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.

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

···

On Sat, 18 Feb 2006, Stephan Mueller wrote:

* Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:

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.

--
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama

> * Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:
>> 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.

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

···

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

On Sat, 18 Feb 2006, Stephan Mueller wrote:

check this out

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

regards.

-a

--
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama

--
thanks,
-pate
-------------------------

* ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> [060217 16:22]:

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.

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

···

At Sat, 18 Feb 2006 00:22:56 +0900, ara.t.howard@noaa.gov wrote:
--
Let the origin be the middle of the earth, p(x,r) be the probability
density for finding person x at distance r. Make sure that a permanent
solution of int_0^R p(x,r) dr < 1 exists for R being the instantanous
value of the distance between earth and mars.

* Stephan Mueller <d454d@web.de> [060218 18:52]:

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.

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:

···

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.

--
My backlog is currently 64 items over 60 days (avg 2006-02-07) scoring 89 pts.

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 Mueller <d454d@web.de> wrote:

* Stephan Mueller <d454d@web.de> [060218 18:52]:

> 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 Wampler
http://www.aspectprogramming.com

http://www.contract4j.org

* Stephan Mueller <d454d@web.de> [060218 23:06]:

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

> 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

···

On 2/23/06, Ryan Davis <ryand-ruby@zenspider.com> wrote:

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

--
My backlog is currently 64 items over 60 days (avg 2006-02-07)
scoring 89 pts.

--
thanks,
-pate
-------------------------

Dean Wampler 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.

···

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

Stephan Mueller 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,

···

--
Bil Kleb
http://fun3d.larc.nasa.gov

* Bil Kleb <Bil.Kleb@NASA.gov> [060221 17:48]:

Stephan Mueller 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.