Multidimensional linear interpolation/extrapolation.
Uses repeated linear interpolation to evaluate functions which have been tabulated at the nodes of an n-dimensional rectangular grid. If any coordinate lies outside the range of the corresponding variable, then extrapolation is performed using the two nearest points.
Note
The default real kind (wp) can be
changed using optional preprocessor flags.
This library was built with real kind:
real(kind=real64) [8 bytes]
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | finterp_rk | = | real64 |
real kind used by this module [8 bytes] |
| integer, | private, | parameter | :: | wp | = | finterp_rk |
local copy of |
| real(kind=wp), | private, | parameter | :: | zero | = | 0.0_wp |
numeric constant |
| real(kind=wp), | private, | parameter | :: | one | = | 1.0_wp |
numeric constant |
interface for bspline destructor routines
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_class), | intent(inout) | :: | me |
Base class for the linear interpolation types
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | initialized | = | .false. |
if the class was properly initialized |
| procedure(destroy_func), public, deferred :: destroy | ../../ destructor |
| procedure, private :: check_inputs |
Class for 1d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| integer, | private | :: | ilox | = | 1 |
| final :: finalize_1d |
| procedure, public :: initialize => initialize_1d | |
| procedure, public :: evaluate => interp_1d | |
| procedure, public :: destroy => destroy_1d |
Class for 2d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:,:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | y | |||
| integer, | private | :: | ilox | = | 1 | ||
| integer, | private | :: | iloy | = | 1 |
| final :: finalize_2d |
| procedure, public :: initialize => initialize_2d | |
| procedure, public :: evaluate => interp_2d | |
| procedure, public :: destroy => destroy_2d |
Class for 3d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:,:,:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | y | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | z | |||
| integer, | private | :: | ilox | = | 1 | ||
| integer, | private | :: | iloy | = | 1 | ||
| integer, | private | :: | iloz | = | 1 |
| final :: finalize_3d |
| procedure, public :: initialize => initialize_3d | |
| procedure, public :: evaluate => interp_3d | |
| procedure, public :: destroy => destroy_3d |
Class for 4d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:,:,:,:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | y | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | z | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | q | |||
| integer, | private | :: | ilox | = | 1 | ||
| integer, | private | :: | iloy | = | 1 | ||
| integer, | private | :: | iloz | = | 1 | ||
| integer, | private | :: | iloq | = | 1 |
| final :: finalize_4d |
| procedure, public :: initialize => initialize_4d | |
| procedure, public :: evaluate => interp_4d | |
| procedure, public :: destroy => destroy_4d |
Class for 5d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:,:,:,:,:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | y | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | z | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | q | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | r | |||
| integer, | private | :: | ilox | = | 1 | ||
| integer, | private | :: | iloy | = | 1 | ||
| integer, | private | :: | iloz | = | 1 | ||
| integer, | private | :: | iloq | = | 1 | ||
| integer, | private | :: | ilor | = | 1 |
| final :: finalize_5d |
| procedure, public :: initialize => initialize_5d | |
| procedure, public :: evaluate => interp_5d | |
| procedure, public :: destroy => destroy_5d |
Class for 6d linear interpolation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | dimension(:,:,:,:,:,:), allocatable | :: | f | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | x | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | y | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | z | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | q | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | r | |||
| real(kind=wp), | private, | dimension(:), allocatable | :: | s | |||
| integer, | private | :: | ilox | = | 1 | ||
| integer, | private | :: | iloy | = | 1 | ||
| integer, | private | :: | iloz | = | 1 | ||
| integer, | private | :: | iloq | = | 1 | ||
| integer, | private | :: | ilor | = | 1 | ||
| integer, | private | :: | ilos | = | 1 |
| final :: finalize_6d |
| procedure, public :: initialize => initialize_6d | |
| procedure, public :: evaluate => interp_6d | |
| procedure, public :: destroy => destroy_6d |
Class for 1d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_1d | |
| procedure, public :: destroy => destroy_1d | |
| procedure, public :: evaluate => nearest_1d |
Class for 2d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_2d | |
| procedure, public :: destroy => destroy_2d | |
| procedure, public :: evaluate => nearest_2d |
Class for 3d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_3d | |
| procedure, public :: destroy => destroy_3d | |
| procedure, public :: evaluate => nearest_3d |
Class for 4d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_4d | |
| procedure, public :: destroy => destroy_4d | |
| procedure, public :: evaluate => nearest_4d |
Class for 5d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_5d | |
| procedure, public :: destroy => destroy_5d | |
| procedure, public :: evaluate => nearest_5d |
Class for 6d nearest neighbor interpolation.
| procedure, public :: initialize => initialize_6d | |
| procedure, public :: destroy => destroy_6d | |
| procedure, public :: evaluate => nearest_6d |
Finalizer for a linear_interp_1d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_1d), | intent(inout) | :: | me |
Finalizer for a linear_interp_2d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_2d), | intent(inout) | :: | me |
Finalizer for a linear_interp_3d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_3d), | intent(inout) | :: | me |
Finalizer for a linear_interp_4d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_4d), | intent(inout) | :: | me |
Finalizer for a linear_interp_5d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_5d), | intent(inout) | :: | me |
Finalizer for a linear_interp_6d type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(linear_interp_6d), | intent(inout) | :: | me |
Destructor for a linear_interp_1d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_1d), | intent(inout) | :: | me |
Destructor for a linear_interp_2d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_2d), | intent(inout) | :: | me |
Destructor for a linear_interp_3d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_3d), | intent(inout) | :: | me |
Destructor for a linear_interp_4d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_4d), | intent(inout) | :: | me |
Destructor for a linear_interp_5d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_5d), | intent(inout) | :: | me |
Destructor for a linear_interp_6d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_6d), | intent(inout) | :: | me |
Constructor for a linear_interp_1d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_1d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
Constructor for a linear_interp_2d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_2d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | y | ||
| real(kind=wp), | intent(in), | dimension(:,:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
Constructor for a linear_interp_3d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_3d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | y | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | z | ||
| real(kind=wp), | intent(in), | dimension(:,:,:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
Constructor for a linear_interp_4d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_4d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | y | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | z | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | q | ||
| real(kind=wp), | intent(in), | dimension(:,:,:,:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
Constructor for a linear_interp_5d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_5d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | y | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | z | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | q | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | r | ||
| real(kind=wp), | intent(in), | dimension(:,:,:,:,:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
Constructor for a linear_interp_6d class.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_6d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | y | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | z | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | q | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | r | ||
| real(kind=wp), | intent(in), | dimension(:) | :: | s | ||
| real(kind=wp), | intent(in), | dimension(:,:,:,:,:,:) | :: | f | ||
| integer, | intent(out) | :: | istat |
|
1D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_1d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
2D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_2d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
3D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_3d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
4D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_4d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
5D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_5d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(in) | :: | r | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
6D linear interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_6d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(in) | :: | r | |||
| real(kind=wp), | intent(in) | :: | s | |||
| real(kind=wp), | intent(out) | :: | f |
Interpolated |
||
| integer, | intent(out), | optional | :: | istat |
|
Returns the indices in xt that bound x, to use for interpolation.
If outside the range, then the indices are returned that can
be used for extrapolation.
Precisely,
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in), | dimension(:) | :: | xt |
a knot or break point vector |
|
| real(kind=wp), | intent(in) | :: | x |
argument |
||
| integer, | intent(inout) | :: | ilo |
an initialization parameter which must be set
to 1 the first time the array |
||
| integer, | intent(out) | :: | ileft |
left index |
||
| integer, | intent(out) | :: | iright |
right index |
||
| integer, | intent(out) | :: | mflag |
signals when |
||
| integer, | intent(out), | optional | :: | inearest |
nearest index |
1D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_1d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
2D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_2d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
3D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_3d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
4D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_4d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
5D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_5d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(in) | :: | r | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
6D nearest neighbor interpolation routine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nearest_interp_6d), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x | |||
| real(kind=wp), | intent(in) | :: | y | |||
| real(kind=wp), | intent(in) | :: | z | |||
| real(kind=wp), | intent(in) | :: | q | |||
| real(kind=wp), | intent(in) | :: | r | |||
| real(kind=wp), | intent(in) | :: | s | |||
| real(kind=wp), | intent(out) | :: | f |
Nearest |
||
| integer, | intent(out), | optional | :: | istat |
|
Check the validity of the inputs to the initialize routines.
Prints warning message if there is an error,
and also sets ierr (/=0 if there were any errors).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(linear_interp_class), | intent(in) | :: | me | |||
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | x |
|
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | y |
|
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | z |
|
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | q |
|
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | r |
|
| real(kind=wp), | intent(in), | optional, | dimension(:) | :: | s |
|
| integer, | intent(out) | :: | ierr |
|