3 #include "sll_memory.h"
4 #include "sll_working_precision.h"
21 sll_real64,
dimension(:),
allocatable :: x
23 sll_int32 :: maxmode = 10
24 sll_comp64,
dimension(:),
allocatable :: fmodes
30 print *,
"Test for small number of particles"
32 sll_clear_allocate(x(1:npart), ierr)
33 call random_number(x);
37 sll_allocate(fmodes(1:maxmode), ierr)
38 fmodes = (0.0_f64, 0.0_f64)
70 sll_deallocate_array(fmodes, ierr)
72 sll_deallocate_array(x, ierr)
109 sll_comp64,
intent(out),
dimension(:):: fmodes
110 sll_int32,
intent(in):: maxmode
111 sll_real64,
dimension(:),
intent(in) :: x
113 do fmode = 1, maxmode
114 fmodes(fmode) = sum(exp(-
sll_p_i1*fmode*x))
119 sll_comp64,
intent(out),
dimension(:):: fmodes
120 sll_int32,
intent(in):: maxmode
121 sll_real64,
dimension(:),
intent(in) :: x
122 sll_comp64,
dimension(size(x)) :: modeone
125 do fmode = 1, maxmode
126 fmodes(fmode) = sum(modeone**fmode)
131 sll_comp64,
intent(out),
dimension(:):: fmodes
132 sll_int32,
intent(in):: maxmode
133 sll_real64,
dimension(:),
intent(in) :: x
134 sll_int32,
intent(in):: chunksize
135 sll_int32 :: numx, chunk
136 sll_comp64,
dimension(maxmode):: fmodes_chunk
139 do chunk = 1, numx/chunksize
140 call calc_modes_fast(maxmode, fmodes_chunk, x((chunk - 1)*chunksize + 1:chunk*chunksize))
141 fmodes = fmodes + fmodes_chunk;
146 sll_comp64,
intent(out),
dimension(:):: fmodes
147 sll_int32,
intent(in):: maxmode
148 sll_real64,
dimension(:),
intent(in) :: x
149 sll_comp64,
dimension(size(x)) :: modeone
150 sll_comp64,
dimension(size(x)) :: mode
154 do fmode = 1, maxmode
156 fmodes(fmode) = sum(mode)
161 sll_comp64,
intent(out),
dimension(:):: fmodes
162 sll_int32,
intent(in):: maxmode
163 sll_real64,
dimension(:),
intent(in) :: x
164 sll_int32,
intent(in):: chunksize
165 sll_int32 :: numx, chunk
166 sll_comp64,
dimension(maxmode):: fmodes_chunk
169 do chunk = 1, numx/chunksize
170 call calc_modes_fast2(maxmode, fmodes_chunk, x((chunk - 1)*chunksize + 1:chunk*chunksize))
171 fmodes = fmodes + fmodes_chunk;
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
complex(kind=f64), parameter, public sll_p_i1
We can now use the functions.
subroutine, public sll_s_set_time_mark(timer_obj)
reads time parameters from system and stores in its argument. param timer_obj an object of type sll_t...
real(kind=f64) function, public sll_f_time_elapsed_between(t0, t1)
Computes the time elapsed between two time marks.
program particle_fourier_modes_test
subroutine calc_modes_fast2(maxmode, fmodes, x)
subroutine calc_modes_fast2_chunked(maxmode, fmodes, x, chunksize)
subroutine calc_modes_std(maxmode, fmodes, x)
subroutine calc_modes_fast(maxmode, fmodes, x)
subroutine calc_modes_fast_chunked(maxmode, fmodes, x, chunksize)
type use for clock reading