From: Dmitry V. Gorbatovsky
Subject: Mixing programming with Fortran
Date: 
Message-ID: <e005rt$b87$1@emma.aioe.org>
I would highly appreciate
any link/help on mixing programming Fortran
with Common Lisp(SBCL or CMUCL) and/or
calling Fortran libraries/functions
from Lisp.

From: ·············@specastro.com
Subject: Re: Mixing programming with Fortran
Date: 
Message-ID: <1143220135.701746.275170@j33g2000cwa.googlegroups.com>
You might try looking at Matlisp, as it calls BLAS and LAPACK.  It
should give you some good ideas.  I think the set of interfaces and
macros they came up for calling the BLAS and LAPACK routines are quite
good, and could provide good inspiration and / or some tools for
calling other Fortran routines.

You might also look at cffi.  It might be possible to extend cffi to
know about Fortran.  This might be simple or even a non-issue if
linking against g77 or g95 compiled libraries.  Maybe some of the cffi
folks have thought about this, you might want to shoot their mailing
list a question about this.

Even though you only mentioned SBCL and CMUCL, I'd like to add that
Allegro's FFI already knows about Fortran, although I haven't done
anything other than read the docs on it.

http://matlisp.sourceforge.net/
http://common-lisp.net/project/cffi/

Glenn

Dmitry V. Gorbatovsky wrote:
> I would highly appreciate
> any link/help on mixing programming Fortran
> with Common Lisp(SBCL or CMUCL) and/or
> calling Fortran libraries/functions
> from Lisp.
From: =?utf-8?b?R2lzbGUgU8ODwqZsZW5zbWk=?= =?utf-8?b?bmRl?=
Subject: Re: Mixing programming with Fortran
Date: 
Message-ID: <0ny7z0uqoz.fsf@kaktus.ii.uib.no>
"Dmitry V. Gorbatovsky" <···········@yahoo.com> writes:

> I would highly appreciate
> any link/help on mixing programming Fortran
> with Common Lisp(SBCL or CMUCL) and/or
> calling Fortran libraries/functions
> from Lisp.

Most Common Lisp systems have a way to call functions written in other
languages. These does in most cases follow a C calling convention, including
CMUCL and SBCL. That means that if you know how to call the Fortran code
from C, you will also be able to call it from Lisp. In CMUCL and SBCL the
foreign function interface (FFI) is called "Alien". If you also want your code
to run on other Lisps, you can use a portable FFI, like UFFI or CFFI.

http://uffi.b9.com/
http://common-lisp.net/project/cffi/

In general, Fortran pass all parameters by reference, and in a C perspective
this looks like all parameters are pointers. There are also some special
tricks when passing strings (in some cases passed as two "parameters", one for
the string reference, and one with it's length). Also, some Fortran compilers
add extra underscores to the function names. With gcc you can control this by
compiler options.


-- 
Gisle Sælensminde, Phd student, Scientific programmer
Computational biology unit, BCCS, University of Bergen, Norway, 
Email: ·····@cbu.uib.no
The best way to travel is by means of imagination
From: Paolo Amoroso
Subject: Re: Mixing programming with Fortran
Date: 
Message-ID: <87r74sueh8.fsf@plato.moon.paoloamoroso.it>
"Dmitry V. Gorbatovsky" <···········@yahoo.com> writes:

> I would highly appreciate
> any link/help on mixing programming Fortran
> with Common Lisp(SBCL or CMUCL) and/or

Another approach may be to use a Fortran to Lisp translator.  One such
translator, f2cl, is maintained as part of CLOCC:

  http://clocc.sourceforge.net

You can browse the f2cl code here:

  http://cvs.sourceforge.net/viewcvs.py/clocc/clocc/src/f2cl/


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net
From: ·············@specastro.com
Subject: Re: Mixing programming with Fortran
Date: 
Message-ID: <1143220613.432316.132240@i40g2000cwc.googlegroups.com>
I forgot about f2cl.  You may want to look at Maxima, as it has a lot
of f2cl translated Fortran libraries.  I do know they just had a new
release ane mentioned that the Fortran Slatec library is in there.  If
you're looking at using a classic Fortran routine or library, they may
have already done some of the work for you.

http://maxima.sourceforge.net/

Glenn
From: ········@yahoo.com
Subject: Re: Mixing programming with Fortran
Date: 
Message-ID: <e01bjl$5u8$1@emma.aioe.org>
Thank you all.
I believe cff would be way to go.

-- 
*It is easy to lie with statistics, but it's a lot easier to lie without
them.