我想要构建一个带有默认参数的函数。但是,下列任何一种简单的方法都无法使用F2PY进行编译,无法打印以下简单且无通知的错误消息“f2py目标文件‘/tmp/.’未生成”。
1使用可选
module a
contains
integer function func(j)
implicit none
integer, optional :: j
if(present(j)) then
func = j
else
func = 0
endif
end function
end module另一种是使用接口的函数重载。
module test
interface func
module procedure :: func0, func1
end interface
contains
integer function func0()
implicit none
func0 = 0
end function
integer function func1(j)
implicit none
integer, intent(in) :: j
func1 = j
end function
end module感谢你的帮助。
发布于 2018-04-30 22:59:24
可以使用F2PY指令初始化表达式。
integer function func(j)
implicit none
integer :: j
!f2py integer :: j = 0
func = j
end function https://stackoverflow.com/questions/46290026
复制相似问题