Lua + Fortran?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua + Fortran?

mfmors
It is said in Programming in Lua (p. 205) that "Lua has been designed to
interface easily not only with C/C++, but also with Java, Fortran and the
like."

This interests me with particular regard to Fortran.  For the time being, I
am interested in making Fortran calls from Lua, not the other way around.
However, I find in the book and in the reference manuals nothing about how
to do this.  I assume there is an analogy with the C-specific methods, but
even then, some examples would be helpful.

Could anybody point me to some relevant documentation?  Does anybody on the
list have any experience hooking Lua up to Fortran?

Mark F. Morss
Principal Analyst, Market Risk
American Electric Power

Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

Luiz Henrique de Figueiredo
> I am interested in making Fortran calls from Lua, not the other way around.
> However, I find in the book and in the reference manuals nothing about how
> to do this.  I assume there is an analogy with the C-specific methods, but
> even then, some examples would be helpful.

Any language that can interface with C can interface with Lua. Of course,
this means that you need to write C wrappers for your Fortran functions.
--lhf
Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

mfmors
Ah, I see.  Thank you.

Mark F. Morss
Principal Analyst, Market Risk
American Electric Power


                                                                           
             Luiz Henrique de                                              
             Figueiredo                                                    
             <[hidden email]-                                          To
             rio.br>                   Lua list                            
             Sent by:                  <[hidden email]>      
             lua-bounces@bazar                                          cc
             2.conectiva.com.b                                            
             r                                                     Subject
                                       Re: Lua + Fortran?                  
                                                                           
             02/09/2006 10:18                                              
             AM                                                            
                                                                           
                                                                           
             Please respond to                                            
                 Lua list                                                  
             <[hidden email]                                            
               tiva.com.br>                                                
                                                                           
                                                                           




> I am interested in making Fortran calls from Lua, not the other way
around.
> However, I find in the book and in the reference manuals nothing about
how
> to do this.  I assume there is an analogy with the C-specific methods,
but
> even then, some examples would be helpful.

Any language that can interface with C can interface with Lua. Of course,
this means that you need to write C wrappers for your Fortran functions.
--lhf


Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

Roberto Ierusalimschy
In reply to this post by Luiz Henrique de Figueiredo
> Does anybody on the list have any experience hooking Lua up to Fortran?

I did that, but it was more than ten years ago. And of course it
depends on the specifics of your Fortran compiler (how it interfaces
with C). All I remember is that it was not too difficult :)


> Of course, this means that you need to write C wrappers for your
> Fortran functions.

Not necessarilly. Maybe you can write the wrappers in Fortran.

For instance, LuaInterface (a binding between Lua and C#) uses this
approach. Since the resulting C# functions all have the same signature
(lua_State* -> int), it then uses one single C function to wrap
them. Each C wrapper is a closure over that single function with the C#
function as an upvalue.

-- Roberto
Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

lego-2
In reply to this post by mfmors
You have to wrap the fortran calls in C.

http://www.neurophys.wisc.edu/comp/docs/notes/not017.html

On 2/9/06, [hidden email] <[hidden email]> wrote:

> It is said in Programming in Lua (p. 205) that "Lua has been designed to
> interface easily not only with C/C++, but also with Java, Fortran and the
> like."
>
> This interests me with particular regard to Fortran.  For the time being, I
> am interested in making Fortran calls from Lua, not the other way around.
> However, I find in the book and in the reference manuals nothing about how
> to do this.  I assume there is an analogy with the C-specific methods, but
> even then, some examples would be helpful.
>
> Could anybody point me to some relevant documentation?  Does anybody on the
> list have any experience hooking Lua up to Fortran?
>
> Mark F. Morss
> Principal Analyst, Market Risk
> American Electric Power
>
>


--
This information is top security. When you have read it, destroy yourself.
-- Marshall McLuhan
Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

Luis Carvalho-2
In reply to this post by mfmors
> Could anybody point me to some relevant documentation?  Does anybody on the
> list have any experience hooking Lua up to Fortran?

You can take a look at NumericLua:

http://luaforge.net/projects/numlua

I use a lot of Fortran code there. Bottom line is: no need to wrap routines;
just declare appropriate C prototypes.

Cheers,
luis.

--
A mathematician is a device for turning coffee into theorems.
        -- P. Erdos

--
Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Lua + Fortran?

mfmors
That's quite interesting, thanks.

Mark F. Morss
Principal Analyst, Market Risk
614-583-6757
Audinet 220-6757


                                                                           
             Luis Carvalho                                                
             <[hidden email]                                            
             wn.edu>                                                    To
             Sent by:                  Lua list                            
             lua-bounces@bazar         <[hidden email]>      
             2.conectiva.com.b                                          cc
             r                                                            
                                                                   Subject
                                       Re: Lua + Fortran?                  
             02/09/2006 12:35                                              
             PM                                                            
                                                                           
                                                                           
             Please respond to                                            
                 Lua list                                                  
             <[hidden email]                                            
               tiva.com.br>                                                
                                                                           
                                                                           




> Could anybody point me to some relevant documentation?  Does anybody on
the
> list have any experience hooking Lua up to Fortran?

You can take a look at NumericLua:

http://luaforge.net/projects/numlua

I use a lot of Fortran code there. Bottom line is: no need to wrap
routines;
just declare appropriate C prototypes.

Cheers,
luis.

--
A mathematician is a device for turning coffee into theorems.
        -- P. Erdos

--
Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <[hidden email]>