afivo-streamer 1.1
1D/2D/3D streamer simulations with AMR
Loading...
Searching...
No Matches
test_lookup_table_index.f90
Go to the documentation of this file.
3
4 implicit none
5 integer, parameter :: dp = kind(0.0d0)
6 integer, parameter :: n_points = 1024
7 integer, parameter :: n_samples = 2**20
8 real(dp), allocatable :: x(:)
9 integer :: n, k
10 type(lt_t) :: lt(3)
11 type(lt_loc_t) :: loc
12
13 lt(1) = lt_create(0.0_dp, 1.0_dp, n_points, n_cols=0, &
14 xspacing=lt_xspacing_linear)
15 lt(2) = lt_create(0.0_dp, 1.0_dp, n_points, n_cols=0, &
16 xspacing=lt_xspacing_quadratic)
17 lt(3) = lt_create(0.0_dp, 1.0_dp, n_points, n_cols=0, &
18 xspacing=lt_xspacing_cubic)
19
20 allocate(x(n_samples))
21 call random_number(x)
22
23 do k = 1, 3
24 do n = 1, n_samples
25 loc = lt_get_loc(lt(k), x(n))
26
27 ! Check if xa <= x <= xb
28 if (x(n) < lt(k)%x(loc%low_ix) .or. x(n) > lt(k)%x(loc%low_ix+1)) then
29 print *, "For table with xspacing of order", k
30 print *, lt(k)%x(loc%low_ix), x(n), lt(k)%x(loc%low_ix+1)
31 error stop "FAIL (should have xa <= x <= xb)"
32 end if
33 end do
34 end do
35
36 print *, "PASS"
37
A Fortran 90 module for creating lookup tables. These tables can be used to efficiently interpolate o...
type(lt_t) function, public lt_create(x_min, x_max, n_points, n_cols, xspacing, extrapolate_above)
This function returns a new lookup table.
integer, parameter, public lt_xspacing_cubic
integer, parameter, public lt_xspacing_linear
integer, parameter, public lt_xspacing_quadratic
elemental type(lt_loc_t) function, public lt_get_loc(my_lt, x)
Get a location in the lookup table.
Type to indicate a location in the lookup table, which can be used to speed up multiple lookups of di...
The lookup table type. There can be one or more columns, for which values can be looked up for a give...
program test_lookup_table_index