从具有nagfor的函数返回的过程指针

时间:2015-03-30 16:23:33

标签: pointers fortran procedure fortran2003 nag-fortran

我尝试使用过程指针作为Fortran函数的返回。以下最小代码适用于gfortran(使用4.8.1测试)但不适用于nagfor(NAG 6.0):

function foo() result(f_p)
  implicit none
  procedure(), pointer :: f_p
  f_p => null()
end function foo

nagfor抱怨:

Error: test.f90, line 5: Multiply defined symbol F_P
   detected at ::@F_P
Error: test.f90, line 5: F_P is not a procedure name
   detected at F_P@<end-of-statement>
Warning: test.f90, line 7: Result F_P of function FOO has not been assigned a value
[NAG Fortran Compiler pass 1 error termination, 2 errors, 1 warning]

为什么会这样?

注意:当我以这种方式使用过程指针时,我非常清楚内存泄漏的危险。

1 个答案:

答案 0 :(得分:2)

我在NAG Fortran编译器上工作,我可以确认它还没有实现这个Fortran 2003功能(返回程序指针的函数)。 对该功能的支持暂定于下一次(6.1)发布。

相关问题