Would be nice if the gradient and jacobian functions accepted an optional data parameter. The interface would look something like this:
abstract interface
function dependent_function (x, dat) result (fx)
import :: var
type(var), intent(in) :: x(:)
class(*), optional, intent(in) :: dat
type(var) :: fx
end function dependent_function
end interface