1

I try to use procedure pointers as a return of a function in Fortran. The following minimal code works with gfortran (tested with 4.8.1) but not with nagfor (NAG 6.0):

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

nagfor complains with:

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]

Why is this?

Note: I'm very well aware of the danger for memory leaks when using procedure pointers in this way.

4

1 回答 1

2

我在 NAG Fortran 编译器上工作,我可以确认它还没有实现这个 Fortran 2003 特性(函数返回过程指针)。暂时计划在下一个 (6.1) 版本中支持该功能。

于 2015-03-30T16:59:26.677 回答