我正在尝试从 fortran 函数返回一个类型。这是代码。
module somemodule
implicit none
! define a simple type
type sometype
integer :: someint
end type sometype
! define an interface
interface
! define a function that returns the previously defined type
type(sometype) function somefunction()
end function somefunction
end interface
contains
end module somemodule
在 gfortran (4.4 & 4.5) 中,我收到以下错误:
错误: (1) 处的函数“somefunction”的类型不可访问
我将文件编译为:
gfortran -c ./test.F90
我试图将类型明确公开,但这没有帮助。我本来打算使用 ac 版本的 somefunction,这就是为什么我把它放在接口部分。
为什么类型不可访问?