Suppose I have the following subroutine in Fortran
subroutine exec(routine) implicit none external :: routine real(kind=8) :: res call routine(2.0d0, res) print *, "Fortran Result: res = ", res end subroutine exec
This subroutine receives, as an argument, an external routine. Now, suppose that this routine is written in C, and that I need to call the Fortran routine exec from C as well. Just like this:
void op(double x, double *f) { *f = pow(x, 2); } void main() { exec_(op); }
I know that, if instead of passing an external subroutine I was passing an integer, or a double, or another conventional type, it would work, but this code returns segmentation fault. Is there any way to pass a parameter of type external from C to Fortran?