我正在尝试将一个正则表达式写入^ call X *([(&]|$)README.md,但它会在句子末尾分割:
一些文字...... ^ call X
*([(&]|$)
我认为这是可能理解的存在之间的空间X和*但它仍然会更好,不断显示出来.可能吗?它试过 但似乎没有在内联模式下工作.
据我所知,CMake只附带图形缓存编辑器.但是,我需要从shell脚本编辑一些缓存变量.一种方法是直接编辑,CMakeCache.txt但这不被认为是安全的.或者是吗?如果没有,从命令行编辑缓存变量的一般做法是什么?
链接到英特尔 MKL 静态库会引入循环依赖关系。当我导入库时,
set(LIBRARIES mkl_intel_lp64 mkl_sequential mkl_core)
foreach(_lib ${LIBRARIES})
add_library(${_lib} UNKNOWN IMPORTED)
set_target_properties(${_lib} PROPERTIES IMPORTED_LOCATION
/opt/intel/mkl/lib/intel64/lib${_lib}.a)
endforeach()
Run Code Online (Sandbox Code Playgroud)
并链接到我的可执行文件,
target_link_libraries(main PRIVATE ${LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
我得到了大量对线性代数调用的未定义引用。例如,
ztrevc3_gen.f:(.text+0x1af7): undefined reference to `mkl_blas_zdscal'
Run Code Online (Sandbox Code Playgroud)
解决这个问题的一种方法是使用适当的链接器标志:
target_link_libraries(main PRIVATE -Wl,--start-group ${LIBRARIES} -Wl,--end-group)
Run Code Online (Sandbox Code Playgroud)
另一种选择是这样做:
target_link_libraries(main PRIVATE ${LIBRARIES} ${LIBRARIES} ${LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
然而,当我寻找更优雅的解决方案时,我发现了该LINK_INTERFACE_MULTIPLICITY属性。如果将此属性与导入的库位置一起设置,
set(LIBRARIES mkl_intel_lp64 mkl_sequential mkl_core)
foreach(_lib ${LIBRARIES})
add_library(${_lib} UNKNOWN IMPORTED)
set_target_properties(${_lib} PROPERTIES IMPORTED_LOCATION
/opt/intel/mkl/lib/intel64/lib${_lib}.a
LINK_INTERFACE_MULTIPLICITY 3)
endforeach()
Run Code Online (Sandbox Code Playgroud)
我得到了与以前相同的未定义引用,所以看来这不起作用。使用 LINK_INTERFACE_MULTIPLICITY 的正确方法是什么?是否有更优雅的方法来解决循环依赖?
编辑
这是一个失败的最小示例,这次使用了正确的IMPORTED_LINK_INTERFACE_MULTIPLICITY变量。
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(test Fortran)
add_executable(main main.f90)
set(LIBRARIES mkl_intel_lp64 mkl_sequential mkl_core)
foreach(_lib ${LIBRARIES})
add_library(${_lib} …Run Code Online (Sandbox Code Playgroud) 为什么在Fortran中编程时需要在PROGRAM关键字后面加上一个名字?这有什么不同吗?它在过去有用吗?我想不出它对其余代码的影响,除了名称现在为主程序保留,不能用于任何其他变量或过程.
在英特尔论坛上将此报告为编译器错误之前,我想知道以下是否符合标准.我的问题是:逻辑运算的顺序是否总是在Fortran中修复?
! main.f90
interface
subroutine f(x)
logical, intent(in), optional :: x
end subroutine f
end interface
call f(.false.)
call f(.true.)
call f()
end program
! f.f90
subroutine f(x)
logical, intent(in), optional :: x
print*, present(x) .and. x
end subroutine f
Run Code Online (Sandbox Code Playgroud)
gfortran main.f90 f.f90 && ./a.out 版画
F
T
F
Run Code Online (Sandbox Code Playgroud)
ifort main.f90 f.f90 && ./a.out 版画
F
T
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 0000000000476D75 Unknown Unknown Unknown
a.out 0000000000474997 Unknown Unknown Unknown
a.out …Run Code Online (Sandbox Code Playgroud) 我有一个基类型,其中包含一个将用户定义的函数作为输入的过程.用户定义的函数在扩展类型中定义.以下使用ifort-13.1.3进行编译,但使用gfortran-4.8.1进行编译:
module m
implicit none
type, abstract :: base
contains
procedure :: use_f
end type base
type, extends(base) :: extended
contains
procedure :: f
procedure :: test ! calls use_f which takes f as argument
end type extended
contains
subroutine f(this)
class(extended) :: this
end subroutine f
subroutine use_f(this, func)
class(base) :: this
interface
subroutine func(this)
import :: base
class(base) :: this
end subroutine func
end interface
end subroutine use_f
subroutine test(this)
class(extended) :: this
call this%use_f(f) ! This is …Run Code Online (Sandbox Code Playgroud)