c_trapz_nonlin_func Function

function c_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 complex(kind=8)
real(kind=8), dimension(:) :: x

Return Value complex(kind=8)


Source Code

function c_trapz_nonlin_func(f,x) result(int)
  interface
     function f(x)
       real(8)    :: x
       complex(8) :: f
     end function f
  end interface
  real(8),dimension(:) :: x
  real(8)              :: dh
  integer              :: L,i
  complex(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 c_trapz_nonlin_func