afivo-streamer 1.1
1D/2D/3D streamer simulations with AMR
Loading...
Searching...
No Matches
Data Types | Functions/Subroutines | Variables
m_lookup_table Module Reference

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

Data Types

type  lt2_loc_t
 Type to indicate a location in a 2D lookup table. More...
 
type  lt2_t
 The 2D lookup table type. More...
 
type  lt_loc_t
 Type to indicate a location in the lookup table, which can be used to speed up multiple lookups of different columns. More...
 
type  lt_t
 The lookup table type. There can be one or more columns, for which values can be looked up for a given 'x-coordinate'. 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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
subroutine, public lt_set_col (my_lt, col_ix, x, y)
 Fill the column with index col_ix after linearly interpolating.
 
subroutine, public lt_set_col_data (my_lt, col_ix, y)
 Fill the column with index col_ix with y data.
 
subroutine, public lt_add_col (my_lt, x, y)
 Add a new column by linearly interpolating the (x, y) data.
 
elemental type(lt_loc_t) function, public lt_get_loc (my_lt, x)
 Get a location in the lookup table.
 
pure real(dp) function, dimension(my_lt%n_cols), public lt_get_mcol (my_lt, x)
 Get the values of all columns at x.
 
elemental real(dp) function, public lt_get_col (my_lt, col_ix, x)
 Get the value of a single column at x.
 
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.
 
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.
 
subroutine, public lt_to_file (my_lt, filename)
 Write the lookup table to file (in binary, potentially unportable)
 
subroutine, public lt_from_file (my_lt, filename)
 Read the lookup table from file (in binary, potentially unportable)
 
type(lt2_t) function, public lt2_create (x_min, x_max, n_points, n_cols, xspacing)
 This function returns a new lookup table.
 
subroutine, public lt2_set_col (my_lt, col_ix, x1, x2, y)
 Fill the column with index col_ix using linearly interpolated data.
 
subroutine, public lt2_set_col_data (my_lt, col_ix, y)
 Fill the column with index col_ix with y data.
 
elemental type(lt2_loc_t) function, public lt2_get_loc (my_lt, x1, x2)
 Get a location in the lookup table.
 
pure real(dp) function, public lt2_get_col (my_lt, col_ix, x1, x2)
 Get the value of a single column at x.
 
pure real(dp) function, public lt2_get_col_at_loc (my_lt, col_ix, loc)
 Get the value of a single column at a location.
 

Variables

integer, parameter, public lt_xspacing_linear = 1
 
integer, parameter, public lt_xspacing_quadratic = 2
 
integer, parameter, public lt_xspacing_cubic = 3
 

Detailed Description

A Fortran 90 module for creating 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 m_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 142 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ find_index_bsearch()

pure integer function, public m_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 116 of file m_lookup_table.f90.

◆ find_index_linear()

pure integer function, public m_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 104 of file m_lookup_table.f90.

◆ lt2_create()

type(lt2_t) function, public m_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,
integer, dimension(2), intent(in), optional xspacing )

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
[in]xspacingSpacing of data

Definition at line 446 of file m_lookup_table.f90.

◆ lt2_get_col()

pure real(dp) function, public m_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 534 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt2_get_col_at_loc()

pure real(dp) function, public m_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 546 of file m_lookup_table.f90.

◆ lt2_get_loc()

elemental type(lt2_loc_t) function, public m_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 511 of file m_lookup_table.f90.

◆ lt2_set_col()

subroutine, public m_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 476 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt2_set_col_data()

subroutine, public m_lookup_table::lt2_set_col_data ( type(lt2_t), intent(inout) my_lt,
integer, intent(in) col_ix,
real(dp), dimension(:, :), intent(in) y )

Fill the column with index col_ix with y data.

Definition at line 498 of file m_lookup_table.f90.

◆ lt_add_col()

subroutine, public m_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 284 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_create()

type(lt_t) function, public m_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,
integer, intent(in), optional xspacing,
logical, intent(in), optional extrapolate_above )

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
[in]xspacingSpacing of data
[in]extrapolate_aboveLinearly extrapolate above x_max

Definition at line 186 of file m_lookup_table.f90.

◆ lt_from_file()

subroutine, public m_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 423 of file m_lookup_table.f90.

◆ lt_get_col()

elemental real(dp) function, public m_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 376 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_get_col_at_loc()

elemental real(dp) function, public m_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 398 of file m_lookup_table.f90.

◆ lt_get_loc()

elemental type(lt_loc_t) function, public m_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 330 of file m_lookup_table.f90.

◆ lt_get_mcol()

pure real(dp) function, dimension(my_lt%n_cols), public m_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 365 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_get_mcol_at_loc()

pure real(dp) function, dimension(my_lt%n_cols), public m_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 388 of file m_lookup_table.f90.

◆ lt_get_spaced_data()

real(dp) function, dimension(size(new_x)), public m_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 240 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_lin_interp_list()

pure subroutine, public m_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 161 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_set_col()

subroutine, public m_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 after linearly interpolating.

Definition at line 257 of file m_lookup_table.f90.

Here is the call graph for this function:

◆ lt_set_col_data()

subroutine, public m_lookup_table::lt_set_col_data ( type(lt_t), intent(inout) my_lt,
integer, intent(in) col_ix,
real(dp), dimension(:), intent(in) y )

Fill the column with index col_ix with y data.

Definition at line 270 of file m_lookup_table.f90.

◆ lt_to_file()

subroutine, public m_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 409 of file m_lookup_table.f90.

Variable Documentation

◆ lt_xspacing_cubic

integer, parameter, public m_lookup_table::lt_xspacing_cubic = 3

Definition at line 15 of file m_lookup_table.f90.

◆ lt_xspacing_linear

integer, parameter, public m_lookup_table::lt_xspacing_linear = 1

Definition at line 13 of file m_lookup_table.f90.

◆ lt_xspacing_quadratic

integer, parameter, public m_lookup_table::lt_xspacing_quadratic = 2

Definition at line 14 of file m_lookup_table.f90.