# dpchfd.f

          SUBROUTINE DPCHFD (N, X, F, D, INCFD, SKIP, NE, XE, FE, DE, IERR)
    C***BEGIN PROLOGUE  DPCHFD
    C***PURPOSE  Evaluate a piecewise cubic Hermite function and its first
    C            derivative at an array of points.  May be used by itself
    C            for Hermite interpolation, or as an evaluator for DPCHIM
    C            or DPCHIC. If only function values are required, use
    C            DPCHFE instead.
    C***LIBRARY   SLATEC (PCHIP)
    C***CATEGORY  E3, H1
    C***TYPE      DOUBLE PRECISION (PCHFD-S, DPCHFD-D)
    C***KEYWORDS  CUBIC HERMITE DIFFERENTIATION, CUBIC HERMITE EVALUATION,
    C             HERMITE INTERPOLATION, PCHIP, PIECEWISE CUBIC EVALUATION
    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          DPCHFD:  Piecewise Cubic Hermite Function and Derivative
    C                  evaluator
    C
    C     Evaluates the cubic Hermite function defined by  N, X, F, D,  to-
    C     gether with its first derivative, at the points  XE(J), J=1(1)NE.
    C
    C     If only function values are required, use DPCHFE, instead.
    C
    C     To provide compatibility with DPCHIM and DPCHIC, includes an
    C     increment between successive values of the F- and D-arrays.
    C
    C ----------------------------------------------------------------------
    C
    C  Calling sequence:
    C
    C        PARAMETER  (INCFD = ...)
    C        INTEGER  N, NE, IERR
    C        DOUBLE PRECISION  X(N), F(INCFD,N), D(INCFD,N), XE(NE), FE(NE),
    C                          DE(NE)
    C        LOGICAL  SKIP
    C
    C        CALL  DPCHFD (N, X, F, D, INCFD, SKIP, NE, XE, FE, DE, IERR)
    C
    C   Parameters:
    C
    C     N -- (input) number of data points.  (Error return if N.LT.2 .)
    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 function values.  F(1+(I-1)*INCFD) is
    C           the value corresponding to X(I).
    C
    C     D -- (input) real*8 array of derivative values.  D(1+(I-1)*INCFD)
    C           is the value corresponding to X(I).
    C
    C     INCFD -- (input) increment between successive values in F and D.
    C           (Error return if  INCFD.LT.1 .)
    C
    C     SKIP -- (input/output) logical variable which should be set to
    C           .TRUE. if the user wishes to skip checks for validity of
    C           preceding parameters, or to .FALSE. otherwise.
    C           This will save time in case these checks have already
    C           been performed (say, in DPCHIM or DPCHIC).
    C           SKIP will be set to .TRUE. on normal return.
    C
    C     NE -- (input) number of evaluation points.  (Error return if
    C           NE.LT.1 .)
    C
    C     XE -- (input) real*8 array of points at which the functions are to
    C           be evaluated.
    C
    C
    C          NOTES:
    C           1. The evaluation will be most efficient if the elements
    C              of XE are increasing relative to X;
    C              that is,   XE(J) .GE. X(I)
    C              implies    XE(K) .GE. X(I),  all K.GE.J .
    C           2. If any of the XE are outside the interval [X(1),X(N)],
    C              values are extrapolated from the nearest extreme cubic,
    C              and a warning error is returned.
    C
    C     FE -- (output) real*8 array of values of the cubic Hermite
    C           function defined by  N, X, F, D  at the points  XE.
    C
    C     DE -- (output) real*8 array of values of the first derivative of
    C           the same function at the points  XE.
    C
    C     IERR -- (output) error flag.
    C           Normal return:
    C              IERR = 0  (no errors).
    C           Warning error:
    C              IERR.GT.0  means that extrapolation was performed at
    C                 IERR points.
    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              IERR = -4  if NE.LT.1 .
    C           (Output arrays have 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              IERR = -5  if an error has occurred in the lower-level
    C                         routine DCHFDV.  NB: this should never happen.
    C                         Notify the author **IMMEDIATELY** if it does.
    C
    C***REFERENCES  (NONE)
    C***ROUTINES CALLED  DCHFDV, XERMSG
    C***REVISION HISTORY  (YYMMDD)
    C   811020  DATE WRITTEN
    C   820803  Minor cosmetic changes for release 1.
    C   870707  Corrected XERROR calls for d.p. name(s).
    C   890206  Corrected XERROR calls.
    C   890531  Changed all specific intrinsics to generic.  (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***END PROLOGUE  DPCHFD