source: LMDZ4/trunk/libf/bibio/pchfe_95.F90 @ 5394

Last change on this file since 5394 was 1425, checked in by lguez, 14 years ago

Replaced Numerical Recipes procedures for spline interpolation (not in
the public domain) by procedures from the Pchip package in the Slatec
library. This only affects the program "ce0l", not the program
"gcm". Tested on Brodie SX8 with "-debug" and "-prod", "-parallel
none" and "-parallel mpi". "start.nc" and "limit.nc" are
changed. "startphy.nc" is not changed. The relative change is of order
1e-7 or less. The revision makes the program faster (tested on Brodie
with "-prod -d 144x142x39", CPU time is 38 s, instead of 54
s). Procedures from Slatec are untouched, except for
"i1mach.F". Created procedures "pchfe_95" and "pchsp_95" which are
wrappers for "pchfe" and "pchsp" from Slatec. "pchfe_95" and
"pchsp_95" have a safer and simpler interface.

Replaced "make" by "sxgmake" in "arch-SX8_BRODIE.fcm". Added files for
compilation by FCM with "g95".

In "arch-linux-32bit.fcm", replaced "pgf90" by "pgf95". There was no
difference between "dev" and "debug" so added "-O1" to "dev". Added
debugging options. Removed "-Wl,-Bstatic
-L/usr/lib/gcc-lib/i386-linux/2.95.2", which usually produces an error
at link-time.

Bash is now ubiquitous while KornShell? is not so use Bash instead of
KornShell? in FCM.

Replaced some statements "write(6,*)" by "write(lunout,*)". Replaced
"stop" by "stop 1" in the case where "abort_gcm" is called with "ierr
/= 0". Removed "stop" statements at the end of procedures
"limit_netcdf" and main program "ce0l" (why not let the program end
normally?).

Made some arrays automatic instead of allocatable in "start_inter_3d".

Zeroed "wake_pe", "fm_therm", "entr_therm" and "detr_therm" in
"dyn3dpar/etat0_netcdf.F90". The parallel and sequential results of
"ce0l" are thus identical.

File size: 2.7 KB
Line 
1module PCHFE_95_m
2
3  implicit none
4
5contains
6
7  SUBROUTINE PCHFE_95(X, F, D, SKIP, XE, FE, IERR)
8
9    ! PURPOSE  Evaluate a piecewise cubic Hermite function at an array of
10    !            points.  May be used by itself for Hermite interpolation,
11    !            or as an evaluator for PCHIM or PCHIC.
12    ! CATEGORY  E3
13    ! KEYWORDS  CUBIC HERMITE EVALUATION, HERMITE INTERPOLATION, PCHIP,
14    !             PIECEWISE CUBIC EVALUATION
15
16    !          PCHFE:  Piecewise Cubic Hermite Function Evaluator
17    ! Evaluates the cubic Hermite function defined by  X, F, D  at
18    ! the points  XE.
19
20    use assert_eq_m, only: assert_eq
21
22    REAL, intent(in):: X(:) ! real array of independent variable values
23    ! The elements of X must be strictly increasing.
24
25    REAL, intent(in):: F(:) ! real array of function values
26    ! F(I) is the value corresponding to X(I).
27
28    REAL, intent(in):: D(:) ! real array of derivative values
29    ! D(I) is the value corresponding to X(I).
30
31    LOGICAL, intent(inout):: SKIP
32    ! request to skip checks for validity of "x"
33    ! If "skip" is false then "pchfe" will check that size(x) >= 2 and
34    ! "x" is in strictly ascending order.
35    ! Setting "skip" to true will save time in case these checks have
36    ! already been performed (say, in "PCHIM" or "PCHIC").
37    ! "SKIP" will be set to TRUE on normal return.
38
39    real, intent(in):: XE(:) ! points at which the function is to be evaluated
40    ! NOTES:
41    ! 1. The evaluation will be most efficient if the elements of XE
42    ! are increasing relative to X.
43    ! That is,   XE(J) .GE. X(I)
44    ! implies    XE(K) .GE. X(I),  all K.GE.J
45    ! 2. If any of the XE are outside the interval [X(1),X(N)], values
46    ! are extrapolated from the nearest extreme cubic, and a warning
47    ! error is returned.
48
49    real, intent(out):: FE(:) ! values of the cubic Hermite function
50    ! defined by X, F, D at the points XE
51
52    integer, intent(out):: IERR ! error flag
53    ! Normal return:
54    ! IERR = 0  no error
55    ! Warning error:
56    ! IERR > 0  means that extrapolation was performed at IERR points
57    ! "Recoverable" errors:
58    !              IERR = -1  if N < 2
59    !              IERR = -3  if the X-array is not strictly increasing
60    !              IERR = -4  if NE < 1
61    ! NOTE: The above errors are checked in the order listed, and
62    ! following arguments have **NOT** been validated.
63
64    ! Variables local to the procedure:
65
66    INTEGER  N, NE
67
68    !---------------------------------------
69
70    n = assert_eq(size(x), size(f), size(d), "PCHFE_95 n")
71    ne = assert_eq(size(xe), size(fe), "PCHFE_95 ne")
72    call PCHFE(N, X, F, D, 1, SKIP, NE, XE, FE, IERR)
73
74  end SUBROUTINE PCHFE_95
75
76end module PCHFE_95_m
Note: See TracBrowser for help on using the repository browser.