I found a bug in the compiler (version 5.5). When passing a pure function as an argument to another pure function, the compiler gives an error that the argument is not declared as INTENT (IN). But this is not required, and somewhat meaningless for function arguments I believe. (I'm compiling in Checkmate mode but that shouldn't matter).
e.g. I write some code which finds the maximum of a function passed in as an argument on some interval (A, B). I get the error with this code (I provide only a dummy implementation here).
MODULE CALCULUS
CONTAINS
PURE FUNCTION MAXIMISE(A, B, FUNC)
REAL, INTENT (IN) :: A, B
INTERFACE
PURE FUNCTION FUNC(X)
REAL, INTENT (IN) :: X
REAL :: FUNC !<< Compiler complains here
END FUNCTION FUNC
END INTERFACE
! Here I just return the value mid-way between A and B
MAXIMISE = FUNC((A+B)*0.5)
END FUNCTION MAXIMISE
END MODULE CALCULUS
If I remove the PURE specifiers it compiles ok. I think this should be easy to fix for the next release. Any thoughts Paul? 😄