Ignore:
Timestamp:
Aug 2, 2024, 9:58:25 PM (3 months ago)
Author:
abarral
Message:

Put dimensions.h and paramet.h into modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath_pch.f90

    r5123 r5159  
    3131    !  FTS 532-4275, (510) 422-4275
    3232    !***DESCRIPTION
    33     !
     33
    3434    !      CHFEV:  Cubic Hermite Function EValuator
    35     !
     35
    3636    ! Evaluates the cubic polynomial determined by function values
    3737    ! F1,F2 and derivatives D1,D2 on interval (X1,X2) at the points
    3838    ! XE(J), J=1(1)NE.
    39     !
     39
    4040    ! ----------------------------------------------------------------------
    41     !
     41
    4242    !  Calling sequence:
    43     !
     43
    4444    !    INTEGER  NE, NEXT(2), IERR
    4545    !    REAL  X1, X2, F1, F2, D1, D2, XE(NE), FE(NE)
    46     !
     46
    4747    !    CALL  CHFEV (X1,X2, F1,F2, D1,D2, NE, XE, FE, NEXT, IERR)
    48     !
     48
    4949    !   Parameters:
    50     !
     50
    5151    ! X1,X2 -- (input) endpoints of interval of definition of cubic.
    5252    !       (Error return if  X1.EQ.X2 .)
    53     !
     53
    5454    ! F1,F2 -- (input) values of function at X1 and X2, respectively.
    55     !
     55
    5656    ! D1,D2 -- (input) values of derivative at X1 and X2, respectively.
    57     !
     57
    5858    ! NE -- (input) number of evaluation points.  (Error return if
    5959    !       NE.LT.1 .)
    60     !
     60
    6161    ! XE -- (input) real array of points at which the function is to be
    6262    !       evaluated.  If any of the XE are outside the interval
    6363    !       [X1,X2], a warning error is returned in NEXT.
    64     !
     64
    6565    ! FE -- (output) real array of values of the cubic function defined
    6666    !       by  X1,X2, F1,F2, D1,D2  at the points  XE.
    67     !
     67
    6868    ! NEXT -- (output) integer array indicating number of extrapolation
    6969    !       points:
    7070    !        NEXT(1) = number of evaluation points to left of interval.
    7171    !        NEXT(2) = number of evaluation points to right of interval.
    72     !
     72
    7373    ! IERR -- (output) error flag.
    7474    !       Normal return:
     
    7878    !          IERR = -2  if X1.EQ.X2 .
    7979    !            (The FE-array has not been changed in either case.)
    80     !
     80
    8181    !***REFERENCES  (NONE)
    8282    !***ROUTINES CALLED  XERMSG
     
    9292    !***END PROLOGUE  CHFEV
    9393    !  Programming notes:
    94     !
     94
    9595    ! To produce a double precision version, simply:
    9696    !    a. Change CHFEV to DCHFEV wherever it occurs,
    9797    !    b. Change the real declaration to double precision, and
    9898    !    c. Change the constant ZERO to double precision.
    99     !
     99
    100100    !  DECLARE ARGUMENTS.
    101     !
     101
    102102    INTEGER :: NE, NEXT(2), IERR
    103103    REAL :: X1, X2, F1, F2, D1, D2, XE(*), FE(*)
    104     !
     104
    105105    !  DECLARE LOCAL VARIABLES.
    106     !
     106
    107107    INTEGER :: I
    108108    REAL :: C2, C3, DEL1, DEL2, DELTA, H, X, XMI, XMA, ZERO
    109109    SAVE ZERO
    110110    DATA  ZERO /0./
    111     !
     111
    112112    !  VALIDITY-CHECK ARGUMENTS.
    113     !
     113
    114114    !***FIRST EXECUTABLE STATEMENT  CHFEV
    115115    IF (NE < 1)  GO TO 5001
    116116    H = X2 - X1
    117117    IF (H == ZERO)  GO TO 5002
    118     !
     118
    119119    !  INITIALIZE.
    120     !
     120
    121121    IERR = 0
    122122    NEXT(1) = 0
     
    124124    XMI = MIN(ZERO, H)
    125125    XMA = MAX(ZERO, H)
    126     !
     126
    127127    !  COMPUTE CUBIC COEFFICIENTS (EXPANDED ABOUT X1).
    128     !
     128
    129129    DELTA = (F2 - F1) / H
    130130    DEL1 = (D1 - DELTA) / H
     
    134134    C3 = (DEL1 + DEL2) / H
    135135    ! (H, DEL1 AND DEL2 ARE NO LONGER NEEDED.)
    136     !
     136
    137137    !  EVALUATION LOOP.
    138     !
     138
    139139    DO I = 1, NE
    140140      X = XE(I) - X1
     
    145145      ! (NOTE REDUNDANCY--IF EITHER CONDITION IS TRUE, OTHER IS FALSE.)
    146146    END DO
    147     !
     147
    148148    !  NORMAL RETURN.
    149     !
    150     RETURN
    151     !
     149
     150    RETURN
     151
    152152    !  ERROR RETURNS.
    153     !
     153
    154154    5001   CONTINUE
    155155    ! NE.LT.1 RETURN.
     
    158158            'NUMBER OF EVALUATION POINTS LESS THAN ONE', IERR, 1)
    159159    RETURN
    160     !
     160
    161161    5002   CONTINUE
    162162    ! X1.EQ.X2 RETURN.
     
    184184    !  FTS 532-4275, (510) 422-4275
    185185    !***DESCRIPTION
    186     !
     186
    187187    !      PCHFE:  Piecewise Cubic Hermite Function Evaluator
    188     !
     188
    189189    ! Evaluates the cubic Hermite function defined by  N, X, F, D  at
    190190    ! the points  XE(J), J=1(1)NE.
    191     !
     191
    192192    ! To provide compatibility with PCHIM and PCHIC, includes an
    193193    ! increment between successive values of the F- and D-arrays.
    194     !
     194
    195195    ! ----------------------------------------------------------------------
    196     !
     196
    197197    !  Calling sequence:
    198     !
     198
    199199    !    PARAMETER  (INCFD = ...)
    200200    !    INTEGER  N, NE, IERR
    201201    !    REAL  X(N), F(INCFD,N), D(INCFD,N), XE(NE), FE(NE)
    202202    !    LOGICAL  SKIP
    203     !
     203
    204204    !    CALL  PCHFE (N, X, F, D, INCFD, SKIP, NE, XE, FE, IERR)
    205     !
     205
    206206    !   Parameters:
    207     !
     207
    208208    ! N -- (input) number of data points.  (Error return if N.LT.2 .)
    209     !
     209
    210210    ! X -- (input) real array of independent variable values.  The
    211211    !       elements of X must be strictly increasing:
    212212    !            X(I-1) .LT. X(I),  I = 2(1)N.
    213213    !       (Error return if not.)
    214     !
     214
    215215    ! F -- (input) real array of function values.  F(1+(I-1)*INCFD) is
    216216    !       the value corresponding to X(I).
    217     !
     217
    218218    ! D -- (input) real array of derivative values.  D(1+(I-1)*INCFD) is
    219219    !       the value corresponding to X(I).
    220     !
     220
    221221    ! INCFD -- (input) increment between successive values in F and D.
    222222    !       (Error return if  INCFD.LT.1 .)
    223     !
     223
    224224    ! SKIP -- (input/output) LOGICAL variable which should be set to
    225225    !       .TRUE. if the user wishes to skip checks for validity of
     
    228228    !       been performed (say, in PCHIM or PCHIC).
    229229    !       SKIP will be set to .TRUE. on normal return.
    230     !
     230
    231231    ! NE -- (input) number of evaluation points.  (Error return if
    232232    !       NE.LT.1 .)
    233     !
     233
    234234    ! XE -- (input) real array of points at which the function is to be
    235235    !       evaluated.
    236     !
     236
    237237    !      NOTES:
    238238    !       1. The evaluation will be most efficient if the elements
     
    243243    !          values are extrapolated from the nearest extreme cubic,
    244244    !          and a warning error is returned.
    245     !
     245
    246246    ! FE -- (output) real array of values of the cubic Hermite function
    247247    !       defined by  N, X, F, D  at the points  XE.
    248     !
     248
    249249    ! IERR -- (output) error flag.
    250250    !       Normal return:
     
    261261    !           NOTE:  The above errors are checked in the order listed,
    262262    !               and following arguments have **NOT** been validated.
    263     !
     263
    264264    !***REFERENCES  (NONE)
    265265    !***ROUTINES CALLED  CHFEV, XERMSG
     
    275275    !***END PROLOGUE  PCHFE
    276276    !  Programming notes:
    277     !
     277
    278278    ! 1. To produce a double precision version, simply:
    279279    !    a. Change PCHFE to DPCHFE, and CHFEV to DCHFEV, wherever they
    280280    !       occur,
    281281    !    b. Change the real declaration to double precision,
    282     !
     282
    283283    ! 2. Most of the coding between the CALL to CHFEV and the end of
    284284    !    the IR-loop could be eliminated if it were permissible to
    285285    !    assume that XE is ordered relative to X.
    286     !
     286
    287287    ! 3. CHFEV does not assume that X1 is less than X2.  thus, it would
    288288    !    be possible to write a version of PCHFE that assumes a strict-
    289289    !    ly decreasing X-array by simply running the IR-loop backwards
    290290    !    (and reversing the order of appropriate tests).
    291     !
     291
    292292    ! 4. The present code has a minor bug, which I have decided is not
    293293    !    worth the effort that would be required to fix it.
     
    295295    !    X(N-1), followed by points .GT.X(N), the extrapolation points
    296296    !    will be counted (at least) twice in the total returned in IERR.
    297     !
     297
    298298    !  DECLARE ARGUMENTS.
    299     !
     299
    300300    INTEGER :: N, INCFD, NE, IERR
    301301    REAL :: X(*), F(INCFD, *), D(INCFD, *), XE(*), FE(*)
    302302    LOGICAL :: SKIP
    303     !
     303
    304304    !  DECLARE LOCAL VARIABLES.
    305     !
     305
    306306    INTEGER :: I, IERC, IR, J, JFIRST, NEXT(2), NJ
    307     !
     307
    308308    !  VALIDITY-CHECK ARGUMENTS.
    309     !
     309
    310310    !***FIRST EXECUTABLE STATEMENT  PCHFE
    311311    IF (SKIP)  GO TO 5
    312     !
     312
    313313    IF (N<2)  GO TO 5001
    314314    IF (INCFD<1)  GO TO 5002
     
    316316      IF (X(I)<=X(I - 1))  GO TO 5003
    317317    END DO
    318     !
     318
    319319    !  FUNCTION DEFINITION IS OK, GO ON.
    320     !
     320
    321321    5   CONTINUE
    322322    IF (NE<1)  GO TO 5004
    323323    IERR = 0
    324324    SKIP = .TRUE.
    325     !
     325
    326326    !  LOOP OVER INTERVALS.        (   INTERVAL INDEX IS  IL = IR-1  . )
    327327    !                              ( INTERVAL IS X(IL).LE.X.LT.X(IR) . )
     
    329329    IR = 2
    330330    10   CONTINUE
    331     !
     331
    332332    ! SKIP OUT OF LOOP IF HAVE PROCESSED ALL EVALUATION POINTS.
    333     !
     333
    334334    IF (JFIRST > NE)  GO TO 5000
    335     !
     335
    336336    ! LOCATE ALL POINTS IN INTERVAL.
    337     !
     337
    338338    DO J = JFIRST, NE
    339339      IF (XE(J) >= X(IR))  GO TO 30
     
    341341    J = NE + 1
    342342    GO TO 40
    343     !
     343
    344344    ! HAVE LOCATED FIRST POINT BEYOND INTERVAL.
    345     !
     345
    346346    30   CONTINUE
    347347    IF (IR == N)  J = NE + 1
    348     !
     348
    349349    40   CONTINUE
    350350    NJ = J - JFIRST
    351     !
     351
    352352    ! SKIP EVALUATION IF NO POINTS IN INTERVAL.
    353     !
     353
    354354    IF (NJ == 0)  GO TO 50
    355     !
     355
    356356    ! EVALUATE CUBIC AT XE(I),  I = JFIRST (1) J-1 .
    357     !
     357
    358358    !   ----------------------------------------------------------------
    359359    CALL CHFEV (X(IR - 1), X(IR), F(1, IR - 1), F(1, IR), D(1, IR - 1), D(1, IR), &
     
    361361    ! ----------------------------------------------------------------
    362362    IF (IERC < 0)  GO TO 5005
    363     !
     363
    364364    IF (NEXT(2) == 0)  GO TO 42
    365365    ! IF (NEXT(2) .GT. 0)  THEN
    366366    !    IN THE CURRENT SET OF XE-POINTS, THERE ARE NEXT(2) TO THE
    367367    !    RIGHT OF X(IR).
    368     !
     368
    369369    IF (IR < N)  GO TO 41
    370370    ! IF (IR .EQ. N)  THEN
     
    379379    ! ENDIF
    380380    42   CONTINUE
    381     !
     381
    382382    IF (NEXT(1) == 0)  GO TO 49
    383383    ! IF (NEXT(1) .GT. 0)  THEN
    384384    !    IN THE CURRENT SET OF XE-POINTS, THERE ARE NEXT(1) TO THE
    385385    !    LEFT OF X(IR-1).
    386     !
     386
    387387    IF (IR > 2)  GO TO 43
    388388    ! IF (IR .EQ. 2)  THEN
     
    394394    !    XE IS NOT ORDERED RELATIVE TO X, SO MUST ADJUST
    395395    !    EVALUATION INTERVAL.
    396     !
     396
    397397    !          FIRST, LOCATE FIRST POINT TO LEFT OF X(IR-1).
    398398    DO I = JFIRST, J - 1
     
    402402    !        IN CHFEV.
    403403    GO TO 5005
    404     !
     404
    405405    45       CONTINUE
    406406    ! RESET J.  (THIS WILL BE THE NEW JFIRST.)
    407407    J = I
    408     !
     408
    409409    !          NOW FIND OUT HOW FAR TO BACK UP IN THE X-ARRAY.
    410410    DO I = 1, IR - 1
     
    412412    END DO
    413413    ! NB-- CAN NEVER DROP THROUGH HERE, SINCE XE(J).LT.X(IR-1).
    414     !
     414
    415415    47       CONTINUE
    416416    ! AT THIS POINT, EITHER  XE(J) .LT. X(1)
     
    422422    ! ENDIF
    423423    49   CONTINUE
    424     !
     424
    425425    JFIRST = J
    426     !
     426
    427427    ! END OF IR-LOOP.
    428     !
     428
    429429    50   CONTINUE
    430430    IR = IR + 1
    431431    IF (IR <= N)  GO TO 10
    432     !
     432
    433433    !  NORMAL RETURN.
    434     !
     434
    435435    5000   CONTINUE
    436436    RETURN
    437     !
     437
    438438    !  ERROR RETURNS.
    439     !
     439
    440440    5001   CONTINUE
    441441    ! N.LT.2 RETURN.
     
    444444            'NUMBER OF DATA POINTS LESS THAN TWO', IERR, 1)
    445445    RETURN
    446     !
     446
    447447    5002   CONTINUE
    448448    ! INCFD.LT.1 RETURN.
     
    451451            1)
    452452    RETURN
    453     !
     453
    454454    5003   CONTINUE
    455455    ! X-ARRAY NOT STRICTLY INCREASING.
     
    458458            , IERR, 1)
    459459    RETURN
    460     !
     460
    461461    5004   CONTINUE
    462462    ! NE.LT.1 RETURN.
     
    465465            'NUMBER OF EVALUATION POINTS LESS THAN ONE', IERR, 1)
    466466    RETURN
    467     !
     467
    468468    5005   CONTINUE
    469469    ! ERROR RETURN FROM CHFEV.
     
    662662    !***AUTHOR  Fritsch, F. N., (LLNL)
    663663    !***DESCRIPTION
    664     !
     664
    665665    !      PCHDF:   PCHIP Finite Difference Formula
    666     !
     666
    667667    ! Uses a divided difference formulation to compute a K-point approx-
    668668    ! imation to the derivative at X(K) based on the data in X and S.
    669     !
     669
    670670    ! Called by  PCHCE  and  PCHSP  to compute 3- and 4-point boundary
    671671    ! derivative approximations.
    672     !
     672
    673673    ! ----------------------------------------------------------------------
    674     !
     674
    675675    ! On input:
    676676    !    K      is the order of the desired derivative approximation.
     
    682682    !              S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1.
    683683    !           (Note that S need only be of length K-1.)
    684     !
     684
    685685    ! On return:
    686686    !    S      will be destroyed.
     
    688688    !    PCHDF  will be set to the desired derivative approximation if
    689689    !           IERR=0 or to zero if IERR=-1.
    690     !
     690
    691691    ! ----------------------------------------------------------------------
    692     !
     692
    693693    !***SEE ALSO  PCHCE, PCHSP
    694694    !***REFERENCES  Carl de Boor, A Practical Guide to Splines, Springer-
     
    708708    !   930503  Improved purpose.  (FNF)
    709709    !***END PROLOGUE  PCHDF
    710     !
     710
    711711    !**End
    712     !
     712
    713713    !  DECLARE ARGUMENTS.
    714     !
     714
    715715    INTEGER :: K, IERR
    716716    REAL :: X(K), S(K)
    717     !
     717
    718718    !  DECLARE LOCAL VARIABLES.
    719     !
     719
    720720    INTEGER :: I, J
    721721    REAL :: VALUE, ZERO
    722722    SAVE ZERO
    723723    DATA  ZERO /0./
    724     !
     724
    725725    !  CHECK FOR LEGAL VALUE OF K.
    726     !
     726
    727727    !***FIRST EXECUTABLE STATEMENT  PCHDF
    728728    IF (K < 3)  GO TO 5001
    729     !
     729
    730730    !  COMPUTE COEFFICIENTS OF INTERPOLATING POLYNOMIAL.
    731     !
     731
    732732    DO J = 2, K - 1
    733733      DO I = 1, K - J
     
    735735      END DO
    736736    END DO
    737     !
     737
    738738    !  EVALUATE DERIVATIVE AT X(K).
    739     !
     739
    740740    VALUE = S(1)
    741741    DO I = 2, K - 1
    742742      VALUE = S(I) + VALUE * (X(K) - X(I))
    743743    END DO
    744     !
     744
    745745    !  NORMAL RETURN.
    746     !
     746
    747747    IERR = 0
    748748    PCHDF = VALUE
    749749    RETURN
    750     !
     750
    751751    !  ERROR RETURN.
    752     !
     752
    753753    5001   CONTINUE
    754754    ! K.LT.3 RETURN.
     
    776776    !  FTS 532-4275, (510) 422-4275
    777777    !***DESCRIPTION
    778     !
     778
    779779    !      PCHSP:   Piecewise Cubic Hermite Spline
    780     !
     780
    781781    ! Computes the Hermite representation of the cubic spline inter-
    782782    ! polant to the data given in X and F satisfying the boundary
    783783    ! conditions specified by IC and VC.
    784     !
     784
    785785    ! To facilitate two-dimensional applications, includes an increment
    786786    ! between successive values of the F- and D-arrays.
    787     !
     787
    788788    ! The resulting piecewise cubic Hermite function may be evaluated
    789789    ! by PCHFE or PCHFD.
    790     !
     790
    791791    ! NOTE:  This is a modified version of C. de Boor's cubic spline
    792792    !        routine CUBSPL.
    793     !
     793
    794794    ! ----------------------------------------------------------------------
    795     !
     795
    796796    !  Calling sequence:
    797     !
     797
    798798    !    PARAMETER  (INCFD = ...)
    799799    !    INTEGER  IC(2), N, NWK, IERR
    800800    !    REAL  VC(2), X(N), F(INCFD,N), D(INCFD,N), WK(NWK)
    801     !
     801
    802802    !    CALL  PCHSP (IC, VC, N, X, F, D, INCFD, WK, NWK, IERR)
    803     !
     803
    804804    !   Parameters:
    805     !
     805
    806806    ! IC -- (input) integer array of length 2 specifying desired
    807807    !       boundary conditions:
    808808    !       IC(1) = IBEG, desired condition at beginning of data.
    809809    !       IC(2) = IEND, desired condition at end of data.
    810     !
     810
    811811    !       IBEG = 0  to set D(1) so that the third derivative is con-
    812812    !          tinuous at X(2).  This is the "not a knot" condition
     
    823823    !       2. For the "natural" boundary condition, use IBEG=2 and
    824824    !          VC(1)=0.
    825     !
     825
    826826    !       IEND may take on the same values as IBEG, but applied to
    827827    !       derivative at X(N).  In case IEND = 1 or 2, the value is
    828828    !       given in VC(2).
    829     !
     829
    830830    !      NOTES:
    831831    !       1. An error return is taken if IEND is out of range.
    832832    !       2. For the "natural" boundary condition, use IEND=2 and
    833833    !          VC(2)=0.
    834     !
     834
    835835    ! VC -- (input) real array of length 2 specifying desired boundary
    836836    !       values, as indicated above.
    837837    !       VC(1) need be set only if IC(1) = 1 or 2 .
    838838    !       VC(2) need be set only if IC(2) = 1 or 2 .
    839     !
     839
    840840    ! N -- (input) number of data points.  (Error return if N.LT.2 .)
    841     !
     841
    842842    ! X -- (input) real array of independent variable values.  The
    843843    !       elements of X must be strictly increasing:
    844844    !            X(I-1) .LT. X(I),  I = 2(1)N.
    845845    !       (Error return if not.)
    846     !
     846
    847847    ! F -- (input) real array of dependent variable values to be inter-
    848848    !       polated.  F(1+(I-1)*INCFD) is value corresponding to X(I).
    849     !
     849
    850850    ! D -- (output) real array of derivative values at the data points.
    851851    !       These values will determine the cubic spline interpolant
     
    854854    !            D(1+(I-1)*INCFD),  I=1(1)N.
    855855    !       No other entries in D are changed.
    856     !
     856
    857857    ! INCFD -- (input) increment between successive values in F and D.
    858858    !       This argument is provided primarily for 2-D applications.
    859859    !       (Error return if  INCFD.LT.1 .)
    860     !
     860
    861861    ! WK -- (scratch) real array of working storage.
    862     !
     862
    863863    ! NWK -- (input) length of work array.
    864864    !       (Error return if NWK.LT.2*N .)
    865     !
     865
    866866    ! IERR -- (output) error flag.
    867867    !       Normal return:
     
    882882    !         (The D-array may have been changed in this case.)
    883883    !         (             Do **NOT** use it!                )
    884     !
     884
    885885    !***REFERENCES  Carl de Boor, A Practical Guide to Splines, Springer-
    886886    !             Verlag, New York, 1978, pp. 53-59.
     
    899899    !***END PROLOGUE  PCHSP
    900900    !  Programming notes:
    901     !
     901
    902902    ! To produce a double precision version, simply:
    903903    !    a. Change PCHSP to DPCHSP wherever it occurs,
    904904    !    b. Change the real declarations to double precision, and
    905905    !    c. Change the constants ZERO, HALF, ... to double precision.
    906     !
     906
    907907    !  DECLARE ARGUMENTS.
    908     !
     908
    909909    INTEGER :: IC(2), N, INCFD, NWK, IERR
    910910    REAL :: VC(2), X(*), F(INCFD, *), D(INCFD, *), WK(2, *)
    911     !
     911
    912912    !  DECLARE LOCAL VARIABLES.
    913     !
     913
    914914    INTEGER :: IBEG, IEND, INDEX, J, NM1
    915915    REAL :: G, HALF, ONE, STEMP(3), THREE, TWO, XTEMP(4), ZERO
    916916    SAVE ZERO, HALF, ONE, TWO, THREE
    917     !
     917
    918918    DATA  ZERO /0./, HALF /0.5/, ONE /1./, TWO /2./, THREE /3./
    919     !
     919
    920920    !  VALIDITY-CHECK ARGUMENTS.
    921     !
     921
    922922    !***FIRST EXECUTABLE STATEMENT  PCHSP
    923923    IF (N<2)  GO TO 5001
     
    926926      IF (X(J)<=X(J - 1))  GO TO 5003
    927927    END DO
    928     !
     928
    929929    IBEG = IC(1)
    930930    IEND = IC(2)
     
    933933    IF ((IEND<0).OR.(IEND>4))  IERR = IERR - 2
    934934    IF (IERR<0)  GO TO 5004
    935     !
     935
    936936    !  FUNCTION DEFINITION IS OK -- GO ON.
    937     !
     937
    938938    IF (NWK < 2 * N)  GO TO 5007
    939     !
     939
    940940    !  COMPUTE FIRST DIFFERENCES OF X SEQUENCE AND STORE IN WK(1,.). ALSO,
    941941    !  COMPUTE FIRST DIVIDED DIFFERENCE OF DATA AND STORE IN WK(2,.).
     
    944944      WK(2, J) = (F(1, J) - F(1, J - 1)) / WK(1, J)
    945945    END DO
    946     !
     946
    947947    !  SET TO DEFAULT BOUNDARY CONDITIONS IF N IS TOO SMALL.
    948     !
     948
    949949    IF (IBEG>N)  IBEG = 0
    950950    IF (IEND>N)  IEND = 0
    951     !
     951
    952952    !  SET UP FOR BOUNDARY CONDITIONS.
    953     !
     953
    954954    IF ((IBEG==1).OR.(IBEG==2))  THEN
    955955      D(1, 1) = VC(1)
     
    968968      IBEG = 1
    969969    ENDIF
    970     !
     970
    971971    IF ((IEND==1).OR.(IEND==2))  THEN
    972972      D(1, N) = VC(2)
     
    985985      IEND = 1
    986986    ENDIF
    987     !
     987
    988988    ! --------------------( BEGIN CODING FROM CUBSPL )--------------------
    989     !
     989
    990990    !  **** A TRIDIAGONAL LINEAR SYSTEM FOR THE UNKNOWN SLOPES S(J) OF
    991991    !  F  AT X(J), J=1,...,N, IS GENERATED AND THEN SOLVED BY GAUSS ELIM-
    992992    !  INATION, WITH S(J) ENDING UP IN D(1,J), ALL J.
    993993    ! WK(1,.) AND WK(2,.) ARE USED FOR TEMPORARY STORAGE.
    994     !
     994
    995995    !  CONSTRUCT FIRST EQUATION FROM FIRST BOUNDARY CONDITION, OF THE FORM
    996996    !         WK(2,1)*S(1) + WK(1,1)*S(2) = D(1,1)
    997     !
     997
    998998    IF (IBEG == 0)  THEN
    999999      IF (N == 2)  THEN
     
    10191019      D(1, 1) = THREE * WK(2, 2) - HALF * WK(1, 2) * D(1, 1)
    10201020    ENDIF
    1021     !
     1021
    10221022    !  IF THERE ARE INTERIOR KNOTS, GENERATE THE CORRESPONDING EQUATIONS AND
    10231023    !  CARRY OUT THE FORWARD PASS OF GAUSS ELIMINATION, AFTER WHICH THE J-TH
    10241024    !  EQUATION READS    WK(2,J)*S(J) + WK(1,J)*S(J+1) = D(1,J).
    1025     !
     1025
    10261026    NM1 = N - 1
    10271027    IF (NM1 > 1)  THEN
     
    10341034      END DO
    10351035    ENDIF
    1036     !
     1036
    10371037    !  CONSTRUCT LAST EQUATION FROM SECOND BOUNDARY CONDITION, OF THE FORM
    10381038    !       (-G*WK(2,N-1))*S(N-1) + WK(2,N)*S(N) = D(1,N)
    1039     !
     1039
    10401040    ! IF SLOPE IS PRESCRIBED AT RIGHT END, ONE CAN GO DIRECTLY TO BACK-
    10411041    ! SUBSTITUTION, SINCE ARRAYS HAPPEN TO BE SET UP JUST RIGHT FOR IT
    10421042    ! AT THIS POINT.
    10431043    IF (IEND == 1)  GO TO 30
    1044     !
     1044
    10451045    IF (IEND == 0)  THEN
    10461046      IF (N==2 .AND. IBEG==0)  THEN
     
    10731073      G = -ONE / WK(2, N - 1)
    10741074    ENDIF
    1075     !
     1075
    10761076    !  COMPLETE FORWARD PASS OF GAUSS ELIMINATION.
    1077     !
     1077
    10781078    WK(2, N) = G * WK(1, N - 1) + WK(2, N)
    10791079    IF (WK(2, N) == ZERO)   GO TO 5008
    10801080    D(1, N) = (G * D(1, N - 1) + D(1, N)) / WK(2, N)
    1081     !
     1081
    10821082    !  CARRY OUT BACK SUBSTITUTION
    1083     !
     1083
    10841084    30   CONTINUE
    10851085    DO J = NM1, 1, -1
     
    10881088    END DO
    10891089    ! --------------------(  END  CODING FROM CUBSPL )--------------------
    1090     !
     1090
    10911091    !  NORMAL RETURN.
    1092     !
    1093     RETURN
    1094     !
     1092
     1093    RETURN
     1094
    10951095    !  ERROR RETURNS.
    1096     !
     1096
    10971097    5001   CONTINUE
    10981098    ! N.LT.2 RETURN.
     
    11011101            'NUMBER OF DATA POINTS LESS THAN TWO', IERR, 1)
    11021102    RETURN
    1103     !
     1103
    11041104    5002   CONTINUE
    11051105    ! INCFD.LT.1 RETURN.
     
    11081108            1)
    11091109    RETURN
    1110     !
     1110
    11111111    5003   CONTINUE
    11121112    ! X-ARRAY NOT STRICTLY INCREASING.
     
    11151115            , IERR, 1)
    11161116    RETURN
    1117     !
     1117
    11181118    5004   CONTINUE
    11191119    ! IC OUT OF RANGE RETURN.
     
    11211121    CALL XERMSG ('SLATEC', 'PCHSP', 'IC OUT OF RANGE', IERR, 1)
    11221122    RETURN
    1123     !
     1123
    11241124    5007   CONTINUE
    11251125    ! NWK TOO SMALL RETURN.
     
    11271127    CALL XERMSG ('SLATEC', 'PCHSP', 'WORK ARRAY TOO SMALL', IERR, 1)
    11281128    RETURN
    1129     !
     1129
    11301130    5008   CONTINUE
    11311131    ! SINGULAR SYSTEM.
     
    11361136            1)
    11371137    RETURN
    1138     !
     1138
    11391139    5009   CONTINUE
    11401140    ! ERROR RETURN FROM PCHDF.
Note: See TracChangeset for help on using the changeset viewer.