5 integer,
parameter :: dp = kind(0.0d0)
6 integer,
parameter :: in_size(2) = [53, 39]
7 integer,
parameter :: tbl_size(2) = [64, 8]
10 type(
lt2_t) :: lkp_tbl
11 real(dp) :: x1(in_size(1))
12 real(dp) :: x2(in_size(2))
13 real(dp) :: y_values(in_size(1), in_size(2))
14 real(dp) :: diff, mean_diff, xy(2)
16 print *,
'Start test_lookup_table_2d'
17 print *,
'Here, the input data has a different shape than the table,'
18 print *,
'so linear interpolation is used to create the 2D table.'
21 x1(i) = (i-1) * acos(-1.0_dp) / (in_size(1) - 1)
25 x2(i) = (i-1) * acos(-1.0_dp) / (in_size(2) - 1)
32 y_values(i, j) =
sol(x1(i), x2(j))
37 [x1(in_size(1)), x2(in_size(2))], tbl_size, 1)
44 diff = abs(y_values(i, j) - &
46 mean_diff = mean_diff + diff / product(in_size)
50 print *,
"Mean difference at input points: ", mean_diff
56 call random_number(xy)
57 xy = xy * acos(-1.0_dp)
58 diff = abs(
sol(xy(1), xy(2)) - &
60 mean_diff = mean_diff + diff / product(in_size)
64 print *,
"Mean difference at random points: ", mean_diff
68 real(dp) function
sol(x, y)
69 real(dp),
intent(in) :: x, y
70 sol = 2 * x**2 + 3 * y
A Fortran 90 module for creating lookup tables. These tables can be used to efficiently interpolate o...
pure real(dp) function, public lt2_get_col(my_lt, col_ix, x1, x2)
Get the value of a single column at x.
subroutine, public lt2_set_col(my_lt, col_ix, x1, x2, y)
Fill the column with index col_ix using linearly interpolated data.
type(lt2_t) function, public lt2_create(x_min, x_max, n_points, n_cols, xspacing)
This function returns a new lookup table.
The 2D lookup table type.
real(dp) function sol(x, y)