dpchim.f
SUBROUTINE DPCHIM (N, X, F, D, INCFD, IERR)
C***BEGIN PROLOGUE DPCHIM
C***PURPOSE Set derivatives needed to determine a monotone piecewise
C cubic Hermite interpolant to given data. Boundary values
C are provided which are compatible with monotonicity. The
C interpolant will have an extremum at each point where mono-
C tonicity switches direction. (See DPCHIC if user control
C is desired over boundary or switch conditions.)
C***LIBRARY SLATEC (PCHIP)
C***CATEGORY E1A
C***TYPE DOUBLE PRECISION (PCHIM-S, DPCHIM-D)
C***KEYWORDS CUBIC HERMITE INTERPOLATION, MONOTONE INTERPOLATION,
C PCHIP, PIECEWISE CUBIC INTERPOLATION
C***AUTHOR Fritsch, F. N., (LLNL)
C Lawrence Livermore National Laboratory
C P.O. Box 808 (L-316)
C Livermore, CA 94550
C FTS 532-4275, (510) 422-4275
C***DESCRIPTION
C
C DPCHIM: Piecewise Cubic Hermite Interpolation to
C Monotone data.
C
C Sets derivatives needed to determine a monotone piecewise cubic
C Hermite interpolant to the data given in X and F.
C
C Default boundary conditions are provided which are compatible
C with monotonicity. (See DPCHIC if user control of boundary con-
C ditions is desired.)
C
C If the data are only piecewise monotonic, the interpolant will
C have an extremum at each point where monotonicity switches direc-
C tion. (See DPCHIC if user control is desired in such cases.)
C
C To facilitate two-dimensional applications, includes an increment
C between successive values of the F- and D-arrays.
C
C The resulting piecewise cubic Hermite function may be evaluated
C by DPCHFE or DPCHFD.
C
C ----------------------------------------------------------------------
C
C Calling sequence:
C
C PARAMETER (INCFD = ...)
C INTEGER N, IERR
C DOUBLE PRECISION X(N), F(INCFD,N), D(INCFD,N)
C
C CALL DPCHIM (N, X, F, D, INCFD, IERR)
C
C Parameters:
C
C N -- (input) number of data points. (Error return if N.LT.2 .)
C If N=2, simply does linear interpolation.
C
C X -- (input) real*8 array of independent variable values. The
C elements of X must be strictly increasing:
C X(I-1) .LT. X(I), I = 2(1)N.
C (Error return if not.)
C
C F -- (input) real*8 array of dependent variable values to be
C interpolated. F(1+(I-1)*INCFD) is value corresponding to
C X(I). DPCHIM is designed for monotonic data, but it will
C work for any F-array. It will force extrema at points where
C monotonicity switches direction. If some other treatment of
C switch points is desired, DPCHIC should be used instead.
C -----
C D -- (output) real*8 array of derivative values at the data
C points. If the data are monotonic, these values will
C determine a monotone cubic Hermite function.
C The value corresponding to X(I) is stored in
C D(1+(I-1)*INCFD), I=1(1)N.
C No other entries in D are changed.
C
C INCFD -- (input) increment between successive values in F and D.
C This argument is provided primarily for 2-D applications.
C (Error return if INCFD.LT.1 .)
C
C IERR -- (output) error flag.
C Normal return:
C IERR = 0 (no errors).
C Warning error:
C IERR.GT.0 means that IERR switches in the direction
C of monotonicity were detected.
C "Recoverable" errors:
C IERR = -1 if N.LT.2 .
C IERR = -2 if INCFD.LT.1 .
C IERR = -3 if the X-array is not strictly increasing.
C (The D-array has not been changed in any of these cases.)
C NOTE: The above errors are checked in the order listed,
C and following arguments have **NOT** been validated.
C
C***REFERENCES 1. F. N. Fritsch and J. Butland, A method for construc-
C ting local monotone piecewise cubic interpolants, SIAM
C Journal on Scientific and Statistical Computing 5, 2
C (June 1984), pp. 300-304.
C 2. F. N. Fritsch and R. E. Carlson, Monotone piecewise
C cubic interpolation, SIAM Journal on Numerical Ana-
C lysis 17, 2 (April 1980), pp. 238-246.
C***ROUTINES CALLED DPCHST, XERMSG
C***REVISION HISTORY (YYMMDD)
C 811103 DATE WRITTEN
C 820201 1. Introduced DPCHST to reduce possible over/under-
C flow problems.
C 2. Rearranged derivative formula for same reason.
C 820602 1. Modified end conditions to be continuous functions
C of data when monotonicity switches in next interval.
C 2. Modified formulas so end conditions are less prone
C of over/underflow problems.
C 820803 Minor cosmetic changes for release 1.
C 870707 Corrected XERROR calls for d.p. name(s).
C 870813 Updated Reference 1.
C 890206 Corrected XERROR calls.
C 890411 Added SAVE statements (Vers. 3.2).
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890703 Corrected category record. (WRB)
C 890831 Modified array declarations. (WRB)
C 891006 Cosmetic changes to prologue. (WRB)
C 891006 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 920429 Revised format and order of references. (WRB,FNF)
C***END PROLOGUE DPCHIM