spline Derived Type

type, public :: spline

Holds data representing a non-periodic spline. Should be set up by calling new_spline.


Contents

Source Code


Components

Type Visibility Attributes Name Initial
integer, private :: n = 0

Length of the data arrays represented by the spline

real, private, dimension (:), allocatable :: x

Holds the independent and dependent values of the splined data in x and y. The second derivative is held in y2 and calculated automatically.

real, private, dimension (:), allocatable :: y

Holds the independent and dependent values of the splined data in x and y. The second derivative is held in y2 and calculated automatically.

real, private, dimension (:), allocatable :: y2

Holds the independent and dependent values of the splined data in x and y. The second derivative is held in y2 and calculated automatically.

logical, public :: valid = .false.

Indicates if the spline corresponding to this data is valid and can be used with the spline evaluation routines.

real, private :: tension = 1.0

The tension used in computing the splined data, note this must be the value used in the initialisation when passed to the spline evaluation routines.


Constructor

public interface spline

Constructor for spline

  • public function new_spline(x, y, tension) result(spl)

    Populates a spline instance spl representing the non-periodic data y(x).

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (:) :: x
    real, intent(in), dimension (:) :: y
    real, intent(in), optional :: tension

    Return Value type(spline)


Type-Bound Procedures

procedure, public, :: interpolate => spline_interp

  • private function spline_interp(self, x)

    Bound wrapper to splint

    Arguments

    Type IntentOptional Attributes Name
    class(spline), intent(in) :: self
    real, intent(in) :: x

    Return Value real

procedure, public, :: derivative => spline_deriv

  • private function spline_deriv(self, x)

    Bound wrapper to dsplint

    Arguments

    Type IntentOptional Attributes Name
    class(spline), intent(in) :: self
    real, intent(in) :: x

    Return Value real

Source Code

  type :: spline
     private
     !> Length of the data arrays represented by the spline
     integer :: n = 0
     !> Holds the independent and dependent values of the
     !> splined data in `x` and `y`. The second derivative
     !> is held in `y2` and calculated automatically.
     real, dimension (:), allocatable :: x, y, y2
     !> Indicates if the spline corresponding to this data is valid
     !> and can be used with the spline evaluation routines.
     logical, public :: valid = .false.
     !> The tension used in computing the splined data, note this
     !> must be the value used in the initialisation when passed
     !> to the spline evaluation routines.
     real :: tension = 1.0
   contains
     procedure :: interpolate => spline_interp
     procedure :: derivative => spline_deriv
  end type spline