finite_difference_backward_T0_T0 Function

private impure function finite_difference_backward_T0_T0(f, x, h) result(dfdx)

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using the backward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: z

scalar variable

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

Return Value real(kind=rk)

derivative of w.r.t.


Called by

proc~~finite_difference_backward_t0_t0~~CalledByGraph proc~finite_difference_backward_t0_t0 fordiff::finite_difference_backward_T0_T0 proc~finite_difference_t0_t0 fordiff::finite_difference_T0_T0 proc~finite_difference_t0_t0->proc~finite_difference_backward_t0_t0 interface~derivative fordiff::derivative interface~derivative->proc~finite_difference_t0_t0 program~test1 test1 program~test1->interface~derivative program~test2 test2 program~test2->interface~derivative program~test3 test3 program~test3->interface~derivative program~test4 test4 program~test4->interface~derivative program~test5 test5 program~test5->interface~derivative program~test6 test6 program~test6->interface~derivative

Source Code

   impure function finite_difference_backward_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) - f(x-h)) / h

   end function finite_difference_backward_T0_T0