Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_rectangle_integration.F90
Go to the documentation of this file.
1 
9 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 #include "sll_working_precision.h"
11 
12  implicit none
13 
14  public :: &
16 
17  private
18 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 
20 #ifndef DOXYGEN_SHOULD_SKIP_THIS
21  abstract interface
22 
23  function function_1d(x)
24  use sll_m_working_precision ! can't pass a header file because the
25  ! preprocessor prevents double inclusion.
26  ! This is very rare.
27  sll_real64 :: function_1d
28  sll_real64, intent(in) :: x
29  end function function_1d
30  end interface
31 #endif
32 
35  module procedure rectangle_integral_1d
36  end interface
37 
38 contains
39 
51  function rectangle_integral_1d(f, x, n)
52  sll_real64 :: rectangle_integral_1d
53  procedure(function_1d) :: f
54  sll_int32, intent(in) :: n
55  sll_real64, dimension(n) :: x
56  sll_int32 :: k
57  sll_real64 :: ans
58 
59  ans = 0.0_f64
60  do k = 1, n - 1
61  ans = ans + f(x(k))*(x(k + 1) - x(k))
62  end do
64 
65  end function rectangle_integral_1d
66 
72  function rectangle_weights(n, x) result(w)
73  sll_int32, intent(in) :: n
74  sll_real64, dimension(n) :: x
75  sll_real64, dimension(n) :: w
76  sll_int32 :: k
77 
78  do k = 1, n - 1
79  w(k) = x(k + 1) - x(k)
80  end do
81  w(n) = 0.0_f64
82 
83  end function rectangle_weights
84 
Integrate numerically with Gauss-Lobatto formula.
real(kind=f64) function, dimension(n) rectangle_weights(n, x)
Returns a 1d array of size (n) containing rectangle integration weights in the interval [x(1),...
real(kind=f64) function rectangle_integral_1d(f, x, n)
Integrate with rectangle formula.
Module to select the kind parameter.
    Report Typos and Errors