private pure subroutine dintrv(xt, lxt, xx, ilo, ileft, mflag, extrap)
Computes the largest integer ileft in 1
ileftlxt
such that xt(ileft)x where xt(*) is a subdivision of
the x interval.
precisely,
if x<xt(1)then ileft=1,mflag=-1if xt(i)<=x<xt(i+1)then ileft=i,mflag=0if xt(lxt)<=xthen ileft=lxt,mflag=-2
that is, when multiplicities are present in the break point
to the left of x, the largest index is taken for ileft.
History
interv written by carl de boor [5]
dintrv author: amos, d. e., (snla) : date written 800901
revision date 820801
Jacob Williams, 2/24/2015 : updated to free-form Fortran.
Jacob Williams, 2/17/2016 : additional refactoring (eliminated GOTOs).
Jacob Williams, 3/4/2017 : added extrapolation option.
Arguments
Type
Intent
Optional
Attributes
Name
real(kind=wp),
intent(in),
dimension(:)
::
xt
a knot or break point vector of length lxt
integer(kind=ip),
intent(in)
::
lxt
length of the xt vector
real(kind=wp),
intent(in)
::
xx
argument
integer(kind=ip),
intent(inout)
::
ilo
an initialization parameter which must be set
to 1 the first time the spline array xt is
processed by dintrv. ilo contains information for
efficient processing after the initial call and ilo
must not be changed by the user. distinct splines
require distinct ilo parameters.
integer(kind=ip),
intent(out)
::
ileft
largest integer satisfying xt(ileft)x
integer(kind=ip),
intent(out)
::
mflag
signals when x lies out of bounds
logical,
intent(in),
optional
::
extrap
if extrapolation is allowed
(if not present, default is False)
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Source Code
pure subroutine dintrv(xt,lxt,xx,ilo,ileft,mflag,extrap)implicit noneinteger(ip),intent(in)::lxt!! length of the `xt` vectorreal(wp),dimension(:),intent(in)::xt!! a knot or break point vector of length `lxt`real(wp),intent(in)::xx!! argumentinteger(ip),intent(inout)::ilo!! an initialization parameter which must be set!! to 1 the first time the spline array `xt` is!! processed by dintrv. `ilo` contains information for!! efficient processing after the initial call and `ilo`!! must not be changed by the user. distinct splines!! require distinct `ilo` parameters.integer(ip),intent(out)::ileft!! largest integer satisfying `xt(ileft)` \( \le \) `x`integer(ip),intent(out)::mflag!! signals when `x` lies out of boundslogical,intent(in),optional::extrap!! if extrapolation is allowed!! (if not present, default is False)integer(ip)::ihi,istep,middlereal(wp)::xx=get_temp_x_for_extrap(xx,xt(1_ip),xt(lxt),extrap)ihi=ilo+1_ipif(ihi>=lxt)then if(x>=xt(lxt))thenmflag=-2_ipileft=lxtreturn end if if(lxt<=1)thenmflag=-1_ipileft=1_ipreturn end ifilo=lxt-1_ipihi=lxtend if if(x>=xt(ihi))then! now x >= xt(ilo). find upper boundistep=1_ipdoilo=ihiihi=ilo+istepif(ihi>=lxt)then if(x>=xt(lxt))thenmflag=-2_ipileft=lxtreturn end ifihi=lxtelse if(x>=xt(ihi))thenistep=istep*2_ipcycle end if exit end do else if(x>=xt(ilo))thenmflag=0_ipileft=iloreturn end if! now x <= xt(ihi). find lower boundistep=1_ipdoihi=iloilo=ihi-istepif(ilo<=1_ip)thenilo=1_ipif(x<xt(1_ip))thenmflag=-1_ipileft=1_ipreturn end if else if(x<xt(ilo))thenistep=istep*2_ipcycle end if exit end do end if! now xt(ilo) <= x < xt(ihi). narrow the intervaldomiddle=(ilo+ihi)/2_ipif(middle==ilo)thenmflag=0_ipileft=iloreturn end if! note. it is assumed that middle = ilo in case ihi = ilo+1if(x<xt(middle))thenihi=middleelseilo=middleend if end do end subroutine dintrv