MPI-AMRVAC  3.1
The MPI - Adaptive Mesh Refinement - Versatile Advection Code
Data Types | Functions/Subroutines
mod_lookup_table Module Reference

A Fortran 90 module for creating 1D and 2D lookup tables. These tables can be used to efficiently interpolate one or more values. More...

Functions/Subroutines

pure integer function, public find_index_linear (list, val)
 Linear search of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1. More...
 
pure integer function, public find_index_bsearch (list, val)
 Binary search of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1. More...
 
pure integer function, public find_index_adaptive (list, val)
 Adaptive search (combination of linear and binary search) of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1. More...
 
type(lt_t) function, public lt_create (x_min, x_max, n_points, n_cols)
 This function returns a new lookup table. More...
 
type(lt_t) function, public lt_create_from_data (x_min, x_max, spaced_data)
 This function returns a new lookup table from regularly spaced data. More...
 
pure real(dp) function, dimension(n_points), public lt_get_xdata (x_min, dx, n_points)
 Returns the x-coordinates of the lookup table. More...
 
pure real(dp) function, dimension(size(new_x)), public lt_get_spaced_data (in_x, in_y, new_x)
 Linearly interpolate the (x, y) input data to the new_x coordinates. More...
 
pure subroutine, public lt_set_col (my_lt, col_ix, x, y)
 Fill the column with index col_ix using the linearly interpolated (x, y) data. More...
 
pure subroutine, public lt_add_col (my_lt, x, y)
 Add a new column by linearly interpolating the (x, y) data. More...
 
elemental type(lt_loc_t) function, public lt_get_loc (my_lt, x)
 Get a location in the lookup table. More...
 
pure real(dp) function, dimension(my_lt%n_cols), public lt_get_mcol (my_lt, x)
 Get the values of all columns at x. More...
 
elemental real(dp) function, public lt_get_col (my_lt, col_ix, x)
 Get the value of a single column at x. More...
 
pure real(dp) function, dimension(my_lt%n_cols), public lt_get_mcol_at_loc (my_lt, loc)
 Get the values of all columns at a location. More...
 
elemental real(dp) function, public lt_get_col_at_loc (my_lt, col_ix, loc)
 Get the value of a single column at a location. More...
 
pure subroutine, public lt_get_data (my_lt, x_data, cols_rows)
 Get the x-coordinates and the columns of the lookup table. More...
 
pure subroutine, public lt_lin_interp_list (x_list, y_list, x_value, y_value)
 Compute by use of linear interpolation the value in the middle. More...
 
subroutine, public lt_to_file (my_lt, filename)
 Write the lookup table to file (in binary, potentially unportable) More...
 
subroutine, public lt_from_file (my_lt, filename)
 Read the lookup table from file (in binary, potentially unportable) More...
 
type(lt2_t) function, public lt2_create (x_min, x_max, n_points, n_cols)
 This function returns a new lookup table. More...
 
type(lt2_t) function, public lt2_create_from_data (x_min, x_max, spaced_data)
 This function returns a new lookup table from regularly spaced data. More...
 
pure subroutine, public lt2_set_col (my_lt, col_ix, x1, x2, y)
 Fill the column with index col_ix using linearly interpolated data. More...
 
elemental type(lt2_loc_t) function, public lt2_get_loc (my_lt, x1, x2)
 Get a location in the lookup table. More...
 
elemental real(dp) function, public lt2_get_col (my_lt, col_ix, x1, x2)
 Get the value of a single column at x. More...
 
elemental real(dp) function, public lt2_get_col_at_loc (my_lt, col_ix, loc)
 Get the value of a single column at a location. More...
 
type(lt3_t) function, public lt3_create (x_min, x_max, n_points, n_cols)
 This function returns a new lookup table. More...
 
type(lt3_t) function, public lt3_create_from_data (x_min, x_max, spaced_data)
 This function returns a new lookup table from regularly spaced data. More...
 
elemental type(lt3_loc_t) function, public lt3_get_loc (my_lt, x1, x2, x3)
 Get a location in the lookup table. More...
 
elemental real(dp) function, public lt3_get_col (my_lt, col_ix, x1, x2, x3)
 Get the value of a single column at x. More...
 
elemental real(dp) function, public lt3_get_col_at_loc (my_lt, col_ix, loc)
 Get the value of a single column at a location. More...
 

Detailed Description

A Fortran 90 module for creating 1D and 2D lookup tables. These tables can be used to efficiently interpolate one or more values.

Author: Jannis Teunissen

Function/Subroutine Documentation

◆ find_index_adaptive()

pure integer function, public mod_lookup_table::find_index_adaptive ( real(dp), dimension(:), intent(in)  list,
real(dp), intent(in)  val 
)

Adaptive search (combination of linear and binary search) of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1.

Parameters
[in]listSorted list
[in]valValue to search for

Definition at line 163 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ find_index_bsearch()

pure integer function, public mod_lookup_table::find_index_bsearch ( real(dp), dimension(:), intent(in)  list,
real(dp), intent(in)  val 
)

Binary search of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1.

Parameters
[in]listSorted list
[in]valValue to search for

Definition at line 137 of file mod_lookup_table.t.

◆ find_index_linear()

pure integer function, public mod_lookup_table::find_index_linear ( real(dp), dimension(:), intent(in)  list,
real(dp), intent(in)  val 
)

Linear search of sorted list for the smallest ix such that list(ix) >= val. On failure, returns size(list)+1.

Parameters
[in]listSorted list
[in]valValue to search for

Definition at line 125 of file mod_lookup_table.t.

◆ lt2_create()

type(lt2_t) function, public mod_lookup_table::lt2_create ( real(dp), dimension(2), intent(in)  x_min,
real(dp), dimension(2), intent(in)  x_max,
integer, dimension(2), intent(in)  n_points,
integer, intent(in)  n_cols 
)

This function returns a new lookup table.

Parameters
[in]x_minMinimum coordinate
[in]x_maxMaximum coordinate
[in]n_pointsHow many values to store
[in]n_colsNumber of variables that will be looked up

Definition at line 418 of file mod_lookup_table.t.

◆ lt2_create_from_data()

type(lt2_t) function, public mod_lookup_table::lt2_create_from_data ( real(dp), dimension(2), intent(in)  x_min,
real(dp), dimension(2), intent(in)  x_max,
real(dp), dimension(:, :, :), intent(in)  spaced_data 
)

This function returns a new lookup table from regularly spaced data.

Parameters
[in]x_minMinimum coordinate
[in]x_maxMaximum coordinate
[in]spaced_dataInput data of shape (nx, ny, n_cols)

Definition at line 439 of file mod_lookup_table.t.

◆ lt2_get_col()

elemental real(dp) function, public mod_lookup_table::lt2_get_col ( type(lt2_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
real(dp), intent(in)  x1,
real(dp), intent(in)  x2 
)

Get the value of a single column at x.

Definition at line 512 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt2_get_col_at_loc()

elemental real(dp) function, public mod_lookup_table::lt2_get_col_at_loc ( type(lt2_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
type(lt2_loc_t), intent(in)  loc 
)

Get the value of a single column at a location.

Definition at line 524 of file mod_lookup_table.t.

◆ lt2_get_loc()

elemental type(lt2_loc_t) function, public mod_lookup_table::lt2_get_loc ( type(lt2_t), intent(in)  my_lt,
real(dp), intent(in)  x1,
real(dp), intent(in)  x2 
)

Get a location in the lookup table.

Definition at line 489 of file mod_lookup_table.t.

◆ lt2_set_col()

pure subroutine, public mod_lookup_table::lt2_set_col ( type(lt2_t), intent(inout)  my_lt,
integer, intent(in)  col_ix,
real(dp), dimension(:), intent(in)  x1,
real(dp), dimension(:), intent(in)  x2,
real(dp), dimension(:, :), intent(in)  y 
)

Fill the column with index col_ix using linearly interpolated data.

Definition at line 463 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt3_create()

type(lt3_t) function, public mod_lookup_table::lt3_create ( real(dp), dimension(3), intent(in)  x_min,
real(dp), dimension(3), intent(in)  x_max,
integer, dimension(3), intent(in)  n_points,
integer, intent(in)  n_cols 
)

This function returns a new lookup table.

Parameters
[in]x_minMinimum coordinate
[in]x_maxMaximum coordinate
[in]n_pointsHow many values to store
[in]n_colsNumber of variables that will be looked up

Definition at line 546 of file mod_lookup_table.t.

◆ lt3_create_from_data()

type(lt3_t) function, public mod_lookup_table::lt3_create_from_data ( real(dp), dimension(3), intent(in)  x_min,
real(dp), dimension(3), intent(in)  x_max,
real(dp), dimension(:, :, :, :), intent(in)  spaced_data 
)

This function returns a new lookup table from regularly spaced data.

Parameters
[in]x_minMinimum coordinate
[in]x_maxMaximum coordinate
[in]spaced_dataInput data of shape (nx, ny, nz, n_cols)

Definition at line 567 of file mod_lookup_table.t.

◆ lt3_get_col()

elemental real(dp) function, public mod_lookup_table::lt3_get_col ( type(lt3_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
real(dp), intent(in)  x1,
real(dp), intent(in)  x2,
real(dp), intent(in)  x3 
)

Get the value of a single column at x.

Definition at line 616 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt3_get_col_at_loc()

elemental real(dp) function, public mod_lookup_table::lt3_get_col_at_loc ( type(lt3_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
type(lt3_loc_t), intent(in)  loc 
)

Get the value of a single column at a location.

Definition at line 628 of file mod_lookup_table.t.

◆ lt3_get_loc()

elemental type(lt3_loc_t) function, public mod_lookup_table::lt3_get_loc ( type(lt3_t), intent(in)  my_lt,
real(dp), intent(in)  x1,
real(dp), intent(in)  x2,
real(dp), intent(in)  x3 
)

Get a location in the lookup table.

Definition at line 593 of file mod_lookup_table.t.

◆ lt_add_col()

pure subroutine, public mod_lookup_table::lt_add_col ( type(lt_t), intent(inout)  my_lt,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y 
)

Add a new column by linearly interpolating the (x, y) data.

Definition at line 260 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_create()

type(lt_t) function, public mod_lookup_table::lt_create ( real(dp), intent(in)  x_min,
real(dp), intent(in)  x_max,
integer, intent(in)  n_points,
integer, intent(in)  n_cols 
)

This function returns a new lookup table.

Parameters
[in]x_minMinimum x-coordinate
[in]x_maxMaximum x-coordinate
[in]n_pointsHow many x-values to store
[in]n_colsNumber of variables that will be looked up

Definition at line 179 of file mod_lookup_table.t.

◆ lt_create_from_data()

type(lt_t) function, public mod_lookup_table::lt_create_from_data ( real(dp), intent(in)  x_min,
real(dp), intent(in)  x_max,
real(dp), dimension(:, :), intent(in)  spaced_data 
)

This function returns a new lookup table from regularly spaced data.

Parameters
[in]x_minMinimum coordinate
[in]x_maxMaximum coordinate
[in]spaced_dataInput data of shape (n_points, n_cols)

Definition at line 202 of file mod_lookup_table.t.

◆ lt_from_file()

subroutine, public mod_lookup_table::lt_from_file ( type(lt_t), intent(inout)  my_lt,
character(len=*), intent(in)  filename 
)

Read the lookup table from file (in binary, potentially unportable)

Definition at line 396 of file mod_lookup_table.t.

◆ lt_get_col()

elemental real(dp) function, public mod_lookup_table::lt_get_col ( type(lt_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
real(dp), intent(in)  x 
)

Get the value of a single column at x.

Definition at line 312 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_get_col_at_loc()

elemental real(dp) function, public mod_lookup_table::lt_get_col_at_loc ( type(lt_t), intent(in)  my_lt,
integer, intent(in)  col_ix,
type(lt_loc_t), intent(in)  loc 
)

Get the value of a single column at a location.

Definition at line 334 of file mod_lookup_table.t.

◆ lt_get_data()

pure subroutine, public mod_lookup_table::lt_get_data ( type(lt_t), intent(in)  my_lt,
real(dp), dimension(:), intent(out)  x_data,
real(dp), dimension(:, :), intent(out)  cols_rows 
)

Get the x-coordinates and the columns of the lookup table.

Definition at line 345 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_get_loc()

elemental type(lt_loc_t) function, public mod_lookup_table::lt_get_loc ( type(lt_t), intent(in)  my_lt,
real(dp), intent(in)  x 
)

Get a location in the lookup table.

Definition at line 280 of file mod_lookup_table.t.

◆ lt_get_mcol()

pure real(dp) function, dimension(my_lt%n_cols), public mod_lookup_table::lt_get_mcol ( type(lt_t), intent(in)  my_lt,
real(dp), intent(in)  x 
)

Get the values of all columns at x.

Definition at line 301 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_get_mcol_at_loc()

pure real(dp) function, dimension(my_lt%n_cols), public mod_lookup_table::lt_get_mcol_at_loc ( type(lt_t), intent(in)  my_lt,
type(lt_loc_t), intent(in)  loc 
)

Get the values of all columns at a location.

Definition at line 324 of file mod_lookup_table.t.

◆ lt_get_spaced_data()

pure real(dp) function, dimension(size(new_x)), public mod_lookup_table::lt_get_spaced_data ( real(dp), dimension(:), intent(in)  in_x,
real(dp), dimension(:), intent(in)  in_y,
real(dp), dimension(:), intent(in)  new_x 
)

Linearly interpolate the (x, y) input data to the new_x coordinates.

Definition at line 238 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_get_xdata()

pure real(dp) function, dimension(n_points), public mod_lookup_table::lt_get_xdata ( real(dp), intent(in)  x_min,
real(dp), intent(in)  dx,
integer, intent(in)  n_points 
)

Returns the x-coordinates of the lookup table.

Definition at line 226 of file mod_lookup_table.t.

◆ lt_lin_interp_list()

pure subroutine, public mod_lookup_table::lt_lin_interp_list ( real(dp), dimension(:), intent(in)  x_list,
real(dp), dimension(:), intent(in)  y_list,
real(dp), intent(in)  x_value,
real(dp), intent(out)  y_value 
)

Compute by use of linear interpolation the value in the middle.

Definition at line 359 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_set_col()

pure subroutine, public mod_lookup_table::lt_set_col ( type(lt_t), intent(inout)  my_lt,
integer, intent(in)  col_ix,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y 
)

Fill the column with index col_ix using the linearly interpolated (x, y) data.

Definition at line 250 of file mod_lookup_table.t.

Here is the call graph for this function:

◆ lt_to_file()

subroutine, public mod_lookup_table::lt_to_file ( type(lt_t), intent(in)  my_lt,
character(len=*), intent(in)  filename 
)

Write the lookup table to file (in binary, potentially unportable)

Definition at line 382 of file mod_lookup_table.t.