Function pointer arrays in Fortran
- by Eduardo Dobay
I can create function pointers in Fortran 90, with code like
real, external :: f
and then use f as an argument to another function/subroutine. But what if I want an array of function pointers? In C I would just do
double (*f[])(int);
to create an array of functions returning double and taking an integer argument. I tried the most obvious,
real, external, dimension(3) :: f
but gfortran doesn't let me mix EXTERNAL and DIMENSION. Is there any way to do what I want? (The context for this is a program for solving a system of differential equations, so I could input the equations without having a million parameters in my subroutines.)