As we know that function name can be treated as parameters to pass in/out by other subroutines. I wonder if we have any tricks to save a list of functions into an array, whi
Firstly you should create a type that contain only a procedure pointer that doesn't pass any argument. and then create an array of that type.
Example:
program test_func_array
implicit none
type pp
procedure(func) ,pointer ,nopass :: f =>null()
end type pp
interface
function func(x)
real :: func
real, intent (in) :: x
end function func
end interface
type(pp) :: func_array(4)
func_array(1)%f => exp
func_array(2)%f => tan
func_array(3)%f => cos
func_array(4)%f => sin
print*,func_array(1)%f(1.)
print*,func_array(2)%f(1.)
print*,func_array(3)%f(0.)
print*,func_array(4)%f(0.)
end program test_func_array