3 #include "sll_assert.h"
4 #include "sll_memory.h"
5 #include "sll_working_precision.h"
38 sll_real64,
dimension(:, :),
pointer :: buf
42 sll_real64,
dimension(:),
pointer :: w
48 sll_real64,
intent(in) :: iota
49 sll_int32,
intent(in) :: nc_x1
50 sll_int32,
intent(out) :: shift
51 sll_real64,
intent(out) :: iota_modif
53 shift = floor(iota*nc_x1 + 0.5)
54 iota_modif = real(shift, f64)/real(nc_x1, f64)
59 sll_int32,
intent(in) :: nc_x1
60 sll_int32,
intent(in) :: shift
61 sll_real64,
intent(out) :: iota_modif
63 iota_modif = real(shift, f64)/real(nc_x1, f64)
77 sll_real64,
dimension(:, :),
intent(in) :: f_input
78 sll_real64,
dimension(:, :),
intent(out) :: f_output
79 sll_int32,
intent(in) :: nc_x1
80 sll_int32,
intent(in) :: nc_x2
82 sll_real64,
intent(in) :: x1_min
83 sll_real64,
intent(in) :: x1_max
84 sll_real64,
intent(in) :: iota
88 sll_real64 :: delta_x1
89 a = iota*real(nc_x1, f64)/real(nc_x2, f64)
90 delta_x1 = (x1_max - x1_min)/real(nc_x1, f64)
93 call adv%advect_1d_constant( &
95 real(i - 1, f64)*delta_x1, &
96 f_input(1:nc_x1 + 1, i), &
97 f_output(1:nc_x1 + 1, i))
105 sll_int32,
intent(in) :: nc_x1
106 sll_int32,
intent(in) :: shift
107 sll_int32,
intent(out) :: spaghetti_size
114 i_loc = modulo(i*shift, nc_x1)
115 if (i_loc .ne. 0)
then
116 spaghetti_size = spaghetti_size + 1
132 spaghetti_size_guess, &
135 sll_int32,
intent(in) :: nc_x1
136 sll_int32,
intent(in) :: nc_x2
138 sll_real64,
intent(in) :: iota_guess
139 sll_int32,
intent(in) :: spaghetti_size_guess
140 sll_int32,
intent(out) :: shift
141 sll_int32,
intent(out) :: spaghetti_size
143 sll_int32 :: shift_guess
144 sll_int32 :: shift_plus
145 sll_int32 :: shift_minus
150 sll_int32 :: spaghetti_size_new
152 sll_assert(nc_x1 > 0)
153 sll_assert(nc_x2 > 0)
162 if (abs(spaghetti_size_guess - spaghetti_size) < abs(val))
then
163 val = spaghetti_size_guess - spaghetti_size
176 shift_guess = floor(iota_guess*nc_x1)
178 shift_plus = shift_guess
179 shift_minus = shift_guess
186 if (spaghetti_size_new .eq. spaghetti_size)
then
187 shift_plus = shift_guess + i
196 if (spaghetti_size_new .eq. spaghetti_size)
then
197 shift_minus = shift_guess - i
202 if (abs(shift_minus*nc_x1 - iota_guess) < abs(shift_plus*nc_x1 - iota_guess))
then
226 sll_int32,
intent(in) :: nc_x1
227 sll_int32,
intent(in) :: nc_x2
228 sll_int32,
intent(in) :: shift
229 sll_int32,
dimension(:),
intent(out) :: spaghetti_index
230 sll_int32,
intent(out) :: spaghetti_size
237 sll_int32,
dimension(:),
allocatable :: check
240 sll_assert(nc_x1 > 0)
241 sll_assert(nc_x2 > 0)
242 sll_allocate(check(nc_x1 + 1), ierr)
247 spaghetti_index(1) = 1
250 i_loc = modulo(i*shift, nc_x1)
251 if (i_loc .ne. 0)
then
252 spaghetti_size = spaghetti_size + 1
253 spaghetti_index(i + 1) = i_loc + 1
260 q = nc_x1/spaghetti_size
262 do ii = 1, spaghetti_size
263 spaghetti_index(ii + j*spaghetti_size) = modulo(spaghetti_index(ii) + j - 1, nc_x1) + 1
266 spaghetti_index(nc_x1 + 1) = spaghetti_index(1)
269 if (spaghetti_index(i) < 1)
then
270 print *,
'#problem with spaghetti_index'
273 if (spaghetti_index(i) > nc_x1 + 1)
then
274 print *,
'#problem with spaghetti_index'
277 check(spaghetti_index(i)) = check(spaghetti_index(i)) + 1
280 if (maxval(check(1:nc_x1)) .ne. 1)
then
281 print *,
'#problem checking spaghetti_index'
282 print *,
'#maxval=', maxval(check(1:nc_x1))
285 if (minval(check(1:nc_x1)) .ne. 1)
then
286 print *,
'#problem checking spaghetti_index'
287 print *,
'#minval=', minval(check(1:nc_x1))
300 sll_real64,
dimension(:, :),
intent(in) :: input
301 sll_real64,
dimension(:),
intent(out) :: output
302 sll_int32,
dimension(:),
intent(in) :: spaghetti_index
304 sll_int32,
intent(in) :: npts_x1
305 sll_int32,
intent(in) :: npts_x2
314 output(s) = input(spaghetti_index(i), j)
326 sll_real64,
dimension(:),
intent(in) :: input
327 sll_real64,
dimension(:, :),
intent(out) :: output
328 sll_int32,
dimension(:),
intent(in) :: spaghetti_index
330 sll_int32,
intent(in) :: npts_x1
331 sll_int32,
intent(in) :: npts_x2
340 output(spaghetti_index(i), j) = input(s)
356 sll_int32,
intent(in) :: degree
357 sll_real64,
intent(in) :: x1_min
358 sll_real64,
intent(in) :: x1_max
359 sll_real64,
intent(in) :: x2_min
360 sll_real64,
intent(in) :: x2_max
361 sll_int32,
intent(in) :: nc_x1
362 sll_int32,
intent(in) :: nc_x2
366 sll_allocate(res, ierr)
391 sll_int32,
intent(in) :: degree
392 sll_real64,
intent(in) :: x1_min
393 sll_real64,
intent(in) :: x1_max
394 sll_real64,
intent(in) :: x2_min
395 sll_real64,
intent(in) :: x2_max
396 sll_int32,
intent(in) :: nc_x1
397 sll_int32,
intent(in) :: nc_x2
401 deriv%degree = degree
406 sll_allocate(deriv%buf(1:nc_x2 + 2*degree + 1, 1:nc_x1 + 1), ierr)
407 sll_allocate(deriv%w(-degree:nc_x2 + degree), ierr)
414 sll_int32,
intent(in)::r, s
415 sll_real64,
dimension(r:s),
intent(out)::w
433 tmp = tmp*real(i - j, f64)
436 tmp = tmp*real(i - j, f64)
440 tmp = tmp*real(-j, f64)
443 tmp = tmp*real(-j, f64)
446 tmp = tmp*real(-j, f64)
454 tmp = tmp*real(i - j, f64)
457 tmp = tmp*real(i - j, f64)
461 tmp = tmp*real(-j, f64)
464 tmp = tmp*real(-j, f64)
467 tmp = tmp*real(-j, f64)
496 sll_real64,
dimension(:),
intent(in) :: input
497 sll_real64,
dimension(:),
intent(out) :: output
498 sll_int32,
intent(in) :: nc
499 sll_int32,
intent(in) :: r
500 sll_int32,
intent(in) :: s
501 sll_real64,
dimension(r:s),
intent(in) :: w
502 sll_real64,
intent(in) :: length
509 dx = length/real(nc, f64)
513 ind = modulo(i + ii - 1 + nc, nc) + 1
514 tmp = tmp + w(ii)*input(ind)
522 integer,
intent(in)::p
523 real(f64),
dimension(-p/2:(p + 1)/2),
intent(out)::w
552 tmp = tmp*real(i - j, f64)
555 tmp = tmp*real(i - j, f64)
559 tmp = tmp*real(-j, f64)
562 tmp = tmp*real(-j, f64)
565 tmp = tmp*real(-j, f64)
573 tmp = tmp*real(i - j, f64)
576 tmp = tmp*real(i - j, f64)
580 tmp = tmp*real(-j, f64)
583 tmp = tmp*real(-j, f64)
586 tmp = tmp*real(-j, f64)
Abstract class for advection.
Cartesian mesh basic types.
type(sll_t_cartesian_mesh_1d) function, pointer, public sll_f_new_cartesian_mesh_1d(num_cells, eta_min, eta_max)
allocates the memory space for a new 1D cartesian mesh on the heap, initializes it with the given arg...
subroutine, public sll_s_compute_derivative_periodic(input, output, Nc, w, r, s, length)
subroutine, public sll_s_unload_spaghetti(input, output, spaghetti_index, Npts_x1, Npts_x2)
subroutine, public sll_s_compute_spaghetti(Nc_x1, Nc_x2, shift, spaghetti_index, spaghetti_size)
subroutine compute_finite_difference_init(w, p)
subroutine, public sll_s_load_spaghetti(input, output, spaghetti_index, Npts_x1, Npts_x2)
subroutine, public sll_s_compute_spaghetti_size_from_shift(Nc_x1, shift, spaghetti_size)
subroutine, public sll_s_compute_spaghetti_and_shift_from_guess(Nc_x1, Nc_x2, iota_guess, spaghetti_size_guess, shift, spaghetti_size)
subroutine, public sll_s_compute_at_aligned(f_input, f_output, Nc_x1, Nc_x2, adv, x1_min, x1_max, iota)
subroutine, public sll_s_compute_oblic_shift(iota, Nc_x1, shift, iota_modif)
subroutine, public sll_s_compute_w_hermite(w, r, s)
subroutine, public sll_s_compute_iota_from_shift(Nc_x1, shift, iota_modif)
subroutine initialize_oblic_derivative(deriv, degree, x1_min, x1_max, x2_min, x2_max, Nc_x1, Nc_x2, adv)
type(sll_t_oblic_derivative) function, pointer, public sll_f_new_oblic_derivative(degree, x1_min, x1_max, x2_min, x2_max, Nc_x1, Nc_x2, adv)