Function pointer arrays in Fortran

Posted by Eduardo Dobay on Stack Overflow See other posts from Stack Overflow or by Eduardo Dobay
Published on 2010-03-26T03:59:57Z Indexed on 2010/03/26 4:03 UTC
Read the original article Hit count: 351

Filed under:
|
|

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.)

© Stack Overflow or respective owner

Related posts about function-pointers

Related posts about arrays