ftnlf

Check-in [af0a944bfc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix error in LuaFE which prevented traceback. Also simplify CMake file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:af0a944bfccd285c4714ed954063b1b2b179d86c
User & Date: vadim 2018-10-24 10:49:37
Context
2018-12-22
16:20
Rework interfaces to unify support of 1st, 2nd level and cache. Also add integers as 2nd level keys. check-in: 4abf0c698e user: vadim tags: trunk
2018-12-19
21:21
Create new branch named "ftnlf-v2" Leaf check-in: 992f18c37f user: vadim tags: ftnlf-v2
2018-10-24
10:49
Fix error in LuaFE which prevented traceback. Also simplify CMake file. check-in: af0a944bfc user: vadim tags: trunk
2018-10-23
15:14
Unpack-to-table function and option to link static or shared runtime. check-in: 4b3f3fed00 user: vadim tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CMakeLists.txt.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

find_package(Lua51 REQUIRED)

# By default, debug configuration is compiled
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  set (LFLAGS "-mkl -static-intel")
  set (LFLAGS_FX "")
  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set (FCFLAGS "-fp-model precise -xHOST -O2") 
  else()
    set (FCFLAGS "-fp-model precise -g -O0 -C -traceback")
  endif()
  set (FCFLAGS90 "-warn")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
  if(MINGW)
    # set (LFLAGS "-static-libgcc -static-libgfortran -Wl,-s")
    if (STATIC_LINK)
      set (LFLAGS "-static -Wl,-s")
    else()
................................................................................
      set (LFLAGS "")
    endif()
    set (LFLAGS_FX ${LFLAGS})
  else()    
    set (LFLAGS "")
    set (LFLAGS_FX "")
  endif()
  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set (FCFLAGS "-O2 -march=native -mfpmath=sse")
  else()
    set (FCFLAGS "-g -O0 -fcheck=all -fbacktrace -frecursive")
  endif()
  set (FCFLAGS90 "-Wall")
endif()

# gfortran does not respect current directory in INCLUDEs unless explicitly told to
include_directories(${LUA_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_executable(genconf luaf/genconf.c)
target_link_libraries(genconf ${LUA_LIBRARIES})
................................................................................
  )

set (src_test
  test.f90
  )

add_library(ftnlf STATIC ${src_lib})
set_target_properties(ftnlf PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
  set_target_properties(ftnlf PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
endif()

function(add_fxlib FX)
  add_library(${FX} SHARED ${src_shlib})
  target_link_libraries(${FX} ${LUA_LIBRARIES})
  set_target_properties(${FX} PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
  set_target_properties(${FX} PROPERTIES LINK_FLAGS "${LFLAGS_FX}")
  set_target_properties(${FX} PROPERTIES PREFIX "")
  if(CMAKE_BUILD_TYPE STREQUAL "Release")
  	set_target_properties({FX} PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
	endif()
endfunction()

add_fxlib(Core)
add_fxlib(FX)

add_executable(ftnlf_test ${src_test})
# Link static
target_link_libraries(ftnlf_test ftnlf ${LUA_STATIC_LIB} ${CMAKE_DL_LIBS})
# Link dynamic
# target_link_libraries(ftnlf ${LUA_LIBRARIES})
set_target_properties(ftnlf_test PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
set_target_properties(ftnlf_test PROPERTIES LINK_FLAGS "${LFLAGS}")
# set_target_properties(ftnlf PROPERTIES PREFIX "")

# set_target_properties(ftnlf PROPERTIES PREFIX "")

# Ad-hoc
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "")
set(CMAKE_Fortran_FLAGS_RELEASE "")







<
|
<
|
<







 







<
|
<
|
<







 







|
|




|

|


|
|











|

<

<
<

|
<
15
16
17
18
19
20
21

22

23

24
25
26
27
28
29
30
..
31
32
33
34
35
36
37

38

39

40
41
42
43
44
45
46
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102


103
104


find_package(Lua51 REQUIRED)

# By default, debug configuration is compiled
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  set (LFLAGS "-mkl -static-intel")
  set (LFLAGS_FX "")

	set (CMAKE_Fortran_FLAGS_RELEASE "-fp-model precise -xHOST -O2")

	set (CMAKE_Fortran_FLAGS_DEBUG "-fp-model precise -g -O0 -C -traceback")

  set (FCFLAGS90 "-warn")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
  if(MINGW)
    # set (LFLAGS "-static-libgcc -static-libgfortran -Wl,-s")
    if (STATIC_LINK)
      set (LFLAGS "-static -Wl,-s")
    else()
................................................................................
      set (LFLAGS "")
    endif()
    set (LFLAGS_FX ${LFLAGS})
  else()    
    set (LFLAGS "")
    set (LFLAGS_FX "")
  endif()

	set (CMAKE_Fortran_FLAGS_RELEASE  "-O2 -march=native -mfpmath=sse")

	set (CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -fcheck=all -fbacktrace -frecursive")

  set (FCFLAGS90 "-Wall")
endif()

# gfortran does not respect current directory in INCLUDEs unless explicitly told to
include_directories(${LUA_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_executable(genconf luaf/genconf.c)
target_link_libraries(genconf ${LUA_LIBRARIES})
................................................................................
  )

set (src_test
  test.f90
  )

add_library(ftnlf STATIC ${src_lib})
set_target_properties(ftnlf PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  set_target_properties(ftnlf PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
endif()

function(add_fxlib FX)
  add_library(${FX} MODULE ${src_shlib})
  target_link_libraries(${FX} ${LUA_LIBRARIES})
  set_target_properties(${FX} PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
  set_target_properties(${FX} PROPERTIES LINK_FLAGS "${LFLAGS_FX}")
  set_target_properties(${FX} PROPERTIES PREFIX "")
  if(CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  	set_target_properties(${FX} PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
	endif()
endfunction()

add_fxlib(Core)
add_fxlib(FX)

add_executable(ftnlf_test ${src_test})
# Link static
target_link_libraries(ftnlf_test ftnlf ${LUA_STATIC_LIB} ${CMAKE_DL_LIBS})
# Link dynamic
# target_link_libraries(ftnlf ${LUA_LIBRARIES})
set_target_properties(ftnlf_test PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
set_target_properties(ftnlf_test PROPERTIES LINK_FLAGS "${LFLAGS}")




# Ad-hoc
# set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "")

Changes to luaf/luafe.f90.

28
29
30
31
32
33
34

35

36
37
38
39
40
41
42
        IMPLICIT NONE
        TYPE(C_PTR), INTENT(IN) :: L
        LOGICAL :: cond
        CHARACTER(LEN=*), INTENT(IN) :: msg
        INTEGER(KIND=C_INT) :: dummy

        IF (.NOT. cond) THEN

            call lua_pushstring_f(L, F_C_STR(msg))

            dummy = lua_error(L)
        END IF
    END SUBROUTINE luaFE_check

    SUBROUTINE luaFE_checktype(L, idx, typ, vname)
        USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_PTR, C_INT
        IMPLICIT NONE







>
|
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        IMPLICIT NONE
        TYPE(C_PTR), INTENT(IN) :: L
        LOGICAL :: cond
        CHARACTER(LEN=*), INTENT(IN) :: msg
        INTEGER(KIND=C_INT) :: dummy

        IF (.NOT. cond) THEN
            call luaL_where(L, 1_C_INT)
            call lua_pushstring_f(L, msg)
            call lua_concat(L, 2_C_INT)
            dummy = lua_error(L)
        END IF
    END SUBROUTINE luaFE_check

    SUBROUTINE luaFE_checktype(L, idx, typ, vname)
        USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_PTR, C_INT
        IMPLICIT NONE