20 #include "sll_memory.h"
21 #include "sll_assert.h"
22 #include "sll_working_precision.h"
40 use sll_m_remapper,
only: &
41 sll_o_apply_remap_2d, &
42 sll_o_compute_local_sizes, &
43 sll_o_get_layout_collective, &
44 sll_o_initialize_layout_with_distributed_array, &
46 sll_o_local_to_global, &
47 sll_f_new_layout_2d, &
48 sll_o_new_remap_plan, &
49 sll_t_remap_plan_2d_comp64, &
80 type(sll_t_layout_2d),
pointer :: layout_seq_x1
81 type(sll_t_layout_2d),
pointer :: layout_seq_x2
82 sll_int32 :: seq_x1_local_sz_x1
83 sll_int32 :: seq_x1_local_sz_x2
84 sll_int32 :: seq_x2_local_sz_x1
85 sll_int32 :: seq_x2_local_sz_x2
86 sll_comp64,
dimension(:, :),
pointer :: fft_x_array
87 sll_comp64,
dimension(:, :),
pointer :: fft_y_array
88 type(sll_t_remap_plan_2d_comp64),
pointer :: rmp_xy
89 type(sll_t_remap_plan_2d_comp64),
pointer :: rmp_yx
90 sll_comp64,
pointer :: tmp_x(:)
91 sll_comp64,
pointer :: tmp_y(:)
109 type(sll_t_layout_2d),
pointer :: start_layout
121 sll_int32 :: loc_sz_x1
122 sll_int32 :: loc_sz_x2
125 collective => sll_o_get_layout_collective(start_layout)
130 print *,
'This test needs to run with numbers of cells which are', &
132 print *,
'Exiting...'
144 plan%layout_seq_x1 => start_layout
145 call sll_o_compute_local_sizes( &
146 plan%layout_seq_x1, &
150 plan%seq_x1_local_sz_x1 = loc_sz_x1
151 plan%seq_x1_local_sz_x2 = loc_sz_x2
153 sll_allocate(plan%fft_x_array(loc_sz_x1, loc_sz_x2), ierr)
154 sll_allocate(plan%tmp_x(ncx), ierr)
160 plan%tmp_x, plan%tmp_x, &
166 plan%tmp_x, plan%tmp_x, &
170 plan%layout_seq_x2 => sll_f_new_layout_2d(collective)
171 nprocx1 = int(colsz, kind=4)
174 call sll_o_initialize_layout_with_distributed_array( &
181 call sll_o_compute_local_sizes( &
182 plan%layout_seq_x2, &
186 plan%seq_x2_local_sz_x1 = loc_sz_x1
187 plan%seq_x2_local_sz_x2 = loc_sz_x2
188 sll_allocate(plan%fft_y_array(loc_sz_x1, loc_sz_x2), ierr)
190 sll_allocate(plan%tmp_y(ncy), ierr)
197 plan%tmp_y, plan%tmp_y, &
203 plan%tmp_y, plan%tmp_y, &
207 sll_o_new_remap_plan(plan%layout_seq_x1, plan%layout_seq_x2, plan%fft_x_array)
209 sll_o_new_remap_plan(plan%layout_seq_x2, plan%layout_seq_x1, plan%fft_y_array)
216 sll_real64,
dimension(:, :) :: rho
217 sll_real64,
dimension(:, :) :: phi
224 sll_real64 :: r_lx, r_ly
226 sll_real64 :: normalization
227 type(sll_t_layout_2d),
pointer :: layout_x
228 type(sll_t_layout_2d),
pointer :: layout_y
229 sll_int32,
dimension(1:2) :: global
234 r_lx = 1.0_f64/plan%Lx
235 r_ly = 1.0_f64/plan%Ly
239 layout_x => plan%layout_seq_x1
240 layout_y => plan%layout_seq_x2
244 npx_loc = plan%seq_x1_local_sz_x1
245 npy_loc = plan%seq_x1_local_sz_x2
248 plan%fft_x_array = cmplx(rho, 0.0_f64, kind=f64)
252 plan%fft_x_array(1:ncx, j) = plan%tmp_x
255 npx_loc = plan%seq_x2_local_sz_x1
256 npy_loc = plan%seq_x2_local_sz_x2
258 call sll_o_apply_remap_2d(plan%rmp_xy, plan%fft_x_array, plan%fft_y_array)
261 plan%tmp_y = plan%fft_y_array(i, 1:ncy)
266 normalization = 1.0_f64/real(ncx*ncy, f64)
269 do j = 1, npy_loc - 1
270 do i = 1, npx_loc - 1
276 global = sll_o_local_to_global(layout_y, (/i, j/))
280 if ((gi == 1) .and. (gj == 1))
then
281 plan%fft_y_array(1, 1) = (0.0_f64, 0.0_f64)
283 kx = real(gi - 1, f64)
284 ky = real(gj - 1, f64)
293 if (kx .ge. ncx/2)
then
297 if (ky .ge. ncy/2)
then
301 plan%fft_y_array(i, j) = -plan%fft_y_array(i, j)/ &
302 (((kx*r_lx)**2 + (ky*r_ly)**2)*4.0_f64*
sll_p_pi**2)
309 plan%tmp_y = plan%fft_y_array(i, 1:ncy)
318 plan%fft_y_array(:, npy_loc) = plan%fft_y_array(:, 1)
321 call sll_o_apply_remap_2d(plan%rmp_yx, plan%fft_y_array, plan%fft_x_array)
323 npx_loc = plan%seq_x1_local_sz_x1
324 npy_loc = plan%seq_x1_local_sz_x2
328 plan%fft_x_array(1:ncx, j) = plan%tmp_x
332 plan%fft_x_array(npx_loc, :) = plan%fft_x_array(1, :)
334 phi(1:npx_loc, 1:npy_loc) = real(plan%fft_x_array(1:npx_loc, 1:npy_loc), f64)
336 phi = phi*normalization
355 type(sll_t_layout_2d),
pointer :: start_layout
366 sll_int32 :: loc_sz_x1
367 sll_int32 :: loc_sz_x2
370 collective => sll_o_get_layout_collective(start_layout)
384 plan%layout_seq_x1 => start_layout
385 call sll_o_compute_local_sizes( &
386 plan%layout_seq_x1, &
390 plan%seq_x1_local_sz_x1 = loc_sz_x1
391 plan%seq_x1_local_sz_x2 = loc_sz_x2
393 sll_allocate(plan%fft_x_array(loc_sz_x1, loc_sz_x2), ierr)
395 allocate (plan%tmp_x(ncx))
411 plan%layout_seq_x2 => sll_f_new_layout_2d(collective)
412 nprocx1 = int(colsz, kind=4)
415 call sll_o_initialize_layout_with_distributed_array( &
422 call sll_o_compute_local_sizes( &
423 plan%layout_seq_x2, &
427 plan%seq_x2_local_sz_x1 = loc_sz_x1
428 plan%seq_x2_local_sz_x2 = ncy
429 sll_allocate(plan%fft_y_array(loc_sz_x1, loc_sz_x2), ierr)
433 allocate (plan%tmp_y(ncy))
449 sll_o_new_remap_plan(plan%layout_seq_x1, plan%layout_seq_x2, plan%fft_x_array)
451 sll_o_new_remap_plan(plan%layout_seq_x2, plan%layout_seq_x1, plan%fft_y_array)
460 sll_real64,
dimension(:, :) :: rho
461 sll_real64,
dimension(:, :) :: phi
468 sll_real64 :: r_lx, r_ly
470 sll_real64 :: normalization
471 type(sll_t_layout_2d),
pointer :: layout_x
472 type(sll_t_layout_2d),
pointer :: layout_y
473 sll_int32,
dimension(1:2) :: global
478 r_lx = 1.0_f64/plan%Lx
479 r_ly = 1.0_f64/plan%Ly
483 layout_x => plan%layout_seq_x1
484 layout_y => plan%layout_seq_x2
488 npx_loc = plan%seq_x1_local_sz_x1
489 npy_loc = plan%seq_x1_local_sz_x2
492 plan%fft_x_array = cmplx(rho, 0.0_f64, kind=f64)
496 plan%fft_x_array(:, j) = plan%tmp_x
499 npx_loc = plan%seq_x2_local_sz_x1
500 npy_loc = plan%seq_x2_local_sz_x2
502 call sll_o_apply_remap_2d(plan%rmp_xy, plan%fft_x_array, plan%fft_y_array)
505 plan%tmp_y = plan%fft_y_array(i, :)
510 normalization = 1.0_f64/real(ncx*ncy, f64)
520 global = sll_o_local_to_global(layout_y, (/i, j/))
524 if ((gi == 1) .and. (gj == 1))
then
525 plan%fft_y_array(1, 1) = (0.0_f64, 0.0_f64)
527 kx = real(gi - 1, f64)
528 ky = real(gj - 1, f64)
537 if (kx .ge. ncx/2)
then
541 if (ky .ge. ncy/2)
then
545 plan%fft_y_array(i, j) = -plan%fft_y_array(i, j)/ &
546 (((kx*r_lx)**2 + (ky*r_ly)**2)*4.0_f64*
sll_p_pi**2)
553 plan%tmp_y = plan%fft_y_array(i, :)
558 call sll_o_apply_remap_2d(plan%rmp_yx, plan%fft_y_array, plan%fft_x_array)
560 npx_loc = plan%seq_x1_local_sz_x1
561 npy_loc = plan%seq_x1_local_sz_x2
565 plan%fft_x_array(:, j) = plan%tmp_x
568 phi = real(plan%fft_x_array, f64)*normalization
582 call sll_o_delete(plan%layout_seq_x1)
583 call sll_o_delete(plan%layout_seq_x2)
584 sll_deallocate_array(plan%fft_x_array, ierr)
585 sll_deallocate_array(plan%fft_y_array, ierr)
586 call sll_o_delete(plan%rmp_xy)
587 call sll_o_delete(plan%rmp_yx)
integer(kind=i32) function, public sll_f_get_collective_rank(col)
Determines the rank of the calling process in the communicator.
integer(kind=i32) function, public sll_f_get_collective_size(col)
Determines the size of the group associated with a communicator.
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine, public sll_s_fft_free(plan)
Delete a plan.
integer, parameter, public sll_p_fft_forward
Flag to specify forward FFT (negative sign) [value -1].
subroutine, public sll_s_fft_exec_c2c_1d(plan, array_in, array_out)
Compute fast Fourier transform in complex to complex mode.
subroutine, public sll_s_fft_init_c2c_1d(plan, nx, array_in, array_out, direction, normalized, aligned, optimization)
Create new 1d complex to complex plan.
integer, parameter, public sll_p_fft_backward
Flag to specify backward FFT (positive sign) [value 1].
Selalib periodic 2D poisson solver for cartesian coordinates.
subroutine, public sll_s_poisson_2d_periodic_par_solve_alt(plan, rho, phi)
Note that the equation that is solved is: Thus the user is responsible for giving the proper sign to...
subroutine, public sll_s_poisson_2d_periodic_par_solve(plan, rho, phi)
Note that the equation that is solved is: Thus the user is responsible for giving the proper sign to...
subroutine, public sll_s_poisson_2d_periodic_par_free(plan)
Delete the Poisson solver object.
subroutine, public sll_s_poisson_2d_periodic_par_init(plan, start_layout, ncx, ncy, Lx, Ly)
Presently, this function receives the geometric information as individual arguments....
subroutine, public sll_s_poisson_2d_periodic_par_init_alt(plan, start_layout, ncx, ncy, Lx, Ly)
Presently, this function receives the geometric information as individual arguments....
Some common numerical utilities.
logical function, public sll_f_is_power_of_two(n)
Check if an integer is equal to.
Wrapper around the communicator.
Type for FFT plan in SeLaLib.
Structure to store data from Poisson solver. This solver is parallel on structured cartesian mesh....