MOM6
polynomial_functions Module Reference

Functions/Subroutines

real function, public evaluation_polynomial (coefficients, nb_coefficients, x)
 
real function, public integration_polynomial (xi0, xi1, C, n)
 

Function/Subroutine Documentation

◆ evaluation_polynomial()

real function, public polynomial_functions::evaluation_polynomial ( real, dimension(:), intent(in)  coefficients,
integer, intent(in)  nb_coefficients,
real, intent(in)  x 
)

Definition at line 26 of file polynomial_functions.F90.

Referenced by regrid_edge_slopes::edge_slopes_implicit_h3(), regrid_edge_slopes::edge_slopes_implicit_h5(), regrid_edge_values::edge_values_explicit_h4(), regrid_edge_values::edge_values_implicit_h4(), and regrid_edge_values::edge_values_implicit_h6().

26 ! -----------------------------------------------------------------------------
27 ! The polynomial is defined by the coefficients contained in the
28 ! array of the same name, as follows: C(1) + C(2)x + C(3)x^2 + C(4)x^3 + ...
29 ! where C refers to the array 'coefficients'.
30 ! The number of coefficients is given by nb_coefficients and x
31 ! is the coordinate where the polynomial is to be evaluated.
32 !
33 ! The function returns the value of the polynomial at x.
34 ! -----------------------------------------------------------------------------
35 
36  ! Arguments
37  real, dimension(:), intent(in) :: coefficients
38  integer, intent(in) :: nb_coefficients
39  real, intent(in) :: x
40 
41  ! Local variables
42  integer :: k
43  real :: f ! value of polynomial at x
44 
45  f = 0.0
46  do k = 1,nb_coefficients
47  f = f + coefficients(k) * ( x**(k-1) )
48  end do
49 
50  evaluation_polynomial = f
51 
Here is the caller graph for this function:

◆ integration_polynomial()

real function, public polynomial_functions::integration_polynomial ( real, intent(in)  xi0,
real, intent(in)  xi1,
real, dimension(:), intent(in)  C,
integer, intent(in)  n 
)

Definition at line 58 of file polynomial_functions.F90.

58 ! -----------------------------------------------------------------------------
59 ! Exact integration of a polynomial of degree n over the interval [xi0,xi1].
60 ! The array of coefficients (C) must be of size n+1, where n is the degree of
61 ! the polynomial to integrate.
62 ! -----------------------------------------------------------------------------
63 
64  ! Arguments
65  real, intent(in) :: xi0, xi1
66  real, dimension(:), intent(in) :: c
67  integer, intent(in) :: n
68 
69  ! Local variables
70  integer :: k
71  real :: integral
72 
73  integral = 0.0
74 
75  do k = 1,(n+1)
76  integral = integral + c(k) * (xi1**k - xi0**k) / real(k)
77  end do
78 !
79 !One non-answer-changing way of unrolling the above is:
80 ! k=1
81 ! integral = integral + C(k) * (xi1**k - xi0**k) / real(k)
82 ! if (n>=1) then
83 ! k=2
84 ! integral = integral + C(k) * (xi1**k - xi0**k) / real(k)
85 ! endif
86 ! if (n>=2) then
87 ! k=3
88 ! integral = integral + C(k) * (xi1**k - xi0**k) / real(k)
89 ! endif
90 ! if (n>=3) then
91 ! k=4
92 ! integral = integral + C(k) * (xi1**k - xi0**k) / real(k)
93 ! endif
94 ! if (n>=4) then
95 ! k=5
96 ! integral = integral + C(k) * (xi1**k - xi0**k) / real(k)
97 ! endif
98 !
99  integration_polynomial = integral
100