Octopus
gauss_legendre.F90
Go to the documentation of this file.
1!! Copyright (C) 2006 Hyllios
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use global_oct_m
23 use, intrinsic :: iso_fortran_env
24
25 implicit none
26
27 private
28 public :: &
30
31
32 ! 2 point
33 real(real64), target :: GL_points_2(1) = (/ &
34 -0.57735026919_real64 /)
35 real(real64), target :: GL_weights_2(1) = (/ &
36 m_one /)
37
38 ! 3 point
39 real(real64), target :: GL_points_3(2) = (/ &
40 -0.774596669241_real64, m_zero /)
41 real(real64), target :: GL_weights_3(2) = (/ &
42 0.555555555556_real64, 0.888888888889_real64 /)
43
44 ! 4 point
45 real(real64), target :: GL_points_4(2) = (/ &
46 -0.861136311594_real64, -0.339981043585_real64 /)
47 real(real64), target :: GL_weights_4(2) = (/ &
48 0.347854845137_real64, 0.652145154863_real64 /)
49
50 ! 5 point
51 real(real64), target :: GL_points_5(3) = (/ &
52 -0.906179845939_real64, -0.538469310106_real64, m_zero /)
53 real(real64), target :: GL_weights_5(3) = (/ &
54 0.236926885056_real64, 0.478628670499_real64, 0.568888888889_real64 /)
55
56 ! 6 point
57 real(real64), target :: GL_points_6(3) = (/ &
58 -0.932469514203_real64, -0.661209386466_real64, -0.238619186083_real64 /)
59 real(real64), target :: GL_weights_6(3) = (/ &
60 0.171324492379_real64, 0.360761573048_real64, 0.467913934573_real64 /)
61
62 ! 7 point
63 real(real64), target :: GL_points_7(4) = (/ &
64 -0.949107912343_real64, -0.741531185599_real64, -0.405845151377_real64, &
65 m_zero /)
66 real(real64), target :: GL_weights_7(4) = (/ &
67 0.129484966169_real64, 0.279705391489_real64, 0.381830050505_real64, &
68 0.417959183673_real64 /)
69
70 ! 8 point
71 real(real64), target :: GL_points_8(4) = (/ &
72 -0.960289856498_real64, -0.796666477414_real64, -0.525532409916_real64, &
73 -0.183434642496_real64 /)
74 real(real64), target :: GL_weights_8(4) = (/ &
75 0.10122853629_real64, 0.222381034453_real64, 0.313706645878_real64, &
76 0.362683783378_real64 /)
77
78 ! 9 point
79 real(real64), target :: GL_points_9(5) = (/ &
80 -0.968160239508_real64, -0.836031107327_real64, -0.613371432701_real64, &
81 -0.324253423404_real64, m_zero /)
82 real(real64), target :: GL_weights_9(5) = (/ &
83 0.0812743883616_real64, 0.180648160695_real64, 0.260610696403_real64, &
84 0.31234707704_real64, 0.330239355001_real64 /)
85
86 ! 10 point
87 real(real64), target :: GL_points_10(5) = (/ &
88 -0.973906528517_real64, -0.865063366689_real64, -0.679409568299_real64, &
89 -0.433395394129_real64, -0.148874338982_real64 /)
90 real(real64), target :: GL_weights_10(5) = (/ &
91 0.0666713443087_real64, 0.149451349151_real64, 0.219086362516_real64, &
92 0.26926671931_real64, 0.295524224715_real64 /)
93
94 ! 11 point
95 real(real64), target :: GL_points_11(6) = (/ &
96 -0.978228658146_real64, -0.887062599768_real64, -0.730152005574_real64, &
97 -0.519096129207_real64, -0.269543155952_real64, m_zero /)
98 real(real64), target :: GL_weights_11(6) = (/ &
99 0.0556685671162_real64, 0.125580369465_real64, 0.186290210928_real64, &
100 0.233193764592_real64, 0.26280454451_real64, 0.272925086778_real64 /)
101
102 ! 12 point
103 real(real64), target :: GL_points_12(6) = (/ &
104 -0.981560634247_real64, -0.90411725637_real64, -0.769902674194_real64, &
105 -0.587317954287_real64, -0.367831498998_real64, -0.125233408511_real64 /)
106 real(real64), target :: GL_weights_12(6) = (/ &
107 0.0471753363866_real64, 0.106939325995_real64, 0.160078328543_real64, &
108 0.203167426723_real64, 0.233492536538_real64, 0.249147045813_real64 /)
109
110contains
111
112 ! --------------------------------------------------------------------
113 subroutine gauss_legendre_points(n, points, weights)
114 integer, intent(in) :: n
115 real(real64), intent(out) :: points(:)
116 real(real64), intent(out) :: weights(:)
117
118 integer :: i
119
120 real(real64), pointer :: points_ref(:), weights_ref(:)
121
122 nullify(points_ref)
123 nullify(weights_ref)
124
125 assert(n >= 2.and.n <= 12)
126 select case (n)
127 case (2)
128 points_ref => gl_points_2
129 weights_ref => gl_weights_2
130 case (3)
131 points_ref => gl_points_3
132 weights_ref => gl_weights_3
133 case (4)
134 points_ref => gl_points_4
135 weights_ref => gl_weights_4
136 case (5)
137 points_ref => gl_points_5
138 weights_ref => gl_weights_5
139 case (6)
140 points_ref => gl_points_6
141 weights_ref => gl_weights_6
142 case (7)
143 points_ref => gl_points_7
144 weights_ref => gl_weights_7
145 case (8)
146 points_ref => gl_points_8
147 weights_ref => gl_weights_8
148 case (9)
149 points_ref => gl_points_9
150 weights_ref => gl_weights_9
151 case (10)
152 points_ref => gl_points_10
153 weights_ref => gl_weights_10
154 case (11)
155 points_ref => gl_points_11
156 weights_ref => gl_weights_11
157 case (12)
158 points_ref => gl_points_12
159 weights_ref => gl_weights_12
160 end select
161
162 do i = 1, n/2
163 points(i) = points_ref(i)
164 points(n-i+1) = -points_ref(i)
165 weights(i) = weights_ref(i)
166 weights(n-i+1) = weights_ref(i)
167 end do
168 if (mod(n, 2) == 1) then
169 points(n/2 + 1) = points_ref(n/2 + 1)
170 weights(n/2 + 1) = weights_ref(n/2 + 1)
171 end if
173 end subroutine gauss_legendre_points
174
176
177!! Local Variables:
178!! mode: f90
179!! coding: utf-8
180!! End:
subroutine, public gauss_legendre_points(n, points, weights)
real(real64), parameter, public m_zero
Definition: global.F90:187
real(real64), parameter, public m_one
Definition: global.F90:188