test_secant_solve Subroutine

public subroutine test_secant_solve()

Arguments

None

Contents

Source Code


Source Code

  subroutine test_secant_solve()
      real(dp) ::solution
      real(dp) ::residual
      logical::error
      !external:: f

      call  secant_solve(dummy,10.d0,30.0d0,solution,error,residual)
      if((abs(solution-24.7386)<0.001d0).and.(error.eqv..FALSE.).and.(abs(residual)<0.001d0))then
          write(*,*)"secant solve: PASS.  Error = ", solution-24.7386, ' residual = ', residual
      else
           write(*,*)"secant solve: FAIL. solution=", solution, 'error flag = ', error, "residual = ", residual
           write(*,*)"Correct solution should be 24.7386"
      end if

  contains
      function dummy(x)
          real(dp), intent(in) :: x
          real(dp) :: dummy
          dummy = x**2 - 612.d0
      end function
  end subroutine test_secant_solve