test5 Program

Uses

  • program~~test5~~UsesGraph program~test5 test5 forunittest forunittest program~test5->forunittest module~fordiff fordiff program~test5->module~fordiff module~mod_func5 mod_func5 program~test5->module~mod_func5 kinds kinds module~fordiff->kinds module~mod_func5->kinds

Calls

program~~test5~~CallsGraph program~test5 test5 check check program~test5->check interface~derivative fordiff::derivative program~test5->interface~derivative proc~complex_step_derivative_t0_t0 fordiff::complex_step_derivative_T0_T0 interface~derivative->proc~complex_step_derivative_t0_t0 proc~complex_step_derivative_t0_t1 fordiff::complex_step_derivative_T0_T1 interface~derivative->proc~complex_step_derivative_t0_t1 proc~complex_step_derivative_t1_t1 fordiff::complex_step_derivative_T1_T1 interface~derivative->proc~complex_step_derivative_t1_t1 proc~finite_difference_t0_t0 fordiff::finite_difference_T0_T0 interface~derivative->proc~finite_difference_t0_t0 proc~finite_difference_t0_t1 fordiff::finite_difference_T0_T1 interface~derivative->proc~finite_difference_t0_t1 proc~finite_difference_t1_t1 fordiff::finite_difference_T1_T1 interface~derivative->proc~finite_difference_t1_t1 proc~finite_difference_backward_t0_t0 fordiff::finite_difference_backward_T0_T0 proc~finite_difference_t0_t0->proc~finite_difference_backward_t0_t0 proc~finite_difference_central_t0_t0 fordiff::finite_difference_central_T0_T0 proc~finite_difference_t0_t0->proc~finite_difference_central_t0_t0 proc~finite_difference_forward_t0_t0 fordiff::finite_difference_forward_T0_T0 proc~finite_difference_t0_t0->proc~finite_difference_forward_t0_t0 proc~finite_difference_backward_t0_t1 fordiff::finite_difference_backward_T0_T1 proc~finite_difference_t0_t1->proc~finite_difference_backward_t0_t1 proc~finite_difference_central_t0_t1 fordiff::finite_difference_central_T0_T1 proc~finite_difference_t0_t1->proc~finite_difference_central_t0_t1 proc~finite_difference_forward_t0_t1 fordiff::finite_difference_forward_T0_T1 proc~finite_difference_t0_t1->proc~finite_difference_forward_t0_t1 proc~finite_difference_backward_t1_t1 fordiff::finite_difference_backward_T1_T1 proc~finite_difference_t1_t1->proc~finite_difference_backward_t1_t1 proc~finite_difference_central_t1_t1 fordiff::finite_difference_central_T1_T1 proc~finite_difference_t1_t1->proc~finite_difference_central_t1_t1 proc~finite_difference_forward_t1_t1 fordiff::finite_difference_forward_T1_T1 proc~finite_difference_t1_t1->proc~finite_difference_forward_t1_t1

Variables

Type Attributes Name Initial
real(kind=rk), dimension(:), allocatable :: dfdx_f
real(kind=rk), dimension(:), allocatable :: dfdx_b
real(kind=rk), dimension(:), allocatable :: dfdx_c
real(kind=rk), dimension(:), allocatable :: expected_dfdx
integer :: i
type(unit_test) :: ut

Source Code

program test5

   use fordiff
   use mod_func5
   use forunittest

   implicit none

   real(rk), dimension(:), allocatable :: dfdx_f, dfdx_b, dfdx_c, expected_dfdx
   integer                             :: i
   type(unit_test) :: ut

   dfdx_f = derivative(f=func5, x=[1.0_rk, -1.0_rk], h=1e-5_rk, method='forward')

   dfdx_b = derivative(f=func5, x=[1.0_rk, -1.0_rk], h=1e-5_rk, method='backward')

   dfdx_c = derivative(f=func5, x=[1.0_rk, -1.0_rk], h=1e-5_rk, method='central')

   ! compute reference derivative
   allocate(expected_dfdx(size(dfdx_f)))
   expected_dfdx(1) = 2.0_rk*(1.0_rk)
   expected_dfdx(2) = 1.0_rk*(-1.0_rk)

   ! check if derivative is correct
   call ut%check(dfdx_f, expected_dfdx, 1.0e-2_rk, 'test5.1' )
   call ut%check(dfdx_b, expected_dfdx, 1.0e-2_rk, 'test5.1' )
   call ut%check(dfdx_c, expected_dfdx, 1.0e-2_rk, 'test5.1' )

   deallocate(dfdx_f, dfdx_b, dfdx_c, expected_dfdx)

end program test5