Commit c26ba8e72d0d3149d72c43e9405f825014e80dcd

Authored by wdaniau
1 parent d55dcfb5ae

Added a timing test between besrj and bsjn

git-svn-id: https://lxsd.femto-st.fr/svn/fvn@62 b657c933-2333-4658-acf2-d3c7c2708721

Showing 6 changed files with 62 additions and 1 deletions Side-by-side Diff

... ... @@ -5,7 +5,7 @@
5 5 test_det$(exext) test_matcon$(exext) test_matev$(exext) test_sparse$(exext) test_inter1d$(exext) \
6 6 test_inter2d$(exext) test_inter3d$(exext) test_akima$(exext) test_lsp$(exext) test_muller$(exext) \
7 7 test_integ$(exext) test_bsyn$(exext) test_bsjn$(exext) test_bskn$(exext) test_bsin$(exext) test_operators$(exext) test_ze1$(exext) \
8   -test_dbesri$(exext) test_dbesrj$(exext)
  8 +test_besri$(exext) test_besrj$(exext) test_bestime$(exext)
9 9  
10 10 prog:$(programs)
11 11  
fvn_test/test_besri.f90
  1 +program test_dbesri
  2 +use fvn_fnlib
  3 +implicit none
  4 +! Variables locales -----------------------------
  5 +integer :: i,n,nstep,norder
  6 +real(kind=dp_kind), dimension(:), allocatable :: bessvec0
  7 +real(kind=dp_kind), dimension(:,:), allocatable:: bessvec1,bessvec2
  8 +real(kind=dp_kind) :: x,xstep,xmax
  9 +
  10 +
  11 +open (unit=1, file='dbesri.dat')
  12 +write (1,*) '# n, x, bsin(n,x), b(n) in dbesri(x,norder+1,b)'
  13 +write (1,*) '# arg x from 0 to 20, 201 points'
  14 +write (1,*) '# order n from 0 to 20'
  15 +
  16 +norder = 20
  17 +nstep = 200
  18 +xmax=20.d0
  19 +xstep=xmax/nstep
  20 +allocate(bessvec1(0:nstep,0:norder),bessvec2(0:nstep,0:norder))
  21 +allocate(bessvec0(0:norder))
  22 +
  23 +do i=0,nstep !loop on x
  24 + x=i*xstep
  25 + call dbesri(x,norder+1,bessvec0)
  26 + bessvec2(i,:)=bessvec0
  27 + do n=0,norder !loop on rank, for dbesjn only
  28 + bessvec1(i,n)=bsin(n,x)
  29 + enddo
  30 +enddo
  31 +
  32 +do n=0,norder
  33 + do i=0,nstep
  34 + x=i*xstep
  35 + write (1,*) n,x,bessvec1(i,n), bessvec2(i,n)
  36 + enddo
  37 + write(1,*)
  38 +enddo
  39 +
  40 +close(1)
  41 +deallocate(bessvec0,bessvec1,bessvec2)
  42 +
  43 +END
fvn_test/test_besrj.f90
  1 +program test_dbesrj
  2 +use fvn_fnlib
  3 +implicit none
  4 +! Variables locales -----------------------------
  5 +integer :: i,n,nstep,norder
  6 +real(kind=dp_kind), dimension(:), allocatable :: bessvec0
  7 +real(kind=dp_kind), dimension(:,:), allocatable:: bessvec1,bessvec2
  8 +real(kind=dp_kind) :: x,xstep,xmax
  9 +
  10 +
  11 +open (unit=1, file='dbesrj.dat')
  12 +write (1,*) '# n, x, bsjn(n,x), b(n) in dbesrj(x,norder+1,b)'
  13 +write (1,*) '# arg x from 0 to 50, 501 points'
  14 +write (1,*) '# order n from 0 to 50'
  15 +
  16 +norder = 50
  17 +nstep = 500
  18 +xmax=50.d0
  19 +xstep=xmax/nstep
  20 +allocate(bessvec1(0:nstep,0:norder),bessvec2(0:nstep,0:norder))
  21 +allocate(bessvec0(0:norder))
  22 +
  23 +do i=0,nstep !loop on x
  24 + x=i*xstep
  25 + call dbesrj(x,norder+1,bessvec0)
  26 + bessvec2(i,:)=bessvec0
  27 + do n=0,norder !loop on rank, for dbesjn only
  28 + bessvec1(i,n)=bsjn(n,x)
  29 + enddo
  30 +enddo
  31 +
  32 +do n=0,norder
  33 + do i=0,nstep
  34 + x=i*xstep
  35 + write (1,*) n,x,bessvec1(i,n), bessvec2(i,n)
  36 + enddo
  37 + write(1,*)
  38 +enddo
  39 +
  40 +close(1)
  41 +deallocate(bessvec0,bessvec1,bessvec2)
  42 +
  43 +END
fvn_test/test_bestime.f90
  1 +program bestime
  2 +use fvn_fnlib
  3 +implicit none
  4 +
  5 +real(kind=dp_kind) :: x,xmin,xmax,xstep,t1,t2,bes,b(51)
  6 +integer(kind=ip_kind) :: npoints,iter,n,i,it,nn
  7 +
  8 +
  9 +iter=10000
  10 +n=10
  11 +npoints=200
  12 +xmin=-50.
  13 +xmax=50.
  14 +xstep=(xmax-xmin)/dble(npoints)
  15 +
  16 +write(*,*) "Computation time comparison between bsjn and besrj"
  17 +write(*,*) "bsjn is faster when computing J_n for only one value of n"
  18 +write(*,*) "besrj is faster when computing J_n for n=0 to n"
  19 +
  20 +call cpu_time(t1)
  21 +do it=1,iter
  22 + do i=1,npoints
  23 + x=xmin+i*xstep
  24 + do nn=0,n
  25 + bes=bsjn(nn,x)
  26 + end do
  27 + end do
  28 +end do
  29 +call cpu_time(t2)
  30 +write (*,'("Calculating "(I10)" values of J_n for n=0 to "(I3)" with bsjn :")') iter*npoints,n
  31 +write(*,*) t2-t1
  32 +
  33 +call cpu_time(t1)
  34 +do it=1,iter
  35 + do i=1,npoints
  36 + x=xmin+i*xstep
  37 + bes=bsjn(n,x)
  38 + end do
  39 +end do
  40 +call cpu_time(t2)
  41 +write (*,'("Calculating "(I10)" values of J_n for n="(I3)" with bsjn :")') iter*npoints,n
  42 +write(*,*) t2-t1
  43 +
  44 +
  45 +! Calcultate J_n(x) on 200 points for n=0 to 50 with besrj
  46 +! do it iter times to have a sufficient time value
  47 +call cpu_time(t1)
  48 +do it=1,iter
  49 + do i=1,npoints
  50 + x=xmin+i*xstep
  51 + call besrj(x,n+1,b)
  52 + end do
  53 +end do
  54 +call cpu_time(t2)
  55 +write (*,'("Calculating "(I10)" values of J_n for n=0 to "(I3)" with besrj :")') iter*npoints,n
  56 +write(*,*) t2-t1
  57 +
  58 +
  59 +
  60 +
  61 +end program bestime
fvn_test/test_dbesri.f90
1   -program test_dbesri
2   -use fvn_fnlib
3   -implicit none
4   -! Variables locales -----------------------------
5   -integer :: i,n,nstep,norder
6   -real(kind=dp_kind), dimension(:), allocatable :: bessvec0
7   -real(kind=dp_kind), dimension(:,:), allocatable:: bessvec1,bessvec2
8   -real(kind=dp_kind) :: x,xstep,xmax
9   -
10   -
11   -open (unit=1, file='dbesri.dat')
12   -write (1,*) '# n, x, bsin(n,x), b(n) in dbesri(x,norder+1,b)'
13   -write (1,*) '# arg x from 0 to 20, 201 points'
14   -write (1,*) '# order n from 0 to 20'
15   -
16   -norder = 20
17   -nstep = 200
18   -xmax=20.d0
19   -xstep=xmax/nstep
20   -allocate(bessvec1(0:nstep,0:norder),bessvec2(0:nstep,0:norder))
21   -allocate(bessvec0(0:norder))
22   -
23   -do i=0,nstep !loop on x
24   - x=i*xstep
25   - call dbesri(x,norder+1,bessvec0)
26   - bessvec2(i,:)=bessvec0
27   - do n=0,norder !loop on rank, for dbesjn only
28   - bessvec1(i,n)=bsin(n,x)
29   - enddo
30   -enddo
31   -
32   -do n=0,norder
33   - do i=0,nstep
34   - x=i*xstep
35   - write (1,*) n,x,bessvec1(i,n), bessvec2(i,n)
36   - enddo
37   - write(1,*)
38   -enddo
39   -
40   -close(1)
41   -deallocate(bessvec0,bessvec1,bessvec2)
42   -
43   -END
fvn_test/test_dbesrj.f90
1   -program test_dbesrj
2   -use fvn_fnlib
3   -implicit none
4   -! Variables locales -----------------------------
5   -integer :: i,n,nstep,norder
6   -real(kind=dp_kind), dimension(:), allocatable :: bessvec0
7   -real(kind=dp_kind), dimension(:,:), allocatable:: bessvec1,bessvec2
8   -real(kind=dp_kind) :: x,xstep,xmax
9   -
10   -
11   -open (unit=1, file='dbesrj.dat')
12   -write (1,*) '# n, x, bsjn(n,x), b(n) in dbesrj(x,norder+1,b)'
13   -write (1,*) '# arg x from 0 to 50, 501 points'
14   -write (1,*) '# order n from 0 to 50'
15   -
16   -norder = 50
17   -nstep = 500
18   -xmax=50.d0
19   -xstep=xmax/nstep
20   -allocate(bessvec1(0:nstep,0:norder),bessvec2(0:nstep,0:norder))
21   -allocate(bessvec0(0:norder))
22   -
23   -do i=0,nstep !loop on x
24   - x=i*xstep
25   - call dbesrj(x,norder+1,bessvec0)
26   - bessvec2(i,:)=bessvec0
27   - do n=0,norder !loop on rank, for dbesjn only
28   - bessvec1(i,n)=bsjn(n,x)
29   - enddo
30   -enddo
31   -
32   -do n=0,norder
33   - do i=0,nstep
34   - x=i*xstep
35   - write (1,*) n,x,bessvec1(i,n), bessvec2(i,n)
36   - enddo
37   - write(1,*)
38   -enddo
39   -
40   -close(1)
41   -deallocate(bessvec0,bessvec1,bessvec2)
42   -
43   -END