Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fortran 2008 interface bindings to Lua 5.3

License

NotificationsYou must be signed in to change notification settings

interkosmos/fortran-lua53

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A collection of ISO C binding interfaces to Lua 5.3 for Fortran 2008, to callLua from Fortran and vice versa.

Similar projects:

  • AOTUS: Library that provides a Fortran wrapper to use Lua scripts as configuration files (MIT).
  • FortLua: Example that shows how to load Lua configuration files from Fortran, based on AOTUS (MIT).
  • fortran-lua54: Fortran 2008 bindings to Lua 5.4 (ISC).
  • f2k3-lua: Lua bindings for loading configuration files only (MIT).
  • luaf: Selected bindings to Lua 5.1 (MIT).

Build

Install Lua 5.3 with development headers. On FreeBSD, run:

# pkg install lang/lua53

On Debian Linux, install:

# apt-get install liblua5.3 liblua5.3-dev

Usexmake to buildfortran-lua53:

$ xmake

This outputslibfortran-lua53.a andlua.mod tobuild/. Without xmake, justcompile the library using the providedMakefile:

$ make

Or, run the Fortran Package Manager:

$ fpm build --profile=release

Link your Fortran applications againstlibfortran-lua53.a, andliblua-5.3.a or-llua53. On Linux, you have to link againstliblua5.3.a or-llua5.3 respectively instead. The include and library search paths may differas well.

Example

The following basic example shows how to call the Lua functionhello() inscript.lua from Fortran.

-- script.luafunctionhello()print('Hello from Lua!')end

Make sure thatscript.lua is stored in the same directory as the Fortranapplication.

! example.f90program main    use,intrinsic:: iso_c_binding, only: c_ptr    use:: luaimplicit none    type(c_ptr):: linteger:: rc    l= lual_newstate()call lual_openlibs(l)    rc= lual_dofile(l,'script.lua')    rc= lua_getglobal(l,'hello')    rc= lua_pcall(l,0,0,0)call lua_close(l)end program main

Compile, (dynamically) link, and run the example with:

$ gfortran -I/usr/local/include/lua53/ -L/usr/local/lib/lua/5.3/ \  -o example example.f90 libfortran-lua53.a -llua-5.3$ ./exampleHello from Lua!

On Linux, change the prefix/usr/local to/usr. To link Lua 5.3 statically,run instead:

$ gfortran -o example example.f90 libfortran-lua53.a /usr/local/lib/liblua-5.3.a

Further Examples

Additional examples can be found inexamples/.

  • fibonacci: calls a recursive Lua routine loaded from file.
  • library: calls a Fortran routine inside a shared library from Lua.
  • string: runs Lua code stored in a Fortran string.
  • table: reads values from a Lua table.

fpm

You can addfortran-lua53 as anfpmdependency:

[dependencies]fortran-lua53 = {git ="https://github.com/interkosmos/fortran-lua53.git" }

Compatibility

The integer and float types used by Lua internally depend on the targetedplatform. The programtest/types.c outputs the types:

$ make test$ ./typeslua_integer.: c_long_longlua_number..: c_doublelua_kcontext: c_intptr_t

You may have to alterlua_integer,lua_number, andlua_kcontext insrc/lua.f90 accordingly.

Coverage

Function NameFortran Interface NameBoundWrapper
luaL_addchar
luaL_addlstring
luaL_addsize
luaL_addstring
luaL_addvalue
luaL_argcheck
luaL_argerror
luaL_buffinit
luaL_buffinitsize
luaL_callmeta
luaL_checkany
luaL_checkinteger
luaL_checklstring
luaL_checknumber
luaL_checkoption
luaL_checkstack
luaL_checkstring
luaL_checktype
luaL_checkudata
luaL_checkversion
luaL_dofilelual_dofile
luaL_dostring
luaL_error
luaL_execresult
luaL_fileresult
luaL_getmetafield
luaL_getmetatable
luaL_getsubtable
luaL_gsub
luaL_lenlual_len
luaL_loadbufferx
luaL_loadfilelual_loadfile
luaL_loadfilexlual_loadfilex
luaL_loadstringlual_loadstring
luaL_newlib
luaL_newlibtable
luaL_newmetatable
luaL_newstatelual_newstate
luaL_openlibslual_openlibs
luaL_opt
luaL_optinteger
luaL_optlstring
luaL_optnumber
luaL_optstring
luaL_prepbuffer
luaL_prepbuffsize
luaL_pushresult
luaL_pushresultsize
luaL_ref
luaL_register
luaL_requiref
luaL_setfuncs
luaL_setmetatable
luaL_testudata
luaL_tolstring
luaL_traceback
luaL_typename
luaL_unref
luaL_where
lua_absindex
lua_arithlua_arith
lua_atpanic
lua_calllua_call
lua_callklua_callk
lua_checkstacklua_checkstack
lua_closelua_close
lua_comparelua_compare
lua_concatlua_concat
lua_copylua_copy
lua_createtablelua_createtable
lua_dump
lua_error
lua_gclua_gc
lua_getallocf
lua_getextraspace
lua_getfieldlua_getfield
lua_getgloballua_getglobal
lua_geti
lua_getmetatable
lua_gettable
lua_gettoplua_gettop
lua_getuservalue
lua_insert
lua_isbooleanlua_isboolean
lua_iscfunctionlua_iscfunction
lua_isfunctionlua_isfunction
lua_isintegerlua_isinteger
lua_islightuserdata
lua_isnillua_isnil
lua_isnonelua_isnone
lua_isnoneornillua_isnoneornil
lua_isnumberlua_isnumber
lua_isstringlua_isstring
lua_istablelua_istable
lua_isthreadlua_isthread
lua_isuserdatalua_isuserdata
lua_isyieldablelua_isyieldable
lua_len
lua_loadlua_load
lua_newstate
lua_newtablelua_newtable
lua_newthread
lua_newuserdata
lua_next
lua_numbertointeger
lua_pcalllua_pcall
lua_pcallklua_pcallk
lua_poplua_pop
lua_pushbooleanlua_pushboolean
lua_pushcclosurelua_pushcclosure
lua_pushcfunction
lua_pushfstring
lua_pushglobaltable
lua_pushintegerlua_pushinteger
lua_pushlightuserdatalua_pushlightuserdata
lua_pushliteral
lua_pushlstringlua_pushlstring
lua_pushnillua_pushnil
lua_pushnumberlua_pushnumber
lua_pushstringlua_pushstring
lua_pushthreadlua_pushthread
lua_pushvaluelua_pushvalue
lua_pushvfstring
lua_rawequal
lua_rawgetlua_rawget
lua_rawgetilua_rawgeti
lua_rawgetp
lua_rawlenlua_rawlen
lua_rawsetlua_rawset
lua_rawsetilua_rawseti
lua_rawsetp
lua_registerlua_register
lua_remove
lua_replace
lua_resume
lua_rotate
lua_setallocf
lua_setfieldlua_setfield
lua_setgloballua_setglobal
lua_setilua_seti
lua_setmetatable
lua_settablelua_settable
lua_settoplua_settop
lua_setuservalue
lua_statuslua_status
lua_stringtonumber
lua_tobooleanlua_toboolean
lua_tocfunction
lua_tointegerlua_tointeger
lua_tointegerxlua_tointegerx
lua_tolstring
lua_tonumberlua_tonumber
lua_tonumberxlua_tonumberx
lua_topointer
lua_tostringlua_tostring
lua_tothread
lua_touserdata
lua_typelua_type
lua_typenamelua_typename
lua_upvalueindex
lua_version
lua_xmove
lua_yield
lua_yieldk

Licence

ISC

About

Fortran 2008 interface bindings to Lua 5.3

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp