Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_lagrange_interpolation_1d_fast.F90
Go to the documentation of this file.
1 
16 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 #include "sll_working_precision.h"
18 #include "sll_errors.h"
19  implicit none
20 
21  public :: &
30 
31  private
32 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 
34  ! --- compile-time constants to avoid run-time division
35  sll_real64, parameter :: inv_6 = 1._f64/6._f64
36  sll_real64, parameter :: inv_12 = 1._f64/12._f64
37  sll_real64, parameter :: inv_24 = 1._f64/24._f64
38  sll_real64, parameter :: inv_36 = 1._f64/36._f64
39  sll_real64, parameter :: inv_48 = 1._f64/48._f64
40  sll_real64, parameter :: inv_120 = 1._f64/120._f64
41  sll_real64, parameter :: inv_144 = 1._f64/144._f64
42  sll_real64, parameter :: inv_240 = 1._f64/240._f64
43  sll_real64, parameter :: inv_576 = 1._f64/576._f64
44  sll_real64, parameter :: inv_720 = 1._f64/720._f64
45  sll_real64, parameter :: inv_1440 = 1._f64/1440._f64
46  sll_real64, parameter :: inv_5040 = 1._f64/5040._f64
47  sll_real64, parameter :: inv_14400 = 1._f64/14400._f64
48  sll_real64, parameter :: inv_17280 = 1._f64/17280._f64
49  sll_real64, parameter :: inv_30240 = 1._f64/30240._f64
50  sll_real64, parameter :: inv_40320 = 1._f64/40320._f64
51  sll_real64, parameter :: inv_80640 = 1._f64/80640._f64
52  sll_real64, parameter :: inv_362880 = 1._f64/362880._f64
53  sll_real64, parameter :: inv_3628800 = 1._f64/3628800._f64
54 
55 contains
56 
57 ! Even order
59  subroutine lagr_4pt_coeff(pp, p)
60  sll_real64, intent(out) :: pp(4)
61  sll_real64, intent(in) :: p
62 
63  pp(1) = -p*(p - 1._f64)*(p - 2._f64)*inv_6
64  pp(2) = (p*p - 1._f64)*(p - 2._f64)*0.5_f64
65  pp(3) = -p*(p + 1._f64)*(p - 2._f64)*0.5_f64
66  pp(4) = p*(p*p - 1.0_f64)*inv_6
67  end subroutine
68 
69 !------------------------------------------------------------------------------!
71  function lagr_4pt(fm1, f0, f1, f2, p)
72  sll_real64 :: lagr_4pt
73  sll_real64, intent(in) :: fm1
74  sll_real64, intent(in) :: f0
75  sll_real64, intent(in) :: f1
76  sll_real64, intent(in) :: f2
77  sll_real64, intent(in) :: p
78  sll_real64 :: pp(4)
79 
80 !DIR$ FORCEINLINE
81  call lagr_4pt_coeff(pp, p)
82  lagr_4pt = pp(1)*fm1 &
83  + pp(2)*f0 &
84  + pp(3)*f1 &
85  + pp(4)*f2
86  end function lagr_4pt
87 
88 !------------------------------------------------------------------------------!
90  subroutine lagr_4pt_vec(fi, fp, p, index_shift)
91  sll_real64, intent(in) :: fi(:)
92  sll_real64, intent(out) :: fp(:)
93  sll_real64, intent(in) :: p
94  sll_int32, intent(in) :: index_shift
95  sll_real64 :: pp(4)
96  sll_int32 :: i, n
97 
98 !DIR$ FORCEINLINE
99  call lagr_4pt_coeff(pp, p)
100  n = size(fi)
101  do i = max(2 - index_shift, 1), min(n - 2 - index_shift, n)
102  fp(i) = pp(1)*fi(i - 1 + index_shift) &
103  + pp(2)*fi(i + index_shift) &
104  + pp(3)*fi(i + 1 + index_shift) &
105  + pp(4)*fi(i + 2 + index_shift)
106  end do
107  end subroutine lagr_4pt_vec
108 
110  subroutine lagr_6pt_coeff(pp, p)
111  sll_real64, intent(out) :: pp(6)
112  sll_real64, intent(in) :: p
113 
114  pp(1) = -p*(p*p - 1._f64)*(p - 2._f64)*(p - 3._f64)*inv_120
115  pp(2) = p*(p - 1._f64)*(p*p - 4._f64)*(p - 3._f64)*inv_24
116  pp(3) = -(p*p - 1._f64)*(p*p - 4._f64)*(p - 3._f64)*inv_12
117  pp(4) = p*(p + 1._f64)*(p*p - 4._f64)*(p - 3._f64)*inv_12
118  pp(5) = -p*(p*p - 1._f64)*(p + 2._f64)*(p - 3.0_f64)*inv_24
119  pp(6) = p*(p*p - 1._f64)*(p*p - 4._f64)*inv_120
120 
121  end subroutine
122 
123 !------------------------------------------------------------------------------!
125  function lagr_6pt(fm2, fm1, f0, f1, f2, f3, p)
126  sll_real64 :: lagr_6pt
127  sll_real64, intent(in) :: fm2
128  sll_real64, intent(in) :: fm1
129  sll_real64, intent(in) :: f0
130  sll_real64, intent(in) :: f1
131  sll_real64, intent(in) :: f2
132  sll_real64, intent(in) :: f3
133  sll_real64, intent(in) :: p
134  sll_real64 :: pp(6)
135 
136 !DIR$ FORCEINLINE
137  call lagr_6pt_coeff(pp, p)
138  lagr_6pt = pp(1)*fm2 &
139  + pp(2)*fm1 &
140  + pp(3)*f0 &
141  + pp(4)*f1 &
142  + pp(5)*f2 &
143  + pp(6)*f3
144  end function lagr_6pt
145 
146 !------------------------------------------------------------------------------!
148  subroutine lagr_6pt_vec(fi, fp, p, index_shift)
149  sll_real64, intent(in) :: fi(:)
150  sll_real64, intent(out) :: fp(:)
151  sll_real64, intent(in) :: p
152  sll_int32, intent(in) :: index_shift
153  sll_real64 :: pp(6)
154  sll_int32 :: i, n
155 
156 !DIR$ FORCEINLINE
157  call lagr_6pt_coeff(pp, p)
158  n = size(fi)
159  do i = max(3 - index_shift, 1), min(n - 3 - index_shift, n)
160  fp(i) = pp(1)*fi(i - 2 + index_shift) &
161  + pp(2)*fi(i - 1 + index_shift) &
162  + pp(3)*fi(i + index_shift) &
163  + pp(4)*fi(i + 1 + index_shift) &
164  + pp(5)*fi(i + 2 + index_shift) &
165  + pp(6)*fi(i + 3 + index_shift)
166  end do
167  end subroutine lagr_6pt_vec
168 
170  subroutine lagr_8pt_coeff(pp, p)
171  sll_real64, intent(out) :: pp(8)
172  sll_real64, intent(in) :: p
173 
174  pp(1) = -p*(p - 3)*(p - 4)*(p**2 - 4)*(p**2 - 1)*inv_5040
175  pp(2) = p*(p - 2)*(p - 4)*(p**2 - 9)*(p**2 - 1)*inv_720
176  pp(3) = -p*(p - 1)*(p - 4)*(p**2 - 9)*(p**2 - 4)*inv_240
177  pp(4) = (p - 4)*(p**2 - 9)*(p**2 - 4)*(p**2 - 1)*inv_144
178  pp(5) = -(p + 1)*p*(p - 4)*(p**2 - 9)*(p**2 - 4)*inv_144
179  pp(6) = (p + 2)*p*(p - 4)*(p**2 - 9)*(p**2 - 1)*inv_240
180  pp(7) = -(p + 3)*p*(p - 4)*(p**2 - 4)*(p**2 - 1)*inv_720
181  pp(8) = p*(p**2 - 9)*(p**2 - 4)*(p**2 - 1)*inv_5040
182  end subroutine
183 !------------------------------------------------------------------------------!
185  function lagr_8pt(fm3, fm2, fm1, f0, f1, f2, f3, f4, p)
186  sll_real64 :: lagr_8pt
187  sll_real64, intent(in) :: fm3
188  sll_real64, intent(in) :: fm2
189  sll_real64, intent(in) :: fm1
190  sll_real64, intent(in) :: f0
191  sll_real64, intent(in) :: f1
192  sll_real64, intent(in) :: f2
193  sll_real64, intent(in) :: f3
194  sll_real64, intent(in) :: f4
195  sll_real64, intent(in) :: p
196  sll_real64 :: pp(8)
197 
198 !DIR$ FORCEINLINE
199  call lagr_8pt_coeff(pp, p)
200  lagr_8pt = pp(1)*fm3 &
201  + pp(2)*fm2 &
202  + pp(3)*fm1 &
203  + pp(4)*f0 &
204  + pp(5)*f1 &
205  + pp(6)*f2 &
206  + pp(7)*f3 &
207  + pp(8)*f4
208  end function lagr_8pt
209 
210 !------------------------------------------------------------------------------!
212  subroutine lagr_8pt_vec(fi, fp, p, index_shift)
213  sll_real64, intent(in) :: fi(:)
214  sll_real64, intent(out) :: fp(:)
215  sll_real64, intent(in) :: p
216  sll_int32, intent(in) :: index_shift
217  sll_real64 :: pp(8)
218  sll_int32 :: i, n
219 
220 !DIR$ FORCEINLINE
221  call lagr_8pt_coeff(pp, p)
222  n = size(fi)
223  do i = max(4 - index_shift, 1), min(n - 4 - index_shift, n)
224  fp(i) = pp(1)*fi(i - 3 + index_shift) &
225  + pp(2)*fi(i - 2 + index_shift) &
226  + pp(3)*fi(i - 1 + index_shift) &
227  + pp(4)*fi(i + index_shift) &
228  + pp(5)*fi(i + 1 + index_shift) &
229  + pp(6)*fi(i + 2 + index_shift) &
230  + pp(7)*fi(i + 3 + index_shift) &
231  + pp(8)*fi(i + 4 + index_shift)
232  end do
233  end subroutine lagr_8pt_vec
234 
235 ! --- Odd order --- !
236 
237 !------------------------------------------------------------------------------!
239  subroutine lagr_3pt_coeff(pp, p)
240  sll_real64, intent(out) :: pp(3)
241  sll_real64, intent(in) :: p
242 
243  pp(1) = p*(p - 1._f64)*0.5_f64
244  pp(2) = 1._f64 - p*p
245  pp(3) = p*(p + 1._f64)*0.5_f64
246  end subroutine
247 
248 !------------------------------------------------------------------------------!
250  function lagr_3pt(fm1, f0, f1, p)
251  sll_real64 :: lagr_3pt
252  sll_real64, intent(in) :: fm1
253  sll_real64, intent(in) :: f0
254  sll_real64, intent(in) :: f1
255  sll_real64, intent(in) :: p
256  sll_real64 :: pp(3)
257 
258 !DIR$ FORCEINLINE
259  call lagr_3pt_coeff(pp, p)
260  lagr_3pt = pp(1)*fm1 &
261  + pp(2)*f0 &
262  + pp(3)*f1
263  end function lagr_3pt
264 
265 !------------------------------------------------------------------------------!
267  subroutine lagr_3pt_vec(fi, fp, p)
268  sll_real64, intent(in) :: fi(:)
269  sll_real64, intent(out) :: fp(:)
270  sll_real64, intent(in) :: p
271  sll_real64 :: pp(3)
272  sll_int32 :: i, n
273 
274 !DIR$ FORCEINLINE
275  call lagr_3pt_coeff(pp, p)
276  n = size(fi)
277  do i = 2, n - 1
278  fp(i) = pp(1)*fi(i - 1) &
279  + pp(2)*fi(i) &
280  + pp(3)*fi(i + 1)
281  end do
282  end subroutine lagr_3pt_vec
283 
284 !------------------------------------------------------------------------------!
286  subroutine lagr_5pt_coeff(pp, p)
287  sll_real64, intent(out) :: pp(5)
288  sll_real64, intent(in) :: p
289 
290  pp(1) = (p*p - 1._f64)*p*(p - 2._f64)*inv_24
291  pp(2) = -(p - 1._f64)*p*(p*p - 4._f64)*inv_6
292  pp(3) = (p*p - 1._f64)*(p*p - 4._f64)*0.25_f64
293  pp(4) = -(p + 1._f64)*p*(p*p - 4._f64)*inv_6
294  pp(5) = (p*p - 1._f64)*p*(p + 2._f64)*inv_24
295  end subroutine
296 
297 !------------------------------------------------------------------------------!
299  function lagr_5pt(fm2, fm1, f0, f1, f2, p)
300  sll_real64 :: lagr_5pt
301  sll_real64, intent(in) :: fm2
302  sll_real64, intent(in) :: fm1
303  sll_real64, intent(in) :: f0
304  sll_real64, intent(in) :: f1
305  sll_real64, intent(in) :: f2
306  sll_real64, intent(in) :: p
307  sll_real64 :: pp(5)
308 
309 !DIR$ FORCEINLINE
310  call lagr_5pt_coeff(pp, p)
311  lagr_5pt = pp(1)*fm2 &
312  + pp(2)*fm1 &
313  + pp(3)*f0 &
314  + pp(4)*f1 &
315  + pp(5)*f2
316  end function lagr_5pt
317 
318 !------------------------------------------------------------------------------!
320  subroutine lagr_5pt_vec(fi, fp, p)
321  sll_real64, intent(in) :: fi(:)
322  sll_real64, intent(out) :: fp(:)
323  sll_real64, intent(in) :: p
324  sll_real64 :: pp(5)
325  sll_int32 :: i, n
326 
327 !DIR$ FORCEINLINE
328  call lagr_5pt_coeff(pp, p)
329  n = size(fi)
330  do i = 3, n - 2
331  fp(i) = pp(1)*fi(i - 2) &
332  + pp(2)*fi(i - 1) &
333  + pp(3)*fi(i) &
334  + pp(4)*fi(i + 1) &
335  + pp(5)*fi(i + 2)
336  end do
337  end subroutine lagr_5pt_vec
338 
339 !------------------------------------------------------------------------------!
341  subroutine lagr_7pt_coeff(pp, p)
342  sll_real64, intent(out) :: pp(7)
343  sll_real64, intent(in) :: p
344 
345  pp(1) = p*(p - 3._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_720
346  pp(2) = -p*(p - 2._f64)*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_120
347  pp(3) = p*(p - 1._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_48
348  pp(4) = -(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_36
349  pp(5) = (p + 1._f64)*p*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_48
350  pp(6) = -(p + 2._f64)*p*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_120
351  pp(7) = (p + 3._f64)*p*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_720
352  end subroutine
353 
354 !------------------------------------------------------------------------------!
356  function lagr_7pt(fm3, fm2, fm1, f0, f1, f2, f3, p)
357  implicit none
358  sll_real64 :: lagr_7pt
359  sll_real64, intent(in) :: fm3
360  sll_real64, intent(in) :: fm2
361  sll_real64, intent(in) :: fm1
362  sll_real64, intent(in) :: f0
363  sll_real64, intent(in) :: f1
364  sll_real64, intent(in) :: f2
365  sll_real64, intent(in) :: f3
366  sll_real64, intent(in) :: p
367  sll_real64 :: pp(7)
368 
369 !DIR$ FORCEINLINE
370  call lagr_7pt_coeff(pp, p)
371  lagr_7pt = pp(1)*fm3 &
372  + pp(2)*fm2 &
373  + pp(3)*fm1 &
374  + pp(4)*f0 &
375  + pp(5)*f1 &
376  + pp(6)*f2 &
377  + pp(7)*f3
378  end function lagr_7pt
379 
380 !------------------------------------------------------------------------------!
382  subroutine lagr_7pt_vec(fi, fp, p)
383  sll_real64, intent(in) :: fi(:)
384  sll_real64, intent(out) :: fp(:)
385  sll_real64, intent(in) :: p
386  sll_real64 :: pp(7)
387  sll_int32 :: i, n
388 
389 !DIR$ FORCEINLINE
390  call lagr_7pt_coeff(pp, p)
391  n = size(fi)
392  do i = 4, n - 3
393  fp(i) = pp(1)*fi(i - 3) &
394  + pp(2)*fi(i - 2) &
395  + pp(3)*fi(i - 1) &
396  + pp(4)*fi(i) &
397  + pp(5)*fi(i + 1) &
398  + pp(6)*fi(i + 2) &
399  + pp(7)*fi(i + 3)
400  end do
401  end subroutine lagr_7pt_vec
402 
403 !------------------------------------------------------------------------------!
405  subroutine lagr_9pt_coeff(pp, p)
406  implicit none
407  sll_real64, intent(out) :: pp(9)
408  sll_real64, intent(in) :: p
409 
410  pp(1) = p*(p - 4._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_40320
411  pp(2) = -p*(p - 3._f64)*(p**2 - 16._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_5040
412  pp(3) = p*(p - 2._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_1440
413  pp(4) = -p*(p - 1._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_720
414  pp(5) = (p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_576
415  pp(6) = -(p + 1._f64)*p*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_720
416  pp(7) = (p + 2._f64)*p*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_1440
417  pp(8) = -(p + 3._f64)*p*(p**2 - 16._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_5040
418  pp(9) = (p + 4._f64)*p*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_40320
419  end subroutine
420 
421 !------------------------------------------------------------------------------!
423  function lagr_9pt(fm4, fm3, fm2, fm1, f0, f1, f2, f3, f4, p)
424  implicit none
425  sll_real64 :: lagr_9pt
426  sll_real64, intent(in) :: fm4
427  sll_real64, intent(in) :: fm3
428  sll_real64, intent(in) :: fm2
429  sll_real64, intent(in) :: fm1
430  sll_real64, intent(in) :: f0
431  sll_real64, intent(in) :: f1
432  sll_real64, intent(in) :: f2
433  sll_real64, intent(in) :: f3
434  sll_real64, intent(in) :: f4
435  sll_real64, intent(in) :: p
436  sll_real64 :: pp(9)
437 
438 !DIR$ FORCEINLINE
439  call lagr_9pt_coeff(pp, p)
440  lagr_9pt = pp(1)*fm4 &
441  + pp(2)*fm3 &
442  + pp(3)*fm2 &
443  + pp(4)*fm1 &
444  + pp(5)*f0 &
445  + pp(6)*f1 &
446  + pp(7)*f2 &
447  + pp(8)*f3 &
448  + pp(9)*f4
449  end function lagr_9pt
450 
451 !------------------------------------------------------------------------------!
453  subroutine lagr_9pt_vec(fi, fp, p)
454  sll_real64, intent(in) :: fi(:)
455  sll_real64, intent(out) :: fp(:)
456  sll_real64, intent(in) :: p
457  sll_real64 :: pp(9)
458  sll_int32 :: i, n
459 
460 !DIR$ FORCEINLINE
461  call lagr_9pt_coeff(pp, p)
462  n = size(fi)
463  do i = 5, n - 4
464  fp(i) = pp(1)*fi(i - 4) &
465  + pp(2)*fi(i - 3) &
466  + pp(3)*fi(i - 2) &
467  + pp(4)*fi(i - 1) &
468  + pp(5)*fi(i) &
469  + pp(6)*fi(i + 1) &
470  + pp(7)*fi(i + 2) &
471  + pp(8)*fi(i + 3) &
472  + pp(9)*fi(i + 4)
473  end do
474  end subroutine lagr_9pt_vec
475 
476 !------------------------------------------------------------------------------!
478  subroutine lagr_11pt_coeff(pp, p)
479  sll_real64, intent(out) :: pp(11)
480  sll_real64, intent(in) :: p
481 
482  ! generated using Maple
483  pp(1) = p*(p - 5._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_3628800
484  pp(2) = -p*(p - 4._f64)*(p**2 - 25._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_362880
485  pp(3) = p*(p - 3._f64)*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_80640
486  pp(4) = -p*(p - 2._f64)*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_30240
487  pp(5) = p*(p - 1._f64)*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_17280
488  pp(6) = -(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_14400
489  pp(7) = (p + 1._f64)*p*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*inv_17280
490  pp(8) = -(p + 2._f64)*p*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 1._f64)*inv_30240
491  pp(9) = (p + 3._f64)*p*(p**2 - 25._f64)*(p**2 - 16._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_80640
492  pp(10) = -(p + 4._f64)*p*(p**2 - 25._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_362880
493  pp(11) = (p + 5._f64)*p*(p**2 - 16._f64)*(p**2 - 9._f64)*(p**2 - 4._f64)*(p**2 - 1._f64)*inv_3628800
494  end subroutine
495 
496 !------------------------------------------------------------------------------!
498  function lagr_11pt(fm5, fm4, fm3, fm2, fm1, f0, f1, f2, f3, f4, f5, p)
499  implicit none
500  sll_real64 :: lagr_11pt
501  sll_real64, intent(in) :: fm5
502  sll_real64, intent(in) :: fm4
503  sll_real64, intent(in) :: fm3
504  sll_real64, intent(in) :: fm2
505  sll_real64, intent(in) :: fm1
506  sll_real64, intent(in) :: f0
507  sll_real64, intent(in) :: f1
508  sll_real64, intent(in) :: f2
509  sll_real64, intent(in) :: f3
510  sll_real64, intent(in) :: f4
511  sll_real64, intent(in) :: f5
512  sll_real64, intent(in) :: p
513  sll_real64 :: pp(11)
514 
515 !DIR$ FORCEINLINE
516  call lagr_11pt_coeff(pp, p)
517  lagr_11pt = pp(1)*fm5 &
518  + pp(2)*fm4 &
519  + pp(3)*fm3 &
520  + pp(4)*fm2 &
521  + pp(5)*fm1 &
522  + pp(6)*f0 &
523  + pp(7)*f1 &
524  + pp(8)*f2 &
525  + pp(9)*f3 &
526  + pp(10)*f4 &
527  + pp(11)*f5
528  end function lagr_11pt
529 
530 !------------------------------------------------------------------------------!
532  subroutine lagr_11pt_vec(fi, fp, p)
533  sll_real64, intent(in) :: fi(:)
534  sll_real64, intent(out) :: fp(:)
535  sll_real64, intent(in) :: p
536  sll_real64 :: pp(11)
537  sll_int32 :: i, n
538 
539 !DIR$ FORCEINLINE
540  call lagr_11pt_coeff(pp, p)
541  n = size(fi)
542  do i = 6, n - 5
543  fp(i) = pp(1)*fi(i - 5) &
544  + pp(2)*fi(i - 4) &
545  + pp(3)*fi(i - 3) &
546  + pp(4)*fi(i - 2) &
547  + pp(5)*fi(i - 1) &
548  + pp(6)*fi(i) &
549  + pp(7)*fi(i + 1) &
550  + pp(8)*fi(i + 2) &
551  + pp(9)*fi(i + 3) &
552  + pp(10)*fi(i + 4) &
553  + pp(11)*fi(i + 5)
554  end do
555  end subroutine lagr_11pt_vec
556 
557 !------------------------------------------------------------------------------!
563 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_fixed_no_bc
565  sll_real64, intent(in) :: fi(:)
566  sll_real64, intent(out) :: fp(:)
567  sll_real64, intent(in) :: p
568  sll_int32, intent(in) :: stencil
569  sll_int32 :: n, i
570  n = size(fi)
571 
572  select case (stencil)
573  case (5)
574  i = 1
575 !DIR$ FORCEINLINE
576  fp(i) = lagr_5pt(fi(i), fi(i + 1), fi(i + 2), fi(i + 3), fi(i + 4), p - 2.0_f64)
577  i = 2
578 !DIR$ FORCEINLINE
579  fp(i) = lagr_5pt(fi(i - 1), fi(i), fi(i + 1), fi(i + 2), fi(i + 3), p - 1.0_f64)
580 !DIR$ FORCEINLINE
581  call lagr_5pt_vec(fi, fp, p)
582  i = n - 1
583 !DIR$ FORCEINLINE
584  fp(i) = lagr_5pt(fi(i - 3), fi(i - 2), fi(i - 1), fi(i), fi(i + 1), p + 1.0_f64)
585  i = n
586 !DIR$ FORCEINLINE
587  fp(i) = lagr_5pt(fi(i - 4), fi(i - 3), fi(i - 2), fi(i - 1), fi(i), p + 2.0_f64)
588  case (3)
589  i = 1
590 !DIR$ FORCEINLINE
591  fp(i) = lagr_3pt(fi(i), fi(i + 1), fi(i + 2), p - 1.0_f64)
592 !DIR$ FORCEINLINE
593  call lagr_3pt_vec(fi, fp, p)
594  i = n
595 !DIR$ FORCEINLINE
596  fp(i) = lagr_3pt(fi(i - 2), fi(i - 1), fi(i), p + 1.0_f64)
597  case default
598  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_fixed_no_bc.', 'Lagrange stencil not implemented.')
599  end select
601 
602 !------------------------------------------------------------------------------!
608 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodic
610  sll_real64, intent(in) :: fi(:)
611  sll_real64, intent(out) :: fp(:)
612  sll_real64, intent(in) :: p
613  sll_int32, intent(in) :: stencil
614  sll_int32 :: n
615 
616  n = size(fi)
617  select case (stencil)
618  case (7)
619 !DIR$ FORCEINLINE
620  fp(1) = lagr_7pt(fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), fi(3), fi(4), p)
621 !DIR$ FORCEINLINE
622  fp(2) = lagr_7pt(fi(n - 1), fi(n), fi(1), fi(2), fi(3), fi(4), fi(5), p)
623 !DIR$ FORCEINLINE
624  fp(3) = lagr_7pt(fi(n), fi(1), fi(2), fi(3), fi(4), fi(5), fi(6), p)
625 !DIR$ FORCEINLINE
626  call lagr_7pt_vec(fi, fp, p)
627 !DIR$ FORCEINLINE
628  fp(n - 2) = lagr_7pt(fi(n - 5), fi(n - 4), fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), p)
629 !DIR$ FORCEINLINE
630  fp(n - 1) = lagr_7pt(fi(n - 4), fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), p)
631 !DIR$ FORCEINLINE
632  fp(n) = lagr_7pt(fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), fi(3), p)
633  case (5)
634 !DIR$ FORCEINLINE
635  fp(1) = lagr_5pt(fi(n - 1), fi(n), fi(1), fi(2), fi(3), p)
636 !DIR$ FORCEINLINE
637  fp(2) = lagr_5pt(fi(n), fi(1), fi(2), fi(3), fi(4), p)
638 !DIR$ FORCEINLINE
639  call lagr_5pt_vec(fi, fp, p)
640 !DIR$ FORCEINLINE
641  fp(n - 1) = lagr_5pt(fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), p)
642 !DIR$ FORCEINLINE
643  fp(n) = lagr_5pt(fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), p)
644  case (3)
645 !DIR$ FORCEINLINE
646  fp(1) = lagr_3pt(fi(n), fi(1), fi(2), p)
647 !DIR$ FORCEINLINE
648  call lagr_3pt_vec(fi, fp, p)
649 !DIR$ FORCEINLINE
650  fp(n) = lagr_3pt(fi(n - 1), fi(n), fi(1), p)
651  case default
652  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodic.', 'Lagrange stencil not implemented.')
653  end select
655 
656 !------------------------------------------------------------------------------!
662 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodicl
664  sll_real64, intent(in) :: fi(:)
665  sll_real64, intent(out) :: fp(:)
666  sll_real64, intent(in) :: p
667  sll_int32, intent(in) :: stencil
668  sll_int32 :: n
669 
670  n = size(fi) - 1
671  select case (stencil)
672  case (7)
673 !DIR$ FORCEINLINE
674  fp(1) = lagr_7pt(fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), fi(3), fi(4), p)
675 !DIR$ FORCEINLINE
676  fp(2) = lagr_7pt(fi(n - 1), fi(n), fi(1), fi(2), fi(3), fi(4), fi(5), p)
677 !DIR$ FORCEINLINE
678  fp(3) = lagr_7pt(fi(n), fi(1), fi(2), fi(3), fi(4), fi(5), fi(6), p)
679 !DIR$ FORCEINLINE
680  call lagr_7pt_vec(fi, fp, p)
681 !DIR$ FORCEINLINE
682  fp(n - 1) = lagr_7pt(fi(n - 4), fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), p)
683 !DIR$ FORCEINLINE
684  fp(n) = lagr_7pt(fi(n - 3), fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), fi(3), p)
685  fp(n + 1) = fp(1)
686  case (5)
687 !DIR$ FORCEINLINE
688  fp(1) = lagr_5pt(fi(n - 1), fi(n), fi(1), fi(2), fi(3), p)
689 !DIR$ FORCEINLINE
690  fp(2) = lagr_5pt(fi(n), fi(1), fi(2), fi(3), fi(4), p)
691 !DIR$ FORCEINLINE
692  call lagr_5pt_vec(fi, fp, p)
693 !DIR$ FORCEINLINE
694  fp(n) = lagr_5pt(fi(n - 2), fi(n - 1), fi(n), fi(1), fi(2), p)
695  fp(n + 1) = fp(1)
696  case (3)
697 !DIR$ FORCEINLINE
698  fp(1) = lagr_3pt(fi(n), fi(1), fi(2), p)
699 !DIR$ FORCEINLINE
700  call lagr_3pt_vec(fi, fp, p)
701  fp(n + 1) = fp(1)
702  case default
703  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodicl.', 'Lagrange stencil not implemented.')
704  end select
706 
709 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_centered_periodicl
711  implicit none
712  sll_real64, intent(in) :: fi(:)
713  sll_real64, intent(out) :: fp(:)
714  sll_real64, intent(in) :: p
715  sll_int32, intent(in) :: stencil
716  sll_int32 :: n, i
717  sll_int32 :: pi
718  sll_real64 :: pq
719 
720  n = size(fi) - 1
721  ! compute interval shift
722  pi = floor(p)
723  pq = p - real(pi, f64)
724 
725  select case (stencil)
726  case (6)
727 !DIR$ FORCEINLINE
728  call lagr_6pt_vec(fi, fp, pq, pi)
729  do i = 1, max(0, 2 - pi)
730  fp(i) = lagr_6pt(fi(modulo(i - 3 + pi, n) + 1), &
731  fi(modulo(i - 2 + pi, n) + 1), &
732  fi(modulo(i + pi - 1, n) + 1), &
733  fi(modulo(i + pi, n) + 1), &
734  fi(modulo(i + 1 + pi, n) + 1), &
735  fi(modulo(i + 2 + pi, n) + 1), &
736  pq)
737  end do
738  do i = min(n, n - 2 - pi), n
739  fp(i) = lagr_6pt(fi(modulo(i - 3 + pi, n) + 1), &
740  fi(modulo(i - 2 + pi, n) + 1), &
741  fi(modulo(i + pi - 1, n) + 1), &
742  fi(modulo(i + pi, n) + 1), &
743  fi(modulo(i + 1 + pi, n) + 1), &
744  fi(modulo(i + 2 + pi, n) + 1), &
745  pq)
746  end do
747  fp(n + 1) = fp(1)
748  case (4)
749 !DIR$ FORCEINLINE
750  call lagr_4pt_vec(fi, fp, pq, pi)
751  do i = 1, max(0, 1 - pi)
752  fp(i) = lagr_4pt(fi(modulo(i - 2 + pi, n) + 1), &
753  fi(modulo(i + pi - 1, n) + 1), &
754  fi(modulo(i + pi, n) + 1), &
755  fi(modulo(i + 1 + pi, n) + 1), &
756  pq)
757  end do
758  do i = min(n, n - 1 - pi), n
759  fp(i) = lagr_4pt(fi(modulo(i - 2 + pi, n) + 1), &
760  fi(modulo(i + pi - 1, n) + 1), &
761  fi(modulo(i + pi, n) + 1), &
762  fi(modulo(i + 1 + pi, n) + 1), &
763  pq)
764  end do
765  fp(n + 1) = fp(1)
766  case default
767  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_centered_periodicl.', 'Lagrange stencil not implemented.')
768  end select
770 
771 !------------------------------------------------------------------------------!
782 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_fixed_haloc_cells
784  sll_real64, intent(in) :: fi(:)
785  sll_real64, intent(out) :: fp(:)
786  sll_real64, intent(in) :: p
787  sll_int32, intent(in) :: stencil
788 
789  select case (stencil)
790  case (7)
791 !DIR$ FORCEINLINE
792  call lagr_7pt_vec(fi, fp, p)
793  case (5)
794 !DIR$ FORCEINLINE
795  call lagr_5pt_vec(fi, fp, p)
796  case (9)
797 !DIR$ FORCEINLINE
798  call lagr_9pt_vec(fi, fp, p)
799  case (11)
800 !DIR$ FORCEINLINE
801  call lagr_11pt_vec(fi, fp, p)
802  case (3)
803 !DIR$ FORCEINLINE
804  call lagr_3pt_vec(fi, fp, p)
805  case default
806  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_fixed_haloc_cells.', 'Lagrange stencil not implemented.')
807  end select
809 
810 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_centered_halo_cells
812  implicit none
813  sll_real64, intent(in) :: fi(:)
814  sll_real64, intent(out) :: fp(:)
815  sll_real64, intent(in) :: p
816  sll_int32, intent(in) :: stencil
817  sll_int32 :: pi
818  sll_real64 :: pq
819 
820  ! Compute interval shift
821  pi = floor(p)
822  pq = p - real(pi, f64)
823 
824  select case (stencil)
825  case (6)
826 !DIR$ FORCEINLINE
827  call lagr_6pt_vec(fi, fp, pq, pi)
828  case (4)
829 !DIR$ FORCEINLINE
830  call lagr_4pt_vec(fi, fp, pq, pi)
831  case (8)
832 !DIR$ FORCEINLINE
833  call lagr_8pt_vec(fi, fp, pq, pi)
834  case default
835  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_centered_halo_cells.', 'Lagrange stencil not implemented.')
836  end select
838 
840 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_disp_even_halo_cells
842  implicit none
843  sll_real64, intent(in) :: fi(:)
844  sll_real64, intent(out) :: fp(:)
845  sll_real64, intent(in) :: p
846  sll_int32, intent(in) :: stencil
847 
848  select case (stencil)
849  case (6)
850 !DIR$ FORCEINLINE
851  call lagr_6pt_vec(fi, fp, p, 0)
852  case (4)
853 !DIR$ FORCEINLINE
854  call lagr_4pt_vec(fi, fp, p, 0)
855  case (8)
856 !DIR$ FORCEINLINE
857  call lagr_8pt_vec(fi, fp, p, 0)
858  case default
859  sll_error('sll_s_lagrange_interpolation_1d_fast_disp_even_halo_cells.', 'Lagrange stencil not implemented.')
860  end select
862 
863  !------------------------------------------------------------------------------!
875 !DIR$ ATTRIBUTES FORCEINLINE :: sll_s_lagrange_interpolation_1d_fast_haloc_cells
876  subroutine sll_s_lagrange_interpolation_1d_fast_haloc_cells(fi, fp, p, stencil, index_shift)
877  sll_real64, intent(in) :: fi(:)
878  sll_real64, intent(out) :: fp(:)
879  sll_real64, intent(in) :: p(:)
880  sll_int32, intent(in) :: stencil
881  sll_int32, intent(in) :: index_shift
882 
883  ! local variables
884  sll_int32 :: n, i
885 
886  n = size(fi)
887 
888  ! TODO: Add also the even values
889 
890  select case (stencil)
891  case (7)
892  do i = 1, n - 6
893  fp(i) = lagr_7pt(fi(i), fi(i + 1), fi(i + 2), fi(i + 3), fi(i + 4), fi(i + 5), fi(i + 6), p(i))
894  end do
895  case (5)
896  do i = 1, n - 4
897  fp(i) = lagr_5pt(fi(i), fi(i + 1), fi(i + 2), fi(i + 3), fi(i + 4), p(i))
898  end do
899  case (9)
900  do i = 1, n - 8
901  fp(i) = lagr_9pt(fi(i), fi(i + 1), fi(i + 2), fi(i + 3), fi(i + 4), fi(i + 5), fi(i + 6), fi(i + 7), fi(i + 8), p(i))
902  end do
903  case (11)
904  do i = 1, n - 10
905  fp(i) = lagr_11pt( fi(i), fi(i+1), fi(i+2), fi(i+3), fi(i+4), fi(i+5), fi(i+6), fi(i+7), fi(i+8), fi(i+9), fi(i+10), p(i) )
906  end do
907  case (3)
908  do i = 1, n - 2
909  fp(i) = lagr_3pt(fi(i), fi(i + 1), fi(i + 2), p(i))
910  end do
911  case default
912  sll_error('sll_s_lagrange_interpolation_1d_fast_haloc_cells.', 'Lagrange stencil not implemented.')
913  end select
915 
Module for 1D Lagrange interpolation on a uniform grid (only odd order)
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_fixed_no_bc(fi, fp, p, stencil)
Lagrange interpolation, without boundary conditions. One sided a the outermost points.
real(kind=f64) function lagr_11pt(fm5, fm4, fm3, fm2, fm1, f0, f1, f2, f3, f4, f5, p)
single point 11-pt-lagrange interpolation
subroutine lagr_11pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine lagr_4pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
real(kind=f64) function lagr_8pt(fm3, fm2, fm1, f0, f1, f2, f3, f4, p)
single point 8-pt-lagrange interpolation
real(kind=f64) function lagr_3pt(fm1, f0, f1, p)
single point 3-pt-lagrange interpolation
subroutine lagr_7pt_vec(fi, fp, p)
vectorizable 7-pt-lagrange interpolation
real(kind=f64) function lagr_6pt(fm2, fm1, f0, f1, f2, f3, p)
single point 6-pt-lagrange interpolation
subroutine lagr_5pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine lagr_11pt_vec(fi, fp, p)
vectorizable 11-pt-lagrange interpolation
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodicl(fi, fp, p, stencil)
Lagrange interpolation, periodic boundary conditions, first value repeated at the end.
subroutine lagr_5pt_vec(fi, fp, p)
vectorizable 5-pt-lagrange interpolation
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_even_halo_cells(fi, fp, p, stencil)
Even Lagrange interpolation with halo cells and no interval shift, i.e. p must be between zero and on...
subroutine lagr_9pt_vec(fi, fp, p)
vectorizable 9-pt-lagrange interpolation
subroutine lagr_9pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine lagr_6pt_vec(fi, fp, p, index_shift)
vectorizable 6-pt-lagrange interpolation
subroutine lagr_8pt_vec(fi, fp, p, index_shift)
vectorizable 6-pt-lagrange interpolation
real(kind=f64) function lagr_5pt(fm2, fm1, f0, f1, f2, p)
single point 5-pt-lagrange interpolation
subroutine lagr_8pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_centered_periodicl(fi, fp, p, stencil)
Lagrange interpolation centered around the interval of displacement, periodic boundary condtions,...
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_fixed_periodic(fi, fp, p, stencil)
Lagrange interpolation, periodic boundary conditions.
real(kind=f64) function lagr_9pt(fm4, fm3, fm2, fm1, f0, f1, f2, f3, f4, p)
single point 9-pt-lagrange interpolation
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_fixed_haloc_cells(fi, fp, p, stencil)
Lagrange interpolation with halo cell boundaries, where the input array already contains halo cells....
subroutine lagr_4pt_vec(fi, fp, p, index_shift)
vectorizable 4-pt-lagrange interpolation
subroutine, public sll_s_lagrange_interpolation_1d_fast_disp_centered_halo_cells(fi, fp, p, stencil)
real(kind=f64) function lagr_7pt(fm3, fm2, fm1, f0, f1, f2, f3, p)
single point 7-pt-lagrange interpolation
subroutine lagr_3pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine lagr_6pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine, public sll_s_lagrange_interpolation_1d_fast_haloc_cells(fi, fp, p, stencil, index_shift)
Lagrange interpolation with halo cell boundaries, where the input array already contains halo cells....
subroutine lagr_7pt_coeff(pp, p)
Compute coefficients for Lagrange interpolation for normalized displacement p.
subroutine lagr_3pt_vec(fi, fp, p)
vectorizable 3-pt-lagrange interpolation
real(kind=f64) function lagr_4pt(fm1, f0, f1, f2, p)
single point 4-pt-lagrange interpolation
    Report Typos and Errors