new_periodic_spline Function

public function new_periodic_spline(x, y, period, drop_last_point, tension) result(spl)

Uses

Populates a periodic_spline instance spl representing the periodic data y(x) of length n and periodic on period. Note that the spline library expects period > x(n) - x(1), which means the input data shouldn't include the duplicate periodic point. As a convenience the user can pass data with the duplicate point and set drop_last_point = .true. to automatically exclude the duplicate point.

Arguments

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

Return Value type(periodic_spline)


Contents

Source Code


Source Code

  type(periodic_spline) function new_periodic_spline (x, y, period, &
       drop_last_point, tension) result(spl)
    use optionals, only: get_option_with_default
    implicit none
    real, dimension (:), intent (in) :: x, y
    real, intent (in) :: period
    logical, intent(in), optional :: drop_last_point
    real, intent(in), optional :: tension
    logical :: drop_point
    real, dimension (:), allocatable :: temp
    integer :: ierr
    spl%valid = .false.
    drop_point = get_option_with_default(drop_last_point, .false.)
    spl%tension = get_option_with_default(tension, 1.0)
    spl%n = size(x)
    if (drop_point) spl%n = spl%n - 1
    allocate(spl%x, source = x(:spl%n)) ; allocate(spl%y, source = y(:spl%n))
    allocate (spl%y2(spl%n), temp(2*spl%n))
    spl%period = period
    call fitp_curvp1 (spl%n,spl%x,spl%y,spl%period,spl%y2,temp,spl%tension,ierr)
    spl%valid = ierr == 0
  end function new_periodic_spline