Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using the forward finite difference method.
Type | Intent | Optional | Attributes | Name | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
private impure function f(z) result(fz)Arguments
Return Value real(kind=rk)scalar function |
||||||||||||||||||||
real(kind=rk), | intent(in) | :: | x |
scalar variable |
||||||||||||||||
real(kind=rk), | intent(in) | :: | h |
perturbation for finite difference methods |
derivative of w.r.t.
impure function finite_difference_forward_T0_T0(f, x, h) result(dfdx) real(rk), intent(in) :: x !! scalar variable real(rk), intent(in) :: h !! perturbation for finite difference methods real(rk) :: dfdx !! derivative of \(f\) w.r.t. \(x\) interface !! scalar-valued function to differentiate impure function f(z) result(fz) use kinds real(rk), intent(in) :: z !! scalar variable real(rk) :: fz !! scalar function end function f end interface dfdx = (f(x+h) - f(x)) / h end function finite_difference_forward_T0_T0