d_trapz_nonlin_func Function

function d_trapz_nonlin_func(f, x) result(int)

Arguments

Type IntentOptional Attributes Name
function f(x)
Arguments
Type IntentOptional Attributes Name
real(kind=8) :: x
Return Value real(kind=8)
real(kind=8), dimension(:) :: x

Return Value real(kind=8)


Source Code

function d_trapz_nonlin_func(f,x) result(int)
  interface
     function f(x)
       real(8) :: x
       real(8) :: f
     end function f
  end interface
  real(8),dimension(:) :: x
  real(8)              :: dh
  integer              :: L,i
  real(8)              :: int
  L  = size(x)
  !
  int=0.d0
  do i=1,L-1
     dh  = (x(i+1)-x(i))/2d0
     int = int + ( f(x(i+1)) + f(x(i)) )*dh
  enddo
end function d_trapz_nonlin_func