In fortran I have an external optimization routine that takes as an input the function f(x) and the starting point and returns the value for local minimum. For
You don't need anonymous functions for this. Your Matlab example is also not anonymous in the end, it has a name g.
Fortran internal functions are of great use here (Fortran 2008 feature, but supported in gfortran and ifort, not supported in Solaris Studio):
call minimum(g, x0, xopt)
contains
real function g(x)
real, intent(in) :: x
g = f(x,data)
end function
end