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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to CMakeLists.txt.

    15     15   
    16     16   find_package(Lua51 REQUIRED)
    17     17   
    18     18   # By default, debug configuration is compiled
    19     19   if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
    20     20     set (LFLAGS "-mkl -static-intel")
    21     21     set (LFLAGS_FX "")
    22         -  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    23         -    set (FCFLAGS "-fp-model precise -xHOST -O2") 
    24         -  else()
    25         -    set (FCFLAGS "-fp-model precise -g -O0 -C -traceback")
    26         -  endif()
           22  +	set (CMAKE_Fortran_FLAGS_RELEASE "-fp-model precise -xHOST -O2")
           23  +	set (CMAKE_Fortran_FLAGS_DEBUG "-fp-model precise -g -O0 -C -traceback")
    27     24     set (FCFLAGS90 "-warn")
    28     25   elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
    29     26     if(MINGW)
    30     27       # set (LFLAGS "-static-libgcc -static-libgfortran -Wl,-s")
    31     28       if (STATIC_LINK)
    32     29         set (LFLAGS "-static -Wl,-s")
    33     30       else()
................................................................................
    34     31         set (LFLAGS "")
    35     32       endif()
    36     33       set (LFLAGS_FX ${LFLAGS})
    37     34     else()    
    38     35       set (LFLAGS "")
    39     36       set (LFLAGS_FX "")
    40     37     endif()
    41         -  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    42         -    set (FCFLAGS "-O2 -march=native -mfpmath=sse")
    43         -  else()
    44         -    set (FCFLAGS "-g -O0 -fcheck=all -fbacktrace -frecursive")
    45         -  endif()
           38  +	set (CMAKE_Fortran_FLAGS_RELEASE  "-O2 -march=native -mfpmath=sse")
           39  +	set (CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -fcheck=all -fbacktrace -frecursive")
    46     40     set (FCFLAGS90 "-Wall")
    47     41   endif()
    48     42   
    49     43   # gfortran does not respect current directory in INCLUDEs unless explicitly told to
    50     44   include_directories(${LUA_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
    51     45   add_executable(genconf luaf/genconf.c)
    52     46   target_link_libraries(genconf ${LUA_LIBRARIES})
................................................................................
    75     69     )
    76     70   
    77     71   set (src_test
    78     72     test.f90
    79     73     )
    80     74   
    81     75   add_library(ftnlf STATIC ${src_lib})
    82         -set_target_properties(ftnlf PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
    83         -if(CMAKE_BUILD_TYPE STREQUAL "Release")
           76  +set_target_properties(ftnlf PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
           77  +if(CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
    84     78     set_target_properties(ftnlf PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
    85     79   endif()
    86     80   
    87     81   function(add_fxlib FX)
    88         -  add_library(${FX} SHARED ${src_shlib})
           82  +  add_library(${FX} MODULE ${src_shlib})
    89     83     target_link_libraries(${FX} ${LUA_LIBRARIES})
    90         -  set_target_properties(${FX} PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
           84  +  set_target_properties(${FX} PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
    91     85     set_target_properties(${FX} PROPERTIES LINK_FLAGS "${LFLAGS_FX}")
    92     86     set_target_properties(${FX} PROPERTIES PREFIX "")
    93         -  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    94         -  	set_target_properties({FX} PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
           87  +  if(CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
           88  +  	set_target_properties(${FX} PROPERTIES INTERPROCEDURAL_OPTIMIZATION 1)
    95     89   	endif()
    96     90   endfunction()
    97     91   
    98     92   add_fxlib(Core)
    99     93   add_fxlib(FX)
   100     94   
   101     95   add_executable(ftnlf_test ${src_test})
   102     96   # Link static
   103     97   target_link_libraries(ftnlf_test ftnlf ${LUA_STATIC_LIB} ${CMAKE_DL_LIBS})
   104     98   # Link dynamic
   105     99   # target_link_libraries(ftnlf ${LUA_LIBRARIES})
   106         -set_target_properties(ftnlf_test PROPERTIES COMPILE_FLAGS "${FCFLAGS} ${FCFLAGS90}")
          100  +set_target_properties(ftnlf_test PROPERTIES COMPILE_FLAGS "${FCFLAGS90}")
   107    101   set_target_properties(ftnlf_test PROPERTIES LINK_FLAGS "${LFLAGS}")
   108         -# set_target_properties(ftnlf PROPERTIES PREFIX "")
   109         -
   110         -# set_target_properties(ftnlf PROPERTIES PREFIX "")
   111    102   
   112    103   # Ad-hoc
   113         -set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "")
   114         -set(CMAKE_Fortran_FLAGS_RELEASE "")
          104  +# set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "")

Changes to luaf/luafe.f90.

    28     28           IMPLICIT NONE
    29     29           TYPE(C_PTR), INTENT(IN) :: L
    30     30           LOGICAL :: cond
    31     31           CHARACTER(LEN=*), INTENT(IN) :: msg
    32     32           INTEGER(KIND=C_INT) :: dummy
    33     33   
    34     34           IF (.NOT. cond) THEN
    35         -            call lua_pushstring_f(L, F_C_STR(msg))
           35  +            call luaL_where(L, 1_C_INT)
           36  +            call lua_pushstring_f(L, msg)
           37  +            call lua_concat(L, 2_C_INT)
    36     38               dummy = lua_error(L)
    37     39           END IF
    38     40       END SUBROUTINE luaFE_check
    39     41   
    40     42       SUBROUTINE luaFE_checktype(L, idx, typ, vname)
    41     43           USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_PTR, C_INT
    42     44           IMPLICIT NONE