      FUNCTION CURVI (XL,XU,N,X,Y,YP,SIGMA)
C
      INTEGER N
      REAL XL,XU,X(N),Y(N),YP(N),SIGMA
C
C                      FROM THE SPLINE UNDER TENSION PACKAGE
C                       CODED BY A. K. CLINE AND R. J. RENKA
C                            DEPARTMENT OF COMPUTER SCIENCES
C                              UNIVERSITY OF TEXAS AT AUSTIN
C
C THIS FUNCTION INTEGRATES A CURVE SPECIFIED BY A SPLINE
C UNDER TENSION BETWEEN TWO GIVEN LIMITS. THE SUBROUTINE
C CURV1 SHOULD BE CALLED EARLIER TO DETERMINE NECESSARY
C PARAMETERS.
C
C ON INPUT--
C
C   XL AND XU CONTAIN THE LOWER AND UPPER LIMITS OF INTE-
C   GRATION, RESPECTIVELY. (XL NEED NOT BE LESS THAN OR
C   EQUAL TO XU, CURVI (XL,XU,...) .EQ. -CURVI (XU,XL,...) ).
C
C   N CONTAINS THE NUMBER OF POINTS WHICH WERE SPECIFIED TO
C   DETERMINE THE CURVE.
C
C   X AND Y ARE ARRAYS CONTAINING THE ABSCISSAE AND
C   ORDINATES, RESPECTIVELY, OF THE SPECIFIED POINTS.
C
C   YP IS AN ARRAY OF SECOND DERIVATIVE VALUES OF THE CURVE
C   AT THE NODES.
C
C AND
C
C   SIGMA CONTAINS THE TENSION FACTOR (ITS SIGN IS IGNORED).
C
C THE PARAMETERS N, X, Y, YP, AND SIGMA SHOULD BE INPUT
C UNALTERED FROM THE OUTPUT OF CURV1.
C
C ON OUTPUT--
C
C   CURVI CONTAINS THE INTEGRAL VALUE.
C
C NONE OF THE INPUT PARAMETERS ARE ALTERED.
C
C THIS FUNCTION REFERENCES PACKAGE MODULES INTRVL AND
C SNHCSH.
C
C-----------------------------------------------------------
C
C STATEMENT FUNCTION FOR COEFFICIENT ASSOCIATED WITH
C DERIVATIVE TERMS
C
      TERM (CMM1,CMM2,T) = (CMM1-CMM2-SIGMAP*T*SS)/(SIGMAP*
     *                     SIGMAP*SIGMAP*(SS+SIGMAP*DELS))
C
C DENORMALIZE TENSION FACTOR
C
      SIGMAP = ABS(SIGMA)*FLOAT(N-1)/(X(N)-X(1))
C
C DETERMINE ACTUAL UPPER AND LOWER BOUNDS
C
      XXL = XL
      XXU = XU
      SSIGN = 1.
      IF (XL .LT. XU) GO TO 1
      XXL = XU
      XXU = XL
      SSIGN = -1.
      IF (XL .GT. XU) GO TO 1
C
C RETURN ZERO IF XL .EQ. XU
C
      CURVI = 0.
      RETURN
C
C SEARCH FOR PROPER INTERVALS
C
    1 ILM1 = INTRVL (XXL,X,N)
      IL = ILM1+1
      IUM1 = INTRVL (XXU,X,N)
      IU = IUM1+1
      IF (IL .EQ. IU) GO TO 8
C
C INTEGRATE FROM XXL TO X(IL)
C
      SUM = 0.
      IF (XXL .EQ. X(IL)) GO TO 3
      DEL1 = XXL-X(ILM1)
      DEL2 = X(IL)-XXL
      DELS = X(IL)-X(ILM1)
      T1 = (DEL1+DELS)*DEL2/(2.*DELS)
      T2 = DEL2*DEL2/(2.*DELS)
      SUM = T1*Y(IL)+T2*Y(ILM1)
      IF (SIGMA .EQ. 0.) GO TO 2
      CALL SNHCSH (DUMMY,C1,SIGMAP*DEL1,2)
      CALL SNHCSH (DUMMY,C2,SIGMAP*DEL2,2)
      CALL SNHCSH (SS,CS,SIGMAP*DELS,3)
      SUM = SUM+TERM(CS,C1,T1)*YP(IL)
     *         +TERM(C2,0.,T2)*YP(ILM1)
      GO TO 3
    2 SUM = SUM-T1*T1*DELS*YP(IL)/6.
     *         -T2*(DEL1*(DEL2+DELS)+DELS*DELS)*YP(ILM1)/12.
C
C INTEGRATE OVER INTERIOR INTERVALS
C
    3 IF (IU-IL .EQ. 1) GO TO 6
      ILP1 = IL+1
      DO 5 I = ILP1,IUM1
        DELS = X(I)-X(I-1)
        SUM = SUM+(Y(I)+Y(I-1))*DELS/2.
        IF (SIGMA .EQ. 0.) GO TO 4
        CALL SNHCSH (SS,CS,SIGMAP*DELS,3)
        SUM = SUM+(YP(I)+YP(I-1))*(CS-SS*SIGMAP*DELS/2.)/
     *            (SIGMAP*SIGMAP*SIGMAP*(SS+SIGMAP*DELS))
        GO TO 5
    4   SUM = SUM-(YP(I)+YP(I-1))*DELS*DELS*DELS/24.
    5   CONTINUE
C
C INTEGRATE FROM X(IU-1) TO XXU
C
    6 IF (XXU .EQ. X(IUM1)) GO TO 10
      DEL1 = XXU-X(IUM1)
      DEL2 = X(IU)-XXU
      DELS = X(IU)-X(IUM1)
      T1 = DEL1*DEL1/(2.*DELS)
      T2 = (DEL2+DELS)*DEL1/(2.*DELS)
      SUM = SUM+T1*Y(IU)+T2*Y(IUM1)
      IF (SIGMA .EQ. 0.) GO TO 7
      CALL SNHCSH (DUMMY,C1,SIGMAP*DEL1,2)
      CALL SNHCSH (DUMMY,C2,SIGMAP*DEL2,2)
      CALL SNHCSH (SS,CS,SIGMAP*DELS,3)
      SUM = SUM+TERM(C1,0.,T1)*YP(IU)
     *         +TERM(CS,C2,T2)*YP(IUM1)
      GO TO 10
    7 SUM = SUM-T1*(DEL2*(DEL1+DELS)+DELS*DELS)*YP(IU)/12.
     *         -T2*T2*DELS*YP(IUM1)/6.
      GO TO 10
C
C INTEGRATE FROM XXL TO XXU
C
    8 DELU1 = XXU-X(IUM1)
      DELU2 = X(IU)-XXU
      DELL1 = XXL-X(IUM1)
      DELL2 = X(IU)-XXL
      DELS = X(IU)-X(IUM1)
      DELI = XXU-XXL
      T1 = (DELU1+DELL1)*DELI/(2.*DELS)
      T2 = (DELU2+DELL2)*DELI/(2.*DELS)
      SUM = T1*Y(IU)+T2*Y(IUM1)
      IF (SIGMA .EQ. 0.) GO TO 9
      CALL SNHCSH (DUMMY,CU1,SIGMAP*DELU1,2)
      CALL SNHCSH (DUMMY,CU2,SIGMAP*DELU2,2)
      CALL SNHCSH (DUMMY,CL1,SIGMAP*DELL1,2)
      CALL SNHCSH (DUMMY,CL2,SIGMAP*DELL2,2)
      CALL SNHCSH (SS,DUMMY,SIGMAP*DELS,-1)
      SUM = SUM+TERM(CU1,CL1,T1)*YP(IU)
     *         +TERM(CL2,CU2,T2)*YP(IUM1)
      GO TO 10
    9 SUM = SUM-T1*(DELU2*(DELS+DELU1)+DELL2*(DELS+DELL1))*
     *             YP(IU)/12.
     *         -T2*(DELL1*(DELS+DELL2)+DELU1*(DELS+DELU2))*
     *             YP(IUM1)/12.
C
C CORRECT SIGN AND RETURN
C
   10 CURVI = SSIGN*SUM
      RETURN
      END
